Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-receipts/blob/main/audit/tls/omega-mv/bench/drivers/ossl_client.c # aien-receipts Append-only AIEN verification receipts, indexed by repository and exact source commit. Read verdicts, signatures and retained logs before making a claim. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-receipts / audit / tls / omega-mv / bench / drivers / ossl_client.c` 78 lines ยท 3254 bytes Raw Blame History 1 /* THROWAWAY HOST TOOLING (benchmark peer arm, not product code). 2 * OpenSSL TLS 1.3 client with the same CLI and output as om/tls/test/bench/bench.om: 3 * ossl_client MODE PORT N PATH ROOTPEM (MODE h|g|b|d) 4 * Offer set matched to the Omega client: TLS 1.3 only, CHACHA20_POLY1305 then AES_128_GCM, 5 * group X25519 only, no resumption (fresh SSL each time, no session cache), SNI bench.test, 6 * hostname verification against bench.test, chain verified against ROOTPEM only. */ 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #include 15 #include 16 #include 17 18 static unsigned long long now(void) { 19 struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); 20 return (unsigned long long)t.tv_sec * 1000000000ull + (unsigned long long)t.tv_nsec; 21 } 22 23 static int dial(int port) { 24 int fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); 25 struct sockaddr_in sa; memset(&sa, 0, sizeof sa); 26 sa.sin_family = AF_INET; sa.sin_port = htons((unsigned short)port); 27 sa.sin_addr.s_addr = htonl(0x7f000001); 28 if (fd < 0 || connect(fd, (struct sockaddr *)&sa, sizeof sa) != 0) return -1; 29 return fd; 30 } 31 32 int main(int argc, char **argv) { 33 if (argc != 6 || strlen(argv[1]) != 1) { fprintf(stderr, "usage: ossl_client h|g|b|d PORT N PATH ROOTPEM\n"); return 2; } 34 char md = argv[1][0]; int port = atoi(argv[2]); long n = atol(argv[3]); 35 char req[1200]; int rl = snprintf(req, sizeof req, "GET /%s HTTP/1.0\r\n\r\n", argv[4]); 36 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method()); 37 SSL_CTX_set_min_proto_version(ctx, TLS1_3_VERSION); 38 SSL_CTX_set_max_proto_version(ctx, TLS1_3_VERSION); 39 SSL_CTX_set_ciphersuites(ctx, getenv("BENCH_SUITES") ? getenv("BENCH_SUITES") 40 : "TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256"); 41 SSL_CTX_set1_groups_list(ctx, "X25519"); 42 SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF); 43 SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL); 44 if (SSL_CTX_load_verify_locations(ctx, argv[5], NULL) != 1) { fprintf(stderr, "TLSERR store\n"); return 12; } 45 static unsigned char buf[16384]; 46 for (long i = 0; i < n; i++) { 47 unsigned long long t0 = now(); 48 int fd = dial(port); 49 if (fd < 0) return 3; 50 SSL *s = SSL_new(ctx); 51 SSL_set_tlsext_host_name(s, "bench.test"); 52 SSL_set1_host(s, "bench.test"); 53 SSL_set_fd(s, fd); 54 if (SSL_connect(s) != 1) { ERR_print_errors_fp(stderr); fprintf(stderr, "TLSERR connect\n"); return 11; } 55 unsigned long long t1 = now(), t2 = 0, by = 0, smp = t1 - t0; 56 if (md != 'h') { 57 t2 = now(); 58 if (SSL_write(s, req, rl) != rl) return 11; 59 for (;;) { 60 int r = SSL_read(s, buf, sizeof buf); 61 if (r <= 0) { 62 if (SSL_get_error(s, r) == SSL_ERROR_ZERO_RETURN) break; 63 fprintf(stderr, "TLSERR read\n"); return 11; 64 } 65 by += (unsigned long long)r; 66 if (md == 'd') fwrite(buf, 1, (size_t)r, stdout); 67 } 68 unsigned long long t3 = now(); 69 smp = md == 'b' ? t3 - t2 : t3 - t0; 70 } 71 SSL_shutdown(s); 72 SSL_free(s); 73 close(fd); 74 if (md != 'd') printf("S %llu %llu\n", smp, by); 75 } 76 SSL_CTX_free(ctx); 77 return 0; 78 }