mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Get Mbed TLS to build
This change configures Mbed TLS to support the fewest number of things possible required to run an HTTPS server that caters to the sweet spot of being legacy enough to support the vast majority of user agents but modern enough that Chrome and Firefox remain happy. That should entail - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - TLS_RSA_WITH_AES_128_CBC_SHA Even though other suites still get included so what usually happens in practice is ECDHE-RSA-AES256-GCM-SHA384 under TLS 1.2 will be selected and the binary footprint is reasonable, and should cost us about 200kb
This commit is contained in:
parent
19bd27358a
commit
d0ac995dc0
204 changed files with 1698 additions and 1490 deletions
|
@ -1,6 +1,8 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_SOCK_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_SOCK_H_
|
||||
#include "libc/bits/bswap.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
|
@ -23,12 +25,6 @@ COSMOPOLITAN_C_START_
|
|||
#define htonl(u32) bswap_32(u32)
|
||||
#define ntohl(u32) bswap_32(u32)
|
||||
|
||||
struct iovec;
|
||||
struct sigset;
|
||||
struct timespec;
|
||||
struct timeval;
|
||||
struct addrinfo;
|
||||
|
||||
struct in_addr { /* ARPA ABI */
|
||||
/* e.g. 127|0<<8|0<<16|1<<24 or inet_pton(AF_INET, "127.0.0.1", &s_addr) */
|
||||
uint32_t s_addr;
|
||||
|
@ -150,7 +146,6 @@ int accept(int, void *, uint32_t *) nodiscard;
|
|||
int accept4(int, void *, uint32_t *, int) nodiscard;
|
||||
int bind(int, const void *, uint32_t);
|
||||
int connect(int, const void *, uint32_t);
|
||||
int socketconnect(const struct addrinfo *, int);
|
||||
int listen(int, int);
|
||||
int shutdown(int, int);
|
||||
int getsockname(int, void *, uint32_t *) paramsnonnull();
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ 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 "libc/calls/calls.h"
|
||||
#include "libc/dns/dns.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/sock/sock.h"
|
||||
|
||||
/**
|
||||
* Opens socket client connection.
|
||||
*
|
||||
* @param ai can be obtained via getaddrinfo()
|
||||
* @return socket file descriptor, or -1 w/ errno
|
||||
*/
|
||||
int socketconnect(const struct addrinfo *ai, int flags) {
|
||||
int fd;
|
||||
fd = socket(ai->ai_family, ai->ai_socktype | flags, ai->ai_protocol);
|
||||
if (fd != -1) {
|
||||
if (connect(fd, ai->ai_addr, ai->ai_addrlen) != -1 ||
|
||||
errno == EINPROGRESS) {
|
||||
return fd;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
return -1;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue