diff options
Diffstat (limited to 'crypto/openssl/include/internal')
110 files changed, 4186 insertions, 4185 deletions
diff --git a/crypto/openssl/include/internal/asn1.h b/crypto/openssl/include/internal/asn1.h index 36dbe0fcd32d..509e5986cee6 100644 --- a/crypto/openssl/include/internal/asn1.h +++ b/crypto/openssl/include/internal/asn1.h @@ -8,10 +8,10 @@ */ #ifndef OSSL_INTERNAL_ASN1_H -# define OSSL_INTERNAL_ASN1_H -# pragma once +#define OSSL_INTERNAL_ASN1_H +#pragma once -# include <openssl/bio.h> +#include <openssl/bio.h> int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb); diff --git a/crypto/openssl/include/internal/bio.h b/crypto/openssl/include/internal/bio.h index 9481f4c985e0..371421139c42 100644 --- a/crypto/openssl/include/internal/bio.h +++ b/crypto/openssl/include/internal/bio.h @@ -8,42 +8,41 @@ */ #ifndef OSSL_INTERNAL_BIO_H -# define OSSL_INTERNAL_BIO_H -# pragma once +#define OSSL_INTERNAL_BIO_H +#pragma once -# include <openssl/core.h> -# include <openssl/bio.h> +#include <openssl/core.h> +#include <openssl/bio.h> struct bio_method_st { int type; char *name; - int (*bwrite) (BIO *, const char *, size_t, size_t *); - int (*bwrite_old) (BIO *, const char *, int); - int (*bread) (BIO *, char *, size_t, size_t *); - int (*bread_old) (BIO *, char *, int); - int (*bputs) (BIO *, const char *); - int (*bgets) (BIO *, char *, int); - long (*ctrl) (BIO *, int, long, void *); - int (*create) (BIO *); - int (*destroy) (BIO *); - long (*callback_ctrl) (BIO *, int, BIO_info_cb *); - int (*bsendmmsg) (BIO *, BIO_MSG *, size_t, size_t, uint64_t, size_t *); - int (*brecvmmsg) (BIO *, BIO_MSG *, size_t, size_t, uint64_t, size_t *); + int (*bwrite)(BIO *, const char *, size_t, size_t *); + int (*bwrite_old)(BIO *, const char *, int); + int (*bread)(BIO *, char *, size_t, size_t *); + int (*bread_old)(BIO *, char *, int); + int (*bputs)(BIO *, const char *); + int (*bgets)(BIO *, char *, int); + long (*ctrl)(BIO *, int, long, void *); + int (*create)(BIO *); + int (*destroy)(BIO *); + long (*callback_ctrl)(BIO *, int, BIO_info_cb *); + int (*bsendmmsg)(BIO *, BIO_MSG *, size_t, size_t, uint64_t, size_t *); + int (*brecvmmsg)(BIO *, BIO_MSG *, size_t, size_t, uint64_t, size_t *); }; void bio_free_ex_data(BIO *bio); void bio_cleanup(void); - /* Old style to new style BIO_METHOD conversion functions */ int bwrite_conv(BIO *bio, const char *data, size_t datal, size_t *written); int bread_conv(BIO *bio, char *data, size_t datal, size_t *read); /* Changes to these internal BIOs must also update include/openssl/bio.h */ -# define BIO_CTRL_SET_KTLS 72 -# define BIO_CTRL_SET_KTLS_TX_SEND_CTRL_MSG 74 -# define BIO_CTRL_CLEAR_KTLS_TX_CTRL_MSG 75 -# define BIO_CTRL_SET_KTLS_TX_ZEROCOPY_SENDFILE 90 +#define BIO_CTRL_SET_KTLS 72 +#define BIO_CTRL_SET_KTLS_TX_SEND_CTRL_MSG 74 +#define BIO_CTRL_CLEAR_KTLS_TX_CTRL_MSG 75 +#define BIO_CTRL_SET_KTLS_TX_ZEROCOPY_SENDFILE 90 /* * This is used with socket BIOs: @@ -53,42 +52,42 @@ int bread_conv(BIO *bio, char *data, size_t datal, size_t *read); * BIO_FLAGS_KTLS_TX_ZEROCOPY_SENDFILE means we are using the zerocopy mode with * this BIO for sending using sendfile. */ -# define BIO_FLAGS_KTLS_TX_CTRL_MSG 0x1000 -# define BIO_FLAGS_KTLS_RX 0x2000 -# define BIO_FLAGS_KTLS_TX 0x4000 -# define BIO_FLAGS_KTLS_TX_ZEROCOPY_SENDFILE 0x8000 +#define BIO_FLAGS_KTLS_TX_CTRL_MSG 0x1000 +#define BIO_FLAGS_KTLS_RX 0x2000 +#define BIO_FLAGS_KTLS_TX 0x4000 +#define BIO_FLAGS_KTLS_TX_ZEROCOPY_SENDFILE 0x8000 /* KTLS related controls and flags */ -# define BIO_set_ktls_flag(b, is_tx) \ +#define BIO_set_ktls_flag(b, is_tx) \ BIO_set_flags(b, (is_tx) ? BIO_FLAGS_KTLS_TX : BIO_FLAGS_KTLS_RX) -# define BIO_should_ktls_flag(b, is_tx) \ +#define BIO_should_ktls_flag(b, is_tx) \ BIO_test_flags(b, (is_tx) ? BIO_FLAGS_KTLS_TX : BIO_FLAGS_KTLS_RX) -# define BIO_set_ktls_ctrl_msg_flag(b) \ +#define BIO_set_ktls_ctrl_msg_flag(b) \ BIO_set_flags(b, BIO_FLAGS_KTLS_TX_CTRL_MSG) -# define BIO_should_ktls_ctrl_msg_flag(b) \ +#define BIO_should_ktls_ctrl_msg_flag(b) \ BIO_test_flags(b, BIO_FLAGS_KTLS_TX_CTRL_MSG) -# define BIO_clear_ktls_ctrl_msg_flag(b) \ +#define BIO_clear_ktls_ctrl_msg_flag(b) \ BIO_clear_flags(b, BIO_FLAGS_KTLS_TX_CTRL_MSG) -# define BIO_set_ktls_zerocopy_sendfile_flag(b) \ +#define BIO_set_ktls_zerocopy_sendfile_flag(b) \ BIO_set_flags(b, BIO_FLAGS_KTLS_TX_ZEROCOPY_SENDFILE) -# define BIO_set_ktls(b, keyblob, is_tx) \ - BIO_ctrl(b, BIO_CTRL_SET_KTLS, is_tx, keyblob) -# define BIO_set_ktls_ctrl_msg(b, record_type) \ - BIO_ctrl(b, BIO_CTRL_SET_KTLS_TX_SEND_CTRL_MSG, record_type, NULL) -# define BIO_clear_ktls_ctrl_msg(b) \ - BIO_ctrl(b, BIO_CTRL_CLEAR_KTLS_TX_CTRL_MSG, 0, NULL) -# define BIO_set_ktls_tx_zerocopy_sendfile(b) \ - BIO_ctrl(b, BIO_CTRL_SET_KTLS_TX_ZEROCOPY_SENDFILE, 0, NULL) +#define BIO_set_ktls(b, keyblob, is_tx) \ + BIO_ctrl(b, BIO_CTRL_SET_KTLS, is_tx, keyblob) +#define BIO_set_ktls_ctrl_msg(b, record_type) \ + BIO_ctrl(b, BIO_CTRL_SET_KTLS_TX_SEND_CTRL_MSG, record_type, NULL) +#define BIO_clear_ktls_ctrl_msg(b) \ + BIO_ctrl(b, BIO_CTRL_CLEAR_KTLS_TX_CTRL_MSG, 0, NULL) +#define BIO_set_ktls_tx_zerocopy_sendfile(b) \ + BIO_ctrl(b, BIO_CTRL_SET_KTLS_TX_ZEROCOPY_SENDFILE, 0, NULL) /* Functions to allow the core to offer the CORE_BIO type to providers */ OSSL_CORE_BIO *ossl_core_bio_new_from_bio(BIO *bio); OSSL_CORE_BIO *ossl_core_bio_new_file(const char *filename, const char *mode); OSSL_CORE_BIO *ossl_core_bio_new_mem_buf(const void *buf, int len); int ossl_core_bio_read_ex(OSSL_CORE_BIO *cb, void *data, size_t dlen, - size_t *readbytes); + size_t *readbytes); int ossl_core_bio_write_ex(OSSL_CORE_BIO *cb, const void *data, size_t dlen, - size_t *written); + size_t *written); int ossl_core_bio_gets(OSSL_CORE_BIO *cb, char *buf, int size); int ossl_core_bio_puts(OSSL_CORE_BIO *cb, const char *buf); long ossl_core_bio_ctrl(OSSL_CORE_BIO *cb, int cmd, long larg, void *parg); diff --git a/crypto/openssl/include/internal/bio_addr.h b/crypto/openssl/include/internal/bio_addr.h index 072f404a2c52..911147b0009e 100644 --- a/crypto/openssl/include/internal/bio_addr.h +++ b/crypto/openssl/include/internal/bio_addr.h @@ -8,23 +8,23 @@ */ #ifndef OSSL_BIO_ADDR_H -# define OSSL_BIO_ADDR_H +#define OSSL_BIO_ADDR_H -# include "internal/e_os.h" -# include "internal/e_winsock.h" -# include "internal/sockets.h" +#include "internal/e_os.h" +#include "internal/e_winsock.h" +#include "internal/sockets.h" -# ifndef OPENSSL_NO_SOCK +#ifndef OPENSSL_NO_SOCK union bio_addr_st { struct sockaddr sa; -# if OPENSSL_USE_IPV6 +#if OPENSSL_USE_IPV6 struct sockaddr_in6 s_in6; -# endif +#endif struct sockaddr_in s_in; -# ifndef OPENSSL_NO_UNIX_SOCK +#ifndef OPENSSL_NO_UNIX_SOCK struct sockaddr_un s_un; -# endif +#endif }; -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/bio_tfo.h b/crypto/openssl/include/internal/bio_tfo.h index 64c0d4c32724..bfce90afafef 100644 --- a/crypto/openssl/include/internal/bio_tfo.h +++ b/crypto/openssl/include/internal/bio_tfo.h @@ -15,9 +15,9 @@ /* If a supported OS is added here, update test/bio_tfo_test.c */ #if defined(TCP_FASTOPEN) && !defined(OPENSSL_NO_TFO) -# if defined(OPENSSL_SYS_MACOSX) || defined(__FreeBSD__) -# include <sys/sysctl.h> -# endif +#if defined(OPENSSL_SYS_MACOSX) || defined(__FreeBSD__) +#include <sys/sysctl.h> +#endif /* * OSSL_TFO_SYSCTL is used to determine if TFO is supported by @@ -82,7 +82,7 @@ * client socket (macOS, FreeBSD, Linux pre-4.14) */ -# if defined(OPENSSL_SYS_WINDOWS) +#if defined(OPENSSL_SYS_WINDOWS) /* * NO WINDOWS SUPPORT * @@ -93,59 +93,59 @@ * * Still have to figure out client support */ -# undef TCP_FASTOPEN -# endif +#undef TCP_FASTOPEN +#endif /* NO VMS SUPPORT */ -# if defined(OPENSSL_SYS_VMS) -# undef TCP_FASTOPEN -# endif +#if defined(OPENSSL_SYS_VMS) +#undef TCP_FASTOPEN +#endif -# if defined(OPENSSL_SYS_MACOSX) -# define OSSL_TFO_SYSCTL "net.inet.tcp.fastopen" -# define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN -# define OSSL_TFO_SERVER_SOCKOPT_VALUE 1 -# define OSSL_TFO_CONNECTX 1 -# define OSSL_TFO_DO_NOT_CONNECT 1 -# define OSSL_TFO_CLIENT_FLAG 1 -# define OSSL_TFO_SERVER_FLAG 2 -# endif +#if defined(OPENSSL_SYS_MACOSX) +#define OSSL_TFO_SYSCTL "net.inet.tcp.fastopen" +#define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN +#define OSSL_TFO_SERVER_SOCKOPT_VALUE 1 +#define OSSL_TFO_CONNECTX 1 +#define OSSL_TFO_DO_NOT_CONNECT 1 +#define OSSL_TFO_CLIENT_FLAG 1 +#define OSSL_TFO_SERVER_FLAG 2 +#endif -# if defined(__FreeBSD__) -# if defined(TCP_FASTOPEN_PSK_LEN) +#if defined(__FreeBSD__) +#if defined(TCP_FASTOPEN_PSK_LEN) /* As of 12.0 these are the SYSCTLs */ -# define OSSL_TFO_SYSCTL_SERVER "net.inet.tcp.fastopen.server_enable" -# define OSSL_TFO_SYSCTL_CLIENT "net.inet.tcp.fastopen.client_enable" -# define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN -# define OSSL_TFO_SERVER_SOCKOPT_VALUE MAX_LISTEN -# define OSSL_TFO_CLIENT_SOCKOPT TCP_FASTOPEN -# define OSSL_TFO_DO_NOT_CONNECT 1 -# define OSSL_TFO_SENDTO 0 +#define OSSL_TFO_SYSCTL_SERVER "net.inet.tcp.fastopen.server_enable" +#define OSSL_TFO_SYSCTL_CLIENT "net.inet.tcp.fastopen.client_enable" +#define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN +#define OSSL_TFO_SERVER_SOCKOPT_VALUE MAX_LISTEN +#define OSSL_TFO_CLIENT_SOCKOPT TCP_FASTOPEN +#define OSSL_TFO_DO_NOT_CONNECT 1 +#define OSSL_TFO_SENDTO 0 /* These are the same because the sysctl are client/server-specific */ -# define OSSL_TFO_CLIENT_FLAG 1 -# define OSSL_TFO_SERVER_FLAG 1 -# else +#define OSSL_TFO_CLIENT_FLAG 1 +#define OSSL_TFO_SERVER_FLAG 1 +#else /* 10.3 through 11.4 SYSCTL - ONLY SERVER SUPPORT */ -# define OSSL_TFO_SYSCTL "net.inet.tcp.fastopen.enabled" -# define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN -# define OSSL_TFO_SERVER_SOCKOPT_VALUE MAX_LISTEN -# define OSSL_TFO_SERVER_FLAG 1 -# endif -# endif +#define OSSL_TFO_SYSCTL "net.inet.tcp.fastopen.enabled" +#define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN +#define OSSL_TFO_SERVER_SOCKOPT_VALUE MAX_LISTEN +#define OSSL_TFO_SERVER_FLAG 1 +#endif +#endif -# if defined(OPENSSL_SYS_LINUX) +#if defined(OPENSSL_SYS_LINUX) /* OSSL_TFO_PROC not used, but of interest */ -# define OSSL_TFO_PROC "/proc/sys/net/ipv4/tcp_fastopen" -# define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN -# define OSSL_TFO_SERVER_SOCKOPT_VALUE MAX_LISTEN -# if defined(TCP_FASTOPEN_CONNECT) -# define OSSL_TFO_CLIENT_SOCKOPT TCP_FASTOPEN_CONNECT -# else -# define OSSL_TFO_SENDTO MSG_FASTOPEN -# define OSSL_TFO_DO_NOT_CONNECT 1 -# endif -# define OSSL_TFO_CLIENT_FLAG 1 -# define OSSL_TFO_SERVER_FLAG 2 -# endif +#define OSSL_TFO_PROC "/proc/sys/net/ipv4/tcp_fastopen" +#define OSSL_TFO_SERVER_SOCKOPT TCP_FASTOPEN +#define OSSL_TFO_SERVER_SOCKOPT_VALUE MAX_LISTEN +#if defined(TCP_FASTOPEN_CONNECT) +#define OSSL_TFO_CLIENT_SOCKOPT TCP_FASTOPEN_CONNECT +#else +#define OSSL_TFO_SENDTO MSG_FASTOPEN +#define OSSL_TFO_DO_NOT_CONNECT 1 +#endif +#define OSSL_TFO_CLIENT_FLAG 1 +#define OSSL_TFO_SERVER_FLAG 2 +#endif #endif diff --git a/crypto/openssl/include/internal/cms.h b/crypto/openssl/include/internal/cms.h index d32b64a25fde..9cf2314fa19f 100644 --- a/crypto/openssl/include/internal/cms.h +++ b/crypto/openssl/include/internal/cms.h @@ -7,16 +7,16 @@ * https://www.openssl.org/source/license.html */ #ifndef OSSL_INTERNAL_CMS_H -# define OSSL_INTERNAL_CMS_H -# pragma once +#define OSSL_INTERNAL_CMS_H +#pragma once -# include <openssl/cms.h> +#include <openssl/cms.h> -# ifndef OPENSSL_NO_CMS +#ifndef OPENSSL_NO_CMS CMS_EnvelopedData *ossl_cms_sign_encrypt(BIO *data, X509 *sign_cert, STACK_OF(X509) *certs, - EVP_PKEY *sign_key, unsigned int sign_flags, - STACK_OF(X509) *enc_recip, const EVP_CIPHER *cipher, - unsigned int enc_flags, OSSL_LIB_CTX *libctx, - const char *propq); -# endif /* OPENSSL_NO_CMS */ + EVP_PKEY *sign_key, unsigned int sign_flags, + STACK_OF(X509) *enc_recip, const EVP_CIPHER *cipher, + unsigned int enc_flags, OSSL_LIB_CTX *libctx, + const char *propq); +#endif /* OPENSSL_NO_CMS */ #endif /* OSSL_INTERNAL_CMS_H */ diff --git a/crypto/openssl/include/internal/common.h b/crypto/openssl/include/internal/common.h index 894dac9a4e2b..5de7279691a8 100644 --- a/crypto/openssl/include/internal/common.h +++ b/crypto/openssl/include/internal/common.h @@ -8,40 +8,40 @@ */ #ifndef OSSL_INTERNAL_COMMON_H -# define OSSL_INTERNAL_COMMON_H -# pragma once +#define OSSL_INTERNAL_COMMON_H +#pragma once -# include <stdlib.h> -# include <string.h> -# include "openssl/configuration.h" +#include <stdlib.h> +#include <string.h> +#include "openssl/configuration.h" -# include "internal/e_os.h" /* ossl_inline in many files */ -# include "internal/nelem.h" +#include "internal/e_os.h" /* ossl_inline in many files */ +#include "internal/nelem.h" -# if defined(__GNUC__) || defined(__clang__) -# define ossl_likely(x) __builtin_expect(!!(x), 1) -# define ossl_unlikely(x) __builtin_expect(!!(x), 0) -# else -# define ossl_likely(x) (x) -# define ossl_unlikely(x) (x) -# endif +#if defined(__GNUC__) || defined(__clang__) +#define ossl_likely(x) __builtin_expect(!!(x), 1) +#define ossl_unlikely(x) __builtin_expect(!!(x), 0) +#else +#define ossl_likely(x) (x) +#define ossl_unlikely(x) (x) +#endif -# if defined(__GNUC__) || defined(__clang__) -# define ALIGN32 __attribute((aligned(32))) -# define ALIGN64 __attribute((aligned(64))) -# elif defined(_MSC_VER) -# define ALIGN32 __declspec(align(32)) -# define ALIGN64 __declspec(align(64)) -# else -# define ALIGN32 -# define ALIGN64 -# endif +#if defined(__GNUC__) || defined(__clang__) +#define ALIGN32 __attribute((aligned(32))) +#define ALIGN64 __attribute((aligned(64))) +#elif defined(_MSC_VER) +#define ALIGN32 __declspec(align(32)) +#define ALIGN64 __declspec(align(64)) +#else +#define ALIGN32 +#define ALIGN64 +#endif -# ifdef NDEBUG -# define ossl_assert(x) ossl_likely((x) != 0) -# else +#ifdef NDEBUG +#define ossl_assert(x) ossl_likely((x) != 0) +#else __owur static ossl_inline int ossl_assert_int(int expr, const char *exprstr, - const char *file, int line) + const char *file, int line) { if (!expr) OPENSSL_die(exprstr, file, line); @@ -49,10 +49,10 @@ __owur static ossl_inline int ossl_assert_int(int expr, const char *exprstr, return expr; } -# define ossl_assert(x) ossl_assert_int((x) != 0, "Assertion failed: "#x, \ - __FILE__, __LINE__) +#define ossl_assert(x) ossl_assert_int((x) != 0, "Assertion failed: " #x, \ + __FILE__, __LINE__) -# endif +#endif /* Check if |pre|, which must be a string literal, is a prefix of |str| */ #define HAS_PREFIX(str, pre) (strncmp(str, pre "", sizeof(pre) - 1) == 0) @@ -65,136 +65,152 @@ __owur static ossl_inline int ossl_assert_int(int expr, const char *exprstr, #define CHECK_AND_SKIP_CASE_PREFIX(str, pre) \ (HAS_CASE_PREFIX(str, pre) ? ((str) += sizeof(pre) - 1, 1) : 0) /* Check if the string literal |suffix| is a case-insensitive suffix of |str| */ -#define HAS_CASE_SUFFIX(str, suffix) (strlen(str) < sizeof(suffix) - 1 ? 0 : \ - OPENSSL_strcasecmp(str + strlen(str) - sizeof(suffix) + 1, suffix "") == 0) +#define HAS_CASE_SUFFIX(str, suffix) (strlen(str) < sizeof(suffix) - 1 ? 0 : OPENSSL_strcasecmp(str + strlen(str) - sizeof(suffix) + 1, suffix "") == 0) /* * Use this inside a union with the field that needs to be aligned to a * reasonable boundary for the platform. The most pessimistic alignment * of the listed types will be used by the compiler. */ -# define OSSL_UNION_ALIGN \ - double align; \ - ossl_uintmax_t align_int; \ +#define OSSL_UNION_ALIGN \ + double align; \ + ossl_uintmax_t align_int; \ void *align_ptr -# define OPENSSL_CONF "openssl.cnf" +#define OPENSSL_CONF "openssl.cnf" -# ifndef OPENSSL_SYS_VMS -# define X509_CERT_AREA OPENSSLDIR -# define X509_CERT_DIR OPENSSLDIR "/certs" -# define X509_CERT_FILE OPENSSLDIR "/cert.pem" -# define X509_PRIVATE_DIR OPENSSLDIR "/private" -# define CTLOG_FILE OPENSSLDIR "/ct_log_list.cnf" -# else -# define X509_CERT_AREA "OSSL$DATAROOT:[000000]" -# define X509_CERT_DIR "OSSL$DATAROOT:[CERTS]" -# define X509_CERT_FILE "OSSL$DATAROOT:[000000]cert.pem" -# define X509_PRIVATE_DIR "OSSL$DATAROOT:[PRIVATE]" -# define CTLOG_FILE "OSSL$DATAROOT:[000000]ct_log_list.cnf" -# endif +#ifndef OPENSSL_SYS_VMS +#define X509_CERT_AREA OPENSSLDIR +#define X509_CERT_DIR OPENSSLDIR "/certs" +#define X509_CERT_FILE OPENSSLDIR "/cert.pem" +#define X509_PRIVATE_DIR OPENSSLDIR "/private" +#define CTLOG_FILE OPENSSLDIR "/ct_log_list.cnf" +#else +#define X509_CERT_AREA "OSSL$DATAROOT:[000000]" +#define X509_CERT_DIR "OSSL$DATAROOT:[CERTS]" +#define X509_CERT_FILE "OSSL$DATAROOT:[000000]cert.pem" +#define X509_PRIVATE_DIR "OSSL$DATAROOT:[PRIVATE]" +#define CTLOG_FILE "OSSL$DATAROOT:[000000]ct_log_list.cnf" +#endif -# define X509_CERT_DIR_EVP "SSL_CERT_DIR" -# define X509_CERT_FILE_EVP "SSL_CERT_FILE" -# define CTLOG_FILE_EVP "CTLOG_FILE" +#define X509_CERT_DIR_EVP "SSL_CERT_DIR" +#define X509_CERT_FILE_EVP "SSL_CERT_FILE" +#define CTLOG_FILE_EVP "CTLOG_FILE" /* size of string representations */ -# define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1) -# define HEX_SIZE(type) (sizeof(type)*2) +#define DECIMAL_SIZE(type) ((sizeof(type) * 8 + 2) / 3 + 1) +#define HEX_SIZE(type) (sizeof(type) * 2) -# define c2l(c,l) (l = ((unsigned long)(*((c)++))) , \ - l|=(((unsigned long)(*((c)++)))<< 8), \ - l|=(((unsigned long)(*((c)++)))<<16), \ - l|=(((unsigned long)(*((c)++)))<<24)) +#define c2l(c, l) (l = ((unsigned long)(*((c)++))), \ + l |= (((unsigned long)(*((c)++))) << 8), \ + l |= (((unsigned long)(*((c)++))) << 16), \ + l |= (((unsigned long)(*((c)++))) << 24)) /* NOTE - c is not incremented as per c2l */ -# define c2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c))))<<24; \ - case 7: l2|=((unsigned long)(*(--(c))))<<16; \ - case 6: l2|=((unsigned long)(*(--(c))))<< 8; \ - case 5: l2|=((unsigned long)(*(--(c)))); \ - case 4: l1 =((unsigned long)(*(--(c))))<<24; \ - case 3: l1|=((unsigned long)(*(--(c))))<<16; \ - case 2: l1|=((unsigned long)(*(--(c))))<< 8; \ - case 1: l1|=((unsigned long)(*(--(c)))); \ - } \ - } +#define c2ln(c, l1, l2, n) \ + { \ + c += n; \ + l1 = l2 = 0; \ + switch (n) { \ + case 8: \ + l2 = ((unsigned long)(*(--(c)))) << 24; \ + case 7: \ + l2 |= ((unsigned long)(*(--(c)))) << 16; \ + case 6: \ + l2 |= ((unsigned long)(*(--(c)))) << 8; \ + case 5: \ + l2 |= ((unsigned long)(*(--(c)))); \ + case 4: \ + l1 = ((unsigned long)(*(--(c)))) << 24; \ + case 3: \ + l1 |= ((unsigned long)(*(--(c)))) << 16; \ + case 2: \ + l1 |= ((unsigned long)(*(--(c)))) << 8; \ + case 1: \ + l1 |= ((unsigned long)(*(--(c)))); \ + } \ + } -# define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24)&0xff)) +#define l2c(l, c) (*((c)++) = (unsigned char)(((l)) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 8) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 16) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 24) & 0xff)) -# define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24, \ - l|=((unsigned long)(*((c)++)))<<16, \ - l|=((unsigned long)(*((c)++)))<< 8, \ - l|=((unsigned long)(*((c)++)))) +#define n2l(c, l) (l = ((unsigned long)(*((c)++))) << 24, \ + l |= ((unsigned long)(*((c)++))) << 16, \ + l |= ((unsigned long)(*((c)++))) << 8, \ + l |= ((unsigned long)(*((c)++)))) -# define n2l8(c,l) (l =((uint64_t)(*((c)++)))<<56, \ - l|=((uint64_t)(*((c)++)))<<48, \ - l|=((uint64_t)(*((c)++)))<<40, \ - l|=((uint64_t)(*((c)++)))<<32, \ - l|=((uint64_t)(*((c)++)))<<24, \ - l|=((uint64_t)(*((c)++)))<<16, \ - l|=((uint64_t)(*((c)++)))<< 8, \ - l|=((uint64_t)(*((c)++)))) +#define n2l8(c, l) (l = ((uint64_t)(*((c)++))) << 56, \ + l |= ((uint64_t)(*((c)++))) << 48, \ + l |= ((uint64_t)(*((c)++))) << 40, \ + l |= ((uint64_t)(*((c)++))) << 32, \ + l |= ((uint64_t)(*((c)++))) << 24, \ + l |= ((uint64_t)(*((c)++))) << 16, \ + l |= ((uint64_t)(*((c)++))) << 8, \ + l |= ((uint64_t)(*((c)++)))) -# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) +#define l2n(l, c) (*((c)++) = (unsigned char)(((l) >> 24) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 16) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 8) & 0xff), \ + *((c)++) = (unsigned char)(((l)) & 0xff)) -# define l2n8(l,c) (*((c)++)=(unsigned char)(((l)>>56)&0xff), \ - *((c)++)=(unsigned char)(((l)>>48)&0xff), \ - *((c)++)=(unsigned char)(((l)>>40)&0xff), \ - *((c)++)=(unsigned char)(((l)>>32)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) +#define l2n8(l, c) (*((c)++) = (unsigned char)(((l) >> 56) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 48) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 40) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 32) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 24) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 16) & 0xff), \ + *((c)++) = (unsigned char)(((l) >> 8) & 0xff), \ + *((c)++) = (unsigned char)(((l)) & 0xff)) /* NOTE - c is not incremented as per l2c */ -# define l2cn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ - case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ - case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ - case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ - case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ - case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ - case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ - case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ - } \ - } +#define l2cn(l1, l2, c, n) \ + { \ + c += n; \ + switch (n) { \ + case 8: \ + *(--(c)) = (unsigned char)(((l2) >> 24) & 0xff); \ + case 7: \ + *(--(c)) = (unsigned char)(((l2) >> 16) & 0xff); \ + case 6: \ + *(--(c)) = (unsigned char)(((l2) >> 8) & 0xff); \ + case 5: \ + *(--(c)) = (unsigned char)(((l2)) & 0xff); \ + case 4: \ + *(--(c)) = (unsigned char)(((l1) >> 24) & 0xff); \ + case 3: \ + *(--(c)) = (unsigned char)(((l1) >> 16) & 0xff); \ + case 2: \ + *(--(c)) = (unsigned char)(((l1) >> 8) & 0xff); \ + case 1: \ + *(--(c)) = (unsigned char)(((l1)) & 0xff); \ + } \ + } -# define n2s(c,s) ((s=(((unsigned int)((c)[0]))<< 8)| \ - (((unsigned int)((c)[1])) )),(c)+=2) -# define s2n(s,c) (((c)[0]=(unsigned char)(((s)>> 8)&0xff), \ - (c)[1]=(unsigned char)(((s) )&0xff)),(c)+=2) +#define n2s(c, s) ((s = (((unsigned int)((c)[0])) << 8) | (((unsigned int)((c)[1])))), (c) += 2) +#define s2n(s, c) (((c)[0] = (unsigned char)(((s) >> 8) & 0xff), \ + (c)[1] = (unsigned char)(((s)) & 0xff)), \ + (c) += 2) -# define n2l3(c,l) ((l =(((unsigned long)((c)[0]))<<16)| \ - (((unsigned long)((c)[1]))<< 8)| \ - (((unsigned long)((c)[2])) )),(c)+=3) +#define n2l3(c, l) ((l = (((unsigned long)((c)[0])) << 16) | (((unsigned long)((c)[1])) << 8) | (((unsigned long)((c)[2])))), (c) += 3) -# define l2n3(l,c) (((c)[0]=(unsigned char)(((l)>>16)&0xff), \ - (c)[1]=(unsigned char)(((l)>> 8)&0xff), \ - (c)[2]=(unsigned char)(((l) )&0xff)),(c)+=3) +#define l2n3(l, c) (((c)[0] = (unsigned char)(((l) >> 16) & 0xff), \ + (c)[1] = (unsigned char)(((l) >> 8) & 0xff), \ + (c)[2] = (unsigned char)(((l)) & 0xff)), \ + (c) += 3) static ossl_inline int ossl_ends_with_dirsep(const char *path) { if (*path != '\0') path += strlen(path) - 1; -# if defined __VMS +#if defined __VMS if (*path == ']' || *path == '>' || *path == ':') return 1; -# elif defined _WIN32 +#elif defined _WIN32 if (*path == '\\') return 1; -# endif +#endif return *path == '/'; } @@ -203,28 +219,28 @@ static ossl_inline char ossl_determine_dirsep(const char *path) if (ossl_ends_with_dirsep(path)) return '\0'; -# if defined(_WIN32) +#if defined(_WIN32) return '\\'; -# elif defined(__VMS) +#elif defined(__VMS) return ':'; -# else +#else return '/'; -# endif +#endif } static ossl_inline int ossl_is_absolute_path(const char *path) { -# if defined __VMS +#if defined __VMS if (strchr(path, ':') != NULL || ((path[0] == '[' || path[0] == '<') && path[1] != '.' && path[1] != '-' && path[1] != ']' && path[1] != '>')) return 1; -# elif defined _WIN32 +#elif defined _WIN32 if (path[0] == '\\' || (path[0] != '\0' && path[1] == ':')) return 1; -# endif +#endif return path[0] == '/'; } diff --git a/crypto/openssl/include/internal/comp.h b/crypto/openssl/include/internal/comp.h index 696042754299..a0151e2b5014 100644 --- a/crypto/openssl/include/internal/comp.h +++ b/crypto/openssl/include/internal/comp.h @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ #ifndef _INTERNAL_COMP_H -#define _INTERNAL_COMP_H +#define _INTERNAL_COMP_H #include <openssl/comp.h> diff --git a/crypto/openssl/include/internal/conf.h b/crypto/openssl/include/internal/conf.h index 8c6c29cd2c5f..e4fb787798ac 100644 --- a/crypto/openssl/include/internal/conf.h +++ b/crypto/openssl/include/internal/conf.h @@ -8,15 +8,13 @@ */ #ifndef OSSL_INTERNAL_CONF_H -# define OSSL_INTERNAL_CONF_H -# pragma once +#define OSSL_INTERNAL_CONF_H +#pragma once -# include <openssl/conf.h> +#include <openssl/conf.h> -# define DEFAULT_CONF_MFLAGS \ - (CONF_MFLAGS_DEFAULT_SECTION | \ - CONF_MFLAGS_IGNORE_MISSING_FILE | \ - CONF_MFLAGS_IGNORE_RETURN_CODES) +#define DEFAULT_CONF_MFLAGS \ + (CONF_MFLAGS_DEFAULT_SECTION | CONF_MFLAGS_IGNORE_MISSING_FILE | CONF_MFLAGS_IGNORE_RETURN_CODES) struct ossl_init_settings_st { char *filename; diff --git a/crypto/openssl/include/internal/constant_time.h b/crypto/openssl/include/internal/constant_time.h index 73219759e0ce..34f2b78329d5 100644 --- a/crypto/openssl/include/internal/constant_time.h +++ b/crypto/openssl/include/internal/constant_time.h @@ -8,12 +8,12 @@ */ #ifndef OSSL_INTERNAL_CONSTANT_TIME_H -# define OSSL_INTERNAL_CONSTANT_TIME_H -# pragma once +#define OSSL_INTERNAL_CONSTANT_TIME_H +#pragma once -# include <stdlib.h> -# include <string.h> -# include <openssl/e_os2.h> /* For 'ossl_inline' */ +#include <stdlib.h> +#include <string.h> +#include <openssl/e_os2.h> /* For 'ossl_inline' */ /*- * The boolean methods return a bitmask of all ones (0xff...f) for true @@ -38,10 +38,10 @@ static ossl_inline uint64_t constant_time_msb_64(uint64_t a); /* Returns 0xff..f if a < b and 0 otherwise. */ static ossl_inline unsigned int constant_time_lt(unsigned int a, - unsigned int b); + unsigned int b); /* Convenience method for getting an 8-bit mask. */ static ossl_inline unsigned char constant_time_lt_8(unsigned int a, - unsigned int b); + unsigned int b); /* Convenience method for uint32_t. */ static ossl_inline uint32_t constant_time_lt_32(uint32_t a, uint32_t b); @@ -50,10 +50,10 @@ static ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b); /* Returns 0xff..f if a >= b and 0 otherwise. */ static ossl_inline unsigned int constant_time_ge(unsigned int a, - unsigned int b); + unsigned int b); /* Convenience method for getting an 8-bit mask. */ static ossl_inline unsigned char constant_time_ge_8(unsigned int a, - unsigned int b); + unsigned int b); /* Returns 0xff..f if a == 0 and 0 otherwise. */ static ossl_inline unsigned int constant_time_is_zero(unsigned int a); @@ -64,10 +64,10 @@ static ossl_inline uint32_t constant_time_is_zero_32(uint32_t a); /* Returns 0xff..f if a == b and 0 otherwise. */ static ossl_inline unsigned int constant_time_eq(unsigned int a, - unsigned int b); + unsigned int b); /* Convenience method for getting an 8-bit mask. */ static ossl_inline unsigned char constant_time_eq_8(unsigned int a, - unsigned int b); + unsigned int b); /* Signed integers. */ static ossl_inline unsigned int constant_time_eq_int(int a, int b); /* Convenience method for getting an 8-bit mask. */ @@ -81,31 +81,29 @@ static ossl_inline unsigned char constant_time_eq_int_8(int a, int b); * (if |mask| is zero). */ static ossl_inline unsigned int constant_time_select(unsigned int mask, - unsigned int a, - unsigned int b); + unsigned int a, + unsigned int b); /* Convenience method for unsigned chars. */ static ossl_inline unsigned char constant_time_select_8(unsigned char mask, - unsigned char a, - unsigned char b); + unsigned char a, + unsigned char b); /* Convenience method for uint32_t. */ static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a, - uint32_t b); + uint32_t b); /* Convenience method for uint64_t. */ static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a, - uint64_t b); + uint64_t b); /* Convenience method for signed integers. */ static ossl_inline int constant_time_select_int(unsigned int mask, int a, - int b); - + int b); static ossl_inline unsigned int constant_time_msb(unsigned int a) { return 0 - (a >> (sizeof(a) * 8 - 1)); } - static ossl_inline uint32_t constant_time_msb_32(uint32_t a) { return 0 - (a >> 31); @@ -122,7 +120,7 @@ static ossl_inline size_t constant_time_msb_s(size_t a) } static ossl_inline unsigned int constant_time_lt(unsigned int a, - unsigned int b) + unsigned int b) { return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b))); } @@ -133,7 +131,7 @@ static ossl_inline size_t constant_time_lt_s(size_t a, size_t b) } static ossl_inline unsigned char constant_time_lt_8(unsigned int a, - unsigned int b) + unsigned int b) { return (unsigned char)constant_time_lt(a, b); } @@ -176,21 +174,21 @@ static ossl_inline BN_ULONG constant_time_is_zero_bn(BN_ULONG a) } static ossl_inline BN_ULONG constant_time_eq_bn(BN_ULONG a, - BN_ULONG b) + BN_ULONG b) { return constant_time_is_zero_bn(a ^ b); } static ossl_inline BN_ULONG constant_time_select_bn(BN_ULONG mask, - BN_ULONG a, - BN_ULONG b) + BN_ULONG a, + BN_ULONG b) { return (value_barrier_bn(mask) & a) | (value_barrier_bn(~mask) & b); } #endif static ossl_inline unsigned int constant_time_ge(unsigned int a, - unsigned int b) + unsigned int b) { return ~constant_time_lt(a, b); } @@ -201,7 +199,7 @@ static ossl_inline size_t constant_time_ge_s(size_t a, size_t b) } static ossl_inline unsigned char constant_time_ge_8(unsigned int a, - unsigned int b) + unsigned int b) { return (unsigned char)constant_time_ge(a, b); } @@ -237,7 +235,7 @@ static ossl_inline uint64_t constant_time_is_zero_64(uint64_t a) } static ossl_inline unsigned int constant_time_eq(unsigned int a, - unsigned int b) + unsigned int b) { return constant_time_is_zero(a ^ b); } @@ -248,7 +246,7 @@ static ossl_inline size_t constant_time_eq_s(size_t a, size_t b) } static ossl_inline unsigned char constant_time_eq_8(unsigned int a, - unsigned int b) + unsigned int b) { return (unsigned char)constant_time_eq(a, b); } @@ -335,28 +333,28 @@ static ossl_inline unsigned char value_barrier_8(unsigned char a) } static ossl_inline unsigned int constant_time_select(unsigned int mask, - unsigned int a, - unsigned int b) + unsigned int a, + unsigned int b) { return (value_barrier(mask) & a) | (value_barrier(~mask) & b); } static ossl_inline size_t constant_time_select_s(size_t mask, - size_t a, - size_t b) + size_t a, + size_t b) { return (value_barrier_s(mask) & a) | (value_barrier_s(~mask) & b); } static ossl_inline unsigned char constant_time_select_8(unsigned char mask, - unsigned char a, - unsigned char b) + unsigned char a, + unsigned char b) { return (unsigned char)constant_time_select(mask, a, b); } static ossl_inline int constant_time_select_int(unsigned int mask, int a, - int b) + int b) { return (int)constant_time_select(mask, (unsigned)(a), (unsigned)(b)); } @@ -364,17 +362,17 @@ static ossl_inline int constant_time_select_int(unsigned int mask, int a, static ossl_inline int constant_time_select_int_s(size_t mask, int a, int b) { return (int)constant_time_select((unsigned)mask, (unsigned)(a), - (unsigned)(b)); + (unsigned)(b)); } static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a, - uint32_t b) + uint32_t b) { return (value_barrier_32(mask) & a) | (value_barrier_32(~mask) & b); } static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a, - uint64_t b) + uint64_t b) { return (value_barrier_64(mask) & a) | (value_barrier_64(~mask) & b); } @@ -390,11 +388,11 @@ static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a, * } */ static ossl_inline void constant_time_cond_swap_32(uint32_t mask, uint32_t *a, - uint32_t *b) + uint32_t *b) { uint32_t xor = *a ^ *b; - xor &= value_barrier_32(mask); + xor&= value_barrier_32(mask); *a ^= xor; *b ^= xor; } @@ -410,11 +408,11 @@ static ossl_inline void constant_time_cond_swap_32(uint32_t mask, uint32_t *a, * } */ static ossl_inline void constant_time_cond_swap_64(uint64_t mask, uint64_t *a, - uint64_t *b) + uint64_t *b) { uint64_t xor = *a ^ *b; - xor &= value_barrier_64(mask); + xor&= value_barrier_64(mask); *a ^= xor; *b ^= xor; } @@ -432,9 +430,9 @@ static ossl_inline void constant_time_cond_swap_64(uint64_t mask, uint64_t *a, * } */ static ossl_inline void constant_time_cond_swap_buff(unsigned char mask, - unsigned char *a, - unsigned char *b, - size_t len) + unsigned char *a, + unsigned char *b, + size_t len) { size_t i; unsigned char tmp; @@ -453,10 +451,10 @@ static ossl_inline void constant_time_cond_swap_buff(unsigned char mask, * private. */ static ossl_inline void constant_time_lookup(void *out, - const void *table, - size_t rowsize, - size_t numrows, - size_t idx) + const void *table, + size_t rowsize, + size_t numrows, + size_t idx) { size_t i, j; const unsigned char *tablec = (const unsigned char *)table; @@ -479,4 +477,4 @@ static ossl_inline void constant_time_lookup(void *out, */ void err_clear_last_constant_time(int clear); -#endif /* OSSL_INTERNAL_CONSTANT_TIME_H */ +#endif /* OSSL_INTERNAL_CONSTANT_TIME_H */ diff --git a/crypto/openssl/include/internal/core.h b/crypto/openssl/include/internal/core.h index 03adb66bd342..ea4b57e18bbb 100644 --- a/crypto/openssl/include/internal/core.h +++ b/crypto/openssl/include/internal/core.h @@ -8,8 +8,8 @@ */ #ifndef OSSL_INTERNAL_CORE_H -# define OSSL_INTERNAL_CORE_H -# pragma once +#define OSSL_INTERNAL_CORE_H +#pragma once /* * namespaces: @@ -38,30 +38,30 @@ typedef struct ossl_method_construct_method_st { void *(*get)(void *store, const OSSL_PROVIDER **prov, void *data); /* Store a method in a store */ int (*put)(void *store, void *method, const OSSL_PROVIDER *prov, - const char *name, const char *propdef, void *data); + const char *name, const char *propdef, void *data); /* Construct a new method */ void *(*construct)(const OSSL_ALGORITHM *algodef, OSSL_PROVIDER *prov, - void *data); + void *data); /* Destruct a method */ void (*destruct)(void *method, void *data); } OSSL_METHOD_CONSTRUCT_METHOD; void *ossl_method_construct(OSSL_LIB_CTX *ctx, int operation_id, - OSSL_PROVIDER **provider_rw, int force_cache, - OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data); + OSSL_PROVIDER **provider_rw, int force_cache, + OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data); void ossl_algorithm_do_all(OSSL_LIB_CTX *libctx, int operation_id, - OSSL_PROVIDER *provider, - int (*pre)(OSSL_PROVIDER *, int operation_id, - int no_store, void *data, int *result), - int (*reserve_store)(int no_store, void *data), - void (*fn)(OSSL_PROVIDER *provider, - const OSSL_ALGORITHM *algo, - int no_store, void *data), - int (*unreserve_store)(void *data), - int (*post)(OSSL_PROVIDER *, int operation_id, - int no_store, void *data, int *result), - void *data); + OSSL_PROVIDER *provider, + int (*pre)(OSSL_PROVIDER *, int operation_id, + int no_store, void *data, int *result), + int (*reserve_store)(int no_store, void *data), + void (*fn)(OSSL_PROVIDER *provider, + const OSSL_ALGORITHM *algo, + int no_store, void *data), + int (*unreserve_store)(void *data), + int (*post)(OSSL_PROVIDER *, int operation_id, + int no_store, void *data, int *result), + void *data); char *ossl_algorithm_get1_first_name(const OSSL_ALGORITHM *algo); __owur int ossl_lib_ctx_write_lock(OSSL_LIB_CTX *ctx); diff --git a/crypto/openssl/include/internal/crmf.h b/crypto/openssl/include/internal/crmf.h index 9e37320d8330..e5f918d8e679 100644 --- a/crypto/openssl/include/internal/crmf.h +++ b/crypto/openssl/include/internal/crmf.h @@ -7,10 +7,10 @@ * https://www.openssl.org/source/license.html */ #ifndef OSSL_CRYPTO_CRMF_H -# define OSSL_CRYPTO_CRMF_H -# pragma once +#define OSSL_CRYPTO_CRMF_H +#pragma once -# include <openssl/crmf.h> +#include <openssl/crmf.h> struct ossl_crmf_attributetypeandvalue_st { ASN1_OBJECT *type; diff --git a/crypto/openssl/include/internal/cryptlib.h b/crypto/openssl/include/internal/cryptlib.h index da442f8a86f7..50aec7e7f4fe 100644 --- a/crypto/openssl/include/internal/cryptlib.h +++ b/crypto/openssl/include/internal/cryptlib.h @@ -8,23 +8,23 @@ */ #ifndef OSSL_INTERNAL_CRYPTLIB_H -# define OSSL_INTERNAL_CRYPTLIB_H -# pragma once +#define OSSL_INTERNAL_CRYPTLIB_H +#pragma once -# ifdef OPENSSL_USE_APPLINK -# define BIO_FLAGS_UPLINK_INTERNAL 0x8000 -# include "ms/uplink.h" -# else -# define BIO_FLAGS_UPLINK_INTERNAL 0 -# endif +#ifdef OPENSSL_USE_APPLINK +#define BIO_FLAGS_UPLINK_INTERNAL 0x8000 +#include "ms/uplink.h" +#else +#define BIO_FLAGS_UPLINK_INTERNAL 0 +#endif -# include "internal/common.h" +#include "internal/common.h" -# include <openssl/crypto.h> -# include <openssl/buffer.h> -# include <openssl/bio.h> -# include <openssl/asn1.h> -# include <openssl/err.h> +#include <openssl/crypto.h> +#include <openssl/buffer.h> +#include <openssl/bio.h> +#include <openssl/asn1.h> +#include <openssl/err.h> typedef struct ex_callback_st EX_CALLBACK; DEFINE_STACK_OF(EX_CALLBACK) @@ -33,10 +33,8 @@ typedef struct mem_st MEM; DEFINE_LHASH_OF_EX(MEM); void OPENSSL_cpuid_setup(void); -#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ - defined(__x86_64) || defined(__x86_64__) || \ - defined(_M_AMD64) || defined(_M_X64) -# define OPENSSL_IA32CAP_P_MAX_INDEXES 10 +#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64) +#define OPENSSL_IA32CAP_P_MAX_INDEXES 10 extern unsigned int OPENSSL_ia32cap_P[]; #endif @@ -50,11 +48,11 @@ char *ossl_safe_getenv(const char *name); extern CRYPTO_RWLOCK *memdbg_lock; int openssl_strerror_r(int errnum, char *buf, size_t buflen); -# if !defined(OPENSSL_NO_STDIO) +#if !defined(OPENSSL_NO_STDIO) FILE *openssl_fopen(const char *filename, const char *mode); -# else +#else void *openssl_fopen(const char *filename, const char *mode); -# endif +#endif uint32_t OPENSSL_rdtsc(void); size_t OPENSSL_instrument_bus(unsigned int *, size_t); @@ -67,9 +65,9 @@ size_t OPENSSL_instrument_bus2(unsigned int *, size_t, size_t); * exdata has a stack of callbacks for each instance. */ struct ex_callback_st { - long argl; /* Arbitrary long */ - void *argp; /* Arbitrary void * */ - int priority; /* Priority ordering for freeing */ + long argl; /* Arbitrary long */ + void *argp; /* Arbitrary void * */ + int priority; /* Priority ordering for freeing */ CRYPTO_EX_new *new_func; CRYPTO_EX_free *free_func; CRYPTO_EX_dup *dup_func; @@ -90,37 +88,37 @@ typedef struct ossl_ex_data_global_st { /* OSSL_LIB_CTX */ -# define OSSL_LIB_CTX_PROVIDER_STORE_RUN_ONCE_INDEX 0 -# define OSSL_LIB_CTX_DEFAULT_METHOD_STORE_RUN_ONCE_INDEX 1 -# define OSSL_LIB_CTX_METHOD_STORE_RUN_ONCE_INDEX 2 -# define OSSL_LIB_CTX_MAX_RUN_ONCE 3 +#define OSSL_LIB_CTX_PROVIDER_STORE_RUN_ONCE_INDEX 0 +#define OSSL_LIB_CTX_DEFAULT_METHOD_STORE_RUN_ONCE_INDEX 1 +#define OSSL_LIB_CTX_METHOD_STORE_RUN_ONCE_INDEX 2 +#define OSSL_LIB_CTX_MAX_RUN_ONCE 3 -# define OSSL_LIB_CTX_EVP_METHOD_STORE_INDEX 0 -# define OSSL_LIB_CTX_PROVIDER_STORE_INDEX 1 -# define OSSL_LIB_CTX_PROPERTY_DEFN_INDEX 2 -# define OSSL_LIB_CTX_PROPERTY_STRING_INDEX 3 -# define OSSL_LIB_CTX_NAMEMAP_INDEX 4 -# define OSSL_LIB_CTX_DRBG_INDEX 5 -# define OSSL_LIB_CTX_DRBG_NONCE_INDEX 6 +#define OSSL_LIB_CTX_EVP_METHOD_STORE_INDEX 0 +#define OSSL_LIB_CTX_PROVIDER_STORE_INDEX 1 +#define OSSL_LIB_CTX_PROPERTY_DEFN_INDEX 2 +#define OSSL_LIB_CTX_PROPERTY_STRING_INDEX 3 +#define OSSL_LIB_CTX_NAMEMAP_INDEX 4 +#define OSSL_LIB_CTX_DRBG_INDEX 5 +#define OSSL_LIB_CTX_DRBG_NONCE_INDEX 6 /* slot 7 unused, was CRNG test data and can be reused */ -# ifdef FIPS_MODULE -# define OSSL_LIB_CTX_THREAD_EVENT_HANDLER_INDEX 8 -# endif -# define OSSL_LIB_CTX_FIPS_PROV_INDEX 9 -# define OSSL_LIB_CTX_ENCODER_STORE_INDEX 10 -# define OSSL_LIB_CTX_DECODER_STORE_INDEX 11 -# define OSSL_LIB_CTX_SELF_TEST_CB_INDEX 12 -# define OSSL_LIB_CTX_BIO_PROV_INDEX 13 -# define OSSL_LIB_CTX_GLOBAL_PROPERTIES 14 -# define OSSL_LIB_CTX_STORE_LOADER_STORE_INDEX 15 -# define OSSL_LIB_CTX_PROVIDER_CONF_INDEX 16 -# define OSSL_LIB_CTX_BIO_CORE_INDEX 17 -# define OSSL_LIB_CTX_CHILD_PROVIDER_INDEX 18 -# define OSSL_LIB_CTX_THREAD_INDEX 19 -# define OSSL_LIB_CTX_DECODER_CACHE_INDEX 20 -# define OSSL_LIB_CTX_COMP_METHODS 21 -# define OSSL_LIB_CTX_INDICATOR_CB_INDEX 22 -# define OSSL_LIB_CTX_MAX_INDEXES 22 +#ifdef FIPS_MODULE +#define OSSL_LIB_CTX_THREAD_EVENT_HANDLER_INDEX 8 +#endif +#define OSSL_LIB_CTX_FIPS_PROV_INDEX 9 +#define OSSL_LIB_CTX_ENCODER_STORE_INDEX 10 +#define OSSL_LIB_CTX_DECODER_STORE_INDEX 11 +#define OSSL_LIB_CTX_SELF_TEST_CB_INDEX 12 +#define OSSL_LIB_CTX_BIO_PROV_INDEX 13 +#define OSSL_LIB_CTX_GLOBAL_PROPERTIES 14 +#define OSSL_LIB_CTX_STORE_LOADER_STORE_INDEX 15 +#define OSSL_LIB_CTX_PROVIDER_CONF_INDEX 16 +#define OSSL_LIB_CTX_BIO_CORE_INDEX 17 +#define OSSL_LIB_CTX_CHILD_PROVIDER_INDEX 18 +#define OSSL_LIB_CTX_THREAD_INDEX 19 +#define OSSL_LIB_CTX_DECODER_CACHE_INDEX 20 +#define OSSL_LIB_CTX_COMP_METHODS 21 +#define OSSL_LIB_CTX_INDICATOR_CB_INDEX 22 +#define OSSL_LIB_CTX_MAX_INDEXES 22 OSSL_LIB_CTX *ossl_lib_ctx_get_concrete(OSSL_LIB_CTX *ctx); int ossl_lib_ctx_is_default(OSSL_LIB_CTX *ctx); @@ -137,32 +135,32 @@ CRYPTO_THREAD_LOCAL *ossl_lib_ctx_get_rcukey(OSSL_LIB_CTX *libctx); OSSL_LIB_CTX *ossl_crypto_ex_data_get_ossl_lib_ctx(const CRYPTO_EX_DATA *ad); int ossl_crypto_new_ex_data_ex(OSSL_LIB_CTX *ctx, int class_index, void *obj, - CRYPTO_EX_DATA *ad); + CRYPTO_EX_DATA *ad); int ossl_crypto_get_ex_new_index_ex(OSSL_LIB_CTX *ctx, int class_index, - long argl, void *argp, - CRYPTO_EX_new *new_func, - CRYPTO_EX_dup *dup_func, - CRYPTO_EX_free *free_func, - int priority); + long argl, void *argp, + CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, + CRYPTO_EX_free *free_func, + int priority); int ossl_crypto_free_ex_index_ex(OSSL_LIB_CTX *ctx, int class_index, int idx); /* Function for simple binary search */ /* Flags */ -# define OSSL_BSEARCH_VALUE_ON_NOMATCH 0x01 -# define OSSL_BSEARCH_FIRST_VALUE_ON_MATCH 0x02 +#define OSSL_BSEARCH_VALUE_ON_NOMATCH 0x01 +#define OSSL_BSEARCH_FIRST_VALUE_ON_MATCH 0x02 const void *ossl_bsearch(const void *key, const void *base, int num, - int size, int (*cmp) (const void *, const void *), - int flags); + int size, int (*cmp)(const void *, const void *), + int flags); char *ossl_sk_ASN1_UTF8STRING2text(STACK_OF(ASN1_UTF8STRING) *text, - const char *sep, size_t max_len); + const char *sep, size_t max_len); char *ossl_ipaddr_to_asc(unsigned char *p, int len); char *ossl_buf2hexstr_sep(const unsigned char *buf, long buflen, char sep); unsigned char *ossl_hexstr2buf_sep(const char *str, long *buflen, - const char sep); + const char sep); /** * Writes |n| value in hex format into |buf|, diff --git a/crypto/openssl/include/internal/dane.h b/crypto/openssl/include/internal/dane.h index a3d78a7f8050..9c040eedc683 100644 --- a/crypto/openssl/include/internal/dane.h +++ b/crypto/openssl/include/internal/dane.h @@ -9,36 +9,36 @@ #ifndef OSSL_INTERNAL_DANE_H #define OSSL_INTERNAL_DANE_H -# pragma once +#pragma once -# include <openssl/safestack.h> +#include <openssl/safestack.h> /*- * Certificate usages: * https://tools.ietf.org/html/rfc6698#section-2.1.1 */ -#define DANETLS_USAGE_PKIX_TA 0 -#define DANETLS_USAGE_PKIX_EE 1 -#define DANETLS_USAGE_DANE_TA 2 -#define DANETLS_USAGE_DANE_EE 3 -#define DANETLS_USAGE_LAST DANETLS_USAGE_DANE_EE +#define DANETLS_USAGE_PKIX_TA 0 +#define DANETLS_USAGE_PKIX_EE 1 +#define DANETLS_USAGE_DANE_TA 2 +#define DANETLS_USAGE_DANE_EE 3 +#define DANETLS_USAGE_LAST DANETLS_USAGE_DANE_EE /*- * Selectors: * https://tools.ietf.org/html/rfc6698#section-2.1.2 */ -#define DANETLS_SELECTOR_CERT 0 -#define DANETLS_SELECTOR_SPKI 1 -#define DANETLS_SELECTOR_LAST DANETLS_SELECTOR_SPKI +#define DANETLS_SELECTOR_CERT 0 +#define DANETLS_SELECTOR_SPKI 1 +#define DANETLS_SELECTOR_LAST DANETLS_SELECTOR_SPKI /*- * Matching types: * https://tools.ietf.org/html/rfc6698#section-2.1.3 */ -#define DANETLS_MATCHING_FULL 0 -#define DANETLS_MATCHING_2256 1 -#define DANETLS_MATCHING_2512 2 -#define DANETLS_MATCHING_LAST DANETLS_MATCHING_2512 +#define DANETLS_MATCHING_FULL 0 +#define DANETLS_MATCHING_2256 1 +#define DANETLS_MATCHING_2512 2 +#define DANETLS_MATCHING_LAST DANETLS_MATCHING_2512 typedef struct danetls_record_st { uint8_t usage; @@ -55,10 +55,10 @@ DEFINE_STACK_OF(danetls_record) * Shared DANE context */ struct dane_ctx_st { - const EVP_MD **mdevp; /* mtype -> digest */ - uint8_t *mdord; /* mtype -> preference */ - uint8_t mdmax; /* highest supported mtype */ - unsigned long flags; /* feature bitmask */ + const EVP_MD **mdevp; /* mtype -> digest */ + uint8_t *mdord; /* mtype -> preference */ + uint8_t mdmax; /* highest supported mtype */ + unsigned long flags; /* feature bitmask */ }; /* @@ -67,19 +67,19 @@ struct dane_ctx_st { struct ssl_dane_st { struct dane_ctx_st *dctx; STACK_OF(danetls_record) *trecs; - STACK_OF(X509) *certs; /* DANE-TA(2) Cert(0) Full(0) certs */ - danetls_record *mtlsa; /* Matching TLSA record */ - X509 *mcert; /* DANE matched cert */ - uint32_t umask; /* Usages present */ - int mdpth; /* Depth of matched cert */ - int pdpth; /* Depth of PKIX trust */ - unsigned long flags; /* feature bitmask */ + STACK_OF(X509) *certs; /* DANE-TA(2) Cert(0) Full(0) certs */ + danetls_record *mtlsa; /* Matching TLSA record */ + X509 *mcert; /* DANE matched cert */ + uint32_t umask; /* Usages present */ + int mdpth; /* Depth of matched cert */ + int pdpth; /* Depth of PKIX trust */ + unsigned long flags; /* feature bitmask */ }; -#define DANETLS_ENABLED(dane) \ +#define DANETLS_ENABLED(dane) \ ((dane) != NULL && sk_danetls_record_num((dane)->trecs) > 0) -#define DANETLS_USAGE_BIT(u) (((uint32_t)1) << u) +#define DANETLS_USAGE_BIT(u) (((uint32_t)1) << u) #define DANETLS_PKIX_TA_MASK (DANETLS_USAGE_BIT(DANETLS_USAGE_PKIX_TA)) #define DANETLS_PKIX_EE_MASK (DANETLS_USAGE_BIT(DANETLS_USAGE_PKIX_EE)) @@ -93,12 +93,12 @@ struct ssl_dane_st { #define DANETLS_HAS_PKIX(dane) ((dane) && ((dane)->umask & DANETLS_PKIX_MASK)) #define DANETLS_HAS_DANE(dane) ((dane) && ((dane)->umask & DANETLS_DANE_MASK)) -#define DANETLS_HAS_TA(dane) ((dane) && ((dane)->umask & DANETLS_TA_MASK)) -#define DANETLS_HAS_EE(dane) ((dane) && ((dane)->umask & DANETLS_EE_MASK)) +#define DANETLS_HAS_TA(dane) ((dane) && ((dane)->umask & DANETLS_TA_MASK)) +#define DANETLS_HAS_EE(dane) ((dane) && ((dane)->umask & DANETLS_EE_MASK)) -#define DANETLS_HAS_PKIX_TA(dane) ((dane)&&((dane)->umask & DANETLS_PKIX_TA_MASK)) -#define DANETLS_HAS_PKIX_EE(dane) ((dane)&&((dane)->umask & DANETLS_PKIX_EE_MASK)) -#define DANETLS_HAS_DANE_TA(dane) ((dane)&&((dane)->umask & DANETLS_DANE_TA_MASK)) -#define DANETLS_HAS_DANE_EE(dane) ((dane)&&((dane)->umask & DANETLS_DANE_EE_MASK)) +#define DANETLS_HAS_PKIX_TA(dane) ((dane) && ((dane)->umask & DANETLS_PKIX_TA_MASK)) +#define DANETLS_HAS_PKIX_EE(dane) ((dane) && ((dane)->umask & DANETLS_PKIX_EE_MASK)) +#define DANETLS_HAS_DANE_TA(dane) ((dane) && ((dane)->umask & DANETLS_DANE_TA_MASK)) +#define DANETLS_HAS_DANE_EE(dane) ((dane) && ((dane)->umask & DANETLS_DANE_EE_MASK)) #endif /* OSSL_INTERNAL_DANE_H */ diff --git a/crypto/openssl/include/internal/deprecated.h b/crypto/openssl/include/internal/deprecated.h index a313a015459e..2675c49f7226 100644 --- a/crypto/openssl/include/internal/deprecated.h +++ b/crypto/openssl/include/internal/deprecated.h @@ -17,14 +17,14 @@ */ #ifndef OSSL_INTERNAL_DEPRECATED_H -# define OSSL_INTERNAL_DEPRECATED_H -# pragma once +#define OSSL_INTERNAL_DEPRECATED_H +#pragma once -# include <openssl/configuration.h> +#include <openssl/configuration.h> -# undef OPENSSL_NO_DEPRECATED -# define OPENSSL_SUPPRESS_DEPRECATED +#undef OPENSSL_NO_DEPRECATED +#define OPENSSL_SUPPRESS_DEPRECATED -# include <openssl/macros.h> +#include <openssl/macros.h> #endif diff --git a/crypto/openssl/include/internal/der.h b/crypto/openssl/include/internal/der.h index 8d6db8f06625..fe2d462caa9f 100644 --- a/crypto/openssl/include/internal/der.h +++ b/crypto/openssl/include/internal/der.h @@ -8,11 +8,11 @@ */ #ifndef OSSL_INTERNAL_DER_H -# define OSSL_INTERNAL_DER_H -# pragma once +#define OSSL_INTERNAL_DER_H +#pragma once -# include <openssl/bn.h> -# include "internal/packet.h" +#include <openssl/bn.h> +#include "internal/packet.h" /* * NOTE: X.690 numbers the identifier octet bits 1 to 8. @@ -26,42 +26,42 @@ * These are only valid for the UNIVERSAL class. With the other classes, * these bits have a different meaning. */ -# define DER_P_EOC 0 /* BER End Of Contents tag */ -# define DER_P_BOOLEAN 1 -# define DER_P_INTEGER 2 -# define DER_P_BIT_STRING 3 -# define DER_P_OCTET_STRING 4 -# define DER_P_NULL 5 -# define DER_P_OBJECT 6 -# define DER_P_OBJECT_DESCRIPTOR 7 -# define DER_P_EXTERNAL 8 -# define DER_P_REAL 9 -# define DER_P_ENUMERATED 10 -# define DER_P_UTF8STRING 12 -# define DER_P_SEQUENCE 16 -# define DER_P_SET 17 -# define DER_P_NUMERICSTRING 18 -# define DER_P_PRINTABLESTRING 19 -# define DER_P_T61STRING 20 -# define DER_P_VIDEOTEXSTRING 21 -# define DER_P_IA5STRING 22 -# define DER_P_UTCTIME 23 -# define DER_P_GENERALIZEDTIME 24 -# define DER_P_GRAPHICSTRING 25 -# define DER_P_ISO64STRING 26 -# define DER_P_GENERALSTRING 27 -# define DER_P_UNIVERSALSTRING 28 -# define DER_P_BMPSTRING 30 +#define DER_P_EOC 0 /* BER End Of Contents tag */ +#define DER_P_BOOLEAN 1 +#define DER_P_INTEGER 2 +#define DER_P_BIT_STRING 3 +#define DER_P_OCTET_STRING 4 +#define DER_P_NULL 5 +#define DER_P_OBJECT 6 +#define DER_P_OBJECT_DESCRIPTOR 7 +#define DER_P_EXTERNAL 8 +#define DER_P_REAL 9 +#define DER_P_ENUMERATED 10 +#define DER_P_UTF8STRING 12 +#define DER_P_SEQUENCE 16 +#define DER_P_SET 17 +#define DER_P_NUMERICSTRING 18 +#define DER_P_PRINTABLESTRING 19 +#define DER_P_T61STRING 20 +#define DER_P_VIDEOTEXSTRING 21 +#define DER_P_IA5STRING 22 +#define DER_P_UTCTIME 23 +#define DER_P_GENERALIZEDTIME 24 +#define DER_P_GRAPHICSTRING 25 +#define DER_P_ISO64STRING 26 +#define DER_P_GENERALSTRING 27 +#define DER_P_UNIVERSALSTRING 28 +#define DER_P_BMPSTRING 30 /* DER Flags, occupying bit 6 in the DER identifier byte */ -# define DER_F_PRIMITIVE 0x00 -# define DER_F_CONSTRUCTED 0x20 +#define DER_F_PRIMITIVE 0x00 +#define DER_F_CONSTRUCTED 0x20 /* DER classes tags, occupying bits 7-8 in the DER identifier byte */ -# define DER_C_UNIVERSAL 0x00 -# define DER_C_APPLICATION 0x40 -# define DER_C_CONTEXT 0x80 -# define DER_C_PRIVATE 0xC0 +#define DER_C_UNIVERSAL 0x00 +#define DER_C_APPLICATION 0x40 +#define DER_C_CONTEXT 0x80 +#define DER_C_PRIVATE 0xC0 /* * Run-time constructors. @@ -71,18 +71,18 @@ */ /* This can be used for all items that don't have a context */ -# define DER_NO_CONTEXT -1 +#define DER_NO_CONTEXT -1 int ossl_DER_w_precompiled(WPACKET *pkt, int tag, - const unsigned char *precompiled, - size_t precompiled_n); + const unsigned char *precompiled, + size_t precompiled_n); int ossl_DER_w_boolean(WPACKET *pkt, int tag, int b); int ossl_DER_w_uint32(WPACKET *pkt, int tag, uint32_t v); int ossl_DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v); int ossl_DER_w_null(WPACKET *pkt, int tag); int ossl_DER_w_octet_string(WPACKET *pkt, int tag, - const unsigned char *data, size_t data_n); + const unsigned char *data, size_t data_n); int ossl_DER_w_octet_string_uint32(WPACKET *pkt, int tag, uint32_t value); /* diff --git a/crypto/openssl/include/internal/deterministic_nonce.h b/crypto/openssl/include/internal/deterministic_nonce.h index 5f0313fe3842..556853045937 100644 --- a/crypto/openssl/include/internal/deterministic_nonce.h +++ b/crypto/openssl/include/internal/deterministic_nonce.h @@ -8,17 +8,17 @@ */ #ifndef OSSL_INTERNAL_DETERMINISTIC_NONCE_H -# define OSSL_INTERNAL_DETERMINISTIC_NONCE_H -# pragma once +#define OSSL_INTERNAL_DETERMINISTIC_NONCE_H +#pragma once -# include <openssl/bn.h> +#include <openssl/bn.h> int ossl_gen_deterministic_nonce_rfc6979(BIGNUM *out, const BIGNUM *q, - const BIGNUM *priv, - const unsigned char *message, - size_t message_len, - const char *digestname, - OSSL_LIB_CTX *libctx, - const char *propq); + const BIGNUM *priv, + const unsigned char *message, + size_t message_len, + const char *digestname, + OSSL_LIB_CTX *libctx, + const char *propq); #endif /*OSSL_INTERNAL_DETERMINISTIC_NONCE_H */ diff --git a/crypto/openssl/include/internal/dso.h b/crypto/openssl/include/internal/dso.h index 160ddb98db14..0f3edbff99c8 100644 --- a/crypto/openssl/include/internal/dso.h +++ b/crypto/openssl/include/internal/dso.h @@ -8,16 +8,16 @@ */ #ifndef OSSL_INTERNAL_DSO_H -# define OSSL_INTERNAL_DSO_H -# pragma once +#define OSSL_INTERNAL_DSO_H +#pragma once -# include <openssl/crypto.h> -# include "internal/dsoerr.h" +#include <openssl/crypto.h> +#include "internal/dsoerr.h" /* These values are used as commands to DSO_ctrl() */ -# define DSO_CTRL_GET_FLAGS 1 -# define DSO_CTRL_SET_FLAGS 2 -# define DSO_CTRL_OR_FLAGS 3 +#define DSO_CTRL_GET_FLAGS 1 +#define DSO_CTRL_SET_FLAGS 2 +#define DSO_CTRL_OR_FLAGS 3 /* * By default, DSO_load() will translate the provided filename into a form @@ -30,7 +30,7 @@ * the caller has prompted the user for a path to a driver library so the * filename should be interpreted as-is. */ -# define DSO_FLAG_NO_NAME_TRANSLATION 0x01 +#define DSO_FLAG_NO_NAME_TRANSLATION 0x01 /* * An extra flag to give if only the extension should be added as * translation. This is obviously only of importance on Unix and other @@ -38,21 +38,21 @@ * something, like 'lib', and ignored everywhere else. This flag is also * ignored if DSO_FLAG_NO_NAME_TRANSLATION is used at the same time. */ -# define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02 +#define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02 /* * Don't unload the DSO when we call DSO_free() */ -# define DSO_FLAG_NO_UNLOAD_ON_FREE 0x04 +#define DSO_FLAG_NO_UNLOAD_ON_FREE 0x04 /* * This flag loads the library with public symbols. Meaning: The exported * symbols of this library are public to all libraries loaded after this * library. At the moment only implemented in unix. */ -# define DSO_FLAG_GLOBAL_SYMBOLS 0x20 +#define DSO_FLAG_GLOBAL_SYMBOLS 0x20 -typedef void (*DSO_FUNC_TYPE) (void); +typedef void (*DSO_FUNC_TYPE)(void); typedef struct dso_st DSO; typedef struct dso_meth_st DSO_METHOD; diff --git a/crypto/openssl/include/internal/dsoerr.h b/crypto/openssl/include/internal/dsoerr.h index b1719e8377f4..3b1de62fccc4 100644 --- a/crypto/openssl/include/internal/dsoerr.h +++ b/crypto/openssl/include/internal/dsoerr.h @@ -9,40 +9,39 @@ */ #ifndef OSSL_INTERNAL_DSOERR_H -# define OSSL_INTERNAL_DSOERR_H -# pragma once +#define OSSL_INTERNAL_DSOERR_H +#pragma once -# include <openssl/opensslconf.h> -# include <openssl/symhacks.h> +#include <openssl/opensslconf.h> +#include <openssl/symhacks.h> -# ifdef __cplusplus +#ifdef __cplusplus extern "C" { -# endif +#endif int ossl_err_load_DSO_strings(void); /* * DSO reason codes. */ -# define DSO_R_CTRL_FAILED 100 -# define DSO_R_DSO_ALREADY_LOADED 110 -# define DSO_R_EMPTY_FILE_STRUCTURE 113 -# define DSO_R_FAILURE 114 -# define DSO_R_FILENAME_TOO_BIG 101 -# define DSO_R_FINISH_FAILED 102 -# define DSO_R_INCORRECT_FILE_SYNTAX 115 -# define DSO_R_LOAD_FAILED 103 -# define DSO_R_NAME_TRANSLATION_FAILED 109 -# define DSO_R_NO_FILENAME 111 -# define DSO_R_NULL_HANDLE 104 -# define DSO_R_SET_FILENAME_FAILED 112 -# define DSO_R_STACK_ERROR 105 -# define DSO_R_SYM_FAILURE 106 -# define DSO_R_UNLOAD_FAILED 107 -# define DSO_R_UNSUPPORTED 108 - +#define DSO_R_CTRL_FAILED 100 +#define DSO_R_DSO_ALREADY_LOADED 110 +#define DSO_R_EMPTY_FILE_STRUCTURE 113 +#define DSO_R_FAILURE 114 +#define DSO_R_FILENAME_TOO_BIG 101 +#define DSO_R_FINISH_FAILED 102 +#define DSO_R_INCORRECT_FILE_SYNTAX 115 +#define DSO_R_LOAD_FAILED 103 +#define DSO_R_NAME_TRANSLATION_FAILED 109 +#define DSO_R_NO_FILENAME 111 +#define DSO_R_NULL_HANDLE 104 +#define DSO_R_SET_FILENAME_FAILED 112 +#define DSO_R_STACK_ERROR 105 +#define DSO_R_SYM_FAILURE 106 +#define DSO_R_UNLOAD_FAILED 107 +#define DSO_R_UNSUPPORTED 108 -# ifdef __cplusplus +#ifdef __cplusplus } -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/e_os.h b/crypto/openssl/include/internal/e_os.h index 8419f7143669..d287d910554b 100644 --- a/crypto/openssl/include/internal/e_os.h +++ b/crypto/openssl/include/internal/e_os.h @@ -8,243 +8,243 @@ */ #ifndef OSSL_E_OS_H -# define OSSL_E_OS_H +#define OSSL_E_OS_H -# include <limits.h> -# include <openssl/opensslconf.h> +#include <limits.h> +#include <openssl/opensslconf.h> -# include <openssl/e_os2.h> -# include <openssl/crypto.h> -# include "internal/numbers.h" /* Ensure the definition of SIZE_MAX */ +#include <openssl/e_os2.h> +#include <openssl/crypto.h> +#include "internal/numbers.h" /* Ensure the definition of SIZE_MAX */ /* * <openssl/e_os2.h> contains what we can justify to make visible to the * outside; this file e_os.h is not part of the exported interface. */ -# if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) -# define NO_CHMOD -# define NO_SYSLOG -# endif +#if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) +#define NO_CHMOD +#define NO_SYSLOG +#endif -# define get_last_sys_error() errno -# define clear_sys_error() errno=0 -# define set_sys_error(e) errno=(e) +#define get_last_sys_error() errno +#define clear_sys_error() errno = 0 +#define set_sys_error(e) errno = (e) /******************************************************************** The Microsoft section ********************************************************************/ -# if defined(OPENSSL_SYS_WIN32) && !defined(WIN32) -# define WIN32 -# endif -# if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -# endif -# if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS) -# define MSDOS -# endif +#if defined(OPENSSL_SYS_WIN32) && !defined(WIN32) +#define WIN32 +#endif +#if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS) +#define WINDOWS +#endif +#if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS) +#define MSDOS +#endif -# ifdef WIN32 -# undef get_last_sys_error -# undef clear_sys_error -# undef set_sys_error -# define get_last_sys_error() GetLastError() -# define clear_sys_error() SetLastError(0) -# define set_sys_error(e) SetLastError(e) -# if !defined(WINNT) -# define WIN_CONSOLE_BUG -# endif -# else -# endif +#ifdef WIN32 +#undef get_last_sys_error +#undef clear_sys_error +#undef set_sys_error +#define get_last_sys_error() GetLastError() +#define clear_sys_error() SetLastError(0) +#define set_sys_error(e) SetLastError(e) +#if !defined(WINNT) +#define WIN_CONSOLE_BUG +#endif +#else +#endif -# if (defined(WINDOWS) || defined(MSDOS)) +#if (defined(WINDOWS) || defined(MSDOS)) -# ifdef __DJGPP__ -# include <unistd.h> -# include <sys/stat.h> -# define _setmode setmode -# define _O_TEXT O_TEXT -# define _O_BINARY O_BINARY -# undef DEVRANDOM_EGD /* Neither MS-DOS nor FreeDOS provide 'egd' sockets. */ -# undef DEVRANDOM -# define DEVRANDOM "/dev/urandom\x24" -# endif /* __DJGPP__ */ +#ifdef __DJGPP__ +#include <unistd.h> +#include <sys/stat.h> +#define _setmode setmode +#define _O_TEXT O_TEXT +#define _O_BINARY O_BINARY +#undef DEVRANDOM_EGD /* Neither MS-DOS nor FreeDOS provide 'egd' sockets. */ +#undef DEVRANDOM +#define DEVRANDOM "/dev/urandom\x24" +#endif /* __DJGPP__ */ -# ifndef S_IFDIR -# define S_IFDIR _S_IFDIR -# endif +#ifndef S_IFDIR +#define S_IFDIR _S_IFDIR +#endif -# ifndef S_IFMT -# define S_IFMT _S_IFMT -# endif +#ifndef S_IFMT +#define S_IFMT _S_IFMT +#endif -# if !defined(WINNT) && !defined(__DJGPP__) -# define NO_SYSLOG -# endif +#if !defined(WINNT) && !defined(__DJGPP__) +#define NO_SYSLOG +#endif -# ifdef WINDOWS -# if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT) - /* - * Defining _WIN32_WINNT here in e_os.h implies certain "discipline." - * Most notably we ought to check for availability of each specific - * routine that was introduced after denoted _WIN32_WINNT with - * GetProcAddress(). Normally newer functions are masked with higher - * _WIN32_WINNT in SDK headers. So that if you wish to use them in - * some module, you'd need to override _WIN32_WINNT definition in - * the target module in order to "reach for" prototypes, but replace - * calls to new functions with indirect calls. Alternatively it - * might be possible to achieve the goal by /DELAYLOAD-ing .DLLs - * and check for current OS version instead. - */ -# define _WIN32_WINNT 0x0501 -# endif -# include <windows.h> -# include <stdio.h> -# include <stddef.h> -# include <errno.h> -# if defined(_WIN32_WCE) && !defined(EACCES) -# define EACCES 13 -# endif -# include <string.h> -# include <malloc.h> -# if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(_DLL) && defined(stdin) -# if _MSC_VER>=1300 && _MSC_VER<1600 -# undef stdin -# undef stdout -# undef stderr +#ifdef WINDOWS +#if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT) +/* + * Defining _WIN32_WINNT here in e_os.h implies certain "discipline." + * Most notably we ought to check for availability of each specific + * routine that was introduced after denoted _WIN32_WINNT with + * GetProcAddress(). Normally newer functions are masked with higher + * _WIN32_WINNT in SDK headers. So that if you wish to use them in + * some module, you'd need to override _WIN32_WINNT definition in + * the target module in order to "reach for" prototypes, but replace + * calls to new functions with indirect calls. Alternatively it + * might be possible to achieve the goal by /DELAYLOAD-ing .DLLs + * and check for current OS version instead. + */ +#define _WIN32_WINNT 0x0501 +#endif +#include <windows.h> +#include <stdio.h> +#include <stddef.h> +#include <errno.h> +#if defined(_WIN32_WCE) && !defined(EACCES) +#define EACCES 13 +#endif +#include <string.h> +#include <malloc.h> +#if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(_DLL) && defined(stdin) +#if _MSC_VER >= 1300 && _MSC_VER < 1600 +#undef stdin +#undef stdout +#undef stderr FILE *__iob_func(void); -# define stdin (&__iob_func()[0]) -# define stdout (&__iob_func()[1]) -# define stderr (&__iob_func()[2]) -# endif -# endif -# endif +#define stdin (&__iob_func()[0]) +#define stdout (&__iob_func()[1]) +#define stderr (&__iob_func()[2]) +#endif +#endif +#endif -# include <io.h> -# include <fcntl.h> +#include <io.h> +#include <fcntl.h> -# ifdef OPENSSL_SYS_WINCE -# define OPENSSL_NO_POSIX_IO -# endif +#ifdef OPENSSL_SYS_WINCE +#define OPENSSL_NO_POSIX_IO +#endif -# define EXIT(n) exit(n) -# define LIST_SEPARATOR_CHAR ';' -# ifndef W_OK -# define W_OK 2 -# endif -# ifndef R_OK -# define R_OK 4 -# endif -# ifdef OPENSSL_SYS_WINCE -# define DEFAULT_HOME "" -# else -# define DEFAULT_HOME "C:" -# endif +#define EXIT(n) exit(n) +#define LIST_SEPARATOR_CHAR ';' +#ifndef W_OK +#define W_OK 2 +#endif +#ifndef R_OK +#define R_OK 4 +#endif +#ifdef OPENSSL_SYS_WINCE +#define DEFAULT_HOME "" +#else +#define DEFAULT_HOME "C:" +#endif /* Avoid Visual Studio 13 GetVersion deprecated problems */ -# if defined(_MSC_VER) && _MSC_VER>=1800 -# define check_winnt() (1) -# define check_win_minplat(x) (1) -# else -# define check_winnt() (GetVersion() < 0x80000000) -# define check_win_minplat(x) (LOBYTE(LOWORD(GetVersion())) >= (x)) -# endif +#if defined(_MSC_VER) && _MSC_VER >= 1800 +#define check_winnt() (1) +#define check_win_minplat(x) (1) +#else +#define check_winnt() (GetVersion() < 0x80000000) +#define check_win_minplat(x) (LOBYTE(LOWORD(GetVersion())) >= (x)) +#endif -# else /* The non-microsoft world */ +#else /* The non-microsoft world */ -# if defined(OPENSSL_SYS_VXWORKS) -# include <time.h> -# else -# include <sys/time.h> -# endif +#if defined(OPENSSL_SYS_VXWORKS) +#include <time.h> +#else +#include <sys/time.h> +#endif -# ifdef OPENSSL_SYS_VMS -# define VMS 1 - /* - * some programs don't include stdlib, so exit() and others give implicit - * function warnings - */ -# include <stdlib.h> -# if defined(__DECC) -# include <unistd.h> -# else -# include <unixlib.h> -# endif -# define LIST_SEPARATOR_CHAR ',' - /* We don't have any well-defined random devices on VMS, yet... */ -# undef DEVRANDOM - /*- - We need to do this since VMS has the following coding on status codes: +#ifdef OPENSSL_SYS_VMS +#define VMS 1 +/* + * some programs don't include stdlib, so exit() and others give implicit + * function warnings + */ +#include <stdlib.h> +#if defined(__DECC) +#include <unistd.h> +#else +#include <unixlib.h> +#endif +#define LIST_SEPARATOR_CHAR ',' +/* We don't have any well-defined random devices on VMS, yet... */ +#undef DEVRANDOM +/*- + We need to do this since VMS has the following coding on status codes: - Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ... - The important thing to know is that odd numbers are considered - good, while even ones are considered errors. - Bits 3-15: actual status number - Bits 16-27: facility number. 0 is considered "unknown" - Bits 28-31: control bits. If bit 28 is set, the shell won't try to - output the message (which, for random codes, just looks ugly) + Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ... + The important thing to know is that odd numbers are considered + good, while even ones are considered errors. + Bits 3-15: actual status number + Bits 16-27: facility number. 0 is considered "unknown" + Bits 28-31: control bits. If bit 28 is set, the shell won't try to + output the message (which, for random codes, just looks ugly) - So, what we do here is to change 0 to 1 to get the default success status, - and everything else is shifted up to fit into the status number field, and - the status is tagged as an error, which is what is wanted here. + So, what we do here is to change 0 to 1 to get the default success status, + and everything else is shifted up to fit into the status number field, and + the status is tagged as an error, which is what is wanted here. - Finally, we add the VMS C facility code 0x35a000, because there are some - programs, such as Perl, that will reinterpret the code back to something - POSIX. 'man perlvms' explains it further. + Finally, we add the VMS C facility code 0x35a000, because there are some + programs, such as Perl, that will reinterpret the code back to something + POSIX. 'man perlvms' explains it further. - NOTE: the perlvms manual wants to turn all codes 2 to 255 into success - codes (status type = 1). I couldn't disagree more. Fortunately, the - status type doesn't seem to bother Perl. - -- Richard Levitte - */ -# define EXIT(n) exit((n) ? (((n) << 3) | 2 | 0x10000000 | 0x35a000) : 1) + NOTE: the perlvms manual wants to turn all codes 2 to 255 into success + codes (status type = 1). I couldn't disagree more. Fortunately, the + status type doesn't seem to bother Perl. + -- Richard Levitte +*/ +#define EXIT(n) exit((n) ? (((n) << 3) | 2 | 0x10000000 | 0x35a000) : 1) -# define DEFAULT_HOME "SYS$LOGIN:" +#define DEFAULT_HOME "SYS$LOGIN:" -# else - /* !defined VMS */ -# include <unistd.h> -# include <sys/types.h> -# ifdef OPENSSL_SYS_WIN32_CYGWIN -# include <io.h> -# include <fcntl.h> -# endif +#else +/* !defined VMS */ +#include <unistd.h> +#include <sys/types.h> +#ifdef OPENSSL_SYS_WIN32_CYGWIN +#include <io.h> +#include <fcntl.h> +#endif -# define LIST_SEPARATOR_CHAR ':' -# define EXIT(n) exit(n) -# endif +#define LIST_SEPARATOR_CHAR ':' +#define EXIT(n) exit(n) +#endif -# endif +#endif /***********************************************/ -# if defined(OPENSSL_SYS_WINDOWS) -# if defined(_MSC_VER) && (_MSC_VER >= 1310) && !defined(_WIN32_WCE) -# define open _open -# define fdopen _fdopen -# define close _close -# ifndef strdup -# define strdup _strdup -# endif -# define unlink _unlink -# define fileno _fileno -# define isatty _isatty -# endif -# else -# include <strings.h> -# endif +#if defined(OPENSSL_SYS_WINDOWS) +#if defined(_MSC_VER) && (_MSC_VER >= 1310) && !defined(_WIN32_WCE) +#define open _open +#define fdopen _fdopen +#define close _close +#ifndef strdup +#define strdup _strdup +#endif +#define unlink _unlink +#define fileno _fileno +#define isatty _isatty +#endif +#else +#include <strings.h> +#endif /* vxworks */ -# if defined(OPENSSL_SYS_VXWORKS) -# include <ioLib.h> -# include <tickLib.h> -# include <sysLib.h> -# include <vxWorks.h> -# include <sockLib.h> -# include <taskLib.h> +#if defined(OPENSSL_SYS_VXWORKS) +#include <ioLib.h> +#include <tickLib.h> +#include <sysLib.h> +#include <vxWorks.h> +#include <sockLib.h> +#include <taskLib.h> -# define TTY_STRUCT int -# define sleep(a) taskDelay((a) * sysClkRateGet()) +#define TTY_STRUCT int +#define sleep(a) taskDelay((a) * sysClkRateGet()) /* * NOTE: these are implemented by helpers in database app! if the database is @@ -254,54 +254,54 @@ struct hostent *gethostbyname(const char *name); struct hostent *gethostbyaddr(const char *addr, int length, int type); struct servent *getservbyname(const char *name, const char *proto); -# endif +#endif /* end vxworks */ /* ----------------------------- HP NonStop -------------------------------- */ /* Required to support platform variant without getpid() and pid_t. */ -# if defined(__TANDEM) && defined(_GUARDIAN_TARGET) -# include <strings.h> -# include <netdb.h> -# define getservbyname(name,proto) getservbyname((char*)name,proto) -# define gethostbyname(name) gethostbyname((char*)name) -# define ioctlsocket(a,b,c) ioctl(a,b,c) -# ifdef NO_GETPID +#if defined(__TANDEM) && defined(_GUARDIAN_TARGET) +#include <strings.h> +#include <netdb.h> +#define getservbyname(name, proto) getservbyname((char *)name, proto) +#define gethostbyname(name) gethostbyname((char *)name) +#define ioctlsocket(a, b, c) ioctl(a, b, c) +#ifdef NO_GETPID inline int nssgetpid(void); -# ifndef NSSGETPID_MACRO -# define NSSGETPID_MACRO -# include <cextdecs.h(PROCESSHANDLE_GETMINE_)> -# include <cextdecs.h(PROCESSHANDLE_DECOMPOSE_)> - inline int nssgetpid(void) - { - short phandle[10]={0}; - union pseudo_pid { - struct { - short cpu; - short pin; - } cpu_pin ; - int ppid; - } ppid = { 0 }; - PROCESSHANDLE_GETMINE_(phandle); - PROCESSHANDLE_DECOMPOSE_(phandle, &ppid.cpu_pin.cpu, &ppid.cpu_pin.pin); - return ppid.ppid; - } -# define getpid(a) nssgetpid(a) -# endif /* NSSGETPID_MACRO */ -# endif /* NO_GETPID */ +#ifndef NSSGETPID_MACRO +#define NSSGETPID_MACRO +#include <cextdecs.h(PROCESSHANDLE_GETMINE_)> +#include <cextdecs.h(PROCESSHANDLE_DECOMPOSE_)> +inline int nssgetpid(void) +{ + short phandle[10] = { 0 }; + union pseudo_pid { + struct { + short cpu; + short pin; + } cpu_pin; + int ppid; + } ppid = { 0 }; + PROCESSHANDLE_GETMINE_(phandle); + PROCESSHANDLE_DECOMPOSE_(phandle, &ppid.cpu_pin.cpu, &ppid.cpu_pin.pin); + return ppid.ppid; +} +#define getpid(a) nssgetpid(a) +#endif /* NSSGETPID_MACRO */ +#endif /* NO_GETPID */ /*# define setsockopt(a,b,c,d,f) setsockopt(a,b,c,(char*)d,f)*/ /*# define getsockopt(a,b,c,d,f) getsockopt(a,b,c,(char*)d,f)*/ /*# define connect(a,b,c) connect(a,(struct sockaddr *)b,c)*/ /*# define bind(a,b,c) bind(a,(struct sockaddr *)b,c)*/ /*# define sendto(a,b,c,d,e,f) sendto(a,(char*)b,c,d,(struct sockaddr *)e,f)*/ -# if defined(OPENSSL_THREADS) && !defined(_PUT_MODEL_) - /* - * HPNS SPT threads - */ -# define SPT_THREAD_SIGNAL 1 -# define SPT_THREAD_AWARE 1 -# include <spthread.h> -# undef close -# define close spt_close +#if defined(OPENSSL_THREADS) && !defined(_PUT_MODEL_) +/* + * HPNS SPT threads + */ +#define SPT_THREAD_SIGNAL 1 +#define SPT_THREAD_AWARE 1 +#include <spthread.h> +#undef close +#define close spt_close /* # define get_last_socket_error() errno # define clear_socket_error() errno=0 @@ -310,27 +310,27 @@ inline int nssgetpid(void); # define readsocket(s,b,n) read((s),(char*)(b),(n)) # define writesocket(s,b,n) write((s),(char*)(b),(n) */ -# define accept(a,b,c) accept(a,(struct sockaddr *)b,c) -# define recvfrom(a,b,c,d,e,f) recvfrom(a,b,(socklen_t)c,d,e,f) -# endif -# endif +#define accept(a, b, c) accept(a, (struct sockaddr *)b, c) +#define recvfrom(a, b, c, d, e, f) recvfrom(a, b, (socklen_t)c, d, e, f) +#endif +#endif -# ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -# define CRYPTO_memcmp memcmp -# endif +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION +#define CRYPTO_memcmp memcmp +#endif -# ifndef OPENSSL_NO_SECURE_MEMORY - /* unistd.h defines _POSIX_VERSION */ -# if (defined(OPENSSL_SYS_UNIX) \ - && ( (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \ - || defined(__sun) || defined(__hpux) || defined(__sgi) \ - || defined(__osf__) )) \ - || defined(_WIN32) - /* secure memory is implemented */ -# else -# define OPENSSL_NO_SECURE_MEMORY -# endif -# endif +#ifndef OPENSSL_NO_SECURE_MEMORY +/* unistd.h defines _POSIX_VERSION */ +#if (defined(OPENSSL_SYS_UNIX) \ + && ((defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \ + || defined(__sun) || defined(__hpux) || defined(__sgi) \ + || defined(__osf__))) \ + || defined(_WIN32) +/* secure memory is implemented */ +#else +#define OPENSSL_NO_SECURE_MEMORY +#endif +#endif /* * str[n]casecmp_l is defined in POSIX 2008-01. Value is taken accordingly @@ -338,18 +338,18 @@ inline int nssgetpid(void); * There are also equivalent functions on Windows. * There is no locale_t on NONSTOP. */ -# if defined(OPENSSL_SYS_WINDOWS) -# define locale_t _locale_t -# define freelocale _free_locale -# define strcasecmp_l _stricmp_l -# define strncasecmp_l _strnicmp_l -# define strcasecmp _stricmp -# define strncasecmp _strnicmp -# elif !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200809L \ - || defined(OPENSSL_SYS_TANDEM) -# ifndef OPENSSL_NO_LOCALE -# define OPENSSL_NO_LOCALE -# endif -# endif +#if defined(OPENSSL_SYS_WINDOWS) +#define locale_t _locale_t +#define freelocale _free_locale +#define strcasecmp_l _stricmp_l +#define strncasecmp_l _strnicmp_l +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#elif !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200809L \ + || defined(OPENSSL_SYS_TANDEM) +#ifndef OPENSSL_NO_LOCALE +#define OPENSSL_NO_LOCALE +#endif +#endif #endif diff --git a/crypto/openssl/include/internal/e_winsock.h b/crypto/openssl/include/internal/e_winsock.h index 72a38a529f5b..c2a08ebed1a1 100644 --- a/crypto/openssl/include/internal/e_winsock.h +++ b/crypto/openssl/include/internal/e_winsock.h @@ -8,45 +8,45 @@ */ #ifndef OSSL_E_WINSOCK_H -# define OSSL_E_WINSOCK_H -# pragma once +#define OSSL_E_WINSOCK_H +#pragma once -# ifdef WINDOWS -# if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT) - /* - * Defining _WIN32_WINNT here in e_winsock.h implies certain "discipline." - * Most notably we ought to check for availability of each specific - * routine that was introduced after denoted _WIN32_WINNT with - * GetProcAddress(). Normally newer functions are masked with higher - * _WIN32_WINNT in SDK headers. So that if you wish to use them in - * some module, you'd need to override _WIN32_WINNT definition in - * the target module in order to "reach for" prototypes, but replace - * calls to new functions with indirect calls. Alternatively it - * might be possible to achieve the goal by /DELAYLOAD-ing .DLLs - * and check for current OS version instead. - */ -# define _WIN32_WINNT 0x0501 -# endif -# if defined(_WIN32_WINNT) || defined(_WIN32_WCE) - /* - * Just like defining _WIN32_WINNT including winsock2.h implies - * certain "discipline" for maintaining [broad] binary compatibility. - * As long as structures are invariant among Winsock versions, - * it's sufficient to check for specific Winsock2 API availability - * at run-time [DSO_global_lookup is recommended]... - */ -# include <winsock2.h> -# include <ws2tcpip.h> - /* - * Clang-based C++Builder 10.3.3 toolchains cannot find C inline - * definitions at link-time. This header defines WspiapiLoad() as an - * __inline function. https://quality.embarcadero.com/browse/RSP-33806 - */ -# if !defined(__BORLANDC__) || !defined(__clang__) -# include <wspiapi.h> -# endif - /* yes, they have to be #included prior to <windows.h> */ -# endif -# include <windows.h> -# endif +#ifdef WINDOWS +#if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT) +/* + * Defining _WIN32_WINNT here in e_winsock.h implies certain "discipline." + * Most notably we ought to check for availability of each specific + * routine that was introduced after denoted _WIN32_WINNT with + * GetProcAddress(). Normally newer functions are masked with higher + * _WIN32_WINNT in SDK headers. So that if you wish to use them in + * some module, you'd need to override _WIN32_WINNT definition in + * the target module in order to "reach for" prototypes, but replace + * calls to new functions with indirect calls. Alternatively it + * might be possible to achieve the goal by /DELAYLOAD-ing .DLLs + * and check for current OS version instead. + */ +#define _WIN32_WINNT 0x0501 +#endif +#if defined(_WIN32_WINNT) || defined(_WIN32_WCE) +/* + * Just like defining _WIN32_WINNT including winsock2.h implies + * certain "discipline" for maintaining [broad] binary compatibility. + * As long as structures are invariant among Winsock versions, + * it's sufficient to check for specific Winsock2 API availability + * at run-time [DSO_global_lookup is recommended]... + */ +#include <winsock2.h> +#include <ws2tcpip.h> +/* + * Clang-based C++Builder 10.3.3 toolchains cannot find C inline + * definitions at link-time. This header defines WspiapiLoad() as an + * __inline function. https://quality.embarcadero.com/browse/RSP-33806 + */ +#if !defined(__BORLANDC__) || !defined(__clang__) +#include <wspiapi.h> +#endif +/* yes, they have to be #included prior to <windows.h> */ +#endif +#include <windows.h> +#endif #endif /* !(OSSL_E_WINSOCK_H) */ diff --git a/crypto/openssl/include/internal/encoder.h b/crypto/openssl/include/internal/encoder.h index d7ad2097f459..239f4c3e7fec 100644 --- a/crypto/openssl/include/internal/encoder.h +++ b/crypto/openssl/include/internal/encoder.h @@ -8,20 +8,20 @@ */ #ifndef OSSL_INTERNAL_ENCODER_H -# define OSSL_INTERNAL_ENCODER_H -# pragma once +#define OSSL_INTERNAL_ENCODER_H +#pragma once -# include <openssl/bio.h> -# include <openssl/buffer.h> -# include <openssl/types.h> -# include "internal/ffc.h" +#include <openssl/bio.h> +#include <openssl/buffer.h> +#include <openssl/types.h> +#include "internal/ffc.h" int ossl_bio_print_labeled_bignum(BIO *out, const char *label, - const BIGNUM *bn); + const BIGNUM *bn); int ossl_bio_print_labeled_buf(BIO *out, const char *label, - const unsigned char *buf, size_t buflen); -# if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA) + const unsigned char *buf, size_t buflen); +#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA) int ossl_bio_print_ffc_params(BIO *out, const FFC_PARAMS *ffc); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/endian.h b/crypto/openssl/include/internal/endian.h index 7d5a73b1bb1f..51c10873cd3c 100644 --- a/crypto/openssl/include/internal/endian.h +++ b/crypto/openssl/include/internal/endian.h @@ -8,8 +8,8 @@ */ #ifndef OSSL_INTERNAL_ENDIAN_H -# define OSSL_INTERNAL_ENDIAN_H -# pragma once +#define OSSL_INTERNAL_ENDIAN_H +#pragma once /* * IS_LITTLE_ENDIAN and IS_BIG_ENDIAN can be used to detect the endianness @@ -21,31 +21,31 @@ * set, it will fall back to code works with either endianness. */ -# if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) -# define DECLARE_IS_ENDIAN const int ossl_is_little_endian = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -# define IS_LITTLE_ENDIAN (ossl_is_little_endian) -# define IS_BIG_ENDIAN (!ossl_is_little_endian) -# if defined(L_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) -# error "L_ENDIAN defined on a big endian machine" -# endif -# if defined(B_ENDIAN) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) -# error "B_ENDIAN defined on a little endian machine" -# endif -# if !defined(L_ENDIAN) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) -# define L_ENDIAN -# endif -# if !defined(B_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) -# define B_ENDIAN -# endif -# else -# define DECLARE_IS_ENDIAN \ - const union { \ - long one; \ - char little; \ +#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) +#define DECLARE_IS_ENDIAN const int ossl_is_little_endian = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define IS_LITTLE_ENDIAN (ossl_is_little_endian) +#define IS_BIG_ENDIAN (!ossl_is_little_endian) +#if defined(L_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) +#error "L_ENDIAN defined on a big endian machine" +#endif +#if defined(B_ENDIAN) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) +#error "B_ENDIAN defined on a little endian machine" +#endif +#if !defined(L_ENDIAN) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) +#define L_ENDIAN +#endif +#if !defined(B_ENDIAN) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) +#define B_ENDIAN +#endif +#else +#define DECLARE_IS_ENDIAN \ + const union { \ + long one; \ + char little; \ } ossl_is_endian = { 1 } -# define IS_LITTLE_ENDIAN (ossl_is_endian.little != 0) -# define IS_BIG_ENDIAN (ossl_is_endian.little == 0) -# endif +#define IS_LITTLE_ENDIAN (ossl_is_endian.little != 0) +#define IS_BIG_ENDIAN (ossl_is_endian.little == 0) +#endif #endif diff --git a/crypto/openssl/include/internal/err.h b/crypto/openssl/include/internal/err.h index d8a308f0b46f..41b28ac47311 100644 --- a/crypto/openssl/include/internal/err.h +++ b/crypto/openssl/include/internal/err.h @@ -8,8 +8,8 @@ */ #ifndef OSSL_INTERNAL_ERR_H -# define OSSL_INTERNAL_ERR_H -# pragma once +#define OSSL_INTERNAL_ERR_H +#pragma once void err_free_strings_int(void); diff --git a/crypto/openssl/include/internal/ffc.h b/crypto/openssl/include/internal/ffc.h index edd8381e8df4..fd56b07e94bf 100644 --- a/crypto/openssl/include/internal/ffc.h +++ b/crypto/openssl/include/internal/ffc.h @@ -8,41 +8,41 @@ */ #ifndef OSSL_INTERNAL_FFC_H -# define OSSL_INTERNAL_FFC_H -# pragma once +#define OSSL_INTERNAL_FFC_H +#pragma once -# include <openssl/core.h> -# include <openssl/bn.h> -# include <openssl/evp.h> -# include <openssl/dh.h> /* Uses Error codes from DH */ -# include <openssl/params.h> -# include <openssl/param_build.h> -# include "internal/sizes.h" +#include <openssl/core.h> +#include <openssl/bn.h> +#include <openssl/evp.h> +#include <openssl/dh.h> /* Uses Error codes from DH */ +#include <openssl/params.h> +#include <openssl/param_build.h> +#include "internal/sizes.h" /* Default value for gindex when canonical generation of g is not used */ -# define FFC_UNVERIFIABLE_GINDEX -1 +#define FFC_UNVERIFIABLE_GINDEX -1 /* The different types of FFC keys */ -# define FFC_PARAM_TYPE_DSA 0 -# define FFC_PARAM_TYPE_DH 1 +#define FFC_PARAM_TYPE_DSA 0 +#define FFC_PARAM_TYPE_DH 1 /* * The mode used by functions that share code for both generation and * verification. See ossl_ffc_params_FIPS186_4_gen_verify(). */ -#define FFC_PARAM_MODE_VERIFY 0 +#define FFC_PARAM_MODE_VERIFY 0 #define FFC_PARAM_MODE_GENERATE 1 /* Return codes for generation and validation of FFC parameters */ -#define FFC_PARAM_RET_STATUS_FAILED 0 -#define FFC_PARAM_RET_STATUS_SUCCESS 1 +#define FFC_PARAM_RET_STATUS_FAILED 0 +#define FFC_PARAM_RET_STATUS_SUCCESS 1 /* Returned if validating and g is only partially verifiable */ #define FFC_PARAM_RET_STATUS_UNVERIFIABLE_G 2 /* Validation flags */ -# define FFC_PARAM_FLAG_VALIDATE_PQ 0x01 -# define FFC_PARAM_FLAG_VALIDATE_G 0x02 -# define FFC_PARAM_FLAG_VALIDATE_PQG \ +#define FFC_PARAM_FLAG_VALIDATE_PQ 0x01 +#define FFC_PARAM_FLAG_VALIDATE_G 0x02 +#define FFC_PARAM_FLAG_VALIDATE_PQG \ (FFC_PARAM_FLAG_VALIDATE_PQ | FFC_PARAM_FLAG_VALIDATE_G) #define FFC_PARAM_FLAG_VALIDATE_LEGACY 0x04 @@ -50,38 +50,38 @@ * NB: These values must align with the equivalently named macros in * openssl/dh.h. We cannot use those macros here in case DH has been disabled. */ -# define FFC_CHECK_P_NOT_PRIME 0x00001 -# define FFC_CHECK_P_NOT_SAFE_PRIME 0x00002 -# define FFC_CHECK_UNKNOWN_GENERATOR 0x00004 -# define FFC_CHECK_NOT_SUITABLE_GENERATOR 0x00008 -# define FFC_CHECK_Q_NOT_PRIME 0x00010 -# define FFC_CHECK_INVALID_Q_VALUE 0x00020 -# define FFC_CHECK_INVALID_J_VALUE 0x00040 +#define FFC_CHECK_P_NOT_PRIME 0x00001 +#define FFC_CHECK_P_NOT_SAFE_PRIME 0x00002 +#define FFC_CHECK_UNKNOWN_GENERATOR 0x00004 +#define FFC_CHECK_NOT_SUITABLE_GENERATOR 0x00008 +#define FFC_CHECK_Q_NOT_PRIME 0x00010 +#define FFC_CHECK_INVALID_Q_VALUE 0x00020 +#define FFC_CHECK_INVALID_J_VALUE 0x00040 /* * 0x80, 0x100 reserved by include/openssl/dh.h with check bits that are not * relevant for FFC. */ -# define FFC_CHECK_MISSING_SEED_OR_COUNTER 0x00200 -# define FFC_CHECK_INVALID_G 0x00400 -# define FFC_CHECK_INVALID_PQ 0x00800 -# define FFC_CHECK_INVALID_COUNTER 0x01000 -# define FFC_CHECK_P_MISMATCH 0x02000 -# define FFC_CHECK_Q_MISMATCH 0x04000 -# define FFC_CHECK_G_MISMATCH 0x08000 -# define FFC_CHECK_COUNTER_MISMATCH 0x10000 -# define FFC_CHECK_BAD_LN_PAIR 0x20000 -# define FFC_CHECK_INVALID_SEED_SIZE 0x40000 +#define FFC_CHECK_MISSING_SEED_OR_COUNTER 0x00200 +#define FFC_CHECK_INVALID_G 0x00400 +#define FFC_CHECK_INVALID_PQ 0x00800 +#define FFC_CHECK_INVALID_COUNTER 0x01000 +#define FFC_CHECK_P_MISMATCH 0x02000 +#define FFC_CHECK_Q_MISMATCH 0x04000 +#define FFC_CHECK_G_MISMATCH 0x08000 +#define FFC_CHECK_COUNTER_MISMATCH 0x10000 +#define FFC_CHECK_BAD_LN_PAIR 0x20000 +#define FFC_CHECK_INVALID_SEED_SIZE 0x40000 /* Validation Return codes */ -# define FFC_ERROR_PUBKEY_TOO_SMALL 0x01 -# define FFC_ERROR_PUBKEY_TOO_LARGE 0x02 -# define FFC_ERROR_PUBKEY_INVALID 0x04 -# define FFC_ERROR_NOT_SUITABLE_GENERATOR 0x08 -# define FFC_ERROR_PRIVKEY_TOO_SMALL 0x10 -# define FFC_ERROR_PRIVKEY_TOO_LARGE 0x20 -# define FFC_ERROR_PASSED_NULL_PARAM 0x40 +#define FFC_ERROR_PUBKEY_TOO_SMALL 0x01 +#define FFC_ERROR_PUBKEY_TOO_LARGE 0x02 +#define FFC_ERROR_PUBKEY_INVALID 0x04 +#define FFC_ERROR_NOT_SUITABLE_GENERATOR 0x08 +#define FFC_ERROR_PRIVKEY_TOO_SMALL 0x10 +#define FFC_ERROR_PRIVKEY_TOO_LARGE 0x20 +#define FFC_ERROR_PASSED_NULL_PARAM 0x40 /* * Finite field cryptography (FFC) domain parameters are used by DH and DSA. @@ -125,26 +125,26 @@ typedef struct ffc_params_st { void ossl_ffc_params_init(FFC_PARAMS *params); void ossl_ffc_params_cleanup(FFC_PARAMS *params); void ossl_ffc_params_set0_pqg(FFC_PARAMS *params, BIGNUM *p, BIGNUM *q, - BIGNUM *g); + BIGNUM *g); void ossl_ffc_params_get0_pqg(const FFC_PARAMS *params, const BIGNUM **p, - const BIGNUM **q, const BIGNUM **g); + const BIGNUM **q, const BIGNUM **g); void ossl_ffc_params_set0_j(FFC_PARAMS *d, BIGNUM *j); int ossl_ffc_params_set_seed(FFC_PARAMS *params, - const unsigned char *seed, size_t seedlen); + const unsigned char *seed, size_t seedlen); void ossl_ffc_params_set_gindex(FFC_PARAMS *params, int index); void ossl_ffc_params_set_pcounter(FFC_PARAMS *params, int index); void ossl_ffc_params_set_h(FFC_PARAMS *params, int index); void ossl_ffc_params_set_flags(FFC_PARAMS *params, unsigned int flags); void ossl_ffc_params_enable_flags(FFC_PARAMS *params, unsigned int flags, - int enable); + int enable); void ossl_ffc_set_digest(FFC_PARAMS *params, const char *alg, const char *props); int ossl_ffc_params_set_validate_params(FFC_PARAMS *params, - const unsigned char *seed, - size_t seedlen, int counter); + const unsigned char *seed, + size_t seedlen, int counter); void ossl_ffc_params_get_validate_params(const FFC_PARAMS *params, - unsigned char **seed, size_t *seedlen, - int *pcounter); + unsigned char **seed, size_t *seedlen, + int *pcounter); int ossl_ffc_params_copy(FFC_PARAMS *dst, const FFC_PARAMS *src); int ossl_ffc_params_cmp(const FFC_PARAMS *a, const FFC_PARAMS *b, int ignore_q); @@ -153,53 +153,52 @@ int ossl_ffc_params_cmp(const FFC_PARAMS *a, const FFC_PARAMS *b, int ignore_q); int ossl_ffc_params_print(BIO *bp, const FFC_PARAMS *ffc, int indent); #endif /* FIPS_MODULE */ - int ossl_ffc_params_FIPS186_4_generate(OSSL_LIB_CTX *libctx, FFC_PARAMS *params, - int type, size_t L, size_t N, - int *res, BN_GENCB *cb); + int type, size_t L, size_t N, + int *res, BN_GENCB *cb); int ossl_ffc_params_FIPS186_2_generate(OSSL_LIB_CTX *libctx, FFC_PARAMS *params, - int type, size_t L, size_t N, - int *res, BN_GENCB *cb); + int type, size_t L, size_t N, + int *res, BN_GENCB *cb); int ossl_ffc_params_FIPS186_4_gen_verify(OSSL_LIB_CTX *libctx, - FFC_PARAMS *params, int mode, int type, - size_t L, size_t N, int *res, - BN_GENCB *cb); + FFC_PARAMS *params, int mode, int type, + size_t L, size_t N, int *res, + BN_GENCB *cb); int ossl_ffc_params_FIPS186_2_gen_verify(OSSL_LIB_CTX *libctx, - FFC_PARAMS *params, int mode, int type, - size_t L, size_t N, int *res, - BN_GENCB *cb); + FFC_PARAMS *params, int mode, int type, + size_t L, size_t N, int *res, + BN_GENCB *cb); int ossl_ffc_params_simple_validate(OSSL_LIB_CTX *libctx, - const FFC_PARAMS *params, - int paramstype, int *res); + const FFC_PARAMS *params, + int paramstype, int *res); int ossl_ffc_params_full_validate(OSSL_LIB_CTX *libctx, - const FFC_PARAMS *params, - int paramstype, int *res); + const FFC_PARAMS *params, + int paramstype, int *res); int ossl_ffc_params_FIPS186_4_validate(OSSL_LIB_CTX *libctx, - const FFC_PARAMS *params, - int type, int *res, BN_GENCB *cb); + const FFC_PARAMS *params, + int type, int *res, BN_GENCB *cb); int ossl_ffc_params_FIPS186_2_validate(OSSL_LIB_CTX *libctx, - const FFC_PARAMS *params, - int type, int *res, BN_GENCB *cb); + const FFC_PARAMS *params, + int type, int *res, BN_GENCB *cb); int ossl_ffc_generate_private_key(BN_CTX *ctx, const FFC_PARAMS *params, - int N, int s, BIGNUM *priv); + int N, int s, BIGNUM *priv); int ossl_ffc_params_validate_unverifiable_g(BN_CTX *ctx, BN_MONT_CTX *mont, - const BIGNUM *p, const BIGNUM *q, - const BIGNUM *g, BIGNUM *tmp, - int *ret); + const BIGNUM *p, const BIGNUM *q, + const BIGNUM *g, BIGNUM *tmp, + int *ret); int ossl_ffc_validate_public_key(const FFC_PARAMS *params, - const BIGNUM *pub_key, int *ret); + const BIGNUM *pub_key, int *ret); int ossl_ffc_validate_public_key_partial(const FFC_PARAMS *params, - const BIGNUM *pub_key, int *ret); + const BIGNUM *pub_key, int *ret); int ossl_ffc_validate_private_key(const BIGNUM *upper, const BIGNUM *priv_key, - int *ret); + int *ret); int ossl_ffc_params_todata(const FFC_PARAMS *ffc, OSSL_PARAM_BLD *tmpl, - OSSL_PARAM params[]); + OSSL_PARAM params[]); int ossl_ffc_params_fromdata(FFC_PARAMS *ffc, const OSSL_PARAM params[]); typedef struct dh_named_group_st DH_NAMED_GROUP; @@ -207,8 +206,8 @@ const DH_NAMED_GROUP *ossl_ffc_name_to_dh_named_group(const char *name); const DH_NAMED_GROUP *ossl_ffc_uid_to_dh_named_group(int uid); #ifndef OPENSSL_NO_DH const DH_NAMED_GROUP *ossl_ffc_numbers_to_dh_named_group(const BIGNUM *p, - const BIGNUM *q, - const BIGNUM *g); + const BIGNUM *q, + const BIGNUM *g); #endif int ossl_ffc_named_group_get_uid(const DH_NAMED_GROUP *group); const char *ossl_ffc_named_group_get_name(const DH_NAMED_GROUP *); diff --git a/crypto/openssl/include/internal/fips.h b/crypto/openssl/include/internal/fips.h index 3f70c0de93c5..2e02ff77b7b4 100644 --- a/crypto/openssl/include/internal/fips.h +++ b/crypto/openssl/include/internal/fips.h @@ -8,14 +8,14 @@ */ #ifndef OSSL_INTERNAL_FIPS_H -# define OSSL_INTERNAL_FIPS_H -# pragma once +#define OSSL_INTERNAL_FIPS_H +#pragma once -# ifdef FIPS_MODULE +#ifdef FIPS_MODULE /* Return 1 if the FIPS self tests are running and 0 otherwise */ int ossl_fips_self_testing(void); -# endif /* FIPS_MODULE */ +#endif /* FIPS_MODULE */ #endif diff --git a/crypto/openssl/include/internal/hashfunc.h b/crypto/openssl/include/internal/hashfunc.h index fae8a275fa2e..78d7c859d59d 100644 --- a/crypto/openssl/include/internal/hashfunc.h +++ b/crypto/openssl/include/internal/hashfunc.h @@ -8,10 +8,10 @@ */ #ifndef OPENSSL_HASHFUNC_H -# define OPENSSL_HASHFUNC_H +#define OPENSSL_HASHFUNC_H -# include <openssl/e_os2.h> -# include <stddef.h> +#include <openssl/e_os2.h> +#include <stddef.h> /** * Generalized fnv1a 64 bit hash function */ diff --git a/crypto/openssl/include/internal/hashtable.h b/crypto/openssl/include/internal/hashtable.h index ccbc470db722..bc44e43678a3 100644 --- a/crypto/openssl/include/internal/hashtable.h +++ b/crypto/openssl/include/internal/hashtable.h @@ -8,8 +8,8 @@ */ #ifndef OPENSSL_HASHTABLE_H -# define OPENSSL_HASHTABLE_H -# pragma once +#define OPENSSL_HASHTABLE_H +#pragma once #include <stddef.h> #include <stdint.h> @@ -72,16 +72,18 @@ typedef struct ht_config_st { * Starts the definition of a hash table key */ #define HT_START_KEY_DEFN(keyname) \ -typedef struct keyname##_st { \ - HT_KEY key_header; \ - struct { + typedef struct keyname##_st { \ + HT_KEY key_header; \ + struct { /* * Ends a hash table key definitions */ #define HT_END_KEY_DEFN(keyname) \ - } keyfields; \ -} keyname; + } \ + keyfields; \ + } \ + keyname; /* * Defines a field in a hash table key @@ -93,7 +95,7 @@ typedef struct keyname##_st { \ * array field in a hash table key */ #define HT_DEF_KEY_FIELD_CHAR_ARRAY(name, size) \ - HT_DEF_KEY_FIELD(name[size], char) + HT_DEF_KEY_FIELD(name[size], char) /* * Defines a uint8_t (blob) field in a hash table key @@ -104,11 +106,12 @@ typedef struct keyname##_st { \ /* * Initializes a key */ -#define HT_INIT_KEY(key) do { \ -memset((key), 0, sizeof(*(key))); \ -(key)->key_header.keysize = (sizeof(*(key)) - sizeof(HT_KEY)); \ -(key)->key_header.keybuf = (((uint8_t *)key) + sizeof(HT_KEY)); \ -} while(0) +#define HT_INIT_KEY(key) \ + do { \ + memset((key), 0, sizeof(*(key))); \ + (key)->key_header.keysize = (sizeof(*(key)) - sizeof(HT_KEY)); \ + (key)->key_header.keybuf = (((uint8_t *)key) + sizeof(HT_KEY)); \ + } while (0) /* * Resets a hash table key to a known state @@ -124,10 +127,11 @@ memset((key), 0, sizeof(*(key))); \ * Sets a string field in a hash table key, preserving * null terminator */ -#define HT_SET_KEY_STRING(key, member, value) do { \ - if ((value) != NULL) \ - strncpy((key)->keyfields.member, value, sizeof((key)->keyfields.member) - 1); \ -} while(0) +#define HT_SET_KEY_STRING(key, member, value) \ + do { \ + if ((value) != NULL) \ + strncpy((key)->keyfields.member, value, sizeof((key)->keyfields.member) - 1); \ + } while (0) /* * This is the same as HT_SET_KEY_STRING, except that it uses @@ -135,37 +139,41 @@ memset((key), 0, sizeof(*(key))); \ * This is useful for instances in which we want upper and lower case * key value to hash to the same entry */ -#define HT_SET_KEY_STRING_CASE(key, member, value) do { \ - ossl_ht_strcase((key)->keyfields.member, value, sizeof((key)->keyfields.member) -1); \ -} while(0) +#define HT_SET_KEY_STRING_CASE(key, member, value) \ + do { \ + ossl_ht_strcase((key)->keyfields.member, value, sizeof((key)->keyfields.member) - 1); \ + } while (0) /* * Same as HT_SET_KEY_STRING but also takes length of the string. */ -#define HT_SET_KEY_STRING_N(key, member, value, len) do { \ - if ((value) != NULL) { \ - if (len < sizeof((key)->keyfields.member)) \ - strncpy((key)->keyfields.member, value, len); \ - else \ - strncpy((key)->keyfields.member, value, sizeof((key)->keyfields.member) - 1); \ - } \ -} while(0) +#define HT_SET_KEY_STRING_N(key, member, value, len) \ + do { \ + if ((value) != NULL) { \ + if (len < sizeof((key)->keyfields.member)) \ + strncpy((key)->keyfields.member, value, len); \ + else \ + strncpy((key)->keyfields.member, value, sizeof((key)->keyfields.member) - 1); \ + } \ + } while (0) /* Same as HT_SET_KEY_STRING_CASE but also takes length of the string. */ -#define HT_SET_KEY_STRING_CASE_N(key, member, value, len) do { \ - if (len < sizeof((key)->keyfields.member)) \ - ossl_ht_strcase((key)->keyfields.member, value, len); \ - else \ - ossl_ht_strcase((key)->keyfields.member, value, sizeof((key)->keyfields.member) - 1); \ -} while(0) +#define HT_SET_KEY_STRING_CASE_N(key, member, value, len) \ + do { \ + if (len < sizeof((key)->keyfields.member)) \ + ossl_ht_strcase((key)->keyfields.member, value, len); \ + else \ + ossl_ht_strcase((key)->keyfields.member, value, sizeof((key)->keyfields.member) - 1); \ + } while (0) /* * Sets a uint8_t (blob) field in a hash table key */ -#define HT_SET_KEY_BLOB(key, member, value, len) do { \ - if (value != NULL) \ - memcpy((key)->keyfields.member, value, len); \ -} while(0) +#define HT_SET_KEY_BLOB(key, member, value, len) \ + do { \ + if (value != NULL) \ + memcpy((key)->keyfields.member, value, len); \ + } while (0) /* * Converts a defined key type to an HT_KEY @@ -186,67 +194,68 @@ memset((key), 0, sizeof(*(key))); \ * ossl_ht_NAME_TYPE_to_value - converts a TYPE to an HT_VALUE * ossl_ht_NAME_TYPE_type - boolean to detect if a value is of TYPE */ -#define IMPLEMENT_HT_VALUE_TYPE_FNS(vtype, name, pfx) \ -static uintptr_t name##_##vtype##_id = 0; \ -pfx ossl_unused int ossl_ht_##name##_##vtype##_insert(HT *h, HT_KEY *key, \ - vtype *data, \ - vtype **olddata) { \ - HT_VALUE inval; \ - HT_VALUE *oval = NULL; \ - int rc; \ +#define IMPLEMENT_HT_VALUE_TYPE_FNS(vtype, name, pfx) \ + static uintptr_t name##_##vtype##_id = 0; \ + pfx ossl_unused int ossl_ht_##name##_##vtype##_insert(HT *h, HT_KEY *key, \ + vtype *data, \ + vtype **olddata) \ + { \ + HT_VALUE inval; \ + HT_VALUE *oval = NULL; \ + int rc; \ \ - inval.value = data; \ - inval.type_id = &name##_##vtype##_id; \ - rc = ossl_ht_insert(h, key, &inval, olddata == NULL ? NULL : &oval); \ - if (oval != NULL) \ - *olddata = (vtype *)oval->value; \ - return rc; \ -} \ + inval.value = data; \ + inval.type_id = &name##_##vtype##_id; \ + rc = ossl_ht_insert(h, key, &inval, olddata == NULL ? NULL : &oval); \ + if (oval != NULL) \ + *olddata = (vtype *)oval->value; \ + return rc; \ + } \ \ -pfx ossl_unused vtype *ossl_ht_##name##_##vtype##_from_value(HT_VALUE *v) \ -{ \ - uintptr_t *expect_type = &name##_##vtype##_id; \ - if (v == NULL) \ - return NULL; \ - if (v->type_id != expect_type) \ - return NULL; \ - return (vtype *)v->value; \ -} \ + pfx ossl_unused vtype *ossl_ht_##name##_##vtype##_from_value(HT_VALUE *v) \ + { \ + uintptr_t *expect_type = &name##_##vtype##_id; \ + if (v == NULL) \ + return NULL; \ + if (v->type_id != expect_type) \ + return NULL; \ + return (vtype *)v->value; \ + } \ \ -pfx ossl_unused vtype *ossl_unused ossl_ht_##name##_##vtype##_get(HT *h, \ - HT_KEY *key, \ - HT_VALUE **v)\ -{ \ - HT_VALUE *vv; \ - vv = ossl_ht_get(h, key); \ - if (vv == NULL) \ - return NULL; \ - *v = ossl_rcu_deref(&vv); \ - return ossl_ht_##name##_##vtype##_from_value(*v); \ -} \ + pfx ossl_unused vtype *ossl_unused ossl_ht_##name##_##vtype##_get(HT *h, \ + HT_KEY *key, \ + HT_VALUE **v) \ + { \ + HT_VALUE *vv; \ + vv = ossl_ht_get(h, key); \ + if (vv == NULL) \ + return NULL; \ + *v = ossl_rcu_deref(&vv); \ + return ossl_ht_##name##_##vtype##_from_value(*v); \ + } \ \ -pfx ossl_unused HT_VALUE *ossl_ht_##name##_##vtype##_to_value(vtype *data, \ - HT_VALUE *v) \ -{ \ - v->type_id = &name##_##vtype##_id; \ - v->value = data; \ - return v; \ -} \ + pfx ossl_unused HT_VALUE *ossl_ht_##name##_##vtype##_to_value(vtype *data, \ + HT_VALUE *v) \ + { \ + v->type_id = &name##_##vtype##_id; \ + v->value = data; \ + return v; \ + } \ \ -pfx ossl_unused int ossl_ht_##name##_##vtype##_type(HT_VALUE *h) \ -{ \ - return h->type_id == &name##_##vtype##_id; \ -} + pfx ossl_unused int ossl_ht_##name##_##vtype##_type(HT_VALUE *h) \ + { \ + return h->type_id == &name##_##vtype##_id; \ + } -#define DECLARE_HT_VALUE_TYPE_FNS(vtype, name) \ -int ossl_ht_##name##_##vtype##_insert(HT *h, HT_KEY *key, vtype *data, \ - vtype **olddata); \ -vtype *ossl_ht_##name##_##vtype##_from_value(HT_VALUE *v); \ -vtype *ossl_unused ossl_ht_##name##_##vtype##_get(HT *h, \ - HT_KEY *key, \ - HT_VALUE **v); \ -HT_VALUE *ossl_ht_##name##_##vtype##_to_value(vtype *data, HT_VALUE *v); \ -int ossl_ht_##name##_##vtype##_type(HT_VALUE *h); \ +#define DECLARE_HT_VALUE_TYPE_FNS(vtype, name) \ + int ossl_ht_##name##_##vtype##_insert(HT *h, HT_KEY *key, vtype *data, \ + vtype **olddata); \ + vtype *ossl_ht_##name##_##vtype##_from_value(HT_VALUE *v); \ + vtype *ossl_unused ossl_ht_##name##_##vtype##_get(HT *h, \ + HT_KEY *key, \ + HT_VALUE **v); \ + HT_VALUE *ossl_ht_##name##_##vtype##_to_value(vtype *data, HT_VALUE *v); \ + int ossl_ht_##name##_##vtype##_type(HT_VALUE *h); /* * Helper function to construct case insensitive keys @@ -295,12 +304,12 @@ void ossl_ht_read_unlock(HT *htable); /* * Write unlock */ -void ossl_ht_write_unlock (HT *htable); +void ossl_ht_write_unlock(HT *htable); /* * Empties a hash table, potentially freeing all elements */ -int ossl_ht_flush(HT *htable); +int ossl_ht_flush(HT *htable); /* * Inserts an element to a hash table, optionally returning @@ -308,7 +317,7 @@ int ossl_ht_flush(HT *htable); * Returns 1 if the insert was successful, 0 on error */ int ossl_ht_insert(HT *htable, HT_KEY *key, HT_VALUE *data, - HT_VALUE **olddata); + HT_VALUE **olddata); /* * Deletes a value from a hash table, based on key @@ -330,17 +339,17 @@ size_t ossl_ht_count(HT *htable); * table may not be inserted or removed while iterating. */ void ossl_ht_foreach_until(HT *htable, int (*cb)(HT_VALUE *obj, void *arg), - void *arg); + void *arg); /* * Returns a list of elements in a hash table based on * filter function return value. Returns NULL on error, * or an HT_VALUE_LIST object on success. Note it is possible * That a list will be returned with 0 entries, if none were found. - * The zero length list must still be freed via ossl_ht_value_list_free + * The zero length list must still be freed via ossl_ht_value_list_free */ HT_VALUE_LIST *ossl_ht_filter(HT *htable, size_t max_len, - int (*filter)(HT_VALUE *obj, void *arg), - void *arg); + int (*filter)(HT_VALUE *obj, void *arg), + void *arg); /* * Frees the list returned from ossl_ht_filter */ diff --git a/crypto/openssl/include/internal/hpke_util.h b/crypto/openssl/include/internal/hpke_util.h index e1da5e0596fb..9c52ba469386 100644 --- a/crypto/openssl/include/internal/hpke_util.h +++ b/crypto/openssl/include/internal/hpke_util.h @@ -8,20 +8,20 @@ */ #ifndef OSSL_INTERNAL_HPKE_UTIL_H -# define OSSL_INTERNAL_HPKE_UTIL_H -# pragma once +#define OSSL_INTERNAL_HPKE_UTIL_H +#pragma once /* Constants from RFC 9180 Section 7.1 and 7.3 */ -# define OSSL_HPKE_MAX_SECRET 64 -# define OSSL_HPKE_MAX_PUBLIC 133 -# define OSSL_HPKE_MAX_PRIVATE 66 -# define OSSL_HPKE_MAX_KDF_INPUTLEN 64 +#define OSSL_HPKE_MAX_SECRET 64 +#define OSSL_HPKE_MAX_PUBLIC 133 +#define OSSL_HPKE_MAX_PRIVATE 66 +#define OSSL_HPKE_MAX_KDF_INPUTLEN 64 /* * max length of a base-nonce (the Nn field from OSSL_HPKE_AEAD_INFO), this * is used for a local stack array size */ -# define OSSL_HPKE_MAX_NONCELEN 12 +#define OSSL_HPKE_MAX_NONCELEN 12 /* * @brief info about a KEM @@ -29,35 +29,35 @@ * and the bitmask for EC curves described in Section 7.1.3 DeriveKeyPair */ typedef struct { - uint16_t kem_id; /* code point for key encipherment method */ - const char *keytype; /* string form of algtype "EC"/"X25519"/"X448" */ - const char *groupname; /* string form of EC group for NIST curves */ - const char *mdname; /* hash alg name for the HKDF */ - size_t Nsecret; /* size of secrets */ - size_t Nenc; /* length of encapsulated key */ - size_t Npk; /* length of public key */ - size_t Nsk; /* length of raw private key */ - uint8_t bitmask; + uint16_t kem_id; /* code point for key encipherment method */ + const char *keytype; /* string form of algtype "EC"/"X25519"/"X448" */ + const char *groupname; /* string form of EC group for NIST curves */ + const char *mdname; /* hash alg name for the HKDF */ + size_t Nsecret; /* size of secrets */ + size_t Nenc; /* length of encapsulated key */ + size_t Npk; /* length of public key */ + size_t Nsk; /* length of raw private key */ + uint8_t bitmask; } OSSL_HPKE_KEM_INFO; /* * @brief info about a KDF */ typedef struct { - uint16_t kdf_id; /* code point for KDF */ - const char *mdname; /* hash alg name for the HKDF */ - size_t Nh; /* length of hash/extract output */ + uint16_t kdf_id; /* code point for KDF */ + const char *mdname; /* hash alg name for the HKDF */ + size_t Nh; /* length of hash/extract output */ } OSSL_HPKE_KDF_INFO; /* * @brief info about an AEAD */ typedef struct { - uint16_t aead_id; /* code point for aead alg */ - const char *name; /* alg name */ - size_t taglen; /* aead tag len */ - size_t Nk; /* size of a key for this aead */ - size_t Nn; /* length of a nonce for this aead */ + uint16_t aead_id; /* code point for aead alg */ + const char *name; /* alg name */ + size_t taglen; /* aead tag len */ + size_t Nk; /* size of a key for this aead */ + size_t Nn; /* length of a nonce for this aead */ } OSSL_HPKE_AEAD_INFO; const OSSL_HPKE_KEM_INFO *ossl_HPKE_KEM_INFO_find_curve(const char *curve); @@ -69,32 +69,32 @@ const OSSL_HPKE_AEAD_INFO *ossl_HPKE_AEAD_INFO_find_id(uint16_t aeadid); const OSSL_HPKE_AEAD_INFO *ossl_HPKE_AEAD_INFO_find_random(OSSL_LIB_CTX *ctx); int ossl_hpke_kdf_extract(EVP_KDF_CTX *kctx, - unsigned char *prk, size_t prklen, - const unsigned char *salt, size_t saltlen, - const unsigned char *ikm, size_t ikmlen); + unsigned char *prk, size_t prklen, + const unsigned char *salt, size_t saltlen, + const unsigned char *ikm, size_t ikmlen); int ossl_hpke_kdf_expand(EVP_KDF_CTX *kctx, - unsigned char *okm, size_t okmlen, - const unsigned char *prk, size_t prklen, - const unsigned char *info, size_t infolen); + unsigned char *okm, size_t okmlen, + const unsigned char *prk, size_t prklen, + const unsigned char *info, size_t infolen); int ossl_hpke_labeled_extract(EVP_KDF_CTX *kctx, - unsigned char *prk, size_t prklen, - const unsigned char *salt, size_t saltlen, - const char *protocol_label, - const unsigned char *suiteid, size_t suiteidlen, - const char *label, - const unsigned char *ikm, size_t ikmlen); + unsigned char *prk, size_t prklen, + const unsigned char *salt, size_t saltlen, + const char *protocol_label, + const unsigned char *suiteid, size_t suiteidlen, + const char *label, + const unsigned char *ikm, size_t ikmlen); int ossl_hpke_labeled_expand(EVP_KDF_CTX *kctx, - unsigned char *okm, size_t okmlen, - const unsigned char *prk, size_t prklen, - const char *protocol_label, - const unsigned char *suiteid, size_t suiteidlen, - const char *label, - const unsigned char *info, size_t infolen); + unsigned char *okm, size_t okmlen, + const unsigned char *prk, size_t prklen, + const char *protocol_label, + const unsigned char *suiteid, size_t suiteidlen, + const char *label, + const unsigned char *info, size_t infolen); EVP_KDF_CTX *ossl_kdf_ctx_create(const char *kdfname, const char *mdname, - OSSL_LIB_CTX *libctx, const char *propq); + OSSL_LIB_CTX *libctx, const char *propq); int ossl_hpke_str2suite(const char *suitestr, OSSL_HPKE_SUITE *suite); #endif diff --git a/crypto/openssl/include/internal/json_enc.h b/crypto/openssl/include/internal/json_enc.h index d736a1d645f9..973debe525c5 100644 --- a/crypto/openssl/include/internal/json_enc.h +++ b/crypto/openssl/include/internal/json_enc.h @@ -8,9 +8,9 @@ */ #ifndef OSSL_JSON_ENC_H -# define OSSL_JSON_ENC_H +#define OSSL_JSON_ENC_H -# include <openssl/bio.h> +#include <openssl/bio.h> /* * JSON Encoder @@ -21,22 +21,22 @@ */ struct json_write_buf { - BIO *bio; - char *buf; - size_t alloc, cur; + BIO *bio; + char *buf; + size_t alloc, cur; }; typedef struct ossl_json_enc_st { - uint32_t flags; + uint32_t flags; /* error: 1 if an error has occurred. */ /* state: current state. */ /* stack stores a bitmap. 0=object, 1=array. */ /* stack cur size: stack_end_byte bytes, stack_end_bit bits. */ /* stack alloc size: stack_bytes bytes. */ - unsigned char error, stack_end_bit, state, *stack, defer_indent; - unsigned char stack_small[16]; - struct json_write_buf wbuf; - size_t stack_end_byte, stack_bytes; + unsigned char error, stack_end_bit, state, *stack, defer_indent; + unsigned char stack_small[16]; + struct json_write_buf wbuf; + size_t stack_end_byte, stack_bytes; } OSSL_JSON_ENC; /* @@ -62,10 +62,10 @@ typedef struct ossl_json_enc_st { * 2**53 - 1]` are automatically converted to decimal strings before * serialization. */ -#define OSSL_JSON_FLAG_NONE 0 -#define OSSL_JSON_FLAG_SEQ (1U << 0) -#define OSSL_JSON_FLAG_PRETTY (1U << 1) -#define OSSL_JSON_FLAG_IJSON (1U << 2) +#define OSSL_JSON_FLAG_NONE 0 +#define OSSL_JSON_FLAG_SEQ (1U << 0) +#define OSSL_JSON_FLAG_PRETTY (1U << 1) +#define OSSL_JSON_FLAG_IJSON (1U << 2) int ossl_json_init(OSSL_JSON_ENC *json, BIO *bio, uint32_t flags); diff --git a/crypto/openssl/include/internal/ktls.h b/crypto/openssl/include/internal/ktls.h index 072653dc5eeb..83f66b9dba93 100644 --- a/crypto/openssl/include/internal/ktls.h +++ b/crypto/openssl/include/internal/ktls.h @@ -8,43 +8,43 @@ */ #if defined(OPENSSL_SYS_LINUX) -# ifndef OPENSSL_NO_KTLS -# include <linux/version.h> -# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) -# define OPENSSL_NO_KTLS -# ifndef PEDANTIC -# warning "KTLS requires Kernel Headers >= 4.13.0" -# warning "Skipping Compilation of KTLS" -# endif -# endif -# endif +#ifndef OPENSSL_NO_KTLS +#include <linux/version.h> +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) +#define OPENSSL_NO_KTLS +#ifndef PEDANTIC +#warning "KTLS requires Kernel Headers >= 4.13.0" +#warning "Skipping Compilation of KTLS" +#endif +#endif +#endif #endif #ifndef HEADER_INTERNAL_KTLS -# define HEADER_INTERNAL_KTLS -# pragma once +#define HEADER_INTERNAL_KTLS +#pragma once -# ifndef OPENSSL_NO_KTLS +#ifndef OPENSSL_NO_KTLS -# if defined(__FreeBSD__) -# include <sys/types.h> -# include <sys/socket.h> -# include <sys/ktls.h> -# include <netinet/in.h> -# include <netinet/tcp.h> -# include <openssl/ssl3.h> +#if defined(__FreeBSD__) +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/ktls.h> +#include <netinet/in.h> +#include <netinet/tcp.h> +#include <openssl/ssl3.h> -# ifndef TCP_RXTLS_ENABLE -# define OPENSSL_NO_KTLS_RX -# endif -# define OPENSSL_KTLS_AES_GCM_128 -# define OPENSSL_KTLS_AES_GCM_256 -# define OPENSSL_KTLS_TLS13 -# ifdef TLS_CHACHA20_IV_LEN -# ifndef OPENSSL_NO_CHACHA -# define OPENSSL_KTLS_CHACHA20_POLY1305 -# endif -# endif +#ifndef TCP_RXTLS_ENABLE +#define OPENSSL_NO_KTLS_RX +#endif +#define OPENSSL_KTLS_AES_GCM_128 +#define OPENSSL_KTLS_AES_GCM_256 +#define OPENSSL_KTLS_TLS13 +#ifdef TLS_CHACHA20_IV_LEN +#ifndef OPENSSL_NO_CHACHA +#define OPENSSL_KTLS_CHACHA20_POLY1305 +#endif +#endif typedef struct tls_enable ktls_crypto_info_t; @@ -71,13 +71,17 @@ static ossl_inline int ktls_start(int fd, ktls_crypto_info_t *tls_en, int is_tx) { if (is_tx) return setsockopt(fd, IPPROTO_TCP, TCP_TXTLS_ENABLE, - tls_en, sizeof(*tls_en)) ? 0 : 1; -# ifndef OPENSSL_NO_KTLS_RX + tls_en, sizeof(*tls_en)) + ? 0 + : 1; +#ifndef OPENSSL_NO_KTLS_RX return setsockopt(fd, IPPROTO_TCP, TCP_RXTLS_ENABLE, tls_en, - sizeof(*tls_en)) ? 0 : 1; -# else + sizeof(*tls_en)) + ? 0 + : 1; +#else return 0; -# endif +#endif } /* Not supported on FreeBSD */ @@ -94,13 +98,13 @@ static ossl_inline int ktls_enable_tx_zerocopy_sendfile(int fd) * record using this control message. */ static ossl_inline int ktls_send_ctrl_message(int fd, unsigned char record_type, - const void *data, size_t length) + const void *data, size_t length) { struct msghdr msg = { 0 }; int cmsg_len = sizeof(record_type); struct cmsghdr *cmsg; char buf[CMSG_SPACE(cmsg_len)]; - struct iovec msg_iov; /* Vector of data to send/receive into */ + struct iovec msg_iov; /* Vector of data to send/receive into */ msg.msg_control = buf; msg.msg_controllen = sizeof(buf); @@ -119,14 +123,14 @@ static ossl_inline int ktls_send_ctrl_message(int fd, unsigned char record_type, return sendmsg(fd, &msg, 0); } -# ifdef OPENSSL_NO_KTLS_RX +#ifdef OPENSSL_NO_KTLS_RX static ossl_inline int ktls_read_record(int fd, void *data, size_t length) { return -1; } -# else /* !defined(OPENSSL_NO_KTLS_RX) */ +#else /* !defined(OPENSSL_NO_KTLS_RX) */ /* * Receive a TLS record using the tls_en provided in ktls_start. The @@ -142,7 +146,7 @@ static ossl_inline int ktls_read_record(int fd, void *data, size_t length) struct tls_get_record *tgr; struct cmsghdr *cmsg; char buf[CMSG_SPACE(cmsg_len)]; - struct iovec msg_iov; /* Vector of data to send/receive into */ + struct iovec msg_iov; /* Vector of data to send/receive into */ int ret; unsigned char *p = data; const size_t prepend_length = SSL3_RT_HEADER_LENGTH; @@ -185,19 +189,20 @@ static ossl_inline int ktls_read_record(int fd, void *data, size_t length) p[0] = tgr->tls_type; p[1] = tgr->tls_vmajor; p[2] = tgr->tls_vminor; - *(uint16_t *)(p + 3) = htons(ret); + p[3] = (ret >> 8) & 0xff; + p[4] = ret & 0xff; return ret + prepend_length; } -# endif /* OPENSSL_NO_KTLS_RX */ +#endif /* OPENSSL_NO_KTLS_RX */ /* * KTLS enables the sendfile system call to send data from a file over * TLS. */ static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off, - size_t size, int flags) + size_t size, int flags) { off_t sbytes = 0; int ret; @@ -208,72 +213,72 @@ static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off, return sbytes; } -# endif /* __FreeBSD__ */ +#endif /* __FreeBSD__ */ -# if defined(OPENSSL_SYS_LINUX) +#if defined(OPENSSL_SYS_LINUX) -# include <linux/tls.h> -# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0) -# define OPENSSL_NO_KTLS_RX -# ifndef PEDANTIC -# warning "KTLS requires Kernel Headers >= 4.17.0 for receiving" -# warning "Skipping Compilation of KTLS receive data path" -# endif -# endif -# if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) -# define OPENSSL_NO_KTLS_ZC_TX -# ifndef PEDANTIC -# warning "KTLS requires Kernel Headers >= 5.19.0 for zerocopy sendfile" -# warning "Skipping Compilation of KTLS zerocopy sendfile" -# endif -# endif -# define OPENSSL_KTLS_AES_GCM_128 -# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) -# define OPENSSL_KTLS_AES_GCM_256 -# define OPENSSL_KTLS_TLS13 -# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) -# define OPENSSL_KTLS_AES_CCM_128 -# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) -# ifndef OPENSSL_NO_CHACHA -# define OPENSSL_KTLS_CHACHA20_POLY1305 -# endif -# endif -# endif -# endif +#include <linux/tls.h> +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0) +#define OPENSSL_NO_KTLS_RX +#ifndef PEDANTIC +#warning "KTLS requires Kernel Headers >= 4.17.0 for receiving" +#warning "Skipping Compilation of KTLS receive data path" +#endif +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) +#define OPENSSL_NO_KTLS_ZC_TX +#ifndef PEDANTIC +#warning "KTLS requires Kernel Headers >= 5.19.0 for zerocopy sendfile" +#warning "Skipping Compilation of KTLS zerocopy sendfile" +#endif +#endif +#define OPENSSL_KTLS_AES_GCM_128 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0) +#define OPENSSL_KTLS_AES_GCM_256 +#define OPENSSL_KTLS_TLS13 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0) +#define OPENSSL_KTLS_AES_CCM_128 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) +#ifndef OPENSSL_NO_CHACHA +#define OPENSSL_KTLS_CHACHA20_POLY1305 +#endif +#endif +#endif +#endif -# include <sys/sendfile.h> -# include <netinet/tcp.h> -# include <linux/socket.h> -# include <openssl/ssl3.h> -# include <openssl/tls1.h> -# include <openssl/evp.h> +#include <sys/sendfile.h> +#include <netinet/tcp.h> +#include <linux/socket.h> +#include <openssl/ssl3.h> +#include <openssl/tls1.h> +#include <openssl/evp.h> -# ifndef SOL_TLS -# define SOL_TLS 282 -# endif +#ifndef SOL_TLS +#define SOL_TLS 282 +#endif -# ifndef TCP_ULP -# define TCP_ULP 31 -# endif +#ifndef TCP_ULP +#define TCP_ULP 31 +#endif -# ifndef TLS_RX -# define TLS_RX 2 -# endif +#ifndef TLS_RX +#define TLS_RX 2 +#endif struct tls_crypto_info_all { union { -# ifdef OPENSSL_KTLS_AES_GCM_128 +#ifdef OPENSSL_KTLS_AES_GCM_128 struct tls12_crypto_info_aes_gcm_128 gcm128; -# endif -# ifdef OPENSSL_KTLS_AES_GCM_256 +#endif +#ifdef OPENSSL_KTLS_AES_GCM_256 struct tls12_crypto_info_aes_gcm_256 gcm256; -# endif -# ifdef OPENSSL_KTLS_AES_CCM_128 +#endif +#ifdef OPENSSL_KTLS_AES_CCM_128 struct tls12_crypto_info_aes_ccm_128 ccm128; -# endif -# ifdef OPENSSL_KTLS_CHACHA20_POLY1305 +#endif +#ifdef OPENSSL_KTLS_CHACHA20_POLY1305 struct tls12_crypto_info_chacha20_poly1305 chacha20poly1305; -# endif +#endif }; size_t tls_crypto_info_len; }; @@ -300,10 +305,18 @@ static ossl_inline int ktls_enable(int fd) * authenticated and decapsulated using the crypto_info provided here. */ static ossl_inline int ktls_start(int fd, ktls_crypto_info_t *crypto_info, - int is_tx) + int is_tx) { + /* + * Socket must be in TCP established state to enable KTLS. + * Further calls to enable ktls will return EEXIST + */ + ktls_enable(fd); + return setsockopt(fd, SOL_TLS, is_tx ? TLS_TX : TLS_RX, - crypto_info, crypto_info->tls_crypto_info_len) ? 0 : 1; + crypto_info, crypto_info->tls_crypto_info_len) + ? 0 + : 1; } static ossl_inline int ktls_enable_tx_zerocopy_sendfile(int fd) @@ -312,7 +325,9 @@ static ossl_inline int ktls_enable_tx_zerocopy_sendfile(int fd) int enable = 1; return setsockopt(fd, SOL_TLS, TLS_TX_ZEROCOPY_RO, - &enable, sizeof(enable)) ? 0 : 1; + &enable, sizeof(enable)) + ? 0 + : 1; #else return 0; #endif @@ -326,7 +341,7 @@ static ossl_inline int ktls_enable_tx_zerocopy_sendfile(int fd) * record using this control message. */ static ossl_inline int ktls_send_ctrl_message(int fd, unsigned char record_type, - const void *data, size_t length) + const void *data, size_t length) { struct msghdr msg; int cmsg_len = sizeof(record_type); @@ -335,7 +350,7 @@ static ossl_inline int ktls_send_ctrl_message(int fd, unsigned char record_type, struct cmsghdr hdr; char buf[CMSG_SPACE(sizeof(unsigned char))]; } cmsgbuf; - struct iovec msg_iov; /* Vector of data to send/receive into */ + struct iovec msg_iov; /* Vector of data to send/receive into */ memset(&msg, 0, sizeof(msg)); msg.msg_control = cmsgbuf.buf; @@ -364,15 +379,14 @@ static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off, size_t s return sendfile(s, fd, &off, size); } -# ifdef OPENSSL_NO_KTLS_RX - +#ifdef OPENSSL_NO_KTLS_RX static ossl_inline int ktls_read_record(int fd, void *data, size_t length) { return -1; } -# else /* !defined(OPENSSL_NO_KTLS_RX) */ +#else /* !defined(OPENSSL_NO_KTLS_RX) */ /* * Receive a TLS record using the crypto_info provided in ktls_start. @@ -427,8 +441,8 @@ static ossl_inline int ktls_read_record(int fd, void *data, size_t length) return ret; } -# endif /* OPENSSL_NO_KTLS_RX */ +#endif /* OPENSSL_NO_KTLS_RX */ -# endif /* OPENSSL_SYS_LINUX */ -# endif /* OPENSSL_NO_KTLS */ +#endif /* OPENSSL_SYS_LINUX */ +#endif /* OPENSSL_NO_KTLS */ #endif /* HEADER_INTERNAL_KTLS */ diff --git a/crypto/openssl/include/internal/list.h b/crypto/openssl/include/internal/list.h index a40f7fe6c249..8bb0b741bed1 100644 --- a/crypto/openssl/include/internal/list.h +++ b/crypto/openssl/include/internal/list.h @@ -8,196 +8,196 @@ */ #ifndef OSSL_INTERNAL_LIST_H -# define OSSL_INTERNAL_LIST_H -# pragma once +#define OSSL_INTERNAL_LIST_H +#pragma once -# include <string.h> -# include <assert.h> +#include <string.h> +#include <assert.h> -# ifdef NDEBUG -# define OSSL_LIST_DBG(x) -# else -# define OSSL_LIST_DBG(x) x; -# endif +#ifdef NDEBUG +#define OSSL_LIST_DBG(x) +#else +#define OSSL_LIST_DBG(x) x; +#endif -# define OSSL_LIST_FOREACH_FROM(p, name, init) \ - for ((p) = (init); \ - (p) != NULL; \ - (p) = ossl_list_##name##_next(p)) -# define OSSL_LIST_FOREACH(p, name, l) \ +#define OSSL_LIST_FOREACH_FROM(p, name, init) \ + for ((p) = (init); \ + (p) != NULL; \ + (p) = ossl_list_##name##_next(p)) +#define OSSL_LIST_FOREACH(p, name, l) \ OSSL_LIST_FOREACH_FROM(p, name, ossl_list_##name##_head(l)) -# define OSSL_LIST_FOREACH_REV_FROM(p, name, init) \ - for ((p) = (init); \ - (p) != NULL; \ - (p) = ossl_list_##name##_prev(p)) -# define OSSL_LIST_FOREACH_REV(p, name, l) \ +#define OSSL_LIST_FOREACH_REV_FROM(p, name, init) \ + for ((p) = (init); \ + (p) != NULL; \ + (p) = ossl_list_##name##_prev(p)) +#define OSSL_LIST_FOREACH_REV(p, name, l) \ OSSL_LIST_FOREACH_FROM(p, name, ossl_list_##name##_tail(l)) -# define OSSL_LIST_FOREACH_DELSAFE_FROM(p, pn, name, init) \ - for ((p) = (init); \ - (p) != NULL && (((pn) = ossl_list_##name##_next(p)), 1); \ - (p) = (pn)) -#define OSSL_LIST_FOREACH_DELSAFE(p, pn, name, l) \ +#define OSSL_LIST_FOREACH_DELSAFE_FROM(p, pn, name, init) \ + for ((p) = (init); \ + (p) != NULL && (((pn) = ossl_list_##name##_next(p)), 1); \ + (p) = (pn)) +#define OSSL_LIST_FOREACH_DELSAFE(p, pn, name, l) \ OSSL_LIST_FOREACH_DELSAFE_FROM(p, pn, name, ossl_list_##name##_head(l)) -# define OSSL_LIST_FOREACH_REV_DELSAFE_FROM(p, pn, name, init) \ - for ((p) = (init); \ - (p) != NULL && (((pn) = ossl_list_##name##_prev(p)), 1); \ - (p) = (pn)) -# define OSSL_LIST_FOREACH_REV_DELSAFE(p, pn, name, l) \ +#define OSSL_LIST_FOREACH_REV_DELSAFE_FROM(p, pn, name, init) \ + for ((p) = (init); \ + (p) != NULL && (((pn) = ossl_list_##name##_prev(p)), 1); \ + (p) = (pn)) +#define OSSL_LIST_FOREACH_REV_DELSAFE(p, pn, name, l) \ OSSL_LIST_FOREACH_REV_DELSAFE_FROM(p, pn, name, ossl_list_##name##_tail(l)) /* Define a list structure */ -# define OSSL_LIST(name) OSSL_LIST_ ## name +#define OSSL_LIST(name) OSSL_LIST_##name /* Define fields to include an element of a list */ -# define OSSL_LIST_MEMBER(name, type) \ - struct { \ - type *next, *prev; \ - OSSL_LIST_DBG(struct ossl_list_st_ ## name *list) \ - } ossl_list_ ## name +#define OSSL_LIST_MEMBER(name, type) \ + struct { \ + type *next, *prev; \ + OSSL_LIST_DBG(struct ossl_list_st_##name *list) \ + } ossl_list_##name -# define DECLARE_LIST_OF(name, type) \ - typedef struct ossl_list_st_ ## name OSSL_LIST(name); \ - struct ossl_list_st_ ## name { \ - type *alpha, *omega; \ - size_t num_elems; \ - } \ +#define DECLARE_LIST_OF(name, type) \ + typedef struct ossl_list_st_##name OSSL_LIST(name); \ + struct ossl_list_st_##name { \ + type *alpha, *omega; \ + size_t num_elems; \ + } -# define DEFINE_LIST_OF_IMPL(name, type) \ - static ossl_unused ossl_inline void \ - ossl_list_##name##_init(OSSL_LIST(name) *list) \ - { \ - memset(list, 0, sizeof(*list)); \ - } \ - static ossl_unused ossl_inline void \ - ossl_list_##name##_init_elem(type *elem) \ - { \ - memset(&elem->ossl_list_ ## name, 0, \ - sizeof(elem->ossl_list_ ## name)); \ - } \ - static ossl_unused ossl_inline int \ - ossl_list_##name##_is_empty(const OSSL_LIST(name) *list) \ - { \ - return list->num_elems == 0; \ - } \ - static ossl_unused ossl_inline size_t \ - ossl_list_##name##_num(const OSSL_LIST(name) *list) \ - { \ - return list->num_elems; \ - } \ - static ossl_unused ossl_inline type * \ - ossl_list_##name##_head(const OSSL_LIST(name) *list) \ - { \ - assert(list->alpha == NULL \ - || list->alpha->ossl_list_ ## name.list == list); \ - return list->alpha; \ - } \ - static ossl_unused ossl_inline type * \ - ossl_list_##name##_tail(const OSSL_LIST(name) *list) \ - { \ - assert(list->omega == NULL \ - || list->omega->ossl_list_ ## name.list == list); \ - return list->omega; \ - } \ - static ossl_unused ossl_inline type * \ - ossl_list_##name##_next(const type *elem) \ - { \ - assert(elem->ossl_list_ ## name.next == NULL \ - || elem->ossl_list_ ## name.next \ - ->ossl_list_ ## name.prev == elem); \ - return elem->ossl_list_ ## name.next; \ - } \ - static ossl_unused ossl_inline type * \ - ossl_list_##name##_prev(const type *elem) \ - { \ - assert(elem->ossl_list_ ## name.prev == NULL \ - || elem->ossl_list_ ## name.prev \ - ->ossl_list_ ## name.next == elem); \ - return elem->ossl_list_ ## name.prev; \ - } \ - static ossl_unused ossl_inline void \ - ossl_list_##name##_remove(OSSL_LIST(name) *list, type *elem) \ - { \ - assert(elem->ossl_list_ ## name.list == list); \ - OSSL_LIST_DBG(elem->ossl_list_ ## name.list = NULL) \ - if (list->alpha == elem) \ - list->alpha = elem->ossl_list_ ## name.next; \ - if (list->omega == elem) \ - list->omega = elem->ossl_list_ ## name.prev; \ - if (elem->ossl_list_ ## name.prev != NULL) \ - elem->ossl_list_ ## name.prev->ossl_list_ ## name.next = \ - elem->ossl_list_ ## name.next; \ - if (elem->ossl_list_ ## name.next != NULL) \ - elem->ossl_list_ ## name.next->ossl_list_ ## name.prev = \ - elem->ossl_list_ ## name.prev; \ - list->num_elems--; \ - memset(&elem->ossl_list_ ## name, 0, \ - sizeof(elem->ossl_list_ ## name)); \ - } \ - static ossl_unused ossl_inline void \ - ossl_list_##name##_insert_head(OSSL_LIST(name) *list, type *elem) \ - { \ - assert(elem->ossl_list_ ## name.list == NULL); \ - OSSL_LIST_DBG(elem->ossl_list_ ## name.list = list) \ - if (list->alpha != NULL) \ - list->alpha->ossl_list_ ## name.prev = elem; \ - elem->ossl_list_ ## name.next = list->alpha; \ - elem->ossl_list_ ## name.prev = NULL; \ - list->alpha = elem; \ - if (list->omega == NULL) \ - list->omega = elem; \ - list->num_elems++; \ - } \ - static ossl_unused ossl_inline void \ - ossl_list_##name##_insert_tail(OSSL_LIST(name) *list, type *elem) \ - { \ - assert(elem->ossl_list_ ## name.list == NULL); \ - OSSL_LIST_DBG(elem->ossl_list_ ## name.list = list) \ - if (list->omega != NULL) \ - list->omega->ossl_list_ ## name.next = elem; \ - elem->ossl_list_ ## name.prev = list->omega; \ - elem->ossl_list_ ## name.next = NULL; \ - list->omega = elem; \ - if (list->alpha == NULL) \ - list->alpha = elem; \ - list->num_elems++; \ - } \ - static ossl_unused ossl_inline void \ - ossl_list_##name##_insert_before(OSSL_LIST(name) *list, type *e, \ - type *elem) \ - { \ - assert(elem->ossl_list_ ## name.list == NULL); \ - OSSL_LIST_DBG(elem->ossl_list_ ## name.list = list) \ - elem->ossl_list_ ## name.next = e; \ - elem->ossl_list_ ## name.prev = e->ossl_list_ ## name.prev; \ - if (e->ossl_list_ ## name.prev != NULL) \ - e->ossl_list_ ## name.prev->ossl_list_ ## name.next = elem; \ - e->ossl_list_ ## name.prev = elem; \ - if (list->alpha == e) \ - list->alpha = elem; \ - list->num_elems++; \ - } \ - static ossl_unused ossl_inline void \ - ossl_list_##name##_insert_after(OSSL_LIST(name) *list, type *e, \ - type *elem) \ - { \ - assert(elem->ossl_list_ ## name.list == NULL); \ - OSSL_LIST_DBG(elem->ossl_list_ ## name.list = list) \ - elem->ossl_list_ ## name.prev = e; \ - elem->ossl_list_ ## name.next = e->ossl_list_ ## name.next; \ - if (e->ossl_list_ ## name.next != NULL) \ - e->ossl_list_ ## name.next->ossl_list_ ## name.prev = elem; \ - e->ossl_list_ ## name.next = elem; \ - if (list->omega == e) \ - list->omega = elem; \ - list->num_elems++; \ - } \ - struct ossl_list_st_ ## name +#define DEFINE_LIST_OF_IMPL(name, type) \ + static ossl_unused ossl_inline void \ + ossl_list_##name##_init(OSSL_LIST(name) * list) \ + { \ + memset(list, 0, sizeof(*list)); \ + } \ + static ossl_unused ossl_inline void \ + ossl_list_##name##_init_elem(type *elem) \ + { \ + memset(&elem->ossl_list_##name, 0, \ + sizeof(elem->ossl_list_##name)); \ + } \ + static ossl_unused ossl_inline int \ + ossl_list_##name##_is_empty(const OSSL_LIST(name) * list) \ + { \ + return list->num_elems == 0; \ + } \ + static ossl_unused ossl_inline size_t \ + ossl_list_##name##_num(const OSSL_LIST(name) * list) \ + { \ + return list->num_elems; \ + } \ + static ossl_unused ossl_inline type * \ + ossl_list_##name##_head(const OSSL_LIST(name) * list) \ + { \ + assert(list->alpha == NULL \ + || list->alpha->ossl_list_##name.list == list); \ + return list->alpha; \ + } \ + static ossl_unused ossl_inline type * \ + ossl_list_##name##_tail(const OSSL_LIST(name) * list) \ + { \ + assert(list->omega == NULL \ + || list->omega->ossl_list_##name.list == list); \ + return list->omega; \ + } \ + static ossl_unused ossl_inline type * \ + ossl_list_##name##_next(const type *elem) \ + { \ + assert(elem->ossl_list_##name.next == NULL \ + || elem->ossl_list_##name.next \ + ->ossl_list_##name.prev \ + == elem); \ + return elem->ossl_list_##name.next; \ + } \ + static ossl_unused ossl_inline type * \ + ossl_list_##name##_prev(const type *elem) \ + { \ + assert(elem->ossl_list_##name.prev == NULL \ + || elem->ossl_list_##name.prev \ + ->ossl_list_##name.next \ + == elem); \ + return elem->ossl_list_##name.prev; \ + } \ + static ossl_unused ossl_inline void \ + ossl_list_##name##_remove(OSSL_LIST(name) * list, type * elem) \ + { \ + assert(elem->ossl_list_##name.list == list); \ + OSSL_LIST_DBG(elem->ossl_list_##name.list = NULL) \ + if (list->alpha == elem) \ + list->alpha = elem->ossl_list_##name.next; \ + if (list->omega == elem) \ + list->omega = elem->ossl_list_##name.prev; \ + if (elem->ossl_list_##name.prev != NULL) \ + elem->ossl_list_##name.prev->ossl_list_##name.next = elem->ossl_list_##name.next; \ + if (elem->ossl_list_##name.next != NULL) \ + elem->ossl_list_##name.next->ossl_list_##name.prev = elem->ossl_list_##name.prev; \ + list->num_elems--; \ + memset(&elem->ossl_list_##name, 0, \ + sizeof(elem->ossl_list_##name)); \ + } \ + static ossl_unused ossl_inline void \ + ossl_list_##name##_insert_head(OSSL_LIST(name) * list, type * elem) \ + { \ + assert(elem->ossl_list_##name.list == NULL); \ + OSSL_LIST_DBG(elem->ossl_list_##name.list = list) \ + if (list->alpha != NULL) \ + list->alpha->ossl_list_##name.prev = elem; \ + elem->ossl_list_##name.next = list->alpha; \ + elem->ossl_list_##name.prev = NULL; \ + list->alpha = elem; \ + if (list->omega == NULL) \ + list->omega = elem; \ + list->num_elems++; \ + } \ + static ossl_unused ossl_inline void \ + ossl_list_##name##_insert_tail(OSSL_LIST(name) * list, type * elem) \ + { \ + assert(elem->ossl_list_##name.list == NULL); \ + OSSL_LIST_DBG(elem->ossl_list_##name.list = list) \ + if (list->omega != NULL) \ + list->omega->ossl_list_##name.next = elem; \ + elem->ossl_list_##name.prev = list->omega; \ + elem->ossl_list_##name.next = NULL; \ + list->omega = elem; \ + if (list->alpha == NULL) \ + list->alpha = elem; \ + list->num_elems++; \ + } \ + static ossl_unused ossl_inline void \ + ossl_list_##name##_insert_before(OSSL_LIST(name) * list, type * e, \ + type * elem) \ + { \ + assert(elem->ossl_list_##name.list == NULL); \ + OSSL_LIST_DBG(elem->ossl_list_##name.list = list) \ + elem->ossl_list_##name.next = e; \ + elem->ossl_list_##name.prev = e->ossl_list_##name.prev; \ + if (e->ossl_list_##name.prev != NULL) \ + e->ossl_list_##name.prev->ossl_list_##name.next = elem; \ + e->ossl_list_##name.prev = elem; \ + if (list->alpha == e) \ + list->alpha = elem; \ + list->num_elems++; \ + } \ + static ossl_unused ossl_inline void \ + ossl_list_##name##_insert_after(OSSL_LIST(name) * list, type * e, \ + type * elem) \ + { \ + assert(elem->ossl_list_##name.list == NULL); \ + OSSL_LIST_DBG(elem->ossl_list_##name.list = list) \ + elem->ossl_list_##name.prev = e; \ + elem->ossl_list_##name.next = e->ossl_list_##name.next; \ + if (e->ossl_list_##name.next != NULL) \ + e->ossl_list_##name.next->ossl_list_##name.prev = elem; \ + e->ossl_list_##name.next = elem; \ + if (list->omega == e) \ + list->omega = elem; \ + list->num_elems++; \ + } \ + struct ossl_list_st_##name -# define DEFINE_LIST_OF(name, type) \ - DECLARE_LIST_OF(name, type); \ +#define DEFINE_LIST_OF(name, type) \ + DECLARE_LIST_OF(name, type); \ DEFINE_LIST_OF_IMPL(name, type) #endif diff --git a/crypto/openssl/include/internal/namemap.h b/crypto/openssl/include/internal/namemap.h index a3a3414869ae..f74a7d72d505 100644 --- a/crypto/openssl/include/internal/namemap.h +++ b/crypto/openssl/include/internal/namemap.h @@ -26,16 +26,16 @@ int ossl_namemap_add_name(OSSL_NAMEMAP *namemap, int number, const char *name); */ int ossl_namemap_name2num(const OSSL_NAMEMAP *namemap, const char *name); int ossl_namemap_name2num_n(const OSSL_NAMEMAP *namemap, - const char *name, size_t name_len); + const char *name, size_t name_len); const char *ossl_namemap_num2name(const OSSL_NAMEMAP *namemap, int number, - size_t idx); + size_t idx); int ossl_namemap_doall_names(const OSSL_NAMEMAP *namemap, int number, - void (*fn)(const char *name, void *data), - void *data); + void (*fn)(const char *name, void *data), + void *data); /* * A utility that handles several names in a string, divided by a given * separator. */ int ossl_namemap_add_names(OSSL_NAMEMAP *namemap, int number, - const char *names, const char separator); + const char *names, const char separator); diff --git a/crypto/openssl/include/internal/nelem.h b/crypto/openssl/include/internal/nelem.h index b758513b4cae..d0b2c39596ec 100644 --- a/crypto/openssl/include/internal/nelem.h +++ b/crypto/openssl/include/internal/nelem.h @@ -8,8 +8,8 @@ */ #ifndef OSSL_INTERNAL_NELEM_H -# define OSSL_INTERNAL_NELEM_H -# pragma once +#define OSSL_INTERNAL_NELEM_H +#pragma once -# define OSSL_NELEM(x) (sizeof(x)/sizeof((x)[0])) +#define OSSL_NELEM(x) (sizeof(x) / sizeof((x)[0])) #endif diff --git a/crypto/openssl/include/internal/numbers.h b/crypto/openssl/include/internal/numbers.h index 4a93a2475637..38d9d102fe85 100644 --- a/crypto/openssl/include/internal/numbers.h +++ b/crypto/openssl/include/internal/numbers.h @@ -8,103 +8,101 @@ */ #ifndef OSSL_INTERNAL_NUMBERS_H -# define OSSL_INTERNAL_NUMBERS_H -# pragma once +#define OSSL_INTERNAL_NUMBERS_H +#pragma once -# include <limits.h> +#include <limits.h> -# if (-1 & 3) == 0x03 /* Two's complement */ +#if (-1 & 3) == 0x03 /* Two's complement */ -# define __MAXUINT__(T) ((T) -1) -# define __MAXINT__(T) ((T) ((((T) 1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T))) -# define __MININT__(T) (-__MAXINT__(T) - 1) +#define __MAXUINT__(T) ((T) - 1) +#define __MAXINT__(T) ((T)((((T)1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T))) +#define __MININT__(T) (-__MAXINT__(T) - 1) -# elif (-1 & 3) == 0x02 /* Ones' complement */ +#elif (-1 & 3) == 0x02 /* Ones' complement */ -# define __MAXUINT__(T) (((T) -1) + 1) -# define __MAXINT__(T) ((T) ((((T) 1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T))) -# define __MININT__(T) (-__MAXINT__(T)) +#define __MAXUINT__(T) (((T) - 1) + 1) +#define __MAXINT__(T) ((T)((((T)1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T))) +#define __MININT__(T) (-__MAXINT__(T)) -# elif (-1 & 3) == 0x01 /* Sign/magnitude */ +#elif (-1 & 3) == 0x01 /* Sign/magnitude */ -# define __MAXINT__(T) ((T) (((((T) 1) << ((sizeof(T) * CHAR_BIT) - 2)) - 1) | (((T) 1) << ((sizeof(T) * CHAR_BIT) - 2)))) -# define __MAXUINT__(T) ((T) (__MAXINT__(T) | (((T) 1) << ((sizeof(T) * CHAR_BIT) - 1)))) -# define __MININT__(T) (-__MAXINT__(T)) +#define __MAXINT__(T) ((T)(((((T)1) << ((sizeof(T) * CHAR_BIT) - 2)) - 1) | (((T)1) << ((sizeof(T) * CHAR_BIT) - 2)))) +#define __MAXUINT__(T) ((T)(__MAXINT__(T) | (((T)1) << ((sizeof(T) * CHAR_BIT) - 1)))) +#define __MININT__(T) (-__MAXINT__(T)) -# else +#else -# error "do not know the integer encoding on this architecture" +#error "do not know the integer encoding on this architecture" -# endif +#endif -# ifndef INT8_MAX -# define INT8_MIN __MININT__(int8_t) -# define INT8_MAX __MAXINT__(int8_t) -# define UINT8_MAX __MAXUINT__(uint8_t) -# endif +#ifndef INT8_MAX +#define INT8_MIN __MININT__(int8_t) +#define INT8_MAX __MAXINT__(int8_t) +#define UINT8_MAX __MAXUINT__(uint8_t) +#endif -# ifndef INT16_MAX -# define INT16_MIN __MININT__(int16_t) -# define INT16_MAX __MAXINT__(int16_t) -# define UINT16_MAX __MAXUINT__(uint16_t) -# endif +#ifndef INT16_MAX +#define INT16_MIN __MININT__(int16_t) +#define INT16_MAX __MAXINT__(int16_t) +#define UINT16_MAX __MAXUINT__(uint16_t) +#endif -# ifndef INT32_MAX -# define INT32_MIN __MININT__(int32_t) -# define INT32_MAX __MAXINT__(int32_t) -# define UINT32_MAX __MAXUINT__(uint32_t) -# endif +#ifndef INT32_MAX +#define INT32_MIN __MININT__(int32_t) +#define INT32_MAX __MAXINT__(int32_t) +#define UINT32_MAX __MAXUINT__(uint32_t) +#endif -# ifndef INT64_MAX -# define INT64_MIN __MININT__(int64_t) -# define INT64_MAX __MAXINT__(int64_t) -# define UINT64_MAX __MAXUINT__(uint64_t) -# endif +#ifndef INT64_MAX +#define INT64_MIN __MININT__(int64_t) +#define INT64_MAX __MAXINT__(int64_t) +#define UINT64_MAX __MAXUINT__(uint64_t) +#endif /* * 64-bit processor with LP64 ABI */ -# ifdef SIXTY_FOUR_BIT_LONG -# ifndef UINT32_C -# define UINT32_C(c) (c) -# endif -# ifndef UINT64_C -# define UINT64_C(c) (c##UL) -# endif -# endif +#ifdef SIXTY_FOUR_BIT_LONG +#ifndef UINT32_C +#define UINT32_C(c) (c) +#endif +#ifndef UINT64_C +#define UINT64_C(c) (c##UL) +#endif +#endif /* * 64-bit processor other than LP64 ABI */ -# ifdef SIXTY_FOUR_BIT -# ifndef UINT32_C -# define UINT32_C(c) (c##UL) -# endif -# ifndef UINT64_C -# define UINT64_C(c) (c##ULL) -# endif -# endif - +#ifdef SIXTY_FOUR_BIT +#ifndef UINT32_C +#define UINT32_C(c) (c##UL) +#endif +#ifndef UINT64_C +#define UINT64_C(c) (c##ULL) +#endif +#endif -# ifndef INT128_MAX -# if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__ == 16 +#ifndef INT128_MAX +#if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__ == 16 typedef __int128_t int128_t; typedef __uint128_t uint128_t; -# define INT128_MIN __MININT__(int128_t) -# define INT128_MAX __MAXINT__(int128_t) -# define UINT128_MAX __MAXUINT__(uint128_t) -# endif -# endif - -# ifndef SIZE_MAX -# define SIZE_MAX __MAXUINT__(size_t) -# endif +#define INT128_MIN __MININT__(int128_t) +#define INT128_MAX __MAXINT__(int128_t) +#define UINT128_MAX __MAXUINT__(uint128_t) +#endif +#endif -# ifndef OSSL_INTMAX_MAX -# define OSSL_INTMAX_MIN __MININT__(ossl_intmax_t) -# define OSSL_INTMAX_MAX __MAXINT__(ossl_intmax_t) -# define OSSL_UINTMAX_MAX __MAXUINT__(ossl_uintmax_t) -# endif +#ifndef SIZE_MAX +#define SIZE_MAX __MAXUINT__(size_t) +#endif +#ifndef OSSL_INTMAX_MAX +#define OSSL_INTMAX_MIN __MININT__(ossl_intmax_t) +#define OSSL_INTMAX_MAX __MAXINT__(ossl_intmax_t) +#define OSSL_UINTMAX_MAX __MAXUINT__(ossl_uintmax_t) #endif +#endif diff --git a/crypto/openssl/include/internal/o_dir.h b/crypto/openssl/include/internal/o_dir.h index add34d14be11..d715a5dd3fe3 100644 --- a/crypto/openssl/include/internal/o_dir.h +++ b/crypto/openssl/include/internal/o_dir.h @@ -37,8 +37,8 @@ */ #ifndef OSSL_INTERNAL_O_DIR_H -# define OSSL_INTERNAL_O_DIR_H -# pragma once +#define OSSL_INTERNAL_O_DIR_H +#pragma once typedef struct OPENSSL_dir_context_st OPENSSL_DIR_CTX; @@ -50,4 +50,4 @@ const char *OPENSSL_DIR_read(OPENSSL_DIR_CTX **ctx, const char *directory); /* returns 1 on success, 0 on error */ int OPENSSL_DIR_end(OPENSSL_DIR_CTX **ctx); -#endif /* LPDIR_H */ +#endif /* LPDIR_H */ diff --git a/crypto/openssl/include/internal/packet.h b/crypto/openssl/include/internal/packet.h index 6fcd345ce28d..e5de4d43283f 100644 --- a/crypto/openssl/include/internal/packet.h +++ b/crypto/openssl/include/internal/packet.h @@ -8,16 +8,16 @@ */ #ifndef OSSL_INTERNAL_PACKET_H -# define OSSL_INTERNAL_PACKET_H -# pragma once +#define OSSL_INTERNAL_PACKET_H +#pragma once -# include <string.h> -# include <openssl/bn.h> -# include <openssl/buffer.h> -# include <openssl/crypto.h> -# include <openssl/e_os2.h> +#include <string.h> +#include <openssl/bn.h> +#include <openssl/buffer.h> +#include <openssl/crypto.h> +#include <openssl/e_os2.h> -# include "internal/numbers.h" +#include "internal/numbers.h" typedef struct { /* Pointer to where we are currently reading from */ @@ -67,8 +67,8 @@ static ossl_inline const unsigned char *PACKET_data(const PACKET *pkt) * is being used. */ __owur static ossl_inline int PACKET_buf_init(PACKET *pkt, - const unsigned char *buf, - size_t len) + const unsigned char *buf, + size_t len) { /* Sanity check for negative values. */ if (len > (size_t)(SIZE_MAX / 2)) @@ -92,7 +92,7 @@ static ossl_inline void PACKET_null_init(PACKET *pkt) * If lengths are equal, performs the comparison in constant time. */ __owur static ossl_inline int PACKET_equal(const PACKET *pkt, const void *ptr, - size_t num) + size_t num) { if (PACKET_remaining(pkt) != num) return 0; @@ -105,7 +105,7 @@ __owur static ossl_inline int PACKET_equal(const PACKET *pkt, const void *ptr, * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. */ __owur static ossl_inline int PACKET_peek_sub_packet(const PACKET *pkt, - PACKET *subpkt, size_t len) + PACKET *subpkt, size_t len) { if (PACKET_remaining(pkt) < len) return 0; @@ -119,7 +119,7 @@ __owur static ossl_inline int PACKET_peek_sub_packet(const PACKET *pkt, * original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. */ __owur static ossl_inline int PACKET_get_sub_packet(PACKET *pkt, - PACKET *subpkt, size_t len) + PACKET *subpkt, size_t len) { if (!PACKET_peek_sub_packet(pkt, subpkt, len)) return 0; @@ -134,7 +134,7 @@ __owur static ossl_inline int PACKET_get_sub_packet(PACKET *pkt, * |*data| */ __owur static ossl_inline int PACKET_peek_net_2(const PACKET *pkt, - unsigned int *data) + unsigned int *data) { if (PACKET_remaining(pkt) < 2) return 0; @@ -174,7 +174,7 @@ __owur static ossl_inline int PACKET_get_net_2_len(PACKET *pkt, size_t *data) * |*data| */ __owur static ossl_inline int PACKET_peek_net_3(const PACKET *pkt, - unsigned long *data) + unsigned long *data) { if (PACKET_remaining(pkt) < 3) return 0; @@ -215,7 +215,7 @@ __owur static ossl_inline int PACKET_get_net_3_len(PACKET *pkt, size_t *data) * |*data| */ __owur static ossl_inline int PACKET_peek_net_4(const PACKET *pkt, - unsigned long *data) + unsigned long *data) { if (PACKET_remaining(pkt) < 4) return 0; @@ -233,7 +233,7 @@ __owur static ossl_inline int PACKET_peek_net_4(const PACKET *pkt, * |*data| */ __owur static ossl_inline int PACKET_peek_net_8(const PACKET *pkt, - uint64_t *data) + uint64_t *data) { if (PACKET_remaining(pkt) < 8) return 0; @@ -287,7 +287,7 @@ __owur static ossl_inline int PACKET_get_net_8(PACKET *pkt, uint64_t *data) /* Peek ahead at 1 byte from |pkt| and store the value in |*data| */ __owur static ossl_inline int PACKET_peek_1(const PACKET *pkt, - unsigned int *data) + unsigned int *data) { if (!PACKET_remaining(pkt)) return 0; @@ -325,7 +325,7 @@ __owur static ossl_inline int PACKET_get_1_len(PACKET *pkt, size_t *data) * in |*data| */ __owur static ossl_inline int PACKET_peek_4(const PACKET *pkt, - unsigned long *data) + unsigned long *data) { if (PACKET_remaining(pkt) < 4) return 0; @@ -360,8 +360,8 @@ __owur static ossl_inline int PACKET_get_4(PACKET *pkt, unsigned long *data) * underlying buffer gets freed */ __owur static ossl_inline int PACKET_peek_bytes(const PACKET *pkt, - const unsigned char **data, - size_t len) + const unsigned char **data, + size_t len) { if (PACKET_remaining(pkt) < len) return 0; @@ -378,8 +378,8 @@ __owur static ossl_inline int PACKET_peek_bytes(const PACKET *pkt, * freed */ __owur static ossl_inline int PACKET_get_bytes(PACKET *pkt, - const unsigned char **data, - size_t len) + const unsigned char **data, + size_t len) { if (!PACKET_peek_bytes(pkt, data, len)) return 0; @@ -391,8 +391,8 @@ __owur static ossl_inline int PACKET_get_bytes(PACKET *pkt, /* Peek ahead at |len| bytes from |pkt| and copy them to |data| */ __owur static ossl_inline int PACKET_peek_copy_bytes(const PACKET *pkt, - unsigned char *data, - size_t len) + unsigned char *data, + size_t len) { if (PACKET_remaining(pkt) < len) return 0; @@ -407,7 +407,7 @@ __owur static ossl_inline int PACKET_peek_copy_bytes(const PACKET *pkt, * The caller is responsible for ensuring that |data| can hold |len| bytes. */ __owur static ossl_inline int PACKET_copy_bytes(PACKET *pkt, - unsigned char *data, size_t len) + unsigned char *data, size_t len) { if (!PACKET_peek_copy_bytes(pkt, data, len)) return 0; @@ -425,8 +425,8 @@ __owur static ossl_inline int PACKET_copy_bytes(PACKET *pkt, * done with a given PACKET). */ __owur static ossl_inline int PACKET_copy_all(const PACKET *pkt, - unsigned char *dest, - size_t dest_len, size_t *len) + unsigned char *dest, + size_t dest_len, size_t *len) { if (PACKET_remaining(pkt) > dest_len) { *len = 0; @@ -447,7 +447,7 @@ __owur static ossl_inline int PACKET_copy_all(const PACKET *pkt, * done with a given PACKET). */ __owur static ossl_inline int PACKET_memdup(const PACKET *pkt, - unsigned char **data, size_t *len) + unsigned char **data, size_t *len) { size_t length; @@ -512,13 +512,12 @@ __owur static ossl_inline int PACKET_forward(PACKET *pkt, size_t len) * Upon failure, the original |pkt| and |subpkt| are not modified. */ __owur static ossl_inline int PACKET_get_length_prefixed_1(PACKET *pkt, - PACKET *subpkt) + PACKET *subpkt) { unsigned int length; const unsigned char *data; PACKET tmp = *pkt; - if (!PACKET_get_1(&tmp, &length) || - !PACKET_get_bytes(&tmp, &data, (size_t)length)) { + if (!PACKET_get_1(&tmp, &length) || !PACKET_get_bytes(&tmp, &data, (size_t)length)) { return 0; } @@ -534,14 +533,12 @@ __owur static ossl_inline int PACKET_get_length_prefixed_1(PACKET *pkt, * leftover bytes in |pkt|. */ __owur static ossl_inline int PACKET_as_length_prefixed_1(PACKET *pkt, - PACKET *subpkt) + PACKET *subpkt) { unsigned int length; const unsigned char *data; PACKET tmp = *pkt; - if (!PACKET_get_1(&tmp, &length) || - !PACKET_get_bytes(&tmp, &data, (size_t)length) || - PACKET_remaining(&tmp) != 0) { + if (!PACKET_get_1(&tmp, &length) || !PACKET_get_bytes(&tmp, &data, (size_t)length) || PACKET_remaining(&tmp) != 0) { return 0; } @@ -560,14 +557,13 @@ __owur static ossl_inline int PACKET_as_length_prefixed_1(PACKET *pkt, * Upon failure, the original |pkt| and |subpkt| are not modified. */ __owur static ossl_inline int PACKET_get_length_prefixed_2(PACKET *pkt, - PACKET *subpkt) + PACKET *subpkt) { unsigned int length; const unsigned char *data; PACKET tmp = *pkt; - if (!PACKET_get_net_2(&tmp, &length) || - !PACKET_get_bytes(&tmp, &data, (size_t)length)) { + if (!PACKET_get_net_2(&tmp, &length) || !PACKET_get_bytes(&tmp, &data, (size_t)length)) { return 0; } @@ -583,15 +579,13 @@ __owur static ossl_inline int PACKET_get_length_prefixed_2(PACKET *pkt, * leftover bytes in |pkt|. */ __owur static ossl_inline int PACKET_as_length_prefixed_2(PACKET *pkt, - PACKET *subpkt) + PACKET *subpkt) { unsigned int length; const unsigned char *data; PACKET tmp = *pkt; - if (!PACKET_get_net_2(&tmp, &length) || - !PACKET_get_bytes(&tmp, &data, (size_t)length) || - PACKET_remaining(&tmp) != 0) { + if (!PACKET_get_net_2(&tmp, &length) || !PACKET_get_bytes(&tmp, &data, (size_t)length) || PACKET_remaining(&tmp) != 0) { return 0; } @@ -610,13 +604,12 @@ __owur static ossl_inline int PACKET_as_length_prefixed_2(PACKET *pkt, * Upon failure, the original |pkt| and |subpkt| are not modified. */ __owur static ossl_inline int PACKET_get_length_prefixed_3(PACKET *pkt, - PACKET *subpkt) + PACKET *subpkt) { unsigned long length; const unsigned char *data; PACKET tmp = *pkt; - if (!PACKET_get_net_3(&tmp, &length) || - !PACKET_get_bytes(&tmp, &data, (size_t)length)) { + if (!PACKET_get_net_3(&tmp, &length) || !PACKET_get_bytes(&tmp, &data, (size_t)length)) { return 0; } @@ -680,19 +673,19 @@ struct wpacket_st { /* Flags */ /* Default */ -#define WPACKET_FLAGS_NONE 0 +#define WPACKET_FLAGS_NONE 0 /* Error on WPACKET_close() if no data written to the WPACKET */ -#define WPACKET_FLAGS_NON_ZERO_LENGTH 1 +#define WPACKET_FLAGS_NON_ZERO_LENGTH 1 /* * Abandon all changes on WPACKET_close() if no data written to the WPACKET, * i.e. this does not write out a zero packet length */ -#define WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH 2 +#define WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH 2 /* QUIC variable-length integer length prefix */ -#define WPACKET_FLAGS_QUIC_VLINT 4 +#define WPACKET_FLAGS_QUIC_VLINT 4 /* * Initialise a WPACKET with the buffer in |buf|. The buffer must exist @@ -727,7 +720,7 @@ int WPACKET_init_null_der(WPACKET *pkt); * occur if you attempt to write beyond the end of the buffer */ int WPACKET_init_static_len(WPACKET *pkt, unsigned char *buf, size_t len, - size_t lenbytes); + size_t lenbytes); /* * Same as WPACKET_init_static_len except lenbytes is always 0, and we set the @@ -799,7 +792,7 @@ int WPACKET_start_sub_packet(WPACKET *pkt); * change its location. */ int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, - unsigned char **allocbytes); + unsigned char **allocbytes); /* * The same as WPACKET_allocate_bytes() except additionally a new sub-packet is @@ -808,7 +801,7 @@ int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, * directly. Use the convenience macros below instead. */ int WPACKET_sub_allocate_bytes__(WPACKET *pkt, size_t len, - unsigned char **allocbytes, size_t lenbytes); + unsigned char **allocbytes, size_t lenbytes); /* * Convenience macros for calling WPACKET_sub_allocate_bytes with different @@ -847,7 +840,7 @@ int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes); * The "reserve_bytes" equivalent of WPACKET_sub_allocate_bytes__() */ int WPACKET_sub_reserve_bytes__(WPACKET *pkt, size_t len, - unsigned char **allocbytes, size_t lenbytes); + unsigned char **allocbytes, size_t lenbytes); /* * Convenience macros for WPACKET_sub_reserve_bytes with different lengths @@ -900,7 +893,7 @@ int WPACKET_memset(WPACKET *pkt, int ch, size_t len); * directly. Use the convenience macros below instead. */ int WPACKET_sub_memcpy__(WPACKET *pkt, const void *src, size_t len, - size_t lenbytes); + size_t lenbytes); /* Convenience macros for calling WPACKET_sub_memcpy with different lengths */ #define WPACKET_sub_memcpy_u8(pkt, src, len) \ @@ -936,4 +929,4 @@ int WPACKET_is_null_buf(WPACKET *pkt); /* Release resources in a WPACKET if a failure has occurred. */ void WPACKET_cleanup(WPACKET *pkt); -#endif /* OSSL_INTERNAL_PACKET_H */ +#endif /* OSSL_INTERNAL_PACKET_H */ diff --git a/crypto/openssl/include/internal/packet_quic.h b/crypto/openssl/include/internal/packet_quic.h index 5173b4675d8d..783ede37715e 100644 --- a/crypto/openssl/include/internal/packet_quic.h +++ b/crypto/openssl/include/internal/packet_quic.h @@ -8,19 +8,19 @@ */ #ifndef OSSL_INTERNAL_PACKET_QUIC_H -# define OSSL_INTERNAL_PACKET_QUIC_H -# pragma once +#define OSSL_INTERNAL_PACKET_QUIC_H +#pragma once -# include "internal/packet.h" -# include "internal/quic_vlint.h" +#include "internal/packet.h" +#include "internal/quic_vlint.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * Decodes a QUIC variable-length integer in |pkt| and stores the result in * |data|. */ __owur static ossl_inline int PACKET_get_quic_vlint(PACKET *pkt, - uint64_t *data) + uint64_t *data) { size_t enclen; @@ -44,8 +44,8 @@ __owur static ossl_inline int PACKET_get_quic_vlint(PACKET *pkt, * was encoded using the minimal possible number of bytes and 0 otherwise. */ __owur static ossl_inline int PACKET_peek_quic_vlint_ex(PACKET *pkt, - uint64_t *data, - int *was_minimal) + uint64_t *data, + int *was_minimal) { size_t enclen; @@ -66,7 +66,7 @@ __owur static ossl_inline int PACKET_peek_quic_vlint_ex(PACKET *pkt, } __owur static ossl_inline int PACKET_peek_quic_vlint(PACKET *pkt, - uint64_t *data) + uint64_t *data) { return PACKET_peek_quic_vlint_ex(pkt, data, NULL); } @@ -98,15 +98,13 @@ __owur static ossl_inline int PACKET_skip_quic_vlint(PACKET *pkt) * |subpkt|. Upon failure, the original |pkt| and |subpkt| are not modified. */ __owur static ossl_inline int PACKET_get_quic_length_prefixed(PACKET *pkt, - PACKET *subpkt) + PACKET *subpkt) { uint64_t length; const unsigned char *data; PACKET tmp = *pkt; - if (!PACKET_get_quic_vlint(&tmp, &length) || - length > SIZE_MAX || - !PACKET_get_bytes(&tmp, &data, (size_t)length)) { + if (!PACKET_get_quic_vlint(&tmp, &length) || length > SIZE_MAX || !PACKET_get_bytes(&tmp, &data, (size_t)length)) { return 0; } @@ -139,12 +137,12 @@ __owur int WPACKET_start_quic_sub_packet_bound(WPACKET *pkt, size_t max_len); * variable-length integer encoding length. */ __owur int WPACKET_quic_sub_allocate_bytes(WPACKET *pkt, size_t len, - unsigned char **bytes); + unsigned char **bytes); /* * Write a QUIC variable-length integer to the packet. */ __owur int WPACKET_quic_write_vlint(WPACKET *pkt, uint64_t v); -# endif /* OPENSSL_NO_QUIC */ -#endif /* OSSL_INTERNAL_PACKET_QUIC_H */ +#endif /* OPENSSL_NO_QUIC */ +#endif /* OSSL_INTERNAL_PACKET_QUIC_H */ diff --git a/crypto/openssl/include/internal/param_build_set.h b/crypto/openssl/include/internal/param_build_set.h index 3518f008f009..c7785a12e616 100644 --- a/crypto/openssl/include/internal/param_build_set.h +++ b/crypto/openssl/include/internal/param_build_set.h @@ -8,44 +8,44 @@ */ #ifndef OSSL_INTERNAL_PARAM_BUILD_SET_H -# define OSSL_INTERNAL_PARAM_BUILD_SET_H -# pragma once +#define OSSL_INTERNAL_PARAM_BUILD_SET_H +#pragma once -# include <openssl/safestack.h> -# include <openssl/param_build.h> -# include "internal/cryptlib.h" +#include <openssl/safestack.h> +#include <openssl/param_build.h> +#include "internal/cryptlib.h" typedef union { OSSL_UNION_ALIGN; } OSSL_PARAM_ALIGNED_BLOCK; -# define OSSL_PARAM_ALIGN_SIZE sizeof(OSSL_PARAM_ALIGNED_BLOCK) +#define OSSL_PARAM_ALIGN_SIZE sizeof(OSSL_PARAM_ALIGNED_BLOCK) size_t ossl_param_bytes_to_blocks(size_t bytes); void ossl_param_set_secure_block(OSSL_PARAM *last, void *secure_buffer, - size_t secure_buffer_sz); + size_t secure_buffer_sz); int ossl_param_build_set_int(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, - const char *key, int num); + const char *key, int num); int ossl_param_build_set_long(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, - const char *key, long num); + const char *key, long num); int ossl_param_build_set_utf8_string(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, - const char *key, const char *buf); + const char *key, const char *buf); int ossl_param_build_set_octet_string(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, - const char *key, - const unsigned char *data, - size_t data_len); + const char *key, + const unsigned char *data, + size_t data_len); int ossl_param_build_set_bn(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, - const char *key, const BIGNUM *bn); + const char *key, const BIGNUM *bn); int ossl_param_build_set_bn_pad(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, - const char *key, const BIGNUM *bn, size_t sz); + const char *key, const BIGNUM *bn, size_t sz); int ossl_param_build_set_signed_bn(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, - const char *key, const BIGNUM *bn); + const char *key, const BIGNUM *bn); int ossl_param_build_set_signed_bn_pad(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, - const char *key, const BIGNUM *bn, - size_t sz); + const char *key, const BIGNUM *bn, + size_t sz); int ossl_param_build_set_multi_key_bn(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, - const char *names[], - STACK_OF(BIGNUM_const) *stk); + const char *names[], + STACK_OF(BIGNUM_const) *stk); -#endif /* OSSL_INTERNAL_PARAM_BUILD_SET_H */ +#endif /* OSSL_INTERNAL_PARAM_BUILD_SET_H */ diff --git a/crypto/openssl/include/internal/param_names.h b/crypto/openssl/include/internal/param_names.h index 0a0404a57e82..cefb8dfa75fa 100644 --- a/crypto/openssl/include/internal/param_names.h +++ b/crypto/openssl/include/internal/param_names.h @@ -9,11 +9,14 @@ * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ +/* clang-format off */ +/* clang-format on */ int ossl_param_find_pidx(const char *s); /* Parameter name definitions - generated by util/perl/OpenSSL/paramnames.pm */ +/* clang-format off */ #define NUM_PIDX 346 #define PIDX_ALG_PARAM_ALGORITHM_ID 0 @@ -467,3 +470,4 @@ int ossl_param_find_pidx(const char *s); #define PIDX_STORE_PARAM_PROPERTIES 7 #define PIDX_STORE_PARAM_SERIAL 344 #define PIDX_STORE_PARAM_SUBJECT 345 +/* clang-format on */ diff --git a/crypto/openssl/include/internal/param_names.h.in b/crypto/openssl/include/internal/param_names.h.in index f34db21951c5..cb1378b3908a 100644 --- a/crypto/openssl/include/internal/param_names.h.in +++ b/crypto/openssl/include/internal/param_names.h.in @@ -8,11 +8,15 @@ * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ +/* clang-format off */ {- use OpenSSL::paramnames qw(generate_internal_macros); -} +/* clang-format on */ int ossl_param_find_pidx(const char *s); /* Parameter name definitions - generated by util/perl/OpenSSL/paramnames.pm */ +/* clang-format off */ {- generate_internal_macros(); -} +/* clang-format on */ diff --git a/crypto/openssl/include/internal/params.h b/crypto/openssl/include/internal/params.h index 3fbd0cf954c5..d0d309886d9a 100644 --- a/crypto/openssl/include/internal/params.h +++ b/crypto/openssl/include/internal/params.h @@ -20,7 +20,7 @@ * doesn't return success. */ int ossl_param_get1_octet_string(const OSSL_PARAM *params, const char *name, - unsigned char **out, size_t *out_len); + unsigned char **out, size_t *out_len); /* * Concatenate all of the matching params together. * *out will point to an allocated buffer on successful return. @@ -34,5 +34,5 @@ int ossl_param_get1_octet_string(const OSSL_PARAM *params, const char *name, * doesn't return success. */ int ossl_param_get1_concat_octet_string(const OSSL_PARAM *params, const char *name, - unsigned char **out, size_t *out_len, - size_t maxsize); + unsigned char **out, size_t *out_len, + size_t maxsize); diff --git a/crypto/openssl/include/internal/passphrase.h b/crypto/openssl/include/internal/passphrase.h index 54d997b0d90b..803622867b73 100644 --- a/crypto/openssl/include/internal/passphrase.h +++ b/crypto/openssl/include/internal/passphrase.h @@ -8,8 +8,8 @@ */ #ifndef OSSL_INTERNAL_PASSPHRASE_H -# define OSSL_INTERNAL_PASSPHRASE_H -# pragma once +#define OSSL_INTERNAL_PASSPHRASE_H +#pragma once /* * This is a passphrase reader bridge with bells and whistles. @@ -41,9 +41,9 @@ struct ossl_passphrase_data_st { enum { is_expl_passphrase = 1, /* Explicit passphrase given by user */ - is_pem_password, /* pem_password_cb given by user */ - is_ossl_passphrase, /* OSSL_PASSPHRASE_CALLBACK given by user */ - is_ui_method /* UI_METHOD given by user */ + is_pem_password, /* pem_password_cb given by user */ + is_ossl_passphrase, /* OSSL_PASSPHRASE_CALLBACK given by user */ + is_ui_method /* UI_METHOD given by user */ } type; union { struct { @@ -72,7 +72,7 @@ struct ossl_passphrase_data_st { */ /* Set to indicate that caching should be done */ - unsigned int flag_cache_passphrase:1; + unsigned int flag_cache_passphrase : 1; /*- * Misc section: caches and other @@ -88,14 +88,14 @@ void ossl_pw_clear_passphrase_data(struct ossl_passphrase_data_st *data); void ossl_pw_clear_passphrase_cache(struct ossl_passphrase_data_st *data); int ossl_pw_set_passphrase(struct ossl_passphrase_data_st *data, - const unsigned char *passphrase, - size_t passphrase_len); + const unsigned char *passphrase, + size_t passphrase_len); int ossl_pw_set_pem_password_cb(struct ossl_passphrase_data_st *data, - pem_password_cb *cb, void *cbarg); + pem_password_cb *cb, void *cbarg); int ossl_pw_set_ossl_passphrase_cb(struct ossl_passphrase_data_st *data, - OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg); + OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg); int ossl_pw_set_ui_method(struct ossl_passphrase_data_st *data, - const UI_METHOD *ui_method, void *ui_data); + const UI_METHOD *ui_method, void *ui_data); int ossl_pw_enable_passphrase_caching(struct ossl_passphrase_data_st *data); int ossl_pw_disable_passphrase_caching(struct ossl_passphrase_data_st *data); @@ -103,8 +103,8 @@ int ossl_pw_disable_passphrase_caching(struct ossl_passphrase_data_st *data); /* Central function for direct calls */ int ossl_pw_get_passphrase(char *pass, size_t pass_size, size_t *pass_len, - const OSSL_PARAM params[], int verify, - struct ossl_passphrase_data_st *data); + const OSSL_PARAM params[], int verify, + struct ossl_passphrase_data_st *data); /* Callback functions */ diff --git a/crypto/openssl/include/internal/priority_queue.h b/crypto/openssl/include/internal/priority_queue.h index 5be03bf131c8..067c8815961e 100644 --- a/crypto/openssl/include/internal/priority_queue.h +++ b/crypto/openssl/include/internal/priority_queue.h @@ -8,68 +8,67 @@ */ #ifndef OSSL_INTERNAL_PRIORITY_QUEUE_H -# define OSSL_INTERNAL_PRIORITY_QUEUE_H -# pragma once +#define OSSL_INTERNAL_PRIORITY_QUEUE_H +#pragma once -# include <stdlib.h> -# include <openssl/e_os2.h> +#include <stdlib.h> +#include <openssl/e_os2.h> -# define PRIORITY_QUEUE_OF(type) OSSL_PRIORITY_QUEUE_ ## type +#define PRIORITY_QUEUE_OF(type) OSSL_PRIORITY_QUEUE_##type -# define DEFINE_PRIORITY_QUEUE_OF_INTERNAL(type, ctype) \ - typedef struct ossl_priority_queue_st_ ## type PRIORITY_QUEUE_OF(type); \ - static ossl_unused ossl_inline PRIORITY_QUEUE_OF(type) * \ - ossl_pqueue_##type##_new(int (*compare)(const ctype *, const ctype *)) \ - { \ - return (PRIORITY_QUEUE_OF(type) *)ossl_pqueue_new( \ - (int (*)(const void *, const void *))compare); \ - } \ - static ossl_unused ossl_inline void \ - ossl_pqueue_##type##_free(PRIORITY_QUEUE_OF(type) *pq) \ - { \ - ossl_pqueue_free((OSSL_PQUEUE *)pq); \ - } \ - static ossl_unused ossl_inline void \ - ossl_pqueue_##type##_pop_free(PRIORITY_QUEUE_OF(type) *pq, \ - void (*freefunc)(ctype *)) \ - { \ - ossl_pqueue_pop_free((OSSL_PQUEUE *)pq, (void (*)(void *))freefunc);\ - } \ - static ossl_unused ossl_inline int \ - ossl_pqueue_##type##_reserve(PRIORITY_QUEUE_OF(type) *pq, size_t n) \ - { \ - return ossl_pqueue_reserve((OSSL_PQUEUE *)pq, n); \ - } \ - static ossl_unused ossl_inline size_t \ - ossl_pqueue_##type##_num(const PRIORITY_QUEUE_OF(type) *pq) \ - { \ - return ossl_pqueue_num((OSSL_PQUEUE *)pq); \ - } \ - static ossl_unused ossl_inline int \ - ossl_pqueue_##type##_push(PRIORITY_QUEUE_OF(type) *pq, \ - ctype *data, size_t *elem) \ - { \ - return ossl_pqueue_push((OSSL_PQUEUE *)pq, (void *)data, elem); \ - } \ - static ossl_unused ossl_inline ctype * \ - ossl_pqueue_##type##_peek(const PRIORITY_QUEUE_OF(type) *pq) \ - { \ - return (type *)ossl_pqueue_peek((OSSL_PQUEUE *)pq); \ - } \ - static ossl_unused ossl_inline ctype * \ - ossl_pqueue_##type##_pop(PRIORITY_QUEUE_OF(type) *pq) \ - { \ - return (type *)ossl_pqueue_pop((OSSL_PQUEUE *)pq); \ - } \ - static ossl_unused ossl_inline ctype * \ - ossl_pqueue_##type##_remove(PRIORITY_QUEUE_OF(type) *pq, \ - size_t elem) \ - { \ - return (type *)ossl_pqueue_remove((OSSL_PQUEUE *)pq, elem); \ - } \ - struct ossl_priority_queue_st_ ## type +#define DEFINE_PRIORITY_QUEUE_OF_INTERNAL(type, ctype) \ + typedef struct ossl_priority_queue_st_##type PRIORITY_QUEUE_OF(type); \ + static ossl_unused ossl_inline PRIORITY_QUEUE_OF(type) * ossl_pqueue_##type##_new(int (*compare)(const ctype *, const ctype *)) \ + { \ + return (PRIORITY_QUEUE_OF(type) *)ossl_pqueue_new( \ + (int (*)(const void *, const void *))compare); \ + } \ + static ossl_unused ossl_inline void \ + ossl_pqueue_##type##_free(PRIORITY_QUEUE_OF(type) * pq) \ + { \ + ossl_pqueue_free((OSSL_PQUEUE *)pq); \ + } \ + static ossl_unused ossl_inline void \ + ossl_pqueue_##type##_pop_free(PRIORITY_QUEUE_OF(type) * pq, \ + void (*freefunc)(ctype *)) \ + { \ + ossl_pqueue_pop_free((OSSL_PQUEUE *)pq, (void (*)(void *))freefunc); \ + } \ + static ossl_unused ossl_inline int \ + ossl_pqueue_##type##_reserve(PRIORITY_QUEUE_OF(type) * pq, size_t n) \ + { \ + return ossl_pqueue_reserve((OSSL_PQUEUE *)pq, n); \ + } \ + static ossl_unused ossl_inline size_t \ + ossl_pqueue_##type##_num(const PRIORITY_QUEUE_OF(type) * pq) \ + { \ + return ossl_pqueue_num((OSSL_PQUEUE *)pq); \ + } \ + static ossl_unused ossl_inline int \ + ossl_pqueue_##type##_push(PRIORITY_QUEUE_OF(type) * pq, \ + ctype * data, size_t *elem) \ + { \ + return ossl_pqueue_push((OSSL_PQUEUE *)pq, (void *)data, elem); \ + } \ + static ossl_unused ossl_inline ctype * \ + ossl_pqueue_##type##_peek(const PRIORITY_QUEUE_OF(type) * pq) \ + { \ + return (type *)ossl_pqueue_peek((OSSL_PQUEUE *)pq); \ + } \ + static ossl_unused ossl_inline ctype * \ + ossl_pqueue_##type##_pop(PRIORITY_QUEUE_OF(type) * pq) \ + { \ + return (type *)ossl_pqueue_pop((OSSL_PQUEUE *)pq); \ + } \ + static ossl_unused ossl_inline ctype * \ + ossl_pqueue_##type##_remove(PRIORITY_QUEUE_OF(type) * pq, \ + size_t elem) \ + { \ + return (type *)ossl_pqueue_remove((OSSL_PQUEUE *)pq, elem); \ + } \ + struct ossl_priority_queue_st_##type -# define DEFINE_PRIORITY_QUEUE_OF(type) \ +#define DEFINE_PRIORITY_QUEUE_OF(type) \ DEFINE_PRIORITY_QUEUE_OF_INTERNAL(type, type) typedef struct ossl_pqueue_st OSSL_PQUEUE; diff --git a/crypto/openssl/include/internal/property.h b/crypto/openssl/include/internal/property.h index 3adff4994003..b63634c678d5 100644 --- a/crypto/openssl/include/internal/property.h +++ b/crypto/openssl/include/internal/property.h @@ -9,16 +9,17 @@ */ #ifndef OSSL_INTERNAL_PROPERTY_H -# define OSSL_INTERNAL_PROPERTY_H -# pragma once +#define OSSL_INTERNAL_PROPERTY_H +#pragma once -# include "internal/cryptlib.h" +#include "internal/cryptlib.h" typedef struct ossl_method_store_st OSSL_METHOD_STORE; typedef struct ossl_property_list_st OSSL_PROPERTY_LIST; typedef enum { - OSSL_PROPERTY_TYPE_STRING, OSSL_PROPERTY_TYPE_NUMBER, + OSSL_PROPERTY_TYPE_STRING, + OSSL_PROPERTY_TYPE_NUMBER, OSSL_PROPERTY_TYPE_VALUE_UNDEFINED } OSSL_PROPERTY_TYPE; typedef struct ossl_property_definition_st OSSL_PROPERTY_DEFINITION; @@ -30,25 +31,24 @@ int ossl_property_parse_init(OSSL_LIB_CTX *ctx); OSSL_PROPERTY_LIST *ossl_parse_property(OSSL_LIB_CTX *ctx, const char *defn); /* Property query parser */ OSSL_PROPERTY_LIST *ossl_parse_query(OSSL_LIB_CTX *ctx, const char *s, - int create_values); + int create_values); /* Property checker of query vs definition */ int ossl_property_match_count(const OSSL_PROPERTY_LIST *query, - const OSSL_PROPERTY_LIST *defn); -int ossl_property_is_enabled(OSSL_LIB_CTX *ctx, const char *property_name, - const OSSL_PROPERTY_LIST *prop_list); + const OSSL_PROPERTY_LIST *defn); +int ossl_property_is_enabled(OSSL_LIB_CTX *ctx, const char *property_name, + const OSSL_PROPERTY_LIST *prop_list); /* Free a parsed property list */ void ossl_property_free(OSSL_PROPERTY_LIST *p); /* Get a property from a property list */ const OSSL_PROPERTY_DEFINITION * ossl_property_find_property(const OSSL_PROPERTY_LIST *list, - OSSL_LIB_CTX *libctx, const char *name); + OSSL_LIB_CTX *libctx, const char *name); OSSL_PROPERTY_TYPE ossl_property_get_type(const OSSL_PROPERTY_DEFINITION *prop); const char *ossl_property_get_string_value(OSSL_LIB_CTX *libctx, - const OSSL_PROPERTY_DEFINITION *prop); + const OSSL_PROPERTY_DEFINITION *prop); int64_t ossl_property_get_number_value(const OSSL_PROPERTY_DEFINITION *prop); - /* Implementation store functions */ OSSL_METHOD_STORE *ossl_method_store_new(OSSL_LIB_CTX *ctx); void ossl_method_store_free(OSSL_METHOD_STORE *store); @@ -57,41 +57,41 @@ int ossl_method_lock_store(OSSL_METHOD_STORE *store); int ossl_method_unlock_store(OSSL_METHOD_STORE *store); int ossl_method_store_add(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov, - int nid, const char *properties, void *method, - int (*method_up_ref)(void *), - void (*method_destruct)(void *)); + int nid, const char *properties, void *method, + int (*method_up_ref)(void *), + void (*method_destruct)(void *)); int ossl_method_store_remove(OSSL_METHOD_STORE *store, int nid, - const void *method); + const void *method); void ossl_method_store_do_all(OSSL_METHOD_STORE *store, - void (*fn)(int id, void *method, void *fnarg), - void *fnarg); + void (*fn)(int id, void *method, void *fnarg), + void *fnarg); int ossl_method_store_fetch(OSSL_METHOD_STORE *store, - int nid, const char *prop_query, - const OSSL_PROVIDER **prov, void **method); + int nid, const char *prop_query, + const OSSL_PROVIDER **prov, void **method); int ossl_method_store_remove_all_provided(OSSL_METHOD_STORE *store, - const OSSL_PROVIDER *prov); + const OSSL_PROVIDER *prov); /* Get the global properties associate with the specified library context */ OSSL_PROPERTY_LIST **ossl_ctx_global_properties(OSSL_LIB_CTX *ctx, - int loadconfig); + int loadconfig); /* property query cache functions */ int ossl_method_store_cache_get(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov, - int nid, const char *prop_query, void **result); + int nid, const char *prop_query, void **result); int ossl_method_store_cache_set(OSSL_METHOD_STORE *store, OSSL_PROVIDER *prov, - int nid, const char *prop_query, void *result, - int (*method_up_ref)(void *), - void (*method_destruct)(void *)); + int nid, const char *prop_query, void *result, + int (*method_up_ref)(void *), + void (*method_destruct)(void *)); __owur int ossl_method_store_cache_flush_all(OSSL_METHOD_STORE *store); /* Merge two property queries together */ OSSL_PROPERTY_LIST *ossl_property_merge(const OSSL_PROPERTY_LIST *a, - const OSSL_PROPERTY_LIST *b); + const OSSL_PROPERTY_LIST *b); size_t ossl_property_list_to_string(OSSL_LIB_CTX *ctx, - const OSSL_PROPERTY_LIST *list, char *buf, - size_t bufsize); + const OSSL_PROPERTY_LIST *list, char *buf, + size_t bufsize); int ossl_global_properties_no_mirrored(OSSL_LIB_CTX *libctx); void ossl_global_properties_stop_mirroring(OSSL_LIB_CTX *libctx); diff --git a/crypto/openssl/include/internal/propertyerr.h b/crypto/openssl/include/internal/propertyerr.h index fbee53f11e84..94e2c90955d7 100644 --- a/crypto/openssl/include/internal/propertyerr.h +++ b/crypto/openssl/include/internal/propertyerr.h @@ -9,35 +9,34 @@ */ #ifndef OSSL_INTERNAL_PROPERTYERR_H -# define OSSL_INTERNAL_PROPERTYERR_H -# pragma once +#define OSSL_INTERNAL_PROPERTYERR_H +#pragma once -# include <openssl/opensslconf.h> -# include <openssl/symhacks.h> +#include <openssl/opensslconf.h> +#include <openssl/symhacks.h> -# ifdef __cplusplus +#ifdef __cplusplus extern "C" { -# endif +#endif int ossl_err_load_PROP_strings(void); /* * PROP reason codes. */ -# define PROP_R_NAME_TOO_LONG 100 -# define PROP_R_NOT_AN_ASCII_CHARACTER 101 -# define PROP_R_NOT_AN_HEXADECIMAL_DIGIT 102 -# define PROP_R_NOT_AN_IDENTIFIER 103 -# define PROP_R_NOT_AN_OCTAL_DIGIT 104 -# define PROP_R_NOT_A_DECIMAL_DIGIT 105 -# define PROP_R_NO_MATCHING_STRING_DELIMITER 106 -# define PROP_R_NO_VALUE 107 -# define PROP_R_PARSE_FAILED 108 -# define PROP_R_STRING_TOO_LONG 109 -# define PROP_R_TRAILING_CHARACTERS 110 - +#define PROP_R_NAME_TOO_LONG 100 +#define PROP_R_NOT_AN_ASCII_CHARACTER 101 +#define PROP_R_NOT_AN_HEXADECIMAL_DIGIT 102 +#define PROP_R_NOT_AN_IDENTIFIER 103 +#define PROP_R_NOT_AN_OCTAL_DIGIT 104 +#define PROP_R_NOT_A_DECIMAL_DIGIT 105 +#define PROP_R_NO_MATCHING_STRING_DELIMITER 106 +#define PROP_R_NO_VALUE 107 +#define PROP_R_PARSE_FAILED 108 +#define PROP_R_STRING_TOO_LONG 109 +#define PROP_R_TRAILING_CHARACTERS 110 -# ifdef __cplusplus +#ifdef __cplusplus } -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/provider.h b/crypto/openssl/include/internal/provider.h index 7d94346155cc..1b4050a81f52 100644 --- a/crypto/openssl/include/internal/provider.h +++ b/crypto/openssl/include/internal/provider.h @@ -8,17 +8,17 @@ */ #ifndef OSSL_INTERNAL_PROVIDER_H -# define OSSL_INTERNAL_PROVIDER_H -# pragma once +#define OSSL_INTERNAL_PROVIDER_H +#pragma once -# include <openssl/core.h> -# include <openssl/core_dispatch.h> -# include "internal/dso.h" -# include "internal/symhacks.h" +#include <openssl/core.h> +#include <openssl/core_dispatch.h> +#include "internal/dso.h" +#include "internal/symhacks.h" -# ifdef __cplusplus +#ifdef __cplusplus extern "C" { -# endif +#endif /* * namespaces: @@ -29,10 +29,10 @@ extern "C" { /* Provider Object finder, constructor and destructor */ OSSL_PROVIDER *ossl_provider_find(OSSL_LIB_CTX *libctx, const char *name, - int noconfig); + int noconfig); OSSL_PROVIDER *ossl_provider_new(OSSL_LIB_CTX *libctx, const char *name, - OSSL_provider_init_fn *init_function, - OSSL_PARAM *params, int noconfig); + OSSL_provider_init_fn *init_function, + OSSL_PARAM *params, int noconfig); int ossl_provider_up_ref(OSSL_PROVIDER *prov); void ossl_provider_free(OSSL_PROVIDER *prov); @@ -56,7 +56,7 @@ int ossl_provider_disable_fallback_loading(OSSL_LIB_CTX *libctx); int ossl_provider_activate(OSSL_PROVIDER *prov, int upcalls, int aschild); int ossl_provider_deactivate(OSSL_PROVIDER *prov, int removechildren); int ossl_provider_add_to_store(OSSL_PROVIDER *prov, OSSL_PROVIDER **actualprov, - int retain_fallbacks); + int retain_fallbacks); /* Return pointer to the provider's context */ void *ossl_provider_ctx(const OSSL_PROVIDER *prov); @@ -66,9 +66,9 @@ int ossl_provider_activate_fallbacks(OSSL_LIB_CTX *ctx); /* Iterate over all loaded providers */ int ossl_provider_doall_activated(OSSL_LIB_CTX *, - int (*cb)(OSSL_PROVIDER *provider, - void *cbdata), - void *cbdata); + int (*cb)(OSSL_PROVIDER *provider, + void *cbdata), + void *cbdata); /* Getters for other library functions */ const char *ossl_provider_name(const OSSL_PROVIDER *prov); @@ -83,18 +83,18 @@ void ossl_provider_teardown(const OSSL_PROVIDER *prov); const OSSL_PARAM *ossl_provider_gettable_params(const OSSL_PROVIDER *prov); int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]); int ossl_provider_get_capabilities(const OSSL_PROVIDER *prov, - const char *capability, - OSSL_CALLBACK *cb, - void *arg); + const char *capability, + OSSL_CALLBACK *cb, + void *arg); int ossl_provider_self_test(const OSSL_PROVIDER *prov); int ossl_provider_random_bytes(const OSSL_PROVIDER *prov, int which, - void *buf, size_t n, unsigned int strength); + void *buf, size_t n, unsigned int strength); const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov, - int operation_id, - int *no_cache); + int operation_id, + int *no_cache); void ossl_provider_unquery_operation(const OSSL_PROVIDER *prov, - int operation_id, - const OSSL_ALGORITHM *algs); + int operation_id, + const OSSL_ALGORITHM *algs); /* * Cache of bits to see if we already added methods for an operation in @@ -103,19 +103,19 @@ void ossl_provider_unquery_operation(const OSSL_PROVIDER *prov, */ int ossl_provider_set_operation_bit(OSSL_PROVIDER *provider, size_t bitnum); int ossl_provider_test_operation_bit(OSSL_PROVIDER *provider, size_t bitnum, - int *result); + int *result); /* Configuration */ void ossl_provider_add_conf_module(void); /* Child providers */ int ossl_provider_init_as_child(OSSL_LIB_CTX *ctx, - const OSSL_CORE_HANDLE *handle, - const OSSL_DISPATCH *in); + const OSSL_CORE_HANDLE *handle, + const OSSL_DISPATCH *in); void ossl_provider_deinit_child(OSSL_LIB_CTX *ctx); -# ifdef __cplusplus +#ifdef __cplusplus } -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/qlog.h b/crypto/openssl/include/internal/qlog.h index b81bfe7e4b96..0455f21b48c9 100644 --- a/crypto/openssl/include/internal/qlog.h +++ b/crypto/openssl/include/internal/qlog.h @@ -8,34 +8,34 @@ */ #ifndef OSSL_QLOG_H -# define OSSL_QLOG_H +#define OSSL_QLOG_H -# include <openssl/ssl.h> -# include "internal/quic_types.h" -# include "internal/time.h" +#include <openssl/ssl.h> +#include "internal/quic_types.h" +#include "internal/time.h" typedef struct qlog_st QLOG; -# ifndef OPENSSL_NO_QLOG +#ifndef OPENSSL_NO_QLOG enum { QLOG_EVENT_TYPE_NONE, -# define QLOG_EVENT(cat, name) QLOG_EVENT_TYPE_##cat##_##name, -# include "internal/qlog_events.h" -# undef QLOG_EVENT +#define QLOG_EVENT(cat, name) QLOG_EVENT_TYPE_##cat##_##name, +#include "internal/qlog_events.h" +#undef QLOG_EVENT QLOG_EVENT_TYPE_NUM }; typedef struct qlog_trace_info_st { - QUIC_CONN_ID odcid; - const char *title, *description, *group_id; - int is_server; - OSSL_TIME (*now_cb)(void *arg); - void *now_cb_arg; - uint64_t override_process_id; - const char *override_impl_name; + QUIC_CONN_ID odcid; + const char *title, *description, *group_id; + int is_server; + OSSL_TIME (*now_cb)(void *arg); + void *now_cb_arg; + uint64_t override_process_id; + const char *override_impl_name; } QLOG_TRACE_INFO; QLOG *ossl_qlog_new(const QLOG_TRACE_INFO *info); @@ -45,13 +45,13 @@ void ossl_qlog_free(QLOG *qlog); /* Configuration */ int ossl_qlog_set_event_type_enabled(QLOG *qlog, uint32_t event_type, - int enable); + int enable); int ossl_qlog_set_filter(QLOG *qlog, const char *filter); int ossl_qlog_set_sink_bio(QLOG *qlog, BIO *bio); -# ifndef OPENSSL_NO_STDIO +#ifndef OPENSSL_NO_STDIO int ossl_qlog_set_sink_file(QLOG *qlog, FILE *file, int close_flag); -# endif +#endif int ossl_qlog_set_sink_filename(QLOG *qlog, const char *filename); /* Operations */ @@ -62,8 +62,8 @@ int ossl_qlog_enabled(QLOG *qlog, uint32_t event_type); /* Grouping Functions */ int ossl_qlog_event_try_begin(QLOG *qlog, uint32_t event_type, - const char *event_cat, const char *event_name, - const char *event_combined_name); + const char *event_cat, const char *event_name, + const char *event_combined_name); void ossl_qlog_event_end(QLOG *qlog); void ossl_qlog_group_begin(QLOG *qlog, const char *name); @@ -75,57 +75,57 @@ void ossl_qlog_array_end(QLOG *qlog); void ossl_qlog_override_time(QLOG *qlog, OSSL_TIME event_time); /* Grouping Macros */ -# define QLOG_EVENT_BEGIN(qlog, cat, name) \ - { \ - QLOG *qlog_instance = (qlog); \ - uint32_t qlog_event_type = QLOG_EVENT_TYPE_##cat##_##name; \ - \ - if (ossl_qlog_event_try_begin(qlog_instance, qlog_event_type, \ - #cat, #name, #cat ":" #name)) { +#define QLOG_EVENT_BEGIN(qlog, cat, name) \ + { \ + QLOG *qlog_instance = (qlog); \ + uint32_t qlog_event_type = QLOG_EVENT_TYPE_##cat##_##name; \ + \ + if (ossl_qlog_event_try_begin(qlog_instance, qlog_event_type, \ + #cat, #name, #cat ":" #name)) { -# define QLOG_EVENT_END() \ - ossl_qlog_event_end(qlog_instance); \ - } \ +#define QLOG_EVENT_END() \ + ossl_qlog_event_end(qlog_instance); \ + } \ } -# define QLOG_BEGIN(name) \ - { \ +#define QLOG_BEGIN(name) \ + { \ ossl_qlog_group_begin(qlog_instance, (name)); -# define QLOG_END() \ - ossl_qlog_group_end(qlog_instance); \ +#define QLOG_END() \ + ossl_qlog_group_end(qlog_instance); \ } -# define QLOG_BEGIN_ARRAY(name) \ - { \ +#define QLOG_BEGIN_ARRAY(name) \ + { \ ossl_qlog_array_begin(qlog_instance, (name)); -# define QLOG_END_ARRAY() \ - ossl_qlog_array_end(qlog_instance); \ +#define QLOG_END_ARRAY() \ + ossl_qlog_array_end(qlog_instance); \ } /* Field Functions */ void ossl_qlog_str(QLOG *qlog, const char *name, const char *value); void ossl_qlog_str_len(QLOG *qlog, const char *name, - const char *value, size_t value_len); + const char *value, size_t value_len); void ossl_qlog_u64(QLOG *qlog, const char *name, uint64_t value); void ossl_qlog_i64(QLOG *qlog, const char *name, int64_t value); void ossl_qlog_bool(QLOG *qlog, const char *name, int value); void ossl_qlog_bin(QLOG *qlog, const char *name, - const void *value, size_t value_len); + const void *value, size_t value_len); /* Field Macros */ -# define QLOG_STR(name, value) ossl_qlog_str(qlog_instance, (name), (value)) -# define QLOG_STR_LEN(name, value, value_len) \ +#define QLOG_STR(name, value) ossl_qlog_str(qlog_instance, (name), (value)) +#define QLOG_STR_LEN(name, value, value_len) \ ossl_qlog_str_len(qlog_instance, (name), (value), (value_len)) -# define QLOG_I64(name, value) ossl_qlog_i64(qlog_instance, (name), (value)) -# define QLOG_U64(name, value) ossl_qlog_u64(qlog_instance, (name), (value)) -# define QLOG_F64(name, value) ossl_qlog_f64(qlog_instance, (name), (value)) -# define QLOG_BOOL(name, value) ossl_qlog_bool(qlog_instance, (name), (value)) -# define QLOG_BIN(name, value, value_len) \ +#define QLOG_I64(name, value) ossl_qlog_i64(qlog_instance, (name), (value)) +#define QLOG_U64(name, value) ossl_qlog_u64(qlog_instance, (name), (value)) +#define QLOG_F64(name, value) ossl_qlog_f64(qlog_instance, (name), (value)) +#define QLOG_BOOL(name, value) ossl_qlog_bool(qlog_instance, (name), (value)) +#define QLOG_BIN(name, value, value_len) \ ossl_qlog_bin(qlog_instance, (name), (value), (value_len)) -# define QLOG_CID(name, value) QLOG_BIN((name), (value)->id, (value)->id_len) +#define QLOG_CID(name, value) QLOG_BIN((name), (value)->id, (value)->id_len) -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/qlog_event_helpers.h b/crypto/openssl/include/internal/qlog_event_helpers.h index 43d62360805a..e885bfd50307 100644 --- a/crypto/openssl/include/internal/qlog_event_helpers.h +++ b/crypto/openssl/include/internal/qlog_event_helpers.h @@ -8,49 +8,49 @@ */ #ifndef OSSL_QLOG_EVENT_HELPERS_H -# define OSSL_QLOG_EVENT_HELPERS_H +#define OSSL_QLOG_EVENT_HELPERS_H -# include <openssl/ssl.h> -# include "internal/qlog.h" -# include "internal/quic_types.h" -# include "internal/quic_channel.h" -# include "internal/quic_txpim.h" -# include "internal/quic_record_tx.h" -# include "internal/quic_wire_pkt.h" +#include <openssl/ssl.h> +#include "internal/qlog.h" +#include "internal/quic_types.h" +#include "internal/quic_channel.h" +#include "internal/quic_txpim.h" +#include "internal/quic_record_tx.h" +#include "internal/quic_wire_pkt.h" /* connectivity:connection_started */ void ossl_qlog_event_connectivity_connection_started(QLOG *qlog, - const QUIC_CONN_ID *init_dcid); + const QUIC_CONN_ID *init_dcid); /* connectivity:connection_state_updated */ void ossl_qlog_event_connectivity_connection_state_updated(QLOG *qlog, - uint32_t old_state, - uint32_t new_state, - int handshake_complete, - int handshake_confirmed); + uint32_t old_state, + uint32_t new_state, + int handshake_complete, + int handshake_confirmed); /* connectivity:connection_closed */ void ossl_qlog_event_connectivity_connection_closed(QLOG *qlog, - const QUIC_TERMINATE_CAUSE *tcause); + const QUIC_TERMINATE_CAUSE *tcause); /* recovery:packet_lost */ void ossl_qlog_event_recovery_packet_lost(QLOG *qlog, - const QUIC_TXPIM_PKT *tpkt); + const QUIC_TXPIM_PKT *tpkt); /* transport:packet_sent */ void ossl_qlog_event_transport_packet_sent(QLOG *qlog, - const QUIC_PKT_HDR *hdr, - QUIC_PN pn, - const OSSL_QTX_IOVEC *iovec, - size_t numn_iovec, - uint64_t datagram_id); + const QUIC_PKT_HDR *hdr, + QUIC_PN pn, + const OSSL_QTX_IOVEC *iovec, + size_t numn_iovec, + uint64_t datagram_id); /* transport:packet_received */ void ossl_qlog_event_transport_packet_received(QLOG *qlog, - const QUIC_PKT_HDR *hdr, - QUIC_PN pn, - const OSSL_QTX_IOVEC *iovec, - size_t numn_iovec, - uint64_t datagram_id); + const QUIC_PKT_HDR *hdr, + QUIC_PN pn, + const OSSL_QTX_IOVEC *iovec, + size_t numn_iovec, + uint64_t datagram_id); #endif diff --git a/crypto/openssl/include/internal/quic_ackm.h b/crypto/openssl/include/internal/quic_ackm.h index 949d91903bb1..c0617da4855f 100644 --- a/crypto/openssl/include/internal/quic_ackm.h +++ b/crypto/openssl/include/internal/quic_ackm.h @@ -7,35 +7,35 @@ * https://www.openssl.org/source/license.html */ #ifndef OSSL_QUIC_ACKM_H -# define OSSL_QUIC_ACKM_H +#define OSSL_QUIC_ACKM_H -# include "internal/quic_statm.h" -# include "internal/quic_cc.h" -# include "internal/quic_types.h" -# include "internal/quic_wire.h" -# include "internal/quic_predef.h" -# include "internal/time.h" -# include "internal/list.h" +#include "internal/quic_statm.h" +#include "internal/quic_cc.h" +#include "internal/quic_types.h" +#include "internal/quic_wire.h" +#include "internal/quic_predef.h" +#include "internal/time.h" +#include "internal/list.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC OSSL_ACKM *ossl_ackm_new(OSSL_TIME (*now)(void *arg), - void *now_arg, - OSSL_STATM *statm, - const OSSL_CC_METHOD *cc_method, - OSSL_CC_DATA *cc_data, int is_server); + void *now_arg, + OSSL_STATM *statm, + const OSSL_CC_METHOD *cc_method, + OSSL_CC_DATA *cc_data, int is_server); void ossl_ackm_free(OSSL_ACKM *ackm); void ossl_ackm_set_loss_detection_deadline_callback(OSSL_ACKM *ackm, - void (*fn)(OSSL_TIME deadline, - void *arg), - void *arg); + void (*fn)(OSSL_TIME deadline, + void *arg), + void *arg); void ossl_ackm_set_ack_deadline_callback(OSSL_ACKM *ackm, - void (*fn)(OSSL_TIME deadline, - int pkt_space, - void *arg), - void *arg); + void (*fn)(OSSL_TIME deadline, + int pkt_space, + void *arg), + void *arg); /* * Configures the RX-side maximum ACK delay. This is the maximum amount of time @@ -81,7 +81,7 @@ struct ossl_ackm_tx_pkt_st { * One of the QUIC_PN_SPACE_* values. This qualifies the pkt_num field * into a packet number space. */ - unsigned int pkt_space :2; + unsigned int pkt_space : 2; /* * 1 if the packet is in flight. A packet is considered 'in flight' if it is @@ -90,19 +90,19 @@ struct ossl_ackm_tx_pkt_st { * numbered packet is not considered in flight is if it contains only ACK * frames (not even PADDING frames), as these frames can bypass CC. */ - unsigned int is_inflight :1; + unsigned int is_inflight : 1; /* * 1 if the packet has one or more ACK-eliciting frames. * Note that if this is set, is_inflight must be set. */ - unsigned int is_ack_eliciting :1; + unsigned int is_ack_eliciting : 1; /* 1 if the packet is a PTO probe. */ - unsigned int is_pto_probe :1; + unsigned int is_pto_probe : 1; /* 1 if the packet is an MTU probe. */ - unsigned int is_mtu_probe :1; + unsigned int is_mtu_probe : 1; /* Callback called if frames in this packet are lost. arg is cb_arg. */ void (*on_lost)(void *arg); @@ -113,7 +113,7 @@ struct ossl_ackm_tx_pkt_st { * is cb_arg. */ void (*on_discarded)(void *arg); - void *cb_arg; + void *cb_arg; /* * (Internal use fields; must be zero-initialized.) @@ -131,10 +131,10 @@ struct ossl_ackm_tx_pkt_st { int ossl_ackm_on_tx_packet(OSSL_ACKM *ackm, OSSL_ACKM_TX_PKT *pkt); int ossl_ackm_on_rx_datagram(OSSL_ACKM *ackm, size_t num_bytes); -# define OSSL_ACKM_ECN_NONE 0 -# define OSSL_ACKM_ECN_ECT1 1 -# define OSSL_ACKM_ECN_ECT0 2 -# define OSSL_ACKM_ECN_ECNCE 3 +#define OSSL_ACKM_ECN_NONE 0 +#define OSSL_ACKM_ECN_ECT1 1 +#define OSSL_ACKM_ECN_ECT0 2 +#define OSSL_ACKM_ECN_ECNCE 3 typedef struct ossl_ackm_rx_pkt_st { /* The packet number of the received packet. */ @@ -147,22 +147,22 @@ typedef struct ossl_ackm_rx_pkt_st { * One of the QUIC_PN_SPACE_* values. This qualifies the pkt_num field * into a packet number space. */ - unsigned int pkt_space :2; + unsigned int pkt_space : 2; /* 1 if the packet has one or more ACK-eliciting frames. */ - unsigned int is_ack_eliciting :1; + unsigned int is_ack_eliciting : 1; /* * One of the OSSL_ACKM_ECN_* values. This is the ECN labelling applied to * the received packet. If unknown, use OSSL_ACKM_ECN_NONE. */ - unsigned int ecn :2; + unsigned int ecn : 2; } OSSL_ACKM_RX_PKT; int ossl_ackm_on_rx_packet(OSSL_ACKM *ackm, const OSSL_ACKM_RX_PKT *pkt); int ossl_ackm_on_rx_ack_frame(OSSL_ACKM *ackm, const OSSL_QUIC_FRAME_ACK *ack, - int pkt_space, OSSL_TIME rx_time); + int pkt_space, OSSL_TIME rx_time); /* * Discards a PN space. This must be called for a PN space before freeing the @@ -186,7 +186,7 @@ OSSL_TIME ossl_ackm_get_loss_detection_deadline(OSSL_ACKM *ackm); * returned by ossl_ackm_get_ack_deadline. */ const OSSL_QUIC_FRAME_ACK *ossl_ackm_get_ack_frame(OSSL_ACKM *ackm, - int pkt_space); + int pkt_space); /* * Returns the deadline after which an ACK frame should be generated by calling @@ -280,7 +280,7 @@ int ossl_ackm_get_largest_unacked(OSSL_ACKM *ackm, int pkt_space, QUIC_PN *pn); * true loss situation. */ int ossl_ackm_mark_packet_pseudo_lost(OSSL_ACKM *ackm, - int pkt_space, QUIC_PN pn); + int pkt_space, QUIC_PN pn); /* * Returns the PTO duration as currently calculated. This is a quantity of time. @@ -291,6 +291,6 @@ OSSL_TIME ossl_ackm_get_pto_duration(OSSL_ACKM *ackm); /* Returns the largest acked PN in the given PN space. */ QUIC_PN ossl_ackm_get_largest_acked(OSSL_ACKM *ackm, int pkt_space); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_cc.h b/crypto/openssl/include/internal/quic_cc.h index dbd439dd0cf5..94214655c030 100644 --- a/crypto/openssl/include/internal/quic_cc.h +++ b/crypto/openssl/include/internal/quic_cc.h @@ -7,28 +7,28 @@ * https://www.openssl.org/source/license.html */ #ifndef OSSL_QUIC_CC_H -# define OSSL_QUIC_CC_H +#define OSSL_QUIC_CC_H #include "openssl/params.h" #include "internal/time.h" #include "internal/quic_predef.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC typedef struct ossl_cc_ack_info_st { /* The time the packet being acknowledged was originally sent. */ - OSSL_TIME tx_time; + OSSL_TIME tx_time; /* The size in bytes of the packet being acknowledged. */ - size_t tx_size; + size_t tx_size; } OSSL_CC_ACK_INFO; typedef struct ossl_cc_loss_info_st { /* The time the packet being lost was originally sent. */ - OSSL_TIME tx_time; + OSSL_TIME tx_time; /* The size in bytes of the packet which has been determined lost. */ - size_t tx_size; + size_t tx_size; } OSSL_CC_LOSS_INFO; typedef struct ossl_cc_ecn_info_st { @@ -36,23 +36,23 @@ typedef struct ossl_cc_ecn_info_st { * The time at which the largest acked PN (in the incoming ACK frame) was * sent. */ - OSSL_TIME largest_acked_time; + OSSL_TIME largest_acked_time; } OSSL_CC_ECN_INFO; /* Parameter (read-write): Maximum datagram payload length in bytes. */ -#define OSSL_CC_OPTION_MAX_DGRAM_PAYLOAD_LEN "max_dgram_payload_len" +#define OSSL_CC_OPTION_MAX_DGRAM_PAYLOAD_LEN "max_dgram_payload_len" /* Diagnostic (read-only): current congestion window size in bytes. */ -#define OSSL_CC_OPTION_CUR_CWND_SIZE "cur_cwnd_size" +#define OSSL_CC_OPTION_CUR_CWND_SIZE "cur_cwnd_size" /* Diagnostic (read-only): minimum congestion window size in bytes. */ -#define OSSL_CC_OPTION_MIN_CWND_SIZE "min_cwnd_size" +#define OSSL_CC_OPTION_MIN_CWND_SIZE "min_cwnd_size" /* Diagnostic (read-only): current net bytes in flight. */ -#define OSSL_CC_OPTION_CUR_BYTES_IN_FLIGHT "bytes_in_flight" +#define OSSL_CC_OPTION_CUR_BYTES_IN_FLIGHT "bytes_in_flight" /* Diagnostic (read-only): method-specific state value. */ -#define OSSL_CC_OPTION_CUR_STATE "cur_state" +#define OSSL_CC_OPTION_CUR_STATE "cur_state" /* * Congestion control abstract interface. @@ -77,14 +77,14 @@ typedef struct ossl_cc_ecn_info_st { * All of these changes are intended to avoid having a congestion controller * have to access ACKM internal state. */ -#define OSSL_CC_LOST_FLAG_PERSISTENT_CONGESTION (1U << 0) +#define OSSL_CC_LOST_FLAG_PERSISTENT_CONGESTION (1U << 0) struct ossl_cc_method_st { /* * Instantiation. */ OSSL_CC_DATA *(*new)(OSSL_TIME (*now_cb)(void *arg), - void *now_cb_arg); + void *now_cb_arg); void (*free)(OSSL_CC_DATA *ccdata); @@ -101,7 +101,7 @@ struct ossl_cc_method_st { * Returns 1 on success and 0 on failure. */ int (*set_input_params)(OSSL_CC_DATA *ccdata, - const OSSL_PARAM *params); + const OSSL_PARAM *params); /* * (Re)bind output (diagnostic) information. @@ -118,7 +118,7 @@ struct ossl_cc_method_st { * Returns 1 on success and 0 on failure. */ int (*bind_diagnostics)(OSSL_CC_DATA *ccdata, - OSSL_PARAM *params); + OSSL_PARAM *params); /* * Unbind diagnostic information. The parameters with the given names are @@ -130,7 +130,7 @@ struct ossl_cc_method_st { * Returns 1 on success or 0 on failure. */ int (*unbind_diagnostics)(OSSL_CC_DATA *ccdata, - OSSL_PARAM *params); + OSSL_PARAM *params); /* * Returns the amount of additional data (above and beyond the data @@ -154,14 +154,14 @@ struct ossl_cc_method_st { * sent). */ int (*on_data_sent)(OSSL_CC_DATA *ccdata, - uint64_t num_bytes); + uint64_t num_bytes); /* * The On Data Acked event. See OSSL_CC_ACK_INFO structure for details * of the information to be passed. */ int (*on_data_acked)(OSSL_CC_DATA *ccdata, - const OSSL_CC_ACK_INFO *info); + const OSSL_CC_ACK_INFO *info); /* * The On Data Lost event. See OSSL_CC_LOSS_INFO structure for details @@ -177,7 +177,7 @@ struct ossl_cc_method_st { * calls to on_data_lost(). */ int (*on_data_lost)(OSSL_CC_DATA *ccdata, - const OSSL_CC_LOSS_INFO *info); + const OSSL_CC_LOSS_INFO *info); /* * To be called after a sequence of one or more on_data_lost() calls @@ -193,7 +193,7 @@ struct ossl_cc_method_st { * Only the size of the packet is needed. */ int (*on_data_invalidated)(OSSL_CC_DATA *ccdata, - uint64_t num_bytes); + uint64_t num_bytes); /* * Called from the ACKM when detecting an increased ECN-CE value in an ACK @@ -207,12 +207,12 @@ struct ossl_cc_method_st { * narrower interface between the ACKM and CC. */ int (*on_ecn)(OSSL_CC_DATA *ccdata, - const OSSL_CC_ECN_INFO *info); + const OSSL_CC_ECN_INFO *info); }; extern const OSSL_CC_METHOD ossl_cc_dummy_method; extern const OSSL_CC_METHOD ossl_cc_newreno_method; -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_cfq.h b/crypto/openssl/include/internal/quic_cfq.h index 56ebcb930ed6..0b2a3a4cb2d6 100644 --- a/crypto/openssl/include/internal/quic_cfq.h +++ b/crypto/openssl/include/internal/quic_cfq.h @@ -8,13 +8,13 @@ */ #ifndef OSSL_QUIC_CFQ_H -# define OSSL_QUIC_CFQ_H +#define OSSL_QUIC_CFQ_H -# include <openssl/ssl.h> -# include "internal/quic_types.h" -# include "internal/quic_predef.h" +#include <openssl/ssl.h> +#include "internal/quic_types.h" +#include "internal/quic_predef.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Control Frame Queue Item @@ -31,16 +31,16 @@ struct quic_cfq_item_st { * TXPIM in keeping a list of GCR control frames which were sent in a * packet. They may be used for any purpose. */ - QUIC_CFQ_ITEM *pkt_prev, *pkt_next; + QUIC_CFQ_ITEM *pkt_prev, *pkt_next; /* All other fields are private; use ossl_quic_cfq_item_* accessors. */ }; -# define QUIC_CFQ_STATE_NEW 0 -# define QUIC_CFQ_STATE_TX 1 +#define QUIC_CFQ_STATE_NEW 0 +#define QUIC_CFQ_STATE_TX 1 /* If set, do not retransmit on loss */ -#define QUIC_CFQ_ITEM_FLAG_UNRELIABLE (1U << 0) +#define QUIC_CFQ_ITEM_FLAG_UNRELIABLE (1U << 0) /* Returns the frame type of a CFQ item. */ uint64_t ossl_quic_cfq_item_get_frame_type(const QUIC_CFQ_ITEM *item); @@ -97,17 +97,17 @@ void ossl_quic_cfq_free(QUIC_CFQ *cfq); * * flags is zero or more QUIC_CFQ_ITEM_FLAG values. */ -typedef void (cfq_free_cb)(unsigned char *buf, size_t buf_len, void *arg); +typedef void(cfq_free_cb)(unsigned char *buf, size_t buf_len, void *arg); -QUIC_CFQ_ITEM *ossl_quic_cfq_add_frame(QUIC_CFQ *cfq, - uint32_t priority, - uint32_t pn_space, - uint64_t frame_type, - uint32_t flags, - const unsigned char *encoded, - size_t encoded_len, - cfq_free_cb *free_cb, - void *free_cb_arg); +QUIC_CFQ_ITEM *ossl_quic_cfq_add_frame(QUIC_CFQ *cfq, + uint32_t priority, + uint32_t pn_space, + uint64_t frame_type, + uint32_t flags, + const unsigned char *encoded, + size_t encoded_len, + cfq_free_cb *free_cb, + void *free_cb_arg); /* * Effects an immediate transition of the given CFQ item to the TX state. @@ -120,7 +120,7 @@ void ossl_quic_cfq_mark_tx(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item); * the priority is changed to the given value. */ void ossl_quic_cfq_mark_lost(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item, - uint32_t priority); + uint32_t priority); /* * Releases a CFQ item. The item may be in either state (NEW or TX) prior to the @@ -138,7 +138,7 @@ void ossl_quic_cfq_release(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item); * transmission. If there are none, returns NULL. */ QUIC_CFQ_ITEM *ossl_quic_cfq_get_priority_head(const QUIC_CFQ *cfq, - uint32_t pn_space); + uint32_t pn_space); /* * Given a CFQ item, gets the next CFQ item awaiting transmission in priority @@ -147,8 +147,8 @@ QUIC_CFQ_ITEM *ossl_quic_cfq_get_priority_head(const QUIC_CFQ *cfq, * Returns NULL if the given item is the last item in priority order. */ QUIC_CFQ_ITEM *ossl_quic_cfq_item_get_priority_next(const QUIC_CFQ_ITEM *item, - uint32_t pn_space); + uint32_t pn_space); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_channel.h b/crypto/openssl/include/internal/quic_channel.h index 4476481fef9b..b917b966abeb 100644 --- a/crypto/openssl/include/internal/quic_channel.h +++ b/crypto/openssl/include/internal/quic_channel.h @@ -8,18 +8,18 @@ */ #ifndef OSSL_QUIC_CHANNEL_H -# define OSSL_QUIC_CHANNEL_H +#define OSSL_QUIC_CHANNEL_H -# include <openssl/ssl.h> -# include "internal/quic_types.h" -# include "internal/quic_record_tx.h" -# include "internal/quic_wire.h" -# include "internal/quic_predef.h" -# include "internal/qlog.h" -# include "internal/time.h" -# include "internal/thread.h" +#include <openssl/ssl.h> +#include "internal/quic_types.h" +#include "internal/quic_record_tx.h" +#include "internal/quic_wire.h" +#include "internal/quic_predef.h" +#include "internal/qlog.h" +#include "internal/time.h" +#include "internal/thread.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Channel @@ -71,7 +71,7 @@ * * Precondition: must hold channel mutex (unchecked) */ -# define QUIC_NEEDS_LOCK +#define QUIC_NEEDS_LOCK /* * The function acquires the channel mutex and releases it before returning in @@ -83,7 +83,7 @@ * Precondition: must not hold channel mutex (unchecked) * Postcondition: channel mutex is not held (by calling thread) */ -# define QUIC_TAKES_LOCK +#define QUIC_TAKES_LOCK /* * The function acquires the channel mutex and leaves it acquired @@ -96,38 +96,38 @@ * Postcondition: channel mutex is held by calling thread * or function returned failure */ -# define QUIC_ACQUIRES_LOCK +#define QUIC_ACQUIRES_LOCK -# define QUIC_TODO_LOCK +#define QUIC_TODO_LOCK -# define QUIC_CHANNEL_STATE_IDLE 0 -# define QUIC_CHANNEL_STATE_ACTIVE 1 -# define QUIC_CHANNEL_STATE_TERMINATING_CLOSING 2 -# define QUIC_CHANNEL_STATE_TERMINATING_DRAINING 3 -# define QUIC_CHANNEL_STATE_TERMINATED 4 +#define QUIC_CHANNEL_STATE_IDLE 0 +#define QUIC_CHANNEL_STATE_ACTIVE 1 +#define QUIC_CHANNEL_STATE_TERMINATING_CLOSING 2 +#define QUIC_CHANNEL_STATE_TERMINATING_DRAINING 3 +#define QUIC_CHANNEL_STATE_TERMINATED 4 typedef struct quic_channel_args_st { /* * The QUIC_PORT which the channel is to belong to. The lifetime of the * QUIC_PORT must exceed that of the created channel. */ - QUIC_PORT *port; + QUIC_PORT *port; /* LCIDM to register LCIDs with. */ - QUIC_LCIDM *lcidm; + QUIC_LCIDM *lcidm; /* SRTM to register SRTs with. */ - QUIC_SRTM *srtm; - OSSL_QRX *qrx; + QUIC_SRTM *srtm; + OSSL_QRX *qrx; - int is_server; - SSL *tls; + int is_server; + SSL *tls; /* Whether to use qlog. */ - int use_qlog; + int use_qlog; - int is_tserver_ch; + int is_tserver_ch; /* Title to use for the qlog session, or NULL. */ - const char *qlog_title; + const char *qlog_title; } QUIC_CHANNEL_ARGS; /* Represents the cause for a connection's termination. */ @@ -137,13 +137,13 @@ typedef struct quic_terminate_cause_st { * associated with the error. This field is valid iff we are in the * TERMINATING or TERMINATED states. */ - uint64_t error_code; + uint64_t error_code; /* * If terminate_app is set and this is nonzero, this is the frame type which * caused the connection to be terminated. */ - uint64_t frame_type; + uint64_t frame_type; /* * Optional reason string. When calling ossl_quic_channel_local_close, if a @@ -152,16 +152,16 @@ typedef struct quic_terminate_cause_st { * Thus the string pointed to by this value, if non-NULL, is valid for the * lifetime of the QUIC_CHANNEL object. */ - const char *reason; + const char *reason; /* * Length of reason in bytes. The reason is supposed to contain a UTF-8 * string but may be arbitrary data if the reason came from the network. */ - size_t reason_len; + size_t reason_len; /* Is this error code in the transport (0) or application (1) space? */ - unsigned int app : 1; + unsigned int app : 1; /* * If set, the cause of the termination is a received CONNECTION_CLOSE @@ -169,7 +169,7 @@ typedef struct quic_terminate_cause_st { * CONNECTION_CLOSE frame (regardless of whether the peer later also sends * one). */ - unsigned int remote : 1; + unsigned int remote : 1; } QUIC_TERMINATE_CAUSE; /* @@ -182,15 +182,14 @@ QUIC_CHANNEL *ossl_quic_channel_alloc(const QUIC_CHANNEL_ARGS *args); int ossl_quic_channel_init(QUIC_CHANNEL *ch); void ossl_quic_channel_bind_qrx(QUIC_CHANNEL *tserver_ch, OSSL_QRX *qrx); - /* No-op if ch is NULL. */ void ossl_quic_channel_free(QUIC_CHANNEL *ch); /* Set mutator callbacks for test framework support */ int ossl_quic_channel_set_mutator(QUIC_CHANNEL *ch, - ossl_mutate_packet_cb mutatecb, - ossl_finish_mutate_cb finishmutatecb, - void *mutatearg); + ossl_mutate_packet_cb mutatecb, + ossl_finish_mutate_cb finishmutatecb, + void *mutatearg); /* * Connection Lifecycle Events @@ -212,14 +211,14 @@ int ossl_quic_channel_start(QUIC_CHANNEL *ch); /* Start a locally initiated connection shutdown. */ void ossl_quic_channel_local_close(QUIC_CHANNEL *ch, uint64_t app_error_code, - const char *app_reason); + const char *app_reason); /** * @brief schedules a NEW_TOKEN frame for sending on the channel */ int ossl_quic_channel_schedule_new_token(QUIC_CHANNEL *ch, - const unsigned char *token, - size_t token_len); + const unsigned char *token, + size_t token_len); /* * Called when the handshake is confirmed. @@ -241,32 +240,31 @@ int ossl_quic_channel_on_handshake_confirmed(QUIC_CHANNEL *ch); * error. */ void ossl_quic_channel_raise_protocol_error_loc(QUIC_CHANNEL *ch, - uint64_t error_code, - uint64_t frame_type, - const char *reason, - ERR_STATE *err_state, - const char *src_file, - int src_line, - const char *src_func); + uint64_t error_code, + uint64_t frame_type, + const char *reason, + ERR_STATE *err_state, + const char *src_file, + int src_line, + const char *src_func); #define ossl_quic_channel_raise_protocol_error(ch, error_code, frame_type, reason) \ - ossl_quic_channel_raise_protocol_error_loc((ch), (error_code), \ - (frame_type), \ - (reason), \ - NULL, \ - OPENSSL_FILE, \ - OPENSSL_LINE, \ - OPENSSL_FUNC) + ossl_quic_channel_raise_protocol_error_loc((ch), (error_code), \ + (frame_type), \ + (reason), \ + NULL, \ + OPENSSL_FILE, \ + OPENSSL_LINE, \ + OPENSSL_FUNC) #define ossl_quic_channel_raise_protocol_error_state(ch, error_code, frame_type, reason, state) \ - ossl_quic_channel_raise_protocol_error_loc((ch), (error_code), \ - (frame_type), \ - (reason), \ - (state), \ - OPENSSL_FILE, \ - OPENSSL_LINE, \ - OPENSSL_FUNC) - + ossl_quic_channel_raise_protocol_error_loc((ch), (error_code), \ + (frame_type), \ + (reason), \ + (state), \ + OPENSSL_FILE, \ + OPENSSL_LINE, \ + OPENSSL_FUNC) /* * Returns 1 if permanent net error was detected on the QUIC_CHANNEL, @@ -279,18 +277,18 @@ void ossl_quic_channel_restore_err_state(QUIC_CHANNEL *ch); /* For RXDP use. */ void ossl_quic_channel_on_remote_conn_close(QUIC_CHANNEL *ch, - OSSL_QUIC_FRAME_CONN_CLOSE *f); + OSSL_QUIC_FRAME_CONN_CLOSE *f); void ossl_quic_channel_on_new_conn_id(QUIC_CHANNEL *ch, - OSSL_QUIC_FRAME_NEW_CONN_ID *f); + OSSL_QUIC_FRAME_NEW_CONN_ID *f); /* Temporarily exposed during QUIC_PORT transition. */ int ossl_quic_channel_on_new_conn(QUIC_CHANNEL *ch, const BIO_ADDR *peer, - const QUIC_CONN_ID *peer_scid, - const QUIC_CONN_ID *peer_dcid); + const QUIC_CONN_ID *peer_scid, + const QUIC_CONN_ID *peer_dcid); /* For use by QUIC_PORT. You should not need to call this directly. */ void ossl_quic_channel_subtick(QUIC_CHANNEL *ch, QUIC_TICK_RESULT *r, - uint32_t flags); + uint32_t flags); /* For use by QUIC_PORT only. */ void ossl_quic_channel_raise_net_error(QUIC_CHANNEL *ch); @@ -334,7 +332,7 @@ int ossl_quic_channel_set_peer_addr(QUIC_CHANNEL *ch, const BIO_ADDR *peer_addr) * exist. */ QUIC_STREAM *ossl_quic_channel_get_stream_by_id(QUIC_CHANNEL *ch, - uint64_t stream_id); + uint64_t stream_id); /* Returns 1 if channel is terminating or terminated. */ int ossl_quic_channel_is_term_any(const QUIC_CHANNEL *ch); @@ -381,7 +379,7 @@ QUIC_STREAM *ossl_quic_channel_new_stream_local(QUIC_CHANNEL *ch, int is_uni); * also returned. Returns NULL on failure. */ QUIC_STREAM *ossl_quic_channel_new_stream_remote(QUIC_CHANNEL *ch, - uint64_t stream_id); + uint64_t stream_id); /* * Configures incoming stream auto-reject. If enabled, incoming streams have @@ -390,8 +388,8 @@ QUIC_STREAM *ossl_quic_channel_new_stream_remote(QUIC_CHANNEL *ch, * code to be used for those frames. */ void ossl_quic_channel_set_incoming_stream_auto_reject(QUIC_CHANNEL *ch, - int enable, - uint64_t aec); + int enable, + uint64_t aec); /* * Causes the channel to reject the sending and receiving parts of a stream, @@ -402,18 +400,18 @@ void ossl_quic_channel_reject_stream(QUIC_CHANNEL *ch, QUIC_STREAM *qs); /* Replace local connection ID in TXP and DEMUX for testing purposes. */ int ossl_quic_channel_replace_local_cid(QUIC_CHANNEL *ch, - const QUIC_CONN_ID *conn_id); + const QUIC_CONN_ID *conn_id); /* Setters for the msg_callback and msg_callback_arg */ void ossl_quic_channel_set_msg_callback(QUIC_CHANNEL *ch, - ossl_msg_cb msg_callback, - SSL *msg_callback_ssl); + ossl_msg_cb msg_callback, + SSL *msg_callback_ssl); void ossl_quic_channel_set_msg_callback_arg(QUIC_CHANNEL *ch, - void *msg_callback_arg); + void *msg_callback_arg); /* Testing use only - sets a TXKU threshold packet count override value. */ void ossl_quic_channel_set_txku_threshold_override(QUIC_CHANNEL *ch, - uint64_t tx_pkt_threshold); + uint64_t tx_pkt_threshold); /* Testing use only - gets current 1-RTT key epochs for QTX and QRX. */ uint64_t ossl_quic_channel_get_tx_key_epoch(QUIC_CHANNEL *ch); @@ -448,9 +446,9 @@ int ossl_quic_channel_is_new_local_stream_admissible(QUIC_CHANNEL *ch, int is_un * on flow control. */ uint64_t ossl_quic_channel_get_local_stream_count_avail(const QUIC_CHANNEL *ch, - int is_uni); + int is_uni); uint64_t ossl_quic_channel_get_remote_stream_count_avail(const QUIC_CHANNEL *ch, - int is_uni); + int is_uni); /* * Returns 1 if we have generated our local transport parameters yet. @@ -467,9 +465,9 @@ uint64_t ossl_quic_channel_get_max_idle_timeout_peer_request(const QUIC_CHANNEL uint64_t ossl_quic_channel_get_max_idle_timeout_actual(const QUIC_CHANNEL *ch); int ossl_quic_bind_channel(QUIC_CHANNEL *ch, const BIO_ADDR *peer, - const QUIC_CONN_ID *scid, const QUIC_CONN_ID *dcid, - const QUIC_CONN_ID *odcid); + const QUIC_CONN_ID *scid, const QUIC_CONN_ID *dcid, + const QUIC_CONN_ID *odcid); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_demux.h b/crypto/openssl/include/internal/quic_demux.h index d0781e61cf0f..a1bb344dc468 100644 --- a/crypto/openssl/include/internal/quic_demux.h +++ b/crypto/openssl/include/internal/quic_demux.h @@ -8,16 +8,16 @@ */ #ifndef OSSL_QUIC_DEMUX_H -# define OSSL_QUIC_DEMUX_H +#define OSSL_QUIC_DEMUX_H -# include <openssl/ssl.h> -# include "internal/quic_types.h" -# include "internal/quic_predef.h" -# include "internal/bio_addr.h" -# include "internal/time.h" -# include "internal/list.h" +#include <openssl/ssl.h> +#include "internal/quic_types.h" +#include "internal/quic_predef.h" +#include "internal/bio_addr.h" +#include "internal/time.h" +#include "internal/list.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Demuxer @@ -84,7 +84,7 @@ */ /* Maximum number of packets we allow to exist in one datagram. */ -#define QUIC_MAX_PKT_PER_URXE (sizeof(uint64_t) * 8) +#define QUIC_MAX_PKT_PER_URXE (sizeof(uint64_t) * 8) struct quic_urxe_st { OSSL_LIST_MEMBER(urxe, QUIC_URXE); @@ -97,45 +97,45 @@ struct quic_urxe_st { * should not be common as we will have a good idea of worst-case MTUs up * front. */ - size_t data_len, alloc_len; + size_t data_len, alloc_len; /* * Bitfields per packet. processed indicates the packet has been processed * and must not be processed again, hpr_removed indicates header protection * has already been removed. Used by QRX only; not used by the demuxer. */ - uint64_t processed, hpr_removed; + uint64_t processed, hpr_removed; /* * This monotonically increases with each datagram received. It is used for * diagnostic purposes only. */ - uint64_t datagram_id; + uint64_t datagram_id; /* * Address of peer we received the datagram from, and the local interface * address we received it on. If local address support is not enabled, local * is zeroed. */ - BIO_ADDR peer, local; + BIO_ADDR peer, local; /* * Time at which datagram was received (or ossl_time_zero()) if a now * function was not provided). */ - OSSL_TIME time; + OSSL_TIME time; /* * Used by the QRX to mark whether a datagram has been deferred. Used by the * QRX only; not used by the demuxer. */ - char deferred; + char deferred; /* * Used by the DEMUX to track if a URXE has been handed out. Used primarily * for debugging purposes. */ - char demux_state; + char demux_state; }; /* Accessors for URXE buffer. */ @@ -180,8 +180,8 @@ void ossl_quic_urxe_insert_tail(QUIC_URXE_LIST *l, QUIC_URXE *e); * At the time the callback is made, the URXE will not be in any queue, * therefore the callee can use the prev and next fields as it wishes. */ -typedef void (ossl_quic_demux_cb_fn)(QUIC_URXE *e, void *arg, - const QUIC_CONN_ID *dcid); +typedef void(ossl_quic_demux_cb_fn)(QUIC_URXE *e, void *arg, + const QUIC_CONN_ID *dcid); /* * Creates a new demuxer. The given BIO is used to receive datagrams from the @@ -196,9 +196,9 @@ typedef void (ossl_quic_demux_cb_fn)(QUIC_URXE *e, void *arg, * NULL, ossl_time_zero() is used as the datagram reception time. */ QUIC_DEMUX *ossl_quic_demux_new(BIO *net_bio, - size_t short_conn_id_len, - OSSL_TIME (*now)(void *arg), - void *now_arg); + size_t short_conn_id_len, + OSSL_TIME (*now)(void *arg), + void *now_arg); /* * Destroy a demuxer. All URXEs must have been released back to the demuxer @@ -228,8 +228,8 @@ int ossl_quic_demux_set_mtu(QUIC_DEMUX *demux, unsigned int mtu); * the future, which may or may not be before the handler returns. */ void ossl_quic_demux_set_default_handler(QUIC_DEMUX *demux, - ossl_quic_demux_cb_fn *cb, - void *cb_arg); + ossl_quic_demux_cb_fn *cb, + void *cb_arg); /* * Releases a URXE back to the demuxer. No reference must be made to the URXE or @@ -237,7 +237,7 @@ void ossl_quic_demux_set_default_handler(QUIC_DEMUX *demux, * that is, its prev and next pointers must be NULL. */ void ossl_quic_demux_release_urxe(QUIC_DEMUX *demux, - QUIC_URXE *e); + QUIC_URXE *e); /* * Reinjects a URXE which was issued to a registered DCID callback or the @@ -251,7 +251,7 @@ void ossl_quic_demux_release_urxe(QUIC_DEMUX *demux, * immediately. */ void ossl_quic_demux_reinject_urxe(QUIC_DEMUX *demux, - QUIC_URXE *e); + QUIC_URXE *e); /* * Process any unprocessed RX'd datagrams, by calling registered callbacks by @@ -273,9 +273,9 @@ void ossl_quic_demux_reinject_urxe(QUIC_DEMUX *demux, * similarly to in the case of a protocol violation. * */ -#define QUIC_DEMUX_PUMP_RES_OK 1 -#define QUIC_DEMUX_PUMP_RES_TRANSIENT_FAIL (-1) -#define QUIC_DEMUX_PUMP_RES_PERMANENT_FAIL (-2) +#define QUIC_DEMUX_PUMP_RES_OK 1 +#define QUIC_DEMUX_PUMP_RES_TRANSIENT_FAIL (-1) +#define QUIC_DEMUX_PUMP_RES_PERMANENT_FAIL (-2) int ossl_quic_demux_pump(QUIC_DEMUX *demux); @@ -289,16 +289,16 @@ int ossl_quic_demux_pump(QUIC_DEMUX *demux); * Returns 1 on success or 0 on failure. */ int ossl_quic_demux_inject(QUIC_DEMUX *demux, - const unsigned char *buf, - size_t buf_len, - const BIO_ADDR *peer, - const BIO_ADDR *local); + const unsigned char *buf, + size_t buf_len, + const BIO_ADDR *peer, + const BIO_ADDR *local); /* * Returns 1 if there are any pending URXEs. */ int ossl_quic_demux_has_pending(const QUIC_DEMUX *demux); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_engine.h b/crypto/openssl/include/internal/quic_engine.h index 23e3fd4932eb..30feb03b7f42 100644 --- a/crypto/openssl/include/internal/quic_engine.h +++ b/crypto/openssl/include/internal/quic_engine.h @@ -7,15 +7,15 @@ * https://www.openssl.org/source/license.html */ #ifndef OSSL_QUIC_ENGINE_H -# define OSSL_QUIC_ENGINE_H +#define OSSL_QUIC_ENGINE_H -# include <openssl/ssl.h> +#include <openssl/ssl.h> -# include "internal/quic_predef.h" -# include "internal/quic_port.h" -# include "internal/thread_arch.h" +#include "internal/quic_predef.h" +#include "internal/quic_port.h" +#include "internal/thread_arch.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Engine @@ -37,8 +37,8 @@ * clock management, the QUIC_REACTOR instance, etc.). */ typedef struct quic_engine_args_st { - OSSL_LIB_CTX *libctx; - const char *propq; + OSSL_LIB_CTX *libctx; + const char *propq; /* * This must be a mutex the lifetime of which will exceed that of the engine @@ -51,10 +51,10 @@ typedef struct quic_engine_args_st { * may, depending on the build configuration, be implemented using an OS's * mutex primitive or using its RW mutex primitive. */ - CRYPTO_MUTEX *mutex; + CRYPTO_MUTEX *mutex; /* Flags to pass when initialising the reactor. */ - uint64_t reactor_flags; + uint64_t reactor_flags; } QUIC_ENGINE_ARGS; QUIC_ENGINE *ossl_quic_engine_new(const QUIC_ENGINE_ARGS *args); @@ -65,7 +65,7 @@ void ossl_quic_engine_free(QUIC_ENGINE *qeng); * Create a port which is a child of the engine. args->engine shall be NULL. */ QUIC_PORT *ossl_quic_engine_create_port(QUIC_ENGINE *qeng, - const QUIC_PORT_ARGS *args); + const QUIC_PORT_ARGS *args); /* Gets the mutex used by the engine. */ CRYPTO_MUTEX *ossl_quic_engine_get0_mutex(QUIC_ENGINE *qeng); @@ -82,8 +82,8 @@ OSSL_TIME ossl_quic_engine_make_real_time(QUIC_ENGINE *qeng, OSSL_TIME tm); /* Override the callback for getting the current time */ void ossl_quic_engine_set_time_cb(QUIC_ENGINE *qeng, - OSSL_TIME (*now_cb)(void *arg), - void *now_cb_arg); + OSSL_TIME (*now_cb)(void *arg), + void *now_cb_arg); /* For testing use. While enabled, ticking is not performed. */ void ossl_quic_engine_set_inhibit_tick(QUIC_ENGINE *qeng, int inhibit); @@ -102,6 +102,6 @@ const char *ossl_quic_engine_get0_propq(QUIC_ENGINE *qeng); */ void ossl_quic_engine_update_poll_descriptors(QUIC_ENGINE *qeng, int force); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_error.h b/crypto/openssl/include/internal/quic_error.h index 86d1c692b4f0..44895f77f6a8 100644 --- a/crypto/openssl/include/internal/quic_error.h +++ b/crypto/openssl/include/internal/quic_error.h @@ -8,24 +8,24 @@ */ #ifndef OSSL_QUIC_ERROR_H -# define OSSL_QUIC_ERROR_H +#define OSSL_QUIC_ERROR_H -# include <openssl/ssl.h> -# include <openssl/quic.h> +#include <openssl/ssl.h> +#include <openssl/quic.h> -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC -# define OSSL_QUIC_ERR_CRYPTO_UNEXPECTED_MESSAGE \ +#define OSSL_QUIC_ERR_CRYPTO_UNEXPECTED_MESSAGE \ OSSL_QUIC_ERR_CRYPTO_ERR(SSL3_AD_UNEXPECTED_MESSAGE) -# define OSSL_QUIC_ERR_CRYPTO_MISSING_EXT \ +#define OSSL_QUIC_ERR_CRYPTO_MISSING_EXT \ OSSL_QUIC_ERR_CRYPTO_ERR(TLS13_AD_MISSING_EXTENSION) -# define OSSL_QUIC_ERR_CRYPTO_NO_APP_PROTO \ +#define OSSL_QUIC_ERR_CRYPTO_NO_APP_PROTO \ OSSL_QUIC_ERR_CRYPTO_ERR(TLS1_AD_NO_APPLICATION_PROTOCOL) const char *ossl_quic_err_to_string(uint64_t error_code); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_fc.h b/crypto/openssl/include/internal/quic_fc.h index 923bd43bc328..007e84dd9a9e 100644 --- a/crypto/openssl/include/internal/quic_fc.h +++ b/crypto/openssl/include/internal/quic_fc.h @@ -8,12 +8,12 @@ */ #ifndef OSSL_QUIC_FC_H -# define OSSL_QUIC_FC_H +#define OSSL_QUIC_FC_H -# include <openssl/ssl.h> -# include "internal/time.h" +#include <openssl/ssl.h> +#include "internal/time.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * TX Flow Controller (TXFC) @@ -24,9 +24,9 @@ typedef struct quic_txfc_st QUIC_TXFC; struct quic_txfc_st { - QUIC_TXFC *parent; /* stream-level iff non-NULL */ - uint64_t swm, cwm; - char has_become_blocked; + QUIC_TXFC *parent; /* stream-level iff non-NULL */ + uint64_t swm, cwm; + char has_become_blocked; }; /* @@ -134,12 +134,12 @@ struct quic_rxfc_st { * (STREAM frame offset + payload length) we have seen from a STREAM frame * yet. */ - uint64_t cwm, swm, rwm, esrwm, hwm, cur_window_size, max_window_size; - OSSL_TIME epoch_start; - OSSL_TIME (*now)(void *arg); - void *now_arg; - QUIC_RXFC *parent; - unsigned char error_code, has_cwm_changed, is_fin, standalone; + uint64_t cwm, swm, rwm, esrwm, hwm, cur_window_size, max_window_size; + OSSL_TIME epoch_start; + OSSL_TIME (*now)(void *arg); + void *now_arg; + QUIC_RXFC *parent; + unsigned char error_code, has_cwm_changed, is_fin, standalone; }; /* @@ -151,10 +151,10 @@ struct quic_rxfc_st { * to transmit more data at a time. */ int ossl_quic_rxfc_init(QUIC_RXFC *rxfc, QUIC_RXFC *conn_rxfc, - uint64_t initial_window_size, - uint64_t max_window_size, - OSSL_TIME (*now)(void *arg), - void *now_arg); + uint64_t initial_window_size, + uint64_t max_window_size, + OSSL_TIME (*now)(void *arg), + void *now_arg); /* * Initialises an RX flow controller which is used by itself and not under a @@ -162,9 +162,9 @@ int ossl_quic_rxfc_init(QUIC_RXFC *rxfc, QUIC_RXFC *conn_rxfc, * enforcement as well as CRYPTO buffer enforcement. */ int ossl_quic_rxfc_init_standalone(QUIC_RXFC *rxfc, - uint64_t initial_window_size, - OSSL_TIME (*now)(void *arg), - void *now_arg); + uint64_t initial_window_size, + OSSL_TIME (*now)(void *arg), + void *now_arg); /* * Gets the parent (i.e., connection-level) RXFC. Returns NULL if called on a @@ -176,7 +176,7 @@ QUIC_RXFC *ossl_quic_rxfc_get_parent(QUIC_RXFC *rxfc); * Changes the current maximum window size value. */ void ossl_quic_rxfc_set_max_window_size(QUIC_RXFC *rxfc, - size_t max_window_size); + size_t max_window_size); /* * To be called whenever a STREAM frame is received. @@ -197,7 +197,7 @@ void ossl_quic_rxfc_set_max_window_size(QUIC_RXFC *rxfc, * Returns 1 on success or 0 on failure. */ int ossl_quic_rxfc_on_rx_stream_frame(QUIC_RXFC *rxfc, - uint64_t end, int is_fin); + uint64_t end, int is_fin); /* * To be called whenever controlled bytes are retired, i.e. when bytes are @@ -217,8 +217,8 @@ int ossl_quic_rxfc_on_rx_stream_frame(QUIC_RXFC *rxfc, * Returns 1 on success and 0 on failure. */ int ossl_quic_rxfc_on_retire(QUIC_RXFC *rxfc, - uint64_t num_bytes, - OSSL_TIME rtt); + uint64_t num_bytes, + OSSL_TIME rtt); /* * Returns the current CWM which the RXFC thinks the peer should have. @@ -278,6 +278,6 @@ int ossl_quic_rxfc_get_error(QUIC_RXFC *rxfc, int clear); */ int ossl_quic_rxfc_get_final_size(const QUIC_RXFC *rxfc, uint64_t *final_size); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_fifd.h b/crypto/openssl/include/internal/quic_fifd.h index c1644e4d8ef2..4ea7a2e0d226 100644 --- a/crypto/openssl/include/internal/quic_fifd.h +++ b/crypto/openssl/include/internal/quic_fifd.h @@ -8,17 +8,17 @@ */ #ifndef OSSL_QUIC_FIFD_H -# define OSSL_QUIC_FIFD_H +#define OSSL_QUIC_FIFD_H -# include <openssl/ssl.h> -# include "internal/quic_types.h" -# include "internal/quic_cfq.h" -# include "internal/quic_ackm.h" -# include "internal/quic_txpim.h" -# include "internal/quic_stream.h" -# include "internal/qlog.h" +#include <openssl/ssl.h> +#include "internal/quic_types.h" +#include "internal/quic_cfq.h" +#include "internal/quic_ackm.h" +#include "internal/quic_txpim.h" +#include "internal/quic_stream.h" +#include "internal/qlog.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Frame-in-Flight Dispatcher (FIFD) @@ -26,63 +26,63 @@ */ struct quic_fifd_st { /* Internal data; use the ossl_quic_fifd functions. */ - QUIC_CFQ *cfq; - OSSL_ACKM *ackm; - QUIC_TXPIM *txpim; + QUIC_CFQ *cfq; + OSSL_ACKM *ackm; + QUIC_TXPIM *txpim; QUIC_SSTREAM *(*get_sstream_by_id)(uint64_t stream_id, - uint32_t pn_space, - void *arg); - void *get_sstream_by_id_arg; - void (*regen_frame)(uint64_t frame_type, - uint64_t stream_id, - QUIC_TXPIM_PKT *pkt, - void *arg); - void *regen_frame_arg; - void (*confirm_frame)(uint64_t frame_type, - uint64_t stream_id, - QUIC_TXPIM_PKT *pkt, - void *arg); - void *confirm_frame_arg; - void (*sstream_updated)(uint64_t stream_id, - void *arg); - void *sstream_updated_arg; - QLOG *(*get_qlog_cb)(void *arg); - void *get_qlog_cb_arg; + uint32_t pn_space, + void *arg); + void *get_sstream_by_id_arg; + void (*regen_frame)(uint64_t frame_type, + uint64_t stream_id, + QUIC_TXPIM_PKT *pkt, + void *arg); + void *regen_frame_arg; + void (*confirm_frame)(uint64_t frame_type, + uint64_t stream_id, + QUIC_TXPIM_PKT *pkt, + void *arg); + void *confirm_frame_arg; + void (*sstream_updated)(uint64_t stream_id, + void *arg); + void *sstream_updated_arg; + QLOG *(*get_qlog_cb)(void *arg); + void *get_qlog_cb_arg; }; int ossl_quic_fifd_init(QUIC_FIFD *fifd, - QUIC_CFQ *cfq, - OSSL_ACKM *ackm, - QUIC_TXPIM *txpim, - /* stream_id is UINT64_MAX for the crypto stream */ - QUIC_SSTREAM *(*get_sstream_by_id)(uint64_t stream_id, - uint32_t pn_space, - void *arg), - void *get_sstream_by_id_arg, - /* stream_id is UINT64_MAX if not applicable */ - void (*regen_frame)(uint64_t frame_type, - uint64_t stream_id, - QUIC_TXPIM_PKT *pkt, - void *arg), - void *regen_frame_arg, - void (*confirm_frame)(uint64_t frame_type, - uint64_t stream_id, - QUIC_TXPIM_PKT *pkt, - void *arg), - void *confirm_frame_arg, - void (*sstream_updated)(uint64_t stream_id, - void *arg), - void *sstream_updated_arg, - QLOG *(*get_qlog_cb)(void *arg), - void *get_qlog_cb_arg); + QUIC_CFQ *cfq, + OSSL_ACKM *ackm, + QUIC_TXPIM *txpim, + /* stream_id is UINT64_MAX for the crypto stream */ + QUIC_SSTREAM *(*get_sstream_by_id)(uint64_t stream_id, + uint32_t pn_space, + void *arg), + void *get_sstream_by_id_arg, + /* stream_id is UINT64_MAX if not applicable */ + void (*regen_frame)(uint64_t frame_type, + uint64_t stream_id, + QUIC_TXPIM_PKT *pkt, + void *arg), + void *regen_frame_arg, + void (*confirm_frame)(uint64_t frame_type, + uint64_t stream_id, + QUIC_TXPIM_PKT *pkt, + void *arg), + void *confirm_frame_arg, + void (*sstream_updated)(uint64_t stream_id, + void *arg), + void *sstream_updated_arg, + QLOG *(*get_qlog_cb)(void *arg), + void *get_qlog_cb_arg); void ossl_quic_fifd_cleanup(QUIC_FIFD *fifd); /* (no-op) */ int ossl_quic_fifd_pkt_commit(QUIC_FIFD *fifd, QUIC_TXPIM_PKT *pkt); void ossl_quic_fifd_set_qlog_cb(QUIC_FIFD *fifd, QLOG *(*get_qlog_cb)(void *arg), - void *arg); + void *arg); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_lcidm.h b/crypto/openssl/include/internal/quic_lcidm.h index accfe049b52d..66421e8ac1b7 100644 --- a/crypto/openssl/include/internal/quic_lcidm.h +++ b/crypto/openssl/include/internal/quic_lcidm.h @@ -1,23 +1,23 @@ /* -* Copyright 2023-2025 The OpenSSL Project Authors. All Rights Reserved. -* -* Licensed under the Apache License 2.0 (the "License"). You may not use -* this file except in compliance with the License. You can obtain a copy -* in the file LICENSE in the source distribution or at -* https://www.openssl.org/source/license.html -*/ + * Copyright 2023-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ #ifndef OSSL_INTERNAL_QUIC_LCIDM_H -# define OSSL_INTERNAL_QUIC_LCIDM_H -# pragma once +#define OSSL_INTERNAL_QUIC_LCIDM_H +#pragma once -# include "internal/e_os.h" -# include "internal/time.h" -# include "internal/quic_types.h" -# include "internal/quic_wire.h" -# include "internal/quic_predef.h" +#include "internal/e_os.h" +#include "internal/time.h" +#include "internal/quic_types.h" +#include "internal/quic_wire.h" +#include "internal/quic_predef.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Local Connection ID Manager @@ -116,7 +116,7 @@ size_t ossl_quic_lcidm_get_lcid_len(const QUIC_LCIDM *lcidm); * reception) currently associated with the given opaque pointer. */ size_t ossl_quic_lcidm_get_num_active_lcid(const QUIC_LCIDM *lcidm, - void *opaque); + void *opaque); /* * Enrol an Initial ODCID sent by the peer. This is the DCID in the first @@ -141,7 +141,7 @@ size_t ossl_quic_lcidm_get_num_active_lcid(const QUIC_LCIDM *lcidm, * Returns 1 on success or 0 on failure. */ int ossl_quic_lcidm_enrol_odcid(QUIC_LCIDM *lcidm, void *opaque, - const QUIC_CONN_ID *initial_odcid); + const QUIC_CONN_ID *initial_odcid); /* * Retire a previously enrolled ODCID for a connection. This is generally done @@ -163,8 +163,8 @@ int ossl_quic_lcidm_retire_odcid(QUIC_LCIDM *lcidm, void *opaque); * May not be called more than once for a given opaque pointer value. */ int ossl_quic_lcidm_generate_initial(QUIC_LCIDM *lcidm, - void *opaque, - QUIC_CONN_ID *initial_lcid); + void *opaque, + QUIC_CONN_ID *initial_lcid); /* * Create a subsequent LCID for a given opaque pointer. The information needed @@ -178,8 +178,8 @@ int ossl_quic_lcidm_generate_initial(QUIC_LCIDM *lcidm, * register the new LCID with a DEMUX and queue the NEW_CONN_ID frame. */ int ossl_quic_lcidm_generate(QUIC_LCIDM *lcidm, - void *opaque, - OSSL_QUIC_FRAME_NEW_CONN_ID *ncid_frame); + void *opaque, + OSSL_QUIC_FRAME_NEW_CONN_ID *ncid_frame); /* * Retire up to one LCID for a given opaque pointer value. Called repeatedly to @@ -205,12 +205,12 @@ int ossl_quic_lcidm_generate(QUIC_LCIDM *lcidm, * are retired, this is considered a success condition. */ int ossl_quic_lcidm_retire(QUIC_LCIDM *lcidm, - void *opaque, - uint64_t retire_prior_to, - const QUIC_CONN_ID *containing_pkt_dcid, - QUIC_CONN_ID *retired_lcid, - uint64_t *retired_seq_num, - int *did_retire); + void *opaque, + uint64_t retire_prior_to, + const QUIC_CONN_ID *containing_pkt_dcid, + QUIC_CONN_ID *retired_lcid, + uint64_t *retired_seq_num, + int *did_retire); /* * Cull all LCIDM state relating to a given opaque pointer value. This is useful @@ -228,12 +228,12 @@ int ossl_quic_lcidm_cull(QUIC_LCIDM *lcidm, void *opaque); * If the LCID is for an Initial ODCID, *seq_num is set to * LCIDM_ODCID_SEQ_NUM. */ -#define LCIDM_ODCID_SEQ_NUM UINT64_MAX +#define LCIDM_ODCID_SEQ_NUM UINT64_MAX int ossl_quic_lcidm_lookup(QUIC_LCIDM *lcidm, - const QUIC_CONN_ID *lcid, - uint64_t *seq_num, - void **opaque); + const QUIC_CONN_ID *lcid, + uint64_t *seq_num, + void **opaque); /* * Debug call to manually remove a specific LCID. Should not be needed in normal @@ -241,7 +241,7 @@ int ossl_quic_lcidm_lookup(QUIC_LCIDM *lcidm, * otherwise. */ int ossl_quic_lcidm_debug_remove(QUIC_LCIDM *lcidm, - const QUIC_CONN_ID *lcid); + const QUIC_CONN_ID *lcid); /* * Debug call to manually add a numbered LCID with a specific CID value and @@ -249,8 +249,8 @@ int ossl_quic_lcidm_debug_remove(QUIC_LCIDM *lcidm, * and 0 on failure. */ int ossl_quic_lcidm_debug_add(QUIC_LCIDM *lcidm, void *opaque, - const QUIC_CONN_ID *lcid, - uint64_t seq_num); + const QUIC_CONN_ID *lcid, + uint64_t seq_num); /* * Obtain a local connection id which is not used yet. @@ -263,7 +263,7 @@ int ossl_quic_lcidm_get_unused_cid(QUIC_LCIDM *lcidm, QUIC_CONN_ID *cid); * This should be connection ID we generated during client validation. */ int ossl_quic_lcidm_bind_channel(QUIC_LCIDM *lcidm, void *opaque, - const QUIC_CONN_ID *lcid); -# endif + const QUIC_CONN_ID *lcid); +#endif #endif diff --git a/crypto/openssl/include/internal/quic_port.h b/crypto/openssl/include/internal/quic_port.h index 6a4dde81da9b..5a2c9352378b 100644 --- a/crypto/openssl/include/internal/quic_port.h +++ b/crypto/openssl/include/internal/quic_port.h @@ -7,16 +7,16 @@ * https://www.openssl.org/source/license.html */ #ifndef OSSL_QUIC_PORT_H -# define OSSL_QUIC_PORT_H +#define OSSL_QUIC_PORT_H -# include <openssl/ssl.h> -# include "internal/quic_types.h" -# include "internal/quic_reactor.h" -# include "internal/quic_demux.h" -# include "internal/quic_predef.h" -# include "internal/thread_arch.h" +#include <openssl/ssl.h> +#include "internal/quic_types.h" +#include "internal/quic_reactor.h" +#include "internal/quic_demux.h" +#include "internal/quic_predef.h" +#include "internal/thread_arch.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Port @@ -40,7 +40,7 @@ */ typedef struct quic_port_args_st { /* The engine which the QUIC port is to be a child of. */ - QUIC_ENGINE *engine; + QUIC_ENGINE *engine; /* * This callback allows port_new_handshake_layer to pre-create a quic @@ -54,19 +54,19 @@ typedef struct quic_port_args_st { * This SSL_CTX will be used when constructing the handshake layer object * inside newly created channels. */ - SSL_CTX *channel_ctx; + SSL_CTX *channel_ctx; /* * If 1, this port is to be used for multiple connections, so * non-zero-length CIDs should be used. If 0, this port will only be used * for a single connection, so a zero-length local CID can be used. */ - int is_multi_conn; + int is_multi_conn; /* * if 1, this port should do server address validation */ - int do_addr_validation; + int do_addr_validation; } QUIC_PORT_ARGS; /* Only QUIC_ENGINE should use this function. */ @@ -151,7 +151,7 @@ void ossl_quic_port_restore_err_state(const QUIC_PORT *port); /* For use by QUIC_ENGINE. You should not need to call this directly. */ void ossl_quic_port_subtick(QUIC_PORT *port, QUIC_TICK_RESULT *r, - uint32_t flags); + uint32_t flags); /* Returns the number of queued incoming channels. */ size_t ossl_quic_port_get_num_incoming_channels(const QUIC_PORT *port); @@ -185,8 +185,8 @@ uint64_t ossl_quic_port_get_net_bio_epoch(const QUIC_PORT *port); * a channel which encountered the network error. */ void ossl_quic_port_raise_net_error(QUIC_PORT *port, - QUIC_CHANNEL *triggering_ch); + QUIC_CHANNEL *triggering_ch); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_predef.h b/crypto/openssl/include/internal/quic_predef.h index 657d86329c6e..c8d4ad470f58 100644 --- a/crypto/openssl/include/internal/quic_predef.h +++ b/crypto/openssl/include/internal/quic_predef.h @@ -8,9 +8,9 @@ */ #ifndef OSSL_QUIC_PREDEF_H -# define OSSL_QUIC_PREDEF_H +#define OSSL_QUIC_PREDEF_H -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC typedef struct ssl_token_store_st SSL_TOKEN_STORE; typedef struct quic_port_st QUIC_PORT; @@ -45,6 +45,6 @@ typedef struct quic_xso_st QUIC_XSO; typedef struct quic_listener_st QUIC_LISTENER; typedef struct quic_domain_st QUIC_DOMAIN; -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_rcidm.h b/crypto/openssl/include/internal/quic_rcidm.h index fd102241b294..aa734f364331 100644 --- a/crypto/openssl/include/internal/quic_rcidm.h +++ b/crypto/openssl/include/internal/quic_rcidm.h @@ -1,22 +1,22 @@ /* -* Copyright 2023-2024 The OpenSSL Project Authors. All Rights Reserved. -* -* Licensed under the Apache License 2.0 (the "License"). You may not use -* this file except in compliance with the License. You can obtain a copy -* in the file LICENSE in the source distribution or at -* https://www.openssl.org/source/license.html -*/ + * Copyright 2023-2024 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ #ifndef OSSL_INTERNAL_QUIC_RCIDM_H -# define OSSL_INTERNAL_QUIC_RCIDM_H -# pragma once +#define OSSL_INTERNAL_QUIC_RCIDM_H +#pragma once -# include "internal/e_os.h" -# include "internal/time.h" -# include "internal/quic_types.h" -# include "internal/quic_wire.h" +#include "internal/e_os.h" +#include "internal/time.h" +#include "internal/quic_types.h" +#include "internal/quic_wire.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Remote Connection ID Manager @@ -65,7 +65,7 @@ void ossl_quic_rcidm_free(QUIC_RCIDM *rcidm); * must be enrolled using this function. May only be called once. */ int ossl_quic_rcidm_add_from_initial(QUIC_RCIDM *rcidm, - const QUIC_CONN_ID *rcid); + const QUIC_CONN_ID *rcid); /* * To be called by a client when a server responds to the first Initial packet @@ -78,7 +78,7 @@ int ossl_quic_rcidm_add_from_initial(QUIC_RCIDM *rcidm, * Not for server use. */ int ossl_quic_rcidm_add_from_server_retry(QUIC_RCIDM *rcidm, - const QUIC_CONN_ID *retry_odcid); + const QUIC_CONN_ID *retry_odcid); /* * Processes an incoming NEW_CONN_ID frame, recording the new CID as a potential @@ -87,7 +87,7 @@ int ossl_quic_rcidm_add_from_server_retry(QUIC_RCIDM *rcidm, * is responsible for handling it separately. */ int ossl_quic_rcidm_add_from_ncid(QUIC_RCIDM *rcidm, - const OSSL_QUIC_FRAME_NEW_CONN_ID *ncid); + const OSSL_QUIC_FRAME_NEW_CONN_ID *ncid); /* * Other Events @@ -157,7 +157,7 @@ int ossl_quic_rcidm_peek_retire_seq_num(QUIC_RCIDM *rcid, uint64_t *seq_num); * Returns 1 on success and 0 on failure. */ int ossl_quic_rcidm_get_preferred_tx_dcid(QUIC_RCIDM *rcidm, - QUIC_CONN_ID *tx_dcid); + QUIC_CONN_ID *tx_dcid); /* * Returns 1 if the value output by ossl_quic_rcidm_get_preferred_tx_dcid() has @@ -165,7 +165,7 @@ int ossl_quic_rcidm_get_preferred_tx_dcid(QUIC_RCIDM *rcidm, * clears the changed flag. Returns the old value of the changed flag. */ int ossl_quic_rcidm_get_preferred_tx_dcid_changed(QUIC_RCIDM *rcidm, - int clear); + int clear); /* * Returns the number of active numbered RCIDs we have. Note that this includes @@ -180,6 +180,6 @@ size_t ossl_quic_rcidm_get_num_active(const QUIC_RCIDM *rcidm); */ size_t ossl_quic_rcidm_get_num_retiring(const QUIC_RCIDM *rcidm); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_reactor.h b/crypto/openssl/include/internal/quic_reactor.h index e47ce52e6f31..dffc37d7549e 100644 --- a/crypto/openssl/include/internal/quic_reactor.h +++ b/crypto/openssl/include/internal/quic_reactor.h @@ -7,16 +7,16 @@ * https://www.openssl.org/source/license.html */ #ifndef OSSL_QUIC_REACTOR_H -# define OSSL_QUIC_REACTOR_H +#define OSSL_QUIC_REACTOR_H -# include "internal/time.h" -# include "internal/sockets.h" -# include "internal/quic_predef.h" -# include "internal/thread_arch.h" -# include "internal/rio_notifier.h" -# include <openssl/bio.h> +#include "internal/time.h" +#include "internal/sockets.h" +#include "internal/quic_predef.h" +#include "internal/thread_arch.h" +#include "internal/rio_notifier.h" +#include <openssl/bio.h> -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * Core I/O Reactor Framework @@ -71,20 +71,20 @@ * the reactor interface. */ struct quic_tick_result_st { - OSSL_TIME tick_deadline; - char net_read_desired; - char net_write_desired; - char notify_other_threads; + OSSL_TIME tick_deadline; + char net_read_desired; + char net_write_desired; + char notify_other_threads; }; static ossl_inline ossl_unused void ossl_quic_tick_result_merge_into(QUIC_TICK_RESULT *r, - const QUIC_TICK_RESULT *src) + const QUIC_TICK_RESULT *src) { - r->net_read_desired = r->net_read_desired || src->net_read_desired; - r->net_write_desired = r->net_write_desired || src->net_write_desired; + r->net_read_desired = r->net_read_desired || src->net_read_desired; + r->net_write_desired = r->net_write_desired || src->net_write_desired; r->notify_other_threads = r->notify_other_threads || src->notify_other_threads; - r->tick_deadline = ossl_time_min(r->tick_deadline, src->tick_deadline); + r->tick_deadline = ossl_time_min(r->tick_deadline, src->tick_deadline); } struct quic_reactor_st { @@ -124,8 +124,8 @@ struct quic_reactor_st { * These are true if we would like to know when we can read or write from * the network respectively. */ - unsigned int net_read_desired : 1; - unsigned int net_write_desired : 1; + unsigned int net_read_desired : 1; + unsigned int net_write_desired : 1; /* * Are the read and write poll descriptors we are currently configured with @@ -142,23 +142,23 @@ struct quic_reactor_st { }; /* Create an OS notifier? */ -#define QUIC_REACTOR_FLAG_USE_NOTIFIER (1U << 0) +#define QUIC_REACTOR_FLAG_USE_NOTIFIER (1U << 0) int ossl_quic_reactor_init(QUIC_REACTOR *rtor, - void (*tick_cb)(QUIC_TICK_RESULT *res, void *arg, - uint32_t flags), - void *tick_cb_arg, - CRYPTO_MUTEX *mutex, - OSSL_TIME initial_tick_deadline, - uint64_t flags); + void (*tick_cb)(QUIC_TICK_RESULT *res, void *arg, + uint32_t flags), + void *tick_cb_arg, + CRYPTO_MUTEX *mutex, + OSSL_TIME initial_tick_deadline, + uint64_t flags); void ossl_quic_reactor_cleanup(QUIC_REACTOR *rtor); void ossl_quic_reactor_set_poll_r(QUIC_REACTOR *rtor, - const BIO_POLL_DESCRIPTOR *r); + const BIO_POLL_DESCRIPTOR *r); void ossl_quic_reactor_set_poll_w(QUIC_REACTOR *rtor, - const BIO_POLL_DESCRIPTOR *w); + const BIO_POLL_DESCRIPTOR *w); const BIO_POLL_DESCRIPTOR *ossl_quic_reactor_get_poll_r(const QUIC_REACTOR *rtor); const BIO_POLL_DESCRIPTOR *ossl_quic_reactor_get_poll_w(const QUIC_REACTOR *rtor); @@ -167,7 +167,7 @@ int ossl_quic_reactor_can_poll_r(const QUIC_REACTOR *rtor); int ossl_quic_reactor_can_poll_w(const QUIC_REACTOR *rtor); int ossl_quic_reactor_can_support_poll_descriptor(const QUIC_REACTOR *rtor, - const BIO_POLL_DESCRIPTOR *d); + const BIO_POLL_DESCRIPTOR *d); int ossl_quic_reactor_net_read_desired(QUIC_REACTOR *rtor); int ossl_quic_reactor_net_write_desired(QUIC_REACTOR *rtor); @@ -182,7 +182,7 @@ OSSL_TIME ossl_quic_reactor_get_tick_deadline(QUIC_REACTOR *rtor); * If the CHANNEL_ONLY flag is set, this indicates that we should only * touch state which is synchronised by the channel mutex. */ -#define QUIC_REACTOR_TICK_FLAG_CHANNEL_ONLY (1U << 0) +#define QUIC_REACTOR_TICK_FLAG_CHANNEL_ONLY (1U << 0) int ossl_quic_reactor_tick(QUIC_REACTOR *rtor, uint32_t flags); @@ -235,11 +235,11 @@ RIO_NOTIFIER *ossl_quic_reactor_get0_notifier(QUIC_REACTOR *rtor); * Invariant: The current thread does not have an outstanding * ossl_quic_reactor_enter_blocking_section() call (unchecked) */ -#define SKIP_FIRST_TICK (1U << 0) +#define SKIP_FIRST_TICK (1U << 0) int ossl_quic_reactor_block_until_pred(QUIC_REACTOR *rtor, - int (*pred)(void *arg), void *pred_arg, - uint32_t flags); + int (*pred)(void *arg), void *pred_arg, + uint32_t flags); /* * ossl_quic_reactor_(enter/leave)_blocking_section @@ -279,6 +279,6 @@ int ossl_quic_reactor_block_until_pred(QUIC_REACTOR *rtor, void ossl_quic_reactor_enter_blocking_section(QUIC_REACTOR *rtor); void ossl_quic_reactor_leave_blocking_section(QUIC_REACTOR *rtor); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_reactor_wait_ctx.h b/crypto/openssl/include/internal/quic_reactor_wait_ctx.h index 12e21cb518b7..8adc94d161ab 100644 --- a/crypto/openssl/include/internal/quic_reactor_wait_ctx.h +++ b/crypto/openssl/include/internal/quic_reactor_wait_ctx.h @@ -7,13 +7,13 @@ * https://www.openssl.org/source/license.html */ #ifndef OSSL_QUIC_REACTOR_WAIT_CTX_H -# define OSSL_QUIC_REACTOR_WAIT_CTX_H +#define OSSL_QUIC_REACTOR_WAIT_CTX_H -# include "internal/quic_predef.h" -# include "internal/quic_reactor.h" -# include "internal/list.h" +#include "internal/quic_predef.h" +#include "internal/quic_reactor.h" +#include "internal/list.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC_REACTOR_WAIT_CTX @@ -86,7 +86,8 @@ typedef struct quic_reactor_wait_slot_st QUIC_REACTOR_WAIT_SLOT; DECLARE_LIST_OF(quic_reactor_wait_slot, QUIC_REACTOR_WAIT_SLOT); struct quic_reactor_wait_ctx_st { - OSSL_LIST(quic_reactor_wait_slot) slots; + OSSL_LIST(quic_reactor_wait_slot) + slots; }; /* Initialises a wait context. */ @@ -94,11 +95,11 @@ void ossl_quic_reactor_wait_ctx_init(QUIC_REACTOR_WAIT_CTX *ctx); /* Uprefs a given reactor. */ int ossl_quic_reactor_wait_ctx_enter(QUIC_REACTOR_WAIT_CTX *ctx, - QUIC_REACTOR *rtor); + QUIC_REACTOR *rtor); /* Downrefs a given reactor. */ void ossl_quic_reactor_wait_ctx_leave(QUIC_REACTOR_WAIT_CTX *ctx, - QUIC_REACTOR *rtor); + QUIC_REACTOR *rtor); /* * Destroys a wait context. Must be called after calling init(). @@ -109,6 +110,6 @@ void ossl_quic_reactor_wait_ctx_leave(QUIC_REACTOR_WAIT_CTX *ctx, */ void ossl_quic_reactor_wait_ctx_cleanup(QUIC_REACTOR_WAIT_CTX *ctx); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_record_rx.h b/crypto/openssl/include/internal/quic_record_rx.h index 24143f91f2f3..287837b2a561 100644 --- a/crypto/openssl/include/internal/quic_record_rx.h +++ b/crypto/openssl/include/internal/quic_record_rx.h @@ -8,16 +8,16 @@ */ #ifndef OSSL_QUIC_RECORD_RX_H -# define OSSL_QUIC_RECORD_RX_H +#define OSSL_QUIC_RECORD_RX_H -# include <openssl/ssl.h> -# include "internal/quic_wire_pkt.h" -# include "internal/quic_types.h" -# include "internal/quic_predef.h" -# include "internal/quic_record_util.h" -# include "internal/quic_demux.h" +#include <openssl/ssl.h> +#include "internal/quic_wire_pkt.h" +#include "internal/quic_types.h" +#include "internal/quic_predef.h" +#include "internal/quic_record_util.h" +#include "internal/quic_demux.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Record Layer - RX @@ -25,26 +25,26 @@ */ typedef struct ossl_qrx_args_st { - OSSL_LIB_CTX *libctx; - const char *propq; + OSSL_LIB_CTX *libctx; + const char *propq; /* Demux which owns the URXEs passed to us. */ - QUIC_DEMUX *demux; + QUIC_DEMUX *demux; /* Length of connection IDs used in short-header packets in bytes. */ - size_t short_conn_id_len; + size_t short_conn_id_len; /* * Maximum number of deferred datagrams buffered at any one time. * Suggested value: 32. */ - size_t max_deferred; + size_t max_deferred; /* Initial reference PN used for RX. */ - QUIC_PN init_largest_pn[QUIC_PN_SPACE_NUM]; + QUIC_PN init_largest_pn[QUIC_PN_SPACE_NUM]; /* Initial key phase. For debugging use only; always 0 in real use. */ - unsigned char init_key_phase_bit; + unsigned char init_key_phase_bit; } OSSL_QRX_ARGS; /* Instantiates a new QRX. */ @@ -62,9 +62,9 @@ void ossl_qrx_free(OSSL_QRX *qrx); /* Setters for the msg_callback and msg_callback_arg */ void ossl_qrx_set_msg_callback(OSSL_QRX *qrx, ossl_msg_cb msg_callback, - SSL *msg_callback_ssl); + SSL *msg_callback_ssl); void ossl_qrx_set_msg_callback_arg(OSSL_QRX *qrx, - void *msg_callback_arg); + void *msg_callback_arg); /* * Get the short header connection id len from this qrx @@ -160,12 +160,12 @@ size_t ossl_qrx_get_short_hdr_conn_id_len(OSSL_QRX *qrx); * * Returns 1 on success or 0 on failure. */ -int ossl_qrx_provide_secret(OSSL_QRX *qrx, - uint32_t enc_level, - uint32_t suite_id, - EVP_MD *md, - const unsigned char *secret, - size_t secret_len); +int ossl_qrx_provide_secret(OSSL_QRX *qrx, + uint32_t enc_level, + uint32_t suite_id, + EVP_MD *md, + const unsigned char *secret, + size_t secret_len); /* * Utility function to update the pn space from a src to a dst qrx. @@ -200,20 +200,20 @@ struct ossl_qrx_pkt_st { * data and len fields point to the decrypted QUIC payload (i.e., to a * sequence of zero or more (potentially malformed) frames to be decoded). */ - QUIC_PKT_HDR *hdr; + QUIC_PKT_HDR *hdr; /* * Address the packet was received from. If this is not available for this * packet, this field is NULL (but this can only occur for manually injected * packets). */ - const BIO_ADDR *peer; + const BIO_ADDR *peer; /* * Local address the packet was sent to. If this is not available for this * packet, this field is NULL. */ - const BIO_ADDR *local; + const BIO_ADDR *local; /* * This is the length of the datagram which contained this packet. Note that @@ -221,31 +221,31 @@ struct ossl_qrx_pkt_st { * for this is so that the user can enforce minimum datagram sizes (e.g. for * datagrams containing INITIAL packets), as required by RFC 9000. */ - size_t datagram_len; + size_t datagram_len; /* The PN which was decoded for the packet, if the packet has a PN field. */ - QUIC_PN pn; + QUIC_PN pn; /* * Time the packet was received, or ossl_time_zero() if the demuxer is not * using a now() function. */ - OSSL_TIME time; + OSSL_TIME time; /* The QRX which was used to receive the packet. */ - OSSL_QRX *qrx; + OSSL_QRX *qrx; /* * The key epoch the packet was received with. Always 0 for non-1-RTT * packets. */ - uint64_t key_epoch; + uint64_t key_epoch; /* * This monotonically increases with each datagram received. * It is for diagnostic use only. */ - uint64_t datagram_id; + uint64_t datagram_id; }; /* @@ -322,12 +322,12 @@ uint64_t ossl_qrx_get_bytes_received(OSSL_QRX *qrx, int clear); * The callback is optional and can be unset by passing NULL for cb. * cb_arg is an opaque value passed to cb. */ -typedef int (ossl_qrx_late_validation_cb)(QUIC_PN pn, int pn_space, - void *arg); +typedef int(ossl_qrx_late_validation_cb)(QUIC_PN pn, int pn_space, + void *arg); int ossl_qrx_set_late_validation_cb(OSSL_QRX *qrx, - ossl_qrx_late_validation_cb *cb, - void *cb_arg); + ossl_qrx_late_validation_cb *cb, + void *cb_arg); /* * Forcibly injects a URXE which has been issued by the DEMUX into the QRX for @@ -339,7 +339,7 @@ int ossl_qrx_set_late_validation_cb(OSSL_QRX *qrx, void ossl_qrx_inject_urxe(OSSL_QRX *qrx, QUIC_URXE *e); void ossl_qrx_inject_pkt(OSSL_QRX *qrx, OSSL_QRX_PKT *pkt); int ossl_qrx_validate_initial_packet(OSSL_QRX *qrx, QUIC_URXE *urxe, - const QUIC_CONN_ID *dcid); + const QUIC_CONN_ID *dcid); /* * Decryption of 1-RTT packets must be explicitly enabled by calling this @@ -514,11 +514,11 @@ uint64_t ossl_qrx_get_key_epoch(OSSL_QRX *qrx); * cb_arg is an opaque value passed to cb. pn is the PN of the packet. * Since key update is only supported for 1-RTT packets, the PN is always * in the Application Data PN space. -*/ -typedef void (ossl_qrx_key_update_cb)(QUIC_PN pn, void *arg); + */ +typedef void(ossl_qrx_key_update_cb)(QUIC_PN pn, void *arg); int ossl_qrx_set_key_update_cb(OSSL_QRX *qrx, - ossl_qrx_key_update_cb *cb, void *cb_arg); + ossl_qrx_key_update_cb *cb, void *cb_arg); /* * Relates to the 1-RTT encryption level. The caller should call this after the @@ -540,7 +540,6 @@ int ossl_qrx_set_key_update_cb(OSSL_QRX *qrx, */ int ossl_qrx_key_update_timeout(OSSL_QRX *qrx, int normal); - /* * Key Expiration * ============== @@ -565,8 +564,8 @@ uint64_t ossl_qrx_get_cur_forged_pkt_count(OSSL_QRX *qrx); * permit to be verified using this QRX instance. */ uint64_t ossl_qrx_get_max_forged_pkt_count(OSSL_QRX *qrx, - uint32_t enc_level); + uint32_t enc_level); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_record_tx.h b/crypto/openssl/include/internal/quic_record_tx.h index e84523f895ca..b2be046f8c61 100644 --- a/crypto/openssl/include/internal/quic_record_tx.h +++ b/crypto/openssl/include/internal/quic_record_tx.h @@ -8,50 +8,50 @@ */ #ifndef OSSL_QUIC_RECORD_TX_H -# define OSSL_QUIC_RECORD_TX_H +#define OSSL_QUIC_RECORD_TX_H -# include <openssl/ssl.h> -# include "internal/quic_wire_pkt.h" -# include "internal/quic_types.h" -# include "internal/quic_predef.h" -# include "internal/quic_record_util.h" -# include "internal/qlog.h" +#include <openssl/ssl.h> +#include "internal/quic_wire_pkt.h" +#include "internal/quic_types.h" +#include "internal/quic_predef.h" +#include "internal/quic_record_util.h" +#include "internal/qlog.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Record Layer - TX * ====================== */ typedef struct ossl_qtx_iovec_st { - const unsigned char *buf; - size_t buf_len; + const unsigned char *buf; + size_t buf_len; } OSSL_QTX_IOVEC; typedef struct ossl_qtx_st OSSL_QTX; typedef int (*ossl_mutate_packet_cb)(const QUIC_PKT_HDR *hdrin, - const OSSL_QTX_IOVEC *iovecin, size_t numin, - QUIC_PKT_HDR **hdrout, - const OSSL_QTX_IOVEC **iovecout, - size_t *numout, - void *arg); + const OSSL_QTX_IOVEC *iovecin, size_t numin, + QUIC_PKT_HDR **hdrout, + const OSSL_QTX_IOVEC **iovecout, + size_t *numout, + void *arg); typedef void (*ossl_finish_mutate_cb)(void *arg); typedef struct ossl_qtx_args_st { - OSSL_LIB_CTX *libctx; - const char *propq; + OSSL_LIB_CTX *libctx; + const char *propq; /* BIO to transmit to. */ - BIO *bio; + BIO *bio; /* Maximum datagram payload length (MDPL) for TX purposes. */ - size_t mdpl; + size_t mdpl; /* Callback returning QLOG instance to use, or NULL. */ - QLOG *(*get_qlog_cb)(void *arg); - void *get_qlog_cb_arg; + QLOG *(*get_qlog_cb)(void *arg); + void *get_qlog_cb_arg; } OSSL_QTX_ARGS; /* Instantiates a new QTX. */ @@ -62,16 +62,16 @@ void ossl_qtx_free(OSSL_QTX *qtx); /* Set mutator callbacks for test framework support */ void ossl_qtx_set_mutator(OSSL_QTX *qtx, ossl_mutate_packet_cb mutatecb, - ossl_finish_mutate_cb finishmutatecb, void *mutatearg); + ossl_finish_mutate_cb finishmutatecb, void *mutatearg); /* Setters for the msg_callback and the msg_callback_arg */ void ossl_qtx_set_msg_callback(OSSL_QTX *qtx, ossl_msg_cb msg_callback, - SSL *msg_callback_ssl); + SSL *msg_callback_ssl); void ossl_qtx_set_msg_callback_arg(OSSL_QTX *qtx, void *msg_callback_arg); /* Change QLOG instance retrieval callback in use after instantiation. */ void ossl_qtx_set_qlog_cb(OSSL_QTX *qtx, QLOG *(*get_qlog_cb)(void *arg), - void *get_qlog_cb_arg); + void *get_qlog_cb_arg); /* * Secret Management @@ -111,12 +111,12 @@ void ossl_qtx_set_qlog_cb(OSSL_QTX *qtx, QLOG *(*get_qlog_cb)(void *arg), * * Returns 1 on success or 0 on failure. */ -int ossl_qtx_provide_secret(OSSL_QTX *qtx, - uint32_t enc_level, - uint32_t suite_id, - EVP_MD *md, - const unsigned char *secret, - size_t secret_len); +int ossl_qtx_provide_secret(OSSL_QTX *qtx, + uint32_t enc_level, + uint32_t suite_id, + EVP_MD *md, + const unsigned char *secret, + size_t secret_len); /* * Informs the QTX that it can now discard key material for a given EL. The QTX @@ -137,8 +137,8 @@ int ossl_qtx_is_enc_level_provisioned(OSSL_QTX *qtx, uint32_t enc_level); * small. The result is written to *plaintext_len. */ int ossl_qtx_calculate_plaintext_payload_len(OSSL_QTX *qtx, uint32_t enc_level, - size_t ciphertext_len, - size_t *plaintext_len); + size_t ciphertext_len, + size_t *plaintext_len); /* * Given the value plaintext_len represented a plaintext packet payload length @@ -147,12 +147,11 @@ int ossl_qtx_calculate_plaintext_payload_len(OSSL_QTX *qtx, uint32_t enc_level, * provisioned. The result is written to *ciphertext_len. */ int ossl_qtx_calculate_ciphertext_payload_len(OSSL_QTX *qtx, uint32_t enc_level, - size_t plaintext_len, - size_t *ciphertext_len); + size_t plaintext_len, + size_t *ciphertext_len); uint32_t ossl_qrl_get_suite_cipher_tag_len(uint32_t suite_id); - /* * Packet Transmission * ------------------- @@ -160,32 +159,32 @@ uint32_t ossl_qrl_get_suite_cipher_tag_len(uint32_t suite_id); struct ossl_qtx_pkt_st { /* Logical packet header to be serialized. */ - QUIC_PKT_HDR *hdr; + QUIC_PKT_HDR *hdr; /* * iovecs expressing the logical packet payload buffer. Zero-length entries * are permitted. */ - const OSSL_QTX_IOVEC *iovec; - size_t num_iovec; + const OSSL_QTX_IOVEC *iovec; + size_t num_iovec; /* Destination address. Will be passed through to the BIO if non-NULL. */ - const BIO_ADDR *peer; + const BIO_ADDR *peer; /* * Local address (optional). Specify as non-NULL only if TX BIO * has local address support enabled. */ - const BIO_ADDR *local; + const BIO_ADDR *local; /* * Logical PN. Used for encryption. This will automatically be encoded to * hdr->pn, which need not be initialized. */ - QUIC_PN pn; + QUIC_PN pn; /* Packet flags. Zero or more OSSL_QTX_PKT_FLAG_* values. */ - uint32_t flags; + uint32_t flags; }; /* @@ -201,7 +200,7 @@ struct ossl_qtx_pkt_st { * COALESCE after having passed it to this function but without writing another * packet, it should call ossl_qtx_flush_pkt(). */ -#define OSSL_QTX_PKT_FLAG_COALESCE (1U << 0) +#define OSSL_QTX_PKT_FLAG_COALESCE (1U << 0) /* * Writes a packet. @@ -265,9 +264,9 @@ void ossl_qtx_finish_dgram(OSSL_QTX *qtx); * or the underlying network write BIO indicated a non-transient * error. */ -#define QTX_FLUSH_NET_RES_OK 1 -#define QTX_FLUSH_NET_RES_TRANSIENT_FAIL (-1) -#define QTX_FLUSH_NET_RES_PERMANENT_FAIL (-2) +#define QTX_FLUSH_NET_RES_OK 1 +#define QTX_FLUSH_NET_RES_TRANSIENT_FAIL (-1) +#define QTX_FLUSH_NET_RES_PERMANENT_FAIL (-2) int ossl_qtx_flush_net(OSSL_QTX *qtx); @@ -313,7 +312,6 @@ int ossl_qtx_set_mdpl(OSSL_QTX *qtx, size_t mdpl); /* Retrieves the current MDPL. */ size_t ossl_qtx_get_mdpl(OSSL_QTX *qtx); - /* * Key Update * ---------- @@ -344,7 +342,6 @@ size_t ossl_qtx_get_mdpl(OSSL_QTX *qtx); */ int ossl_qtx_trigger_key_update(OSSL_QTX *qtx); - /* * Key Expiration * -------------- @@ -388,6 +385,6 @@ uint64_t ossl_qtx_get_max_epoch_pkt_count(OSSL_QTX *qtx, uint32_t enc_level); */ uint64_t ossl_qtx_get_key_epoch(OSSL_QTX *qtx); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_record_util.h b/crypto/openssl/include/internal/quic_record_util.h index 97e630d924e0..61ab92546234 100644 --- a/crypto/openssl/include/internal/quic_record_util.h +++ b/crypto/openssl/include/internal/quic_record_util.h @@ -8,12 +8,12 @@ */ #ifndef OSSL_QUIC_RECORD_UTIL_H -# define OSSL_QUIC_RECORD_UTIL_H +#define OSSL_QUIC_RECORD_UTIL_H -# include <openssl/ssl.h> -# include "internal/quic_types.h" +#include <openssl/ssl.h> +#include "internal/quic_types.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC struct ossl_qrx_st; struct ossl_qtx_st; @@ -25,11 +25,11 @@ struct ossl_qtx_st; /* HKDF-Extract(salt, IKM) (RFC 5869) */ int ossl_quic_hkdf_extract(OSSL_LIB_CTX *libctx, - const char *propq, - const EVP_MD *md, - const unsigned char *salt, size_t salt_len, - const unsigned char *ikm, size_t ikm_len, - unsigned char *out, size_t out_len); + const char *propq, + const EVP_MD *md, + const unsigned char *salt, size_t salt_len, + const unsigned char *ikm, size_t ikm_len, + unsigned char *out, size_t out_len); /* * A QUIC client sends its first INITIAL packet with a random DCID, which @@ -59,11 +59,11 @@ int ossl_quic_hkdf_extract(OSSL_LIB_CTX *libctx, * Returns 1 on success or 0 on error. */ int ossl_quic_provide_initial_secret(OSSL_LIB_CTX *libctx, - const char *propq, - const QUIC_CONN_ID *dst_conn_id, - int is_server, - struct ossl_qrx_st *qrx, - struct ossl_qtx_st *qtx); + const char *propq, + const QUIC_CONN_ID *dst_conn_id, + int is_server, + struct ossl_qrx_st *qrx, + struct ossl_qtx_st *qtx); /* * QUIC Record Layer Ciphersuite Info @@ -71,9 +71,9 @@ int ossl_quic_provide_initial_secret(OSSL_LIB_CTX *libctx, */ /* Available QUIC Record Layer (QRL) ciphersuites. */ -# define QRL_SUITE_AES128GCM 1 /* SHA256 */ -# define QRL_SUITE_AES256GCM 2 /* SHA384 */ -# define QRL_SUITE_CHACHA20POLY1305 3 /* SHA256 */ +#define QRL_SUITE_AES128GCM 1 /* SHA256 */ +#define QRL_SUITE_AES256GCM 2 /* SHA384 */ +#define QRL_SUITE_CHACHA20POLY1305 3 /* SHA256 */ /* Returns cipher name in bytes or NULL if suite ID is invalid. */ const char *ossl_qrl_get_suite_cipher_name(uint32_t suite_id); @@ -111,6 +111,6 @@ uint64_t ossl_qrl_get_suite_max_pkt(uint32_t suite_id); */ uint64_t ossl_qrl_get_suite_max_forged_pkt(uint32_t suite_id); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_rx_depack.h b/crypto/openssl/include/internal/quic_rx_depack.h index c90964a7c16c..648341e9c8f0 100644 --- a/crypto/openssl/include/internal/quic_rx_depack.h +++ b/crypto/openssl/include/internal/quic_rx_depack.h @@ -8,14 +8,14 @@ */ #ifndef OSSL_QUIC_RX_DEPACK_H -# define OSSL_QUIC_RX_DEPACK_H +#define OSSL_QUIC_RX_DEPACK_H -# include "internal/quic_channel.h" +#include "internal/quic_channel.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC int ossl_quic_handle_frames(QUIC_CHANNEL *qc, OSSL_QRX_PKT *qpacket); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_sf_list.h b/crypto/openssl/include/internal/quic_sf_list.h index 8ed1dcb137e3..1a22cc3f387a 100644 --- a/crypto/openssl/include/internal/quic_sf_list.h +++ b/crypto/openssl/include/internal/quic_sf_list.h @@ -8,7 +8,7 @@ */ #ifndef OSSL_QUIC_SF_LIST_H -# define OSSL_QUIC_SF_LIST_H +#define OSSL_QUIC_SF_LIST_H #include "internal/common.h" #include "internal/uint_set.h" @@ -35,12 +35,12 @@ * able to mark an empty frame. * Invariant: The offset never points further than into the first frame. */ -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC typedef struct stream_frame_st STREAM_FRAME; typedef struct sframe_list_st { - STREAM_FRAME *head, *tail; + STREAM_FRAME *head, *tail; /* Is the tail frame final. */ unsigned int fin; /* Number of stream frames in the list. */ @@ -75,8 +75,8 @@ void ossl_sframe_list_destroy(SFRAME_LIST *fl); * check it on its own too). */ int ossl_sframe_list_insert(SFRAME_LIST *fl, UINT_RANGE *range, - OSSL_QRX_PKT *pkt, - const unsigned char *data, int fin); + OSSL_QRX_PKT *pkt, + const unsigned char *data, int fin); /* * Iterator to peek at the contiguous frames at the beginning @@ -91,8 +91,8 @@ int ossl_sframe_list_insert(SFRAME_LIST *fl, UINT_RANGE *range, * case *fin is set, if the end of the stream is reached. */ int ossl_sframe_list_peek(const SFRAME_LIST *fl, void **iter, - UINT_RANGE *range, const unsigned char **data, - int *fin); + UINT_RANGE *range, const unsigned char **data, + int *fin); /* * Drop all frames up to the offset limit. @@ -114,8 +114,8 @@ int ossl_sframe_list_drop_frames(SFRAME_LIST *fl, uint64_t limit); * frame is already locked. */ int ossl_sframe_list_lock_head(SFRAME_LIST *fl, UINT_RANGE *range, - const unsigned char **data, - int *fin); + const unsigned char **data, + int *fin); /* * Just returns whether the head frame is locked by previous @@ -130,10 +130,10 @@ int ossl_sframe_list_is_head_locked(SFRAME_LIST *fl); * It should return 1 on success or 0 if there is not enough * space available in the side storage. */ -typedef int (sframe_list_write_at_cb)(uint64_t logical_offset, - const unsigned char *buf, - size_t buf_len, - void *cb_arg); +typedef int(sframe_list_write_at_cb)(uint64_t logical_offset, + const unsigned char *buf, + size_t buf_len, + void *cb_arg); /* * Move the frame data in all the stream frames in the list fl @@ -144,8 +144,8 @@ typedef int (sframe_list_write_at_cb)(uint64_t logical_offset, * frames and returns 0. */ int ossl_sframe_list_move_data(SFRAME_LIST *fl, - sframe_list_write_at_cb *write_at_cb, - void *cb_arg); -# endif + sframe_list_write_at_cb *write_at_cb, + void *cb_arg); +#endif #endif diff --git a/crypto/openssl/include/internal/quic_srt_gen.h b/crypto/openssl/include/internal/quic_srt_gen.h index a25e71aa81ed..69c9df09e71e 100644 --- a/crypto/openssl/include/internal/quic_srt_gen.h +++ b/crypto/openssl/include/internal/quic_srt_gen.h @@ -1,22 +1,22 @@ /* -* Copyright 2023 The OpenSSL Project Authors. All Rights Reserved. -* -* Licensed under the Apache License 2.0 (the "License"). You may not use -* this file except in compliance with the License. You can obtain a copy -* in the file LICENSE in the source distribution or at -* https://www.openssl.org/source/license.html -*/ + * Copyright 2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ #ifndef OSSL_INTERNAL_QUIC_SRT_GEN_H -# define OSSL_INTERNAL_QUIC_SRT_GEN_H -# pragma once +#define OSSL_INTERNAL_QUIC_SRT_GEN_H +#pragma once -# include "internal/e_os.h" -# include "internal/time.h" -# include "internal/quic_types.h" -# include "internal/quic_wire.h" +#include "internal/e_os.h" +#include "internal/time.h" +#include "internal/quic_types.h" +#include "internal/quic_wire.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Stateless Reset Token Generator @@ -40,7 +40,7 @@ typedef struct quic_srt_gen_st QUIC_SRT_GEN; * in any other context. */ QUIC_SRT_GEN *ossl_quic_srt_gen_new(OSSL_LIB_CTX *libctx, const char *propq, - const unsigned char *key, size_t key_len); + const unsigned char *key, size_t key_len); /* Free the stateless reset token generator. No-op if srt_gen is NULL. */ void ossl_quic_srt_gen_free(QUIC_SRT_GEN *srt_gen); @@ -50,8 +50,8 @@ void ossl_quic_srt_gen_free(QUIC_SRT_GEN *srt_gen); * failure. */ int ossl_quic_srt_gen_calculate_token(QUIC_SRT_GEN *srt_gen, - const QUIC_CONN_ID *dcid, - QUIC_STATELESS_RESET_TOKEN *token); + const QUIC_CONN_ID *dcid, + QUIC_STATELESS_RESET_TOKEN *token); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_srtm.h b/crypto/openssl/include/internal/quic_srtm.h index d60c285e2295..1a8f55da5df2 100644 --- a/crypto/openssl/include/internal/quic_srtm.h +++ b/crypto/openssl/include/internal/quic_srtm.h @@ -1,23 +1,23 @@ /* -* Copyright 2023 The OpenSSL Project Authors. All Rights Reserved. -* -* Licensed under the Apache License 2.0 (the "License"). You may not use -* this file except in compliance with the License. You can obtain a copy -* in the file LICENSE in the source distribution or at -* https://www.openssl.org/source/license.html -*/ + * Copyright 2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ #ifndef OSSL_INTERNAL_QUIC_SRTM_H -# define OSSL_INTERNAL_QUIC_SRTM_H -# pragma once +#define OSSL_INTERNAL_QUIC_SRTM_H +#pragma once -# include "internal/e_os.h" -# include "internal/time.h" -# include "internal/quic_types.h" -# include "internal/quic_wire.h" -# include "internal/quic_predef.h" +#include "internal/e_os.h" +#include "internal/time.h" +#include "internal/quic_types.h" +#include "internal/quic_wire.h" +#include "internal/quic_predef.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Stateless Reset Token Manager @@ -67,7 +67,7 @@ void ossl_quic_srtm_free(QUIC_SRTM *srtm); * copied. Returns 1 on success or 0 on failure. */ int ossl_quic_srtm_add(QUIC_SRTM *srtm, void *opaque, uint64_t seq_num, - const QUIC_STATELESS_RESET_TOKEN *token); + const QUIC_STATELESS_RESET_TOKEN *token); /* * Removes an entry by identifying it via its (opaque, seq_num) tuple. @@ -97,13 +97,13 @@ int ossl_quic_srtm_cull(QUIC_SRTM *strm, void *opaque); * Returns 1 if an entry was found and 0 otherwise. */ int ossl_quic_srtm_lookup(QUIC_SRTM *srtm, - const QUIC_STATELESS_RESET_TOKEN *token, - size_t idx, - void **opaque, uint64_t *seq_num); + const QUIC_STATELESS_RESET_TOKEN *token, + size_t idx, + void **opaque, uint64_t *seq_num); /* Verify internal invariants and assert if they are not met. */ void ossl_quic_srtm_check(const QUIC_SRTM *srtm); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_ssl.h b/crypto/openssl/include/internal/quic_ssl.h index e7fd260ab600..f714d1047716 100644 --- a/crypto/openssl/include/internal/quic_ssl.h +++ b/crypto/openssl/include/internal/quic_ssl.h @@ -8,17 +8,17 @@ */ #ifndef OSSL_QUIC_SSL_H -# define OSSL_QUIC_SSL_H +#define OSSL_QUIC_SSL_H -# include <openssl/ssl.h> -# include <openssl/bio.h> -# include "internal/refcount.h" -# include "internal/quic_record_rx.h" /* OSSL_QRX */ -# include "internal/quic_ackm.h" /* OSSL_ACKM */ -# include "internal/quic_channel.h" /* QUIC_CHANNEL */ -# include "internal/quic_predef.h" +#include <openssl/ssl.h> +#include <openssl/bio.h> +#include "internal/refcount.h" +#include "internal/quic_record_rx.h" /* OSSL_QRX */ +#include "internal/quic_ackm.h" /* OSSL_ACKM */ +#include "internal/quic_channel.h" /* QUIC_CHANNEL */ +#include "internal/quic_predef.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC __owur SSL *ossl_quic_new(SSL_CTX *ctx); __owur SSL *ossl_quic_new_listener(SSL_CTX *ctx, uint64_t flags); @@ -42,9 +42,9 @@ void ossl_quic_free_token_store(SSL_TOKEN_STORE *hdl); SSL_TOKEN_STORE *ossl_quic_get0_token_store(SSL_CTX *ctx); int ossl_quic_set1_token_store(SSL_CTX *ctx, SSL_TOKEN_STORE *hdl); int ossl_quic_set_peer_token(SSL_CTX *ctx, BIO_ADDR *peer, - const uint8_t *token, size_t token_len); + const uint8_t *token, size_t token_len); int ossl_quic_get_peer_token(SSL_CTX *ctx, BIO_ADDR *peer, - QUIC_TOKEN **token); + QUIC_TOKEN **token); void ossl_quic_free_peer_token(QUIC_TOKEN *token); __owur int ossl_quic_init(SSL *s); @@ -57,12 +57,12 @@ __owur int ossl_quic_connect(SSL *s); __owur int ossl_quic_read(SSL *s, void *buf, size_t len, size_t *readbytes); __owur int ossl_quic_peek(SSL *s, void *buf, size_t len, size_t *readbytes); __owur int ossl_quic_write_flags(SSL *s, const void *buf, size_t len, - uint64_t flags, size_t *written); + uint64_t flags, size_t *written); __owur int ossl_quic_write(SSL *s, const void *buf, size_t len, size_t *written); __owur long ossl_quic_ctrl(SSL *s, int cmd, long larg, void *parg); __owur long ossl_quic_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg); -__owur long ossl_quic_callback_ctrl(SSL *s, int cmd, void (*fp) (void)); -__owur long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void)); +__owur long ossl_quic_callback_ctrl(SSL *s, int cmd, void (*fp)(void)); +__owur long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void)); __owur size_t ossl_quic_pending(const SSL *s); __owur int ossl_quic_key_update(SSL *s, int update_type); __owur int ossl_quic_get_key_update_type(const SSL *s); @@ -78,7 +78,7 @@ int ossl_quic_set_accept_state(SSL *s, int raiseerrs); __owur int ossl_quic_has_pending(const SSL *s); __owur int ossl_quic_handle_events(SSL *s); __owur int ossl_quic_get_event_timeout(SSL *s, struct timeval *tv, - int *is_infinite); + int *is_infinite); OSSL_TIME ossl_quic_get_event_deadline(SSL *s); __owur int ossl_quic_get_rpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *d); __owur int ossl_quic_get_wpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *d); @@ -89,15 +89,15 @@ __owur int ossl_quic_want(const SSL *s); __owur int ossl_quic_conn_get_blocking_mode(const SSL *s); __owur int ossl_quic_conn_set_blocking_mode(SSL *s, int blocking); __owur int ossl_quic_conn_shutdown(SSL *s, uint64_t flags, - const SSL_SHUTDOWN_EX_ARGS *args, - size_t args_len); + const SSL_SHUTDOWN_EX_ARGS *args, + size_t args_len); __owur int ossl_quic_conn_stream_conclude(SSL *s); void ossl_quic_conn_set0_net_rbio(SSL *s, BIO *net_wbio); void ossl_quic_conn_set0_net_wbio(SSL *s, BIO *net_wbio); BIO *ossl_quic_conn_get_net_rbio(const SSL *s); BIO *ossl_quic_conn_get_net_wbio(const SSL *s); __owur int ossl_quic_conn_set_initial_peer_addr(SSL *s, - const BIO_ADDR *peer_addr); + const BIO_ADDR *peer_addr); __owur SSL *ossl_quic_conn_stream_new(SSL *s, uint64_t flags); __owur SSL *ossl_quic_get0_connection(SSL *s); __owur SSL *ossl_quic_get0_listener(SSL *s); @@ -110,30 +110,30 @@ __owur int ossl_quic_set_default_stream_mode(SSL *s, uint32_t mode); __owur SSL *ossl_quic_detach_stream(SSL *s); __owur int ossl_quic_attach_stream(SSL *conn, SSL *stream); __owur int ossl_quic_set_incoming_stream_policy(SSL *s, int policy, - uint64_t aec); + uint64_t aec); __owur SSL *ossl_quic_accept_stream(SSL *s, uint64_t flags); __owur size_t ossl_quic_get_accept_stream_queue_len(SSL *s); __owur int ossl_quic_get_value_uint(SSL *s, uint32_t class_, uint32_t id, - uint64_t *value); + uint64_t *value); __owur int ossl_quic_set_value_uint(SSL *s, uint32_t class_, uint32_t id, - uint64_t value); + uint64_t value); __owur SSL *ossl_quic_accept_connection(SSL *ssl, uint64_t flags); __owur size_t ossl_quic_get_accept_connection_queue_len(SSL *ssl); __owur int ossl_quic_listen(SSL *ssl); __owur int ossl_quic_stream_reset(SSL *ssl, - const SSL_STREAM_RESET_ARGS *args, - size_t args_len); + const SSL_STREAM_RESET_ARGS *args, + size_t args_len); __owur int ossl_quic_get_stream_read_state(SSL *ssl); __owur int ossl_quic_get_stream_write_state(SSL *ssl); __owur int ossl_quic_get_stream_read_error_code(SSL *ssl, - uint64_t *app_error_code); + uint64_t *app_error_code); __owur int ossl_quic_get_stream_write_error_code(SSL *ssl, - uint64_t *app_error_code); + uint64_t *app_error_code); __owur int ossl_quic_get_conn_close_info(SSL *ssl, - SSL_CONN_CLOSE_INFO *info, - size_t info_len); + SSL_CONN_CLOSE_INFO *info, + size_t info_len); uint64_t ossl_quic_set_options(SSL *s, uint64_t opts); uint64_t ossl_quic_clear_options(SSL *s, uint64_t opts); @@ -148,8 +148,8 @@ __owur int ossl_quic_set_write_buffer_size(SSL *s, size_t size); * connecting. */ int ossl_quic_set_override_now_cb(SSL *s, - OSSL_TIME (*now_cb)(void *arg), - void *now_cb_arg); + OSSL_TIME (*now_cb)(void *arg), + void *now_cb_arg); /* * Condvar waiting in the assist thread doesn't support time faking as it relies @@ -175,11 +175,11 @@ int ossl_quic_set_diag_title(SSL_CTX *ctx, const char *title); /* APIs used by the polling infrastructure */ int ossl_quic_conn_poll_events(SSL *ssl, uint64_t events, int do_tick, - uint64_t *revents); + uint64_t *revents); int ossl_quic_get_notifier_fd(SSL *ssl); void ossl_quic_enter_blocking_section(SSL *ssl, QUIC_REACTOR_WAIT_CTX *wctx); void ossl_quic_leave_blocking_section(SSL *ssl, QUIC_REACTOR_WAIT_CTX *wctx); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_statm.h b/crypto/openssl/include/internal/quic_statm.h index 2fca69b0d181..e6a7ebfb8413 100644 --- a/crypto/openssl/include/internal/quic_statm.h +++ b/crypto/openssl/include/internal/quic_statm.h @@ -8,17 +8,17 @@ */ #ifndef OSSL_QUIC_STATS_H -# define OSSL_QUIC_STATS_H +#define OSSL_QUIC_STATS_H -# include <openssl/ssl.h> -# include "internal/time.h" -# include "internal/quic_predef.h" +#include <openssl/ssl.h> +#include "internal/time.h" +#include "internal/quic_predef.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC struct ossl_statm_st { OSSL_TIME smoothed_rtt, latest_rtt, min_rtt, rtt_variance; - char have_first_sample; + char have_first_sample; }; typedef struct ossl_rtt_info_st { @@ -33,9 +33,9 @@ void ossl_statm_destroy(OSSL_STATM *statm); void ossl_statm_get_rtt_info(OSSL_STATM *statm, OSSL_RTT_INFO *rtt_info); void ossl_statm_update_rtt(OSSL_STATM *statm, - OSSL_TIME ack_delay, - OSSL_TIME override_latest_rtt); + OSSL_TIME ack_delay, + OSSL_TIME override_latest_rtt); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_stream.h b/crypto/openssl/include/internal/quic_stream.h index d446dadc5047..824d4b896967 100644 --- a/crypto/openssl/include/internal/quic_stream.h +++ b/crypto/openssl/include/internal/quic_stream.h @@ -1,15 +1,15 @@ /* -* Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved. -* -* Licensed under the Apache License 2.0 (the "License"). You may not use -* this file except in compliance with the License. You can obtain a copy -* in the file LICENSE in the source distribution or at -* https://www.openssl.org/source/license.html -*/ + * Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ #ifndef OSSL_INTERNAL_QUIC_STREAM_H -# define OSSL_INTERNAL_QUIC_STREAM_H -# pragma once +#define OSSL_INTERNAL_QUIC_STREAM_H +#pragma once #include "internal/e_os.h" #include "internal/time.h" @@ -21,7 +21,7 @@ #include "internal/quic_fc.h" #include "internal/quic_statm.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Send Stream @@ -126,10 +126,10 @@ void ossl_quic_sstream_free(QUIC_SSTREAM *qss); * than two IOVs.) */ int ossl_quic_sstream_get_stream_frame(QUIC_SSTREAM *qss, - size_t skip, - OSSL_QUIC_FRAME_STREAM *hdr, - OSSL_QTX_IOVEC *iov, - size_t *num_iov); + size_t skip, + OSSL_QUIC_FRAME_STREAM *hdr, + OSSL_QTX_IOVEC *iov, + size_t *num_iov); /* * Returns 1 if there is data pending transmission. Equivalent to calling @@ -161,8 +161,8 @@ uint64_t ossl_quic_sstream_get_cur_size(QUIC_SSTREAM *qss); * Returns 1 on success and 0 on error (e.g. if end < start). */ int ossl_quic_sstream_mark_transmitted(QUIC_SSTREAM *qss, - uint64_t start, - uint64_t end); + uint64_t start, + uint64_t end); /* * (For TX packetizer use.) Marks a STREAM frame with the FIN bit set as having @@ -174,7 +174,7 @@ int ossl_quic_sstream_mark_transmitted(QUIC_SSTREAM *qss, * the QUIC_SSTREAM but is required as a sanity check. */ int ossl_quic_sstream_mark_transmitted_fin(QUIC_SSTREAM *qss, - uint64_t final_size); + uint64_t final_size); /* * (RX/ACKM use.) Marks a logical range of the send stream as having been lost. @@ -188,8 +188,8 @@ int ossl_quic_sstream_mark_transmitted_fin(QUIC_SSTREAM *qss, * Returns 1 on success and 0 on error (e.g. if end < start). */ int ossl_quic_sstream_mark_lost(QUIC_SSTREAM *qss, - uint64_t start, - uint64_t end); + uint64_t start, + uint64_t end); /* * (RX/ACKM use.) Informs the QUIC_SSTREAM that a STREAM frame with the FIN bit @@ -212,8 +212,8 @@ int ossl_quic_sstream_mark_lost_fin(QUIC_SSTREAM *qss); * Returns 1 on success and 0 on error (e.g. if end < start). */ int ossl_quic_sstream_mark_acked(QUIC_SSTREAM *qss, - uint64_t start, - uint64_t end); + uint64_t start, + uint64_t end); /* * (RX/ACKM use.) Informs the QUIC_SSTREAM that a STREAM frame with the FIN bit @@ -237,9 +237,9 @@ int ossl_quic_sstream_mark_acked_fin(QUIC_SSTREAM *qss); * Returns 1 on success or 0 on failure. */ int ossl_quic_sstream_append(QUIC_SSTREAM *qss, - const unsigned char *buf, - size_t buf_len, - size_t *consumed); + const unsigned char *buf, + size_t buf_len, + size_t *consumed); /* * Marks a stream as finished. ossl_quic_sstream_append() may not be called anymore @@ -292,8 +292,8 @@ size_t ossl_quic_sstream_get_buffer_avail(QUIC_SSTREAM *qss); * to 0 as necessary. */ void ossl_quic_sstream_adjust_iov(size_t len, - OSSL_QTX_IOVEC *iov, - size_t num_iov); + OSSL_QTX_IOVEC *iov, + size_t num_iov); /* * Sets flag to cleanse the buffered data when it is acked. @@ -322,7 +322,7 @@ void ossl_quic_sstream_set_cleanse(QUIC_SSTREAM *qss, int cleanse); * when ossl_quic_rstream_move_to_rbuf() is called. */ QUIC_RSTREAM *ossl_quic_rstream_new(QUIC_RXFC *rxfc, - OSSL_STATM *statm, size_t rbuf_size); + OSSL_STATM *statm, size_t rbuf_size); /* * Frees a QUIC_RSTREAM and any associated storage. @@ -340,9 +340,9 @@ void ossl_quic_rstream_free(QUIC_RSTREAM *qrs); */ int ossl_quic_rstream_queue_data(QUIC_RSTREAM *qrs, OSSL_QRX_PKT *pkt, - uint64_t offset, - const unsigned char *data, uint64_t data_len, - int fin); + uint64_t offset, + const unsigned char *data, uint64_t data_len, + int fin); /* * Copies the data from the stream storage to buffer `buf` of size `size`. @@ -351,7 +351,7 @@ int ossl_quic_rstream_queue_data(QUIC_RSTREAM *qrs, OSSL_QRX_PKT *pkt, * stream is finished. It is set to 0 otherwise. */ int ossl_quic_rstream_read(QUIC_RSTREAM *qrs, unsigned char *buf, size_t size, - size_t *readbytes, int *fin); + size_t *readbytes, int *fin); /* * Peeks at the data in the stream storage. It copies them to buffer `buf` @@ -360,7 +360,7 @@ int ossl_quic_rstream_read(QUIC_RSTREAM *qrs, unsigned char *buf, size_t size, * It is set to 0 otherwise. */ int ossl_quic_rstream_peek(QUIC_RSTREAM *qrs, unsigned char *buf, size_t size, - size_t *readbytes, int *fin); + size_t *readbytes, int *fin); /* * Returns the size of the data available for reading. `fin` is set to 1 if @@ -382,8 +382,8 @@ int ossl_quic_rstream_available(QUIC_RSTREAM *qrs, size_t *avail, int *fin); * without calling ossl_quic_rstream_release_record() in between. */ int ossl_quic_rstream_get_record(QUIC_RSTREAM *qrs, - const unsigned char **record, size_t *rec_len, - int *fin); + const unsigned char **record, size_t *rec_len, + int *fin); /* * Releases (possibly partially) the record returned by @@ -423,6 +423,6 @@ int ossl_quic_rstream_resize_rbuf(QUIC_RSTREAM *qrs, size_t rbuf_size); * Sets flag to cleanse the buffered data when user reads it. */ void ossl_quic_rstream_set_cleanse(QUIC_RSTREAM *qrs, int cleanse); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_stream_map.h b/crypto/openssl/include/internal/quic_stream_map.h index 76834e743438..3d249009efa1 100644 --- a/crypto/openssl/include/internal/quic_stream_map.h +++ b/crypto/openssl/include/internal/quic_stream_map.h @@ -1,26 +1,26 @@ /* -* Copyright 2022-2025 The OpenSSL Project Authors. All Rights Reserved. -* -* Licensed under the Apache License 2.0 (the "License"). You may not use -* this file except in compliance with the License. You can obtain a copy -* in the file LICENSE in the source distribution or at -* https://www.openssl.org/source/license.html -*/ + * Copyright 2022-2025 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ #ifndef OSSL_INTERNAL_QUIC_STREAM_MAP_H -# define OSSL_INTERNAL_QUIC_STREAM_MAP_H -# pragma once +#define OSSL_INTERNAL_QUIC_STREAM_MAP_H +#pragma once -# include "internal/e_os.h" -# include "internal/time.h" -# include "internal/common.h" -# include "internal/quic_types.h" -# include "internal/quic_predef.h" -# include "internal/quic_stream.h" -# include "internal/quic_fc.h" -# include <openssl/lhash.h> +#include "internal/e_os.h" +#include "internal/time.h" +#include "internal/common.h" +#include "internal/quic_types.h" +#include "internal/quic_predef.h" +#include "internal/quic_stream.h" +#include "internal/quic_fc.h" +#include <openssl/lhash.h> -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Stream @@ -48,13 +48,13 @@ struct quic_stream_list_node_st { * need to keep the QUIC_SSTREAM and data buffers around. Of course, we also * don't have a QUIC_SSTREAM on a receive-only stream. */ -#define QUIC_SSTREAM_STATE_NONE 0 /* --- sstream == NULL */ -#define QUIC_SSTREAM_STATE_READY 1 /* \ */ -#define QUIC_SSTREAM_STATE_SEND 2 /* |-- sstream != NULL */ -#define QUIC_SSTREAM_STATE_DATA_SENT 3 /* / */ -#define QUIC_SSTREAM_STATE_DATA_RECVD 4 /* \ */ -#define QUIC_SSTREAM_STATE_RESET_SENT 5 /* |-- sstream == NULL */ -#define QUIC_SSTREAM_STATE_RESET_RECVD 6 /* / */ +#define QUIC_SSTREAM_STATE_NONE 0 /* --- sstream == NULL */ +#define QUIC_SSTREAM_STATE_READY 1 /* \ */ +#define QUIC_SSTREAM_STATE_SEND 2 /* |-- sstream != NULL */ +#define QUIC_SSTREAM_STATE_DATA_SENT 3 /* / */ +#define QUIC_SSTREAM_STATE_DATA_RECVD 4 /* \ */ +#define QUIC_SSTREAM_STATE_RESET_SENT 5 /* |-- sstream == NULL */ +#define QUIC_SSTREAM_STATE_RESET_RECVD 6 /* / */ /* * QUIC Receive Stream States @@ -69,13 +69,13 @@ struct quic_stream_list_node_st { * finished, we also don't need to keep the QUIC_RSTREAM around. Finally, we * don't need a QUIC_RSTREAM on a send-only stream. */ -#define QUIC_RSTREAM_STATE_NONE 0 /* --- rstream == NULL */ -#define QUIC_RSTREAM_STATE_RECV 1 /* \ */ -#define QUIC_RSTREAM_STATE_SIZE_KNOWN 2 /* |-- rstream != NULL */ -#define QUIC_RSTREAM_STATE_DATA_RECVD 3 /* / */ -#define QUIC_RSTREAM_STATE_DATA_READ 4 /* \ */ -#define QUIC_RSTREAM_STATE_RESET_RECVD 5 /* |-- rstream == NULL */ -#define QUIC_RSTREAM_STATE_RESET_READ 6 /* / */ +#define QUIC_RSTREAM_STATE_NONE 0 /* --- rstream == NULL */ +#define QUIC_RSTREAM_STATE_RECV 1 /* \ */ +#define QUIC_RSTREAM_STATE_SIZE_KNOWN 2 /* |-- rstream != NULL */ +#define QUIC_RSTREAM_STATE_DATA_RECVD 3 /* / */ +#define QUIC_RSTREAM_STATE_DATA_READ 4 /* \ */ +#define QUIC_RSTREAM_STATE_RESET_RECVD 5 /* |-- rstream == NULL */ +#define QUIC_RSTREAM_STATE_RESET_READ 6 /* / */ struct quic_stream_st { QUIC_STREAM_LIST_NODE active_node; /* for use by QUIC_STREAM_MAP */ @@ -83,41 +83,41 @@ struct quic_stream_st { QUIC_STREAM_LIST_NODE ready_for_gc_node; /* queue of streams now ready for GC */ /* Temporary link used by TXP. */ - QUIC_STREAM *txp_next; + QUIC_STREAM *txp_next; /* * QUIC Stream ID. Do not assume that this encodes a type as this is a * version-specific property and may change between QUIC versions; instead, * use the type field. */ - uint64_t id; + uint64_t id; /* * Application Error Code (AEC) used for STOP_SENDING frame. * This is only valid if stop_sending is 1. */ - uint64_t stop_sending_aec; + uint64_t stop_sending_aec; /* * Application Error Code (AEC) used for RESET_STREAM frame. * This is only valid if reset_stream is 1. */ - uint64_t reset_stream_aec; + uint64_t reset_stream_aec; /* * Application Error Code (AEC) for incoming STOP_SENDING frame. * This is only valid if peer_stop_sending is 1. */ - uint64_t peer_stop_sending_aec; + uint64_t peer_stop_sending_aec; /* * Application Error Code (AEC) for incoming RESET_STREAM frame. * This is only valid if peer_reset_stream is 1. */ - uint64_t peer_reset_stream_aec; + uint64_t peer_reset_stream_aec; /* Temporary value used by TXP. */ - uint64_t txp_txfc_new_credit_consumed; + uint64_t txp_txfc_new_credit_consumed; /* * The final size of the send stream. Although this information can be @@ -130,7 +130,7 @@ struct quic_stream_st { * use ossl_quic_stream_recv_get_final_size or * ossl_quic_rxfc_get_final_size. */ - uint64_t send_final_size; + uint64_t send_final_size; /* * Send stream part and receive stream part buffer management objects. @@ -148,20 +148,20 @@ struct quic_stream_st { * correspond with whether a stream's respective send or receive part * logically exists or not. */ - QUIC_SSTREAM *sstream; /* NULL if RX-only */ - QUIC_RSTREAM *rstream; /* NULL if TX only */ + QUIC_SSTREAM *sstream; /* NULL if RX-only */ + QUIC_RSTREAM *rstream; /* NULL if TX only */ /* Stream-level flow control managers. */ - QUIC_TXFC txfc; /* NULL if RX-only */ - QUIC_RXFC rxfc; /* NULL if TX-only */ + QUIC_TXFC txfc; /* NULL if RX-only */ + QUIC_RXFC rxfc; /* NULL if TX-only */ - unsigned int type : 8; /* QUIC_STREAM_INITIATOR_*, QUIC_STREAM_DIR_* */ + unsigned int type : 8; /* QUIC_STREAM_INITIATOR_*, QUIC_STREAM_DIR_* */ - unsigned int send_state : 8; /* QUIC_SSTREAM_STATE_* */ - unsigned int recv_state : 8; /* QUIC_RSTREAM_STATE_* */ + unsigned int send_state : 8; /* QUIC_SSTREAM_STATE_* */ + unsigned int recv_state : 8; /* QUIC_RSTREAM_STATE_* */ /* 1 iff this QUIC_STREAM is on the active queue (invariant). */ - unsigned int active : 1; + unsigned int active : 1; /* * This is a copy of the QUIC connection as_server value, indicating @@ -170,36 +170,36 @@ struct quic_stream_st { * perspective. It never changes after a QUIC_STREAM is created and is the * same for all QUIC_STREAMS under a QUIC_STREAM_MAP. */ - unsigned int as_server : 1; + unsigned int as_server : 1; /* * Has STOP_SENDING been requested (by us)? Note that this is not the same * as want_stop_sending below, as a STOP_SENDING frame may already have been * sent and fully acknowledged. */ - unsigned int stop_sending : 1; + unsigned int stop_sending : 1; /* * Has RESET_STREAM been requested (by us)? Works identically to * STOP_SENDING for transmission purposes. */ /* Has our peer sent a STOP_SENDING frame? */ - unsigned int peer_stop_sending : 1; + unsigned int peer_stop_sending : 1; /* Temporary flags used by TXP. */ - unsigned int txp_sent_fc : 1; - unsigned int txp_sent_stop_sending : 1; - unsigned int txp_sent_reset_stream : 1; - unsigned int txp_drained : 1; - unsigned int txp_blocked : 1; + unsigned int txp_sent_fc : 1; + unsigned int txp_sent_stop_sending : 1; + unsigned int txp_sent_reset_stream : 1; + unsigned int txp_drained : 1; + unsigned int txp_blocked : 1; /* Frame regeneration flags. */ - unsigned int want_max_stream_data : 1; /* used for regen only */ - unsigned int want_stop_sending : 1; /* used for gen or regen */ - unsigned int want_reset_stream : 1; /* used for gen or regen */ + unsigned int want_max_stream_data : 1; /* used for regen only */ + unsigned int want_stop_sending : 1; /* used for gen or regen */ + unsigned int want_reset_stream : 1; /* used for gen or regen */ /* Flags set when frames *we* sent were acknowledged. */ - unsigned int acked_stop_sending : 1; + unsigned int acked_stop_sending : 1; /* * The stream's XSO has been deleted. Pending GC. @@ -309,20 +309,20 @@ struct quic_stream_st { * Once these conditions are met, we can GC the QUIC_STREAM. * */ - unsigned int deleted : 1; + unsigned int deleted : 1; /* Set to 1 once the above conditions are actually met. */ - unsigned int ready_for_gc : 1; + unsigned int ready_for_gc : 1; /* Set to 1 if this is currently counted in the shutdown flush stream count. */ - unsigned int shutdown_flush : 1; + unsigned int shutdown_flush : 1; }; -#define QUIC_STREAM_INITIATOR_CLIENT 0 -#define QUIC_STREAM_INITIATOR_SERVER 1 -#define QUIC_STREAM_INITIATOR_MASK 1 +#define QUIC_STREAM_INITIATOR_CLIENT 0 +#define QUIC_STREAM_INITIATOR_SERVER 1 +#define QUIC_STREAM_INITIATOR_MASK 1 -#define QUIC_STREAM_DIR_BIDI 0 -#define QUIC_STREAM_DIR_UNI 2 -#define QUIC_STREAM_DIR_MASK 2 +#define QUIC_STREAM_DIR_BIDI 0 +#define QUIC_STREAM_DIR_UNI 2 +#define QUIC_STREAM_DIR_MASK 2 void ossl_quic_stream_check(const QUIC_STREAM *s); @@ -453,7 +453,7 @@ static ossl_inline ossl_unused int ossl_quic_stream_recv_is_reset(const QUIC_STR * undefined value otherwise. */ static ossl_inline ossl_unused int ossl_quic_stream_send_get_final_size(const QUIC_STREAM *s, - uint64_t *final_size) + uint64_t *final_size) { switch (s->send_state) { default: @@ -483,7 +483,7 @@ static ossl_inline ossl_unused int ossl_quic_stream_send_get_final_size(const QU * undefined value otherwise. */ static ossl_inline ossl_unused int ossl_quic_stream_recv_get_final_size(const QUIC_STREAM *s, - uint64_t *final_size) + uint64_t *final_size) { switch (s->recv_state) { default: @@ -509,7 +509,7 @@ static ossl_inline ossl_unused int ossl_quic_stream_recv_get_final_size(const QU * include_fin is 1) whether a FIN or reset has yet to be read. */ static ossl_inline ossl_unused int ossl_quic_stream_recv_pending(const QUIC_STREAM *s, - int include_fin) + int include_fin) { size_t avail; int fin = 0; @@ -552,18 +552,18 @@ static ossl_inline ossl_unused int ossl_quic_stream_recv_pending(const QUIC_STRE * */ struct quic_stream_map_st { - LHASH_OF(QUIC_STREAM) *map; - QUIC_STREAM_LIST_NODE active_list; - QUIC_STREAM_LIST_NODE accept_list; - QUIC_STREAM_LIST_NODE ready_for_gc_list; - size_t rr_stepping, rr_counter; - size_t num_accept_bidi, num_accept_uni, num_shutdown_flush; - QUIC_STREAM *rr_cur; - uint64_t (*get_stream_limit_cb)(int uni, void *arg); - void *get_stream_limit_cb_arg; - QUIC_RXFC *max_streams_bidi_rxfc; - QUIC_RXFC *max_streams_uni_rxfc; - int is_server; + LHASH_OF(QUIC_STREAM) *map; + QUIC_STREAM_LIST_NODE active_list; + QUIC_STREAM_LIST_NODE accept_list; + QUIC_STREAM_LIST_NODE ready_for_gc_list; + size_t rr_stepping, rr_counter; + size_t num_accept_bidi, num_accept_uni, num_shutdown_flush; + QUIC_STREAM *rr_cur; + uint64_t (*get_stream_limit_cb)(int uni, void *arg); + void *get_stream_limit_cb_arg; + QUIC_RXFC *max_streams_bidi_rxfc; + QUIC_RXFC *max_streams_uni_rxfc; + int is_server; }; /* @@ -580,11 +580,11 @@ struct quic_stream_map_st { * a stream. */ int ossl_quic_stream_map_init(QUIC_STREAM_MAP *qsm, - uint64_t (*get_stream_limit_cb)(int uni, void *arg), - void *get_stream_limit_cb_arg, - QUIC_RXFC *max_streams_bidi_rxfc, - QUIC_RXFC *max_streams_uni_rxfc, - int is_server); + uint64_t (*get_stream_limit_cb)(int uni, void *arg), + void *get_stream_limit_cb_arg, + QUIC_RXFC *max_streams_bidi_rxfc, + QUIC_RXFC *max_streams_uni_rxfc, + int is_server); /* * Any streams still in the map will be released as though @@ -602,8 +602,8 @@ void ossl_quic_stream_map_cleanup(QUIC_STREAM_MAP *qsm); * with the given ID. */ QUIC_STREAM *ossl_quic_stream_map_alloc(QUIC_STREAM_MAP *qsm, - uint64_t stream_id, - int type); + uint64_t stream_id, + int type); /* * Releases a stream object. Note that this must only be done once the teardown @@ -616,14 +616,14 @@ void ossl_quic_stream_map_release(QUIC_STREAM_MAP *qsm, QUIC_STREAM *stream); * argument which is passed through. */ void ossl_quic_stream_map_visit(QUIC_STREAM_MAP *qsm, - void (*visit_cb)(QUIC_STREAM *stream, void *arg), - void *visit_cb_arg); + void (*visit_cb)(QUIC_STREAM *stream, void *arg), + void *visit_cb_arg); /* * Retrieves a stream by stream ID. Returns NULL if it does not exist. */ QUIC_STREAM *ossl_quic_stream_map_get_by_id(QUIC_STREAM_MAP *qsm, - uint64_t stream_id); + uint64_t stream_id); /* * Marks the given stream as active or inactive based on its state. Idempotent. @@ -652,8 +652,8 @@ void ossl_quic_stream_map_set_rr_stepping(QUIC_STREAM_MAP *qsm, size_t stepping) * Note that stream_ordinal is a stream ordinal, not a stream ID. */ int ossl_quic_stream_map_is_local_allowed_by_stream_limit(QUIC_STREAM_MAP *qsm, - uint64_t stream_ordinal, - int is_uni); + uint64_t stream_ordinal, + int is_uni); /* * Stream Send Part @@ -678,7 +678,7 @@ int ossl_quic_stream_map_is_local_allowed_by_stream_limit(QUIC_STREAM_MAP *qsm, * Returns 0 if there is no send part (caller error) and 1 otherwise. */ int ossl_quic_stream_map_ensure_send_part_id(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *qs); + QUIC_STREAM *qs); /* * Transitions from SEND to the DATA_SENT state. Note that this is NOT the same @@ -693,7 +693,7 @@ int ossl_quic_stream_map_ensure_send_part_id(QUIC_STREAM_MAP *qsm, * because the send part is not in the SEND state. */ int ossl_quic_stream_map_notify_all_data_sent(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *qs); + QUIC_STREAM *qs); /* * Transitions from the DATA_SENT to DATA_RECVD state; should be called @@ -707,7 +707,7 @@ int ossl_quic_stream_map_notify_all_data_sent(QUIC_STREAM_MAP *qsm, * function to succeed. */ int ossl_quic_stream_map_notify_totally_acked(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *qs); + QUIC_STREAM *qs); /* * Resets the sending part of a stream. This is a transition from the READY, @@ -721,8 +721,8 @@ int ossl_quic_stream_map_notify_totally_acked(QUIC_STREAM_MAP *qsm, * in this state. It also returns 0 if there is no send part (caller error). */ int ossl_quic_stream_map_reset_stream_send_part(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *qs, - uint64_t aec); + QUIC_STREAM *qs, + uint64_t aec); /* * Transitions from the RESET_SENT to the RESET_RECVD state. This should be @@ -738,8 +738,7 @@ int ossl_quic_stream_map_reset_stream_send_part(QUIC_STREAM_MAP *qsm, * (caller error). */ int ossl_quic_stream_map_notify_reset_stream_acked(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *qs); - + QUIC_STREAM *qs); /* * Stream Receive Part @@ -754,8 +753,8 @@ int ossl_quic_stream_map_notify_reset_stream_acked(QUIC_STREAM_MAP *qsm, * Returns 1 if the transition was taken. */ int ossl_quic_stream_map_notify_size_known_recv_part(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *qs, - uint64_t final_size); + QUIC_STREAM *qs, + uint64_t final_size); /* * Transitions from the SIZE_KNOWN receive stream state to the DATA_RECVD state. @@ -764,7 +763,7 @@ int ossl_quic_stream_map_notify_size_known_recv_part(QUIC_STREAM_MAP *qsm, * Returns 1 if the transition was taken. */ int ossl_quic_stream_map_notify_totally_received(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *qs); + QUIC_STREAM *qs); /* * Transitions from the DATA_RECVD receive stream state to the DATA_READ state. @@ -774,7 +773,7 @@ int ossl_quic_stream_map_notify_totally_received(QUIC_STREAM_MAP *qsm, * Returns 1 if the transition was taken. */ int ossl_quic_stream_map_notify_totally_read(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *qs); + QUIC_STREAM *qs); /* * Transitions from the RECV, SIZE_KNOWN or DATA_RECVD receive stream state to @@ -783,9 +782,9 @@ int ossl_quic_stream_map_notify_totally_read(QUIC_STREAM_MAP *qsm, * Returns 1 if the transition was taken. */ int ossl_quic_stream_map_notify_reset_recv_part(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *qs, - uint64_t app_error_code, - uint64_t final_size); + QUIC_STREAM *qs, + uint64_t app_error_code, + uint64_t final_size); /* * Transitions from the RESET_RECVD receive stream state to the RESET_READ @@ -793,7 +792,7 @@ int ossl_quic_stream_map_notify_reset_recv_part(QUIC_STREAM_MAP *qsm, * of a stream reset. */ int ossl_quic_stream_map_notify_app_read_reset_recv_part(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *qs); + QUIC_STREAM *qs); /* * Marks the receiving part of a stream for STOP_SENDING. This is orthogonal to @@ -804,8 +803,8 @@ int ossl_quic_stream_map_notify_app_read_reset_recv_part(QUIC_STREAM_MAP *qsm, * Returns 0 otherwise, which need not be considered an error. */ int ossl_quic_stream_map_stop_sending_recv_part(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *qs, - uint64_t aec); + QUIC_STREAM *qs, + uint64_t aec); /* * Marks the stream as wanting a STOP_SENDING frame transmitted. It is not valid @@ -813,8 +812,7 @@ int ossl_quic_stream_map_stop_sending_recv_part(QUIC_STREAM_MAP *qsm, * called. For TXP use. */ int ossl_quic_stream_map_schedule_stop_sending(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *qs); - + QUIC_STREAM *qs); /* * Accept Queue Management @@ -825,7 +823,7 @@ int ossl_quic_stream_map_schedule_stop_sending(QUIC_STREAM_MAP *qsm, * Adds a stream to the accept queue. */ void ossl_quic_stream_map_push_accept_queue(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *s); + QUIC_STREAM *s); /* * Returns the next item to be popped from the accept queue, or NULL if it is @@ -840,8 +838,8 @@ QUIC_STREAM *ossl_quic_stream_map_peek_accept_queue(QUIC_STREAM_MAP *qsm); * Precondition: s is in the accept queue. */ void ossl_quic_stream_map_remove_from_accept_queue(QUIC_STREAM_MAP *qsm, - QUIC_STREAM *s, - OSSL_TIME rtt); + QUIC_STREAM *s, + OSSL_TIME rtt); /* Returns the length of the accept queue for the given stream type. */ size_t ossl_quic_stream_map_get_accept_queue_len(QUIC_STREAM_MAP *qsm, int is_uni); @@ -894,8 +892,8 @@ int ossl_quic_stream_map_is_shutdown_flush_finished(QUIC_STREAM_MAP *qsm); * */ typedef struct quic_stream_iter_st { - QUIC_STREAM_MAP *qsm; - QUIC_STREAM *first_stream, *stream; + QUIC_STREAM_MAP *qsm; + QUIC_STREAM *first_stream, *stream; } QUIC_STREAM_ITER; /* @@ -904,7 +902,7 @@ typedef struct quic_stream_iter_st { * the iteration sequence, or NULL if there are no active streams. */ void ossl_quic_stream_iter_init(QUIC_STREAM_ITER *it, QUIC_STREAM_MAP *qsm, - int advance_rr); + int advance_rr); /* * Advances to next stream in iteration sequence. You do not need to call this @@ -913,6 +911,6 @@ void ossl_quic_stream_iter_init(QUIC_STREAM_ITER *it, QUIC_STREAM_MAP *qsm, */ void ossl_quic_stream_iter_next(QUIC_STREAM_ITER *it); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_thread_assist.h b/crypto/openssl/include/internal/quic_thread_assist.h index 12d9750ad331..fbfac146dab0 100644 --- a/crypto/openssl/include/internal/quic_thread_assist.h +++ b/crypto/openssl/include/internal/quic_thread_assist.h @@ -8,17 +8,17 @@ */ #ifndef OSSL_QUIC_THREAD_ASSIST_H -# define OSSL_QUIC_THREAD_ASSIST_H +#define OSSL_QUIC_THREAD_ASSIST_H -# include <openssl/ssl.h> -# include "internal/thread.h" -# include "internal/time.h" +#include <openssl/ssl.h> +#include "internal/thread.h" +#include "internal/time.h" -# if defined(OPENSSL_NO_QUIC) || defined(OPENSSL_NO_THREAD_POOL) -# define OPENSSL_NO_QUIC_THREAD_ASSIST -# endif +#if defined(OPENSSL_NO_QUIC) || defined(OPENSSL_NO_THREAD_POOL) +#define OPENSSL_NO_QUIC_THREAD_ASSIST +#endif -# ifndef OPENSSL_NO_QUIC_THREAD_ASSIST +#ifndef OPENSSL_NO_QUIC_THREAD_ASSIST /* * QUIC Thread Assisted Functionality @@ -56,7 +56,7 @@ typedef struct quic_thread_assist_st { * not affect the state of the mutex. */ int ossl_quic_thread_assist_init_start(QUIC_THREAD_ASSIST *qta, - QUIC_CHANNEL *ch); + QUIC_CHANNEL *ch); /* * Request the thread assist helper to begin stopping the assist thread. This @@ -93,6 +93,6 @@ int ossl_quic_thread_assist_cleanup(QUIC_THREAD_ASSIST *qta); */ int ossl_quic_thread_assist_notify_deadline_changed(QUIC_THREAD_ASSIST *qta); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_tls.h b/crypto/openssl/include/internal/quic_tls.h index ec0d07da0b39..707f7df9e37c 100644 --- a/crypto/openssl/include/internal/quic_tls.h +++ b/crypto/openssl/include/internal/quic_tls.h @@ -8,9 +8,9 @@ */ #ifndef OSSL_QUIC_TLS_H -# define OSSL_QUIC_TLS_H +#define OSSL_QUIC_TLS_H -# include <openssl/ssl.h> +#include <openssl/ssl.h> typedef struct quic_tls_st QUIC_TLS; @@ -28,7 +28,7 @@ typedef struct quic_tls_args_st { * current EL. */ int (*crypto_send_cb)(const unsigned char *buf, size_t buf_len, - size_t *consumed, void *arg); + size_t *consumed, void *arg); void *crypto_send_cb_arg; /* @@ -37,7 +37,7 @@ typedef struct quic_tls_args_st { * data. */ int (*crypto_recv_rcd_cb)(const unsigned char **buf, size_t *bytes_read, - void *arg); + void *arg); void *crypto_recv_rcd_cb_arg; int (*crypto_release_rcd_cb)(size_t bytes_read, void *arg); void *crypto_release_rcd_cb_arg; @@ -47,9 +47,9 @@ typedef struct quic_tls_args_st { * level. */ int (*yield_secret_cb)(uint32_t prot_level, int direction /* 0=RX, 1=TX */, - uint32_t suite_id, EVP_MD *md, - const unsigned char *secret, size_t secret_len, - void *arg); + uint32_t suite_id, EVP_MD *md, + const unsigned char *secret, size_t secret_len, + void *arg); void *yield_secret_cb_arg; /* @@ -59,8 +59,8 @@ typedef struct quic_tls_args_st { * marked as completed. */ int (*got_transport_params_cb)(const unsigned char *params, - size_t params_len, - void *arg); + size_t params_len, + void *arg); void *got_transport_params_cb_arg; /* @@ -99,13 +99,13 @@ int ossl_quic_tls_tick(QUIC_TLS *qtls); void ossl_quic_tls_clear(QUIC_TLS *qtls); int ossl_quic_tls_set_transport_params(QUIC_TLS *qtls, - const unsigned char *transport_params, - size_t transport_params_len); + const unsigned char *transport_params, + size_t transport_params_len); int ossl_quic_tls_get_error(QUIC_TLS *qtls, - uint64_t *error_code, - const char **error_msg, - ERR_STATE **error_state); + uint64_t *error_code, + const char **error_msg, + ERR_STATE **error_state); int ossl_quic_tls_is_cert_request(QUIC_TLS *qtls); int ossl_quic_tls_has_bad_max_early_data(QUIC_TLS *qtls); diff --git a/crypto/openssl/include/internal/quic_trace.h b/crypto/openssl/include/internal/quic_trace.h index fb3742799641..f462ce0c0090 100644 --- a/crypto/openssl/include/internal/quic_trace.h +++ b/crypto/openssl/include/internal/quic_trace.h @@ -8,13 +8,13 @@ */ #ifndef OSSL_QUIC_TRACE_H -# define OSSL_QUIC_TRACE_H +#define OSSL_QUIC_TRACE_H -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC int ossl_quic_trace(int write_p, int version, int content_type, - const void *buf, size_t msglen, SSL *ssl, void *arg); + const void *buf, size_t msglen, SSL *ssl, void *arg); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_tserver.h b/crypto/openssl/include/internal/quic_tserver.h index 30439bd8535e..91516b1876a1 100644 --- a/crypto/openssl/include/internal/quic_tserver.h +++ b/crypto/openssl/include/internal/quic_tserver.h @@ -8,16 +8,16 @@ */ #ifndef OSSL_QUIC_TSERVER_H -# define OSSL_QUIC_TSERVER_H +#define OSSL_QUIC_TSERVER_H -# include <openssl/ssl.h> -# include <openssl/bio.h> -# include "internal/quic_stream.h" -# include "internal/quic_channel.h" -# include "internal/statem.h" -# include "internal/time.h" +#include <openssl/ssl.h> +#include <openssl/bio.h> +#include "internal/quic_stream.h" +#include "internal/quic_channel.h" +#include "internal/statem.h" +#include "internal/time.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Test Server Module @@ -46,20 +46,20 @@ typedef struct quic_tserver_args_st { } QUIC_TSERVER_ARGS; QUIC_TSERVER *ossl_quic_tserver_new(const QUIC_TSERVER_ARGS *args, - const char *certfile, const char *keyfile); + const char *certfile, const char *keyfile); void ossl_quic_tserver_free(QUIC_TSERVER *srv); /* Set mutator callbacks for test framework support */ int ossl_quic_tserver_set_plain_packet_mutator(QUIC_TSERVER *srv, - ossl_mutate_packet_cb mutatecb, - ossl_finish_mutate_cb finishmutatecb, - void *mutatearg); + ossl_mutate_packet_cb mutatecb, + ossl_finish_mutate_cb finishmutatecb, + void *mutatearg); int ossl_quic_tserver_set_handshake_mutator(QUIC_TSERVER *srv, - ossl_statem_mutate_handshake_cb mutate_handshake_cb, - ossl_statem_finish_mutate_handshake_cb finish_mutate_handshake_cb, - void *mutatearg); + ossl_statem_mutate_handshake_cb mutate_handshake_cb, + ossl_statem_finish_mutate_handshake_cb finish_mutate_handshake_cb, + void *mutatearg); /* Advances the state machine. */ int ossl_quic_tserver_tick(QUIC_TSERVER *srv); @@ -94,10 +94,10 @@ size_t ossl_quic_tserver_get_short_header_conn_id_len(const QUIC_TSERVER *srv); * ossl_quic_tserver_has_read_ended() to identify this condition. */ int ossl_quic_tserver_read(QUIC_TSERVER *srv, - uint64_t stream_id, - unsigned char *buf, - size_t buf_len, - size_t *bytes_read); + uint64_t stream_id, + unsigned char *buf, + size_t buf_len, + size_t *bytes_read); /* * Returns 1 if the read part of the stream has ended normally. @@ -116,10 +116,10 @@ int ossl_quic_tserver_has_read_ended(QUIC_TSERVER *srv, uint64_t stream_id); * Returns 0 if connection is not currently active. */ int ossl_quic_tserver_write(QUIC_TSERVER *srv, - uint64_t stream_id, - const unsigned char *buf, - size_t buf_len, - size_t *bytes_written); + uint64_t stream_id, + const unsigned char *buf, + size_t buf_len, + size_t *bytes_written); /* * Signals normal end of the stream. @@ -131,8 +131,8 @@ int ossl_quic_tserver_conclude(QUIC_TSERVER *srv, uint64_t stream_id); * created stream is written to *stream_id. */ int ossl_quic_tserver_stream_new(QUIC_TSERVER *srv, - int is_uni, - uint64_t *stream_id); + int is_uni, + uint64_t *stream_id); BIO *ossl_quic_tserver_get0_rbio(QUIC_TSERVER *srv); @@ -143,22 +143,22 @@ SSL_CTX *ossl_quic_tserver_get0_ssl_ctx(QUIC_TSERVER *srv); * app_error_code is written if this returns 1. */ int ossl_quic_tserver_stream_has_peer_stop_sending(QUIC_TSERVER *srv, - uint64_t stream_id, - uint64_t *app_error_code); + uint64_t stream_id, + uint64_t *app_error_code); /* * Returns 1 if the peer has sent a RESET_STREAM frame for a stream. * app_error_code is written if this returns 1. */ int ossl_quic_tserver_stream_has_peer_reset_stream(QUIC_TSERVER *srv, - uint64_t stream_id, - uint64_t *app_error_code); + uint64_t stream_id, + uint64_t *app_error_code); /* * Replaces existing local connection ID in the underlying QUIC_CHANNEL. */ int ossl_quic_tserver_set_new_local_cid(QUIC_TSERVER *srv, - const QUIC_CONN_ID *conn_id); + const QUIC_CONN_ID *conn_id); /* * Returns the stream ID of the next incoming stream, or UINT64_MAX if there @@ -170,7 +170,7 @@ uint64_t ossl_quic_tserver_pop_incoming_stream(QUIC_TSERVER *srv); * Returns 1 if all data sent on the given stream_id has been acked by the peer. */ int ossl_quic_tserver_is_stream_totally_acked(QUIC_TSERVER *srv, - uint64_t stream_id); + uint64_t stream_id); /* Returns 1 if we are currently interested in reading data from the network */ int ossl_quic_tserver_get_net_read_desired(QUIC_TSERVER *srv); @@ -192,11 +192,11 @@ int ossl_quic_tserver_ping(QUIC_TSERVER *srv); /* Set tracing callback on channel. */ void ossl_quic_tserver_set_msg_callback(QUIC_TSERVER *srv, - void (*f)(int write_p, int version, - int content_type, - const void *buf, size_t len, - SSL *ssl, void *arg), - void *arg); + void (*f)(int write_p, int version, + int content_type, + const void *buf, size_t len, + SSL *ssl, void *arg), + void *arg); /* * This is similar to ossl_quic_conn_get_channel; it should be used for test @@ -212,12 +212,12 @@ int ossl_quic_tserver_new_ticket(QUIC_TSERVER *srv); * values 0 and 0xffffffff are valid for use in QUIC. */ int ossl_quic_tserver_set_max_early_data(QUIC_TSERVER *srv, - uint32_t max_early_data); + uint32_t max_early_data); /* Set the find session callback for getting a server PSK */ void ossl_quic_tserver_set_psk_find_session_cb(QUIC_TSERVER *srv, - SSL_psk_find_session_cb_func cb); + SSL_psk_find_session_cb_func cb); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_txp.h b/crypto/openssl/include/internal/quic_txp.h index b76308e5878f..d94a79620d27 100644 --- a/crypto/openssl/include/internal/quic_txp.h +++ b/crypto/openssl/include/internal/quic_txp.h @@ -8,22 +8,22 @@ */ #ifndef OSSL_QUIC_TXP_H -# define OSSL_QUIC_TXP_H +#define OSSL_QUIC_TXP_H -# include <openssl/ssl.h> -# include "internal/quic_types.h" -# include "internal/quic_predef.h" -# include "internal/quic_record_tx.h" -# include "internal/quic_cfq.h" -# include "internal/quic_txpim.h" -# include "internal/quic_stream.h" -# include "internal/quic_stream_map.h" -# include "internal/quic_fc.h" -# include "internal/bio_addr.h" -# include "internal/time.h" -# include "internal/qlog.h" +#include <openssl/ssl.h> +#include "internal/quic_types.h" +#include "internal/quic_predef.h" +#include "internal/quic_record_tx.h" +#include "internal/quic_cfq.h" +#include "internal/quic_txpim.h" +#include "internal/quic_stream.h" +#include "internal/quic_stream_map.h" +#include "internal/quic_fc.h" +#include "internal/bio_addr.h" +#include "internal/time.h" +#include "internal/qlog.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC TX Packetiser @@ -31,28 +31,28 @@ */ typedef struct ossl_quic_tx_packetiser_args_st { /* Configuration Settings */ - QUIC_CONN_ID cur_scid; /* Current Source Connection ID we use. */ - QUIC_CONN_ID cur_dcid; /* Current Destination Connection ID we use. */ - BIO_ADDR peer; /* Current destination L4 address we use. */ - uint32_t ack_delay_exponent; /* ACK delay exponent used when encoding. */ + QUIC_CONN_ID cur_scid; /* Current Source Connection ID we use. */ + QUIC_CONN_ID cur_dcid; /* Current Destination Connection ID we use. */ + BIO_ADDR peer; /* Current destination L4 address we use. */ + uint32_t ack_delay_exponent; /* ACK delay exponent used when encoding. */ /* Injected Dependencies */ - OSSL_QTX *qtx; /* QUIC Record Layer TX we are using */ - QUIC_TXPIM *txpim; /* QUIC TX'd Packet Information Manager */ - QUIC_CFQ *cfq; /* QUIC Control Frame Queue */ - OSSL_ACKM *ackm; /* QUIC Acknowledgement Manager */ - QUIC_STREAM_MAP *qsm; /* QUIC Streams Map */ - QUIC_TXFC *conn_txfc; /* QUIC Connection-Level TX Flow Controller */ - QUIC_RXFC *conn_rxfc; /* QUIC Connection-Level RX Flow Controller */ - QUIC_RXFC *max_streams_bidi_rxfc; /* QUIC RXFC for MAX_STREAMS generation */ - QUIC_RXFC *max_streams_uni_rxfc; + OSSL_QTX *qtx; /* QUIC Record Layer TX we are using */ + QUIC_TXPIM *txpim; /* QUIC TX'd Packet Information Manager */ + QUIC_CFQ *cfq; /* QUIC Control Frame Queue */ + OSSL_ACKM *ackm; /* QUIC Acknowledgement Manager */ + QUIC_STREAM_MAP *qsm; /* QUIC Streams Map */ + QUIC_TXFC *conn_txfc; /* QUIC Connection-Level TX Flow Controller */ + QUIC_RXFC *conn_rxfc; /* QUIC Connection-Level RX Flow Controller */ + QUIC_RXFC *max_streams_bidi_rxfc; /* QUIC RXFC for MAX_STREAMS generation */ + QUIC_RXFC *max_streams_uni_rxfc; const OSSL_CC_METHOD *cc_method; /* QUIC Congestion Controller */ - OSSL_CC_DATA *cc_data; /* QUIC Congestion Controller Instance */ - OSSL_TIME (*now)(void *arg); /* Callback to get current time. */ - void *now_arg; - QLOG *(*get_qlog_cb)(void *arg); /* Optional QLOG retrieval func */ - void *get_qlog_cb_arg; - uint32_t protocol_version; /* The protocol version to try negotiating */ + OSSL_CC_DATA *cc_data; /* QUIC Congestion Controller Instance */ + OSSL_TIME (*now)(void *arg); /* Callback to get current time. */ + void *now_arg; + QLOG *(*get_qlog_cb)(void *arg); /* Optional QLOG retrieval func */ + void *get_qlog_cb_arg; + uint32_t protocol_version; /* The protocol version to try negotiating */ /* * Injected dependencies - crypto streams. @@ -60,22 +60,22 @@ typedef struct ossl_quic_tx_packetiser_args_st { * Note: There is no crypto stream for the 0-RTT EL. * crypto[QUIC_PN_SPACE_APP] is the 1-RTT crypto stream. */ - QUIC_SSTREAM *crypto[QUIC_PN_SPACE_NUM]; + QUIC_SSTREAM *crypto[QUIC_PN_SPACE_NUM]; - } OSSL_QUIC_TX_PACKETISER_ARGS; +} OSSL_QUIC_TX_PACKETISER_ARGS; OSSL_QUIC_TX_PACKETISER *ossl_quic_tx_packetiser_new(const OSSL_QUIC_TX_PACKETISER_ARGS *args); void ossl_quic_tx_packetiser_set_validated(OSSL_QUIC_TX_PACKETISER *txp); void ossl_quic_tx_packetiser_add_unvalidated_credit(OSSL_QUIC_TX_PACKETISER *txp, - size_t credit); + size_t credit); void ossl_quic_tx_packetiser_consume_unvalidated_credit(OSSL_QUIC_TX_PACKETISER *txp, - size_t credit); + size_t credit); int ossl_quic_tx_packetiser_check_unvalidated_credit(OSSL_QUIC_TX_PACKETISER *txp, - size_t req_credit); + size_t req_credit); -typedef void (ossl_quic_initial_token_free_fn)(const unsigned char *buf, - size_t buf_len, void *arg); +typedef void(ossl_quic_initial_token_free_fn)(const unsigned char *buf, + size_t buf_len, void *arg); void ossl_quic_tx_packetiser_free(OSSL_QUIC_TX_PACKETISER *txp); @@ -85,7 +85,7 @@ void ossl_quic_tx_packetiser_free(OSSL_QUIC_TX_PACKETISER *txp); * Refer RFC 9000 s. 10.2.1 Closing Connection State. */ void ossl_quic_tx_packetiser_record_received_closing_bytes( - OSSL_QUIC_TX_PACKETISER *txp, size_t n); + OSSL_QUIC_TX_PACKETISER *txp, size_t n); /* * Generates a datagram by polling the various ELs to determine if they want to @@ -106,7 +106,7 @@ typedef struct quic_txp_status_st { } QUIC_TXP_STATUS; int ossl_quic_tx_packetiser_generate(OSSL_QUIC_TX_PACKETISER *txp, - QUIC_TXP_STATUS *status); + QUIC_TXP_STATUS *status); /* * Returns a deadline after which a call to ossl_quic_tx_packetiser_generate() @@ -128,39 +128,39 @@ OSSL_TIME ossl_quic_tx_packetiser_get_deadline(OSSL_QUIC_TX_PACKETISER *txp); * understanding of our PMTU. */ int ossl_quic_tx_packetiser_set_initial_token(OSSL_QUIC_TX_PACKETISER *txp, - const unsigned char *token, - size_t token_len, - ossl_quic_initial_token_free_fn *free_cb, - void *free_cb_arg); + const unsigned char *token, + size_t token_len, + ossl_quic_initial_token_free_fn *free_cb, + void *free_cb_arg); /* * Set the protocol version used when generating packets. Currently should * only ever be set to QUIC_VERSION_1 */ int ossl_quic_tx_packetiser_set_protocol_version(OSSL_QUIC_TX_PACKETISER *txp, - uint32_t protocol_version); + uint32_t protocol_version); /* Change the DCID the TXP uses to send outgoing packets. */ int ossl_quic_tx_packetiser_set_cur_dcid(OSSL_QUIC_TX_PACKETISER *txp, - const QUIC_CONN_ID *dcid); + const QUIC_CONN_ID *dcid); /* Change the SCID the TXP uses to send outgoing (long) packets. */ int ossl_quic_tx_packetiser_set_cur_scid(OSSL_QUIC_TX_PACKETISER *txp, - const QUIC_CONN_ID *scid); + const QUIC_CONN_ID *scid); /* * Change the destination L4 address the TXP uses to send datagrams. Specify * NULL (or AF_UNSPEC) to disable use of addressed mode. */ int ossl_quic_tx_packetiser_set_peer(OSSL_QUIC_TX_PACKETISER *txp, - const BIO_ADDR *peer); + const BIO_ADDR *peer); /* * Change the QLOG instance retrieval function in use after instantiation. */ void ossl_quic_tx_packetiser_set_qlog_cb(OSSL_QUIC_TX_PACKETISER *txp, - QLOG *(*get_qlog_cb)(void *arg), - void *get_qlog_cb_arg); + QLOG *(*get_qlog_cb)(void *arg), + void *get_qlog_cb_arg); /* * Inform the TX packetiser that an EL has been discarded. Idempotent. @@ -172,7 +172,7 @@ void ossl_quic_tx_packetiser_set_qlog_cb(OSSL_QUIC_TX_PACKETISER *txp, * free that QUIC_SSTREAM if desired. */ int ossl_quic_tx_packetiser_discard_enc_level(OSSL_QUIC_TX_PACKETISER *txp, - uint32_t enc_level); + uint32_t enc_level); /* * Informs the TX packetiser that the handshake is complete. The TX packetiser @@ -187,14 +187,14 @@ void ossl_quic_tx_packetiser_schedule_handshake_done(OSSL_QUIC_TX_PACKETISER *tx /* Asks the TXP to ensure the next packet in the given PN space is ACK-eliciting. */ void ossl_quic_tx_packetiser_schedule_ack_eliciting(OSSL_QUIC_TX_PACKETISER *txp, - uint32_t pn_space); + uint32_t pn_space); /* * Asks the TXP to ensure an ACK is put in the next packet in the given PN * space. */ void ossl_quic_tx_packetiser_schedule_ack(OSSL_QUIC_TX_PACKETISER *txp, - uint32_t pn_space); + uint32_t pn_space); /* * Schedules a connection close. *f and f->reason are copied. This operation is @@ -204,31 +204,31 @@ void ossl_quic_tx_packetiser_schedule_ack(OSSL_QUIC_TX_PACKETISER *txp, * successful call to this function. */ int ossl_quic_tx_packetiser_schedule_conn_close(OSSL_QUIC_TX_PACKETISER *txp, - const OSSL_QUIC_FRAME_CONN_CLOSE *f); + const OSSL_QUIC_FRAME_CONN_CLOSE *f); /* Setters for the msg_callback and msg_callback_arg */ void ossl_quic_tx_packetiser_set_msg_callback(OSSL_QUIC_TX_PACKETISER *txp, - ossl_msg_cb msg_callback, - SSL *msg_callback_ssl); + ossl_msg_cb msg_callback, + SSL *msg_callback_ssl); void ossl_quic_tx_packetiser_set_msg_callback_arg(OSSL_QUIC_TX_PACKETISER *txp, - void *msg_callback_arg); + void *msg_callback_arg); /* * Determines the next PN which will be used for a given PN space. */ QUIC_PN ossl_quic_tx_packetiser_get_next_pn(OSSL_QUIC_TX_PACKETISER *txp, - uint32_t pn_space); + uint32_t pn_space); /* * Sets a callback which is called whenever TXP sends an ACK frame. The callee * must not modify the ACK frame data. Can be used to snoop on PNs being ACKed. */ void ossl_quic_tx_packetiser_set_ack_tx_cb(OSSL_QUIC_TX_PACKETISER *txp, - void (*cb)(const OSSL_QUIC_FRAME_ACK *ack, - uint32_t pn_space, - void *arg), - void *cb_arg); + void (*cb)(const OSSL_QUIC_FRAME_ACK *ack, + uint32_t pn_space, + void *arg), + void *cb_arg); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_txpim.h b/crypto/openssl/include/internal/quic_txpim.h index 5df6ad46cb30..d3f96807e21a 100644 --- a/crypto/openssl/include/internal/quic_txpim.h +++ b/crypto/openssl/include/internal/quic_txpim.h @@ -8,15 +8,15 @@ */ #ifndef OSSL_QUIC_TXPIM_H -# define OSSL_QUIC_TXPIM_H +#define OSSL_QUIC_TXPIM_H -# include <openssl/ssl.h> -# include "internal/quic_types.h" -# include "internal/quic_predef.h" -# include "internal/quic_cfq.h" -# include "internal/quic_ackm.h" +#include <openssl/ssl.h> +#include "internal/quic_types.h" +#include "internal/quic_predef.h" +#include "internal/quic_cfq.h" +#include "internal/quic_ackm.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* * QUIC Transmitted Packet Information Manager @@ -25,24 +25,24 @@ typedef struct quic_txpim_pkt_st { /* ACKM-specific data. Caller should fill this. */ - OSSL_ACKM_TX_PKT ackm_pkt; + OSSL_ACKM_TX_PKT ackm_pkt; /* Linked list of CFQ items in this packet. */ - QUIC_CFQ_ITEM *retx_head; + QUIC_CFQ_ITEM *retx_head; /* Reserved for FIFD use. */ - QUIC_FIFD *fifd; + QUIC_FIFD *fifd; /* QUIC_PKT_TYPE value. For diagnostic use only. */ - unsigned char pkt_type; + unsigned char pkt_type; /* Regenerate-strategy frames. */ - unsigned int had_handshake_done_frame : 1; - unsigned int had_max_data_frame : 1; - unsigned int had_max_streams_bidi_frame : 1; - unsigned int had_max_streams_uni_frame : 1; - unsigned int had_ack_frame : 1; - unsigned int had_conn_close : 1; + unsigned int had_handshake_done_frame : 1; + unsigned int had_max_data_frame : 1; + unsigned int had_max_streams_bidi_frame : 1; + unsigned int had_max_streams_uni_frame : 1; + unsigned int had_ack_frame : 1; + unsigned int had_conn_close : 1; /* Private data follows. */ } QUIC_TXPIM_PKT; @@ -50,29 +50,29 @@ typedef struct quic_txpim_pkt_st { /* Represents a range of bytes in an application or CRYPTO stream. */ typedef struct quic_txpim_chunk_st { /* The stream ID, or UINT64_MAX for the CRYPTO stream. */ - uint64_t stream_id; + uint64_t stream_id; /* * The inclusive range of bytes in the stream. Exceptionally, if end < * start, designates a frame of zero length (used for FIN-only frames). In * this case end is the number of the final byte (i.e., one less than the * final size of the stream). */ - uint64_t start, end; + uint64_t start, end; /* * Whether a FIN was sent for this stream in the packet. Not valid for * CRYPTO stream. */ - unsigned int has_fin : 1; + unsigned int has_fin : 1; /* * If set, a STOP_SENDING frame was sent for this stream ID. (If no data was * sent for the stream, set end < start.) */ - unsigned int has_stop_sending : 1; + unsigned int has_stop_sending : 1; /* * If set, a RESET_STREAM frame was sent for this stream ID. (If no data was * sent for the stream, set end < start.) */ - unsigned int has_reset_stream : 1; + unsigned int has_reset_stream : 1; } QUIC_TXPIM_CHUNK; QUIC_TXPIM *ossl_quic_txpim_new(void); @@ -101,11 +101,11 @@ void ossl_quic_txpim_pkt_clear_chunks(QUIC_TXPIM_PKT *fpkt); /* Appends a chunk to the packet. The structure is copied. */ int ossl_quic_txpim_pkt_append_chunk(QUIC_TXPIM_PKT *fpkt, - const QUIC_TXPIM_CHUNK *chunk); + const QUIC_TXPIM_CHUNK *chunk); /* Adds a CFQ item to the packet by prepending it to the retx_head list. */ void ossl_quic_txpim_pkt_add_cfq_item(QUIC_TXPIM_PKT *fpkt, - QUIC_CFQ_ITEM *item); + QUIC_CFQ_ITEM *item); /* * Returns a pointer to an array of stream chunk information structures for the @@ -130,6 +130,6 @@ size_t ossl_quic_txpim_pkt_get_num_chunks(const QUIC_TXPIM_PKT *fpkt); */ size_t ossl_quic_txpim_get_in_use(const QUIC_TXPIM *txpim); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_types.h b/crypto/openssl/include/internal/quic_types.h index 0913b370546f..8636912cd9ed 100644 --- a/crypto/openssl/include/internal/quic_types.h +++ b/crypto/openssl/include/internal/quic_types.h @@ -8,14 +8,14 @@ */ #ifndef OSSL_QUIC_TYPES_H -# define OSSL_QUIC_TYPES_H +#define OSSL_QUIC_TYPES_H -# include <openssl/ssl.h> -# include <internal/ssl.h> -# include <assert.h> -# include <string.h> +#include <openssl/ssl.h> +#include <internal/ssl.h> +#include <assert.h> +#include <string.h> -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* QUIC encryption levels. */ enum { @@ -23,7 +23,7 @@ enum { QUIC_ENC_LEVEL_0RTT, QUIC_ENC_LEVEL_HANDSHAKE, QUIC_ENC_LEVEL_1RTT, - QUIC_ENC_LEVEL_NUM /* Must be the ultimate entry */ + QUIC_ENC_LEVEL_NUM /* Must be the ultimate entry */ }; /* QUIC packet number spaces. */ @@ -32,7 +32,7 @@ enum { QUIC_PN_SPACE_HANDSHAKE, /* New entries must go here, so that QUIC_PN_SPACE_APP is the penultimate */ QUIC_PN_SPACE_APP, - QUIC_PN_SPACE_NUM /* Must be the ultimate entry */ + QUIC_PN_SPACE_NUM /* Must be the ultimate entry */ }; static ossl_unused ossl_inline uint32_t @@ -54,7 +54,7 @@ ossl_quic_enc_level_to_pn_space(uint32_t enc_level) /* QUIC packet number representation. */ typedef uint64_t QUIC_PN; -# define QUIC_PN_INVALID UINT64_MAX +#define QUIC_PN_INVALID UINT64_MAX static ossl_unused ossl_inline QUIC_PN ossl_quic_pn_max(QUIC_PN a, QUIC_PN b) { @@ -72,15 +72,15 @@ static ossl_unused ossl_inline int ossl_quic_pn_valid(QUIC_PN pn) } /* QUIC connection ID representation. */ -# define QUIC_MAX_CONN_ID_LEN 20 -# define QUIC_MIN_ODCID_LEN 8 /* RFC 9000 s. 7.2 */ +#define QUIC_MAX_CONN_ID_LEN 20 +#define QUIC_MIN_ODCID_LEN 8 /* RFC 9000 s. 7.2 */ typedef struct quic_conn_id_st { unsigned char id_len, id[QUIC_MAX_CONN_ID_LEN]; } QUIC_CONN_ID; static ossl_unused ossl_inline int ossl_quic_conn_id_eq(const QUIC_CONN_ID *a, - const QUIC_CONN_ID *b) + const QUIC_CONN_ID *b) { if (a->id_len != b->id_len || a->id_len > QUIC_MAX_CONN_ID_LEN) return 0; @@ -92,21 +92,21 @@ static ossl_unused ossl_inline int ossl_quic_conn_id_eq(const QUIC_CONN_ID *a, * Returns 1 on success or 0 on failure. */ int ossl_quic_gen_rand_conn_id(OSSL_LIB_CTX *libctx, size_t len, - QUIC_CONN_ID *cid); + QUIC_CONN_ID *cid); -# define QUIC_MIN_INITIAL_DGRAM_LEN 1200 +#define QUIC_MIN_INITIAL_DGRAM_LEN 1200 -# define QUIC_DEFAULT_ACK_DELAY_EXP 3 -# define QUIC_MAX_ACK_DELAY_EXP 20 +#define QUIC_DEFAULT_ACK_DELAY_EXP 3 +#define QUIC_MAX_ACK_DELAY_EXP 20 -# define QUIC_DEFAULT_MAX_ACK_DELAY 25 +#define QUIC_DEFAULT_MAX_ACK_DELAY 25 -# define QUIC_MIN_ACTIVE_CONN_ID_LIMIT 2 +#define QUIC_MIN_ACTIVE_CONN_ID_LIMIT 2 /* Arbitrary choice of default idle timeout (not an RFC value). */ -# define QUIC_DEFAULT_IDLE_TIMEOUT 30000 +#define QUIC_DEFAULT_IDLE_TIMEOUT 30000 -# define QUIC_STATELESS_RESET_TOKEN_LEN 16 +#define QUIC_STATELESS_RESET_TOKEN_LEN 16 typedef struct { unsigned char token[QUIC_STATELESS_RESET_TOKEN_LEN]; @@ -116,9 +116,9 @@ typedef struct { * An encoded preferred_addr transport parameter cannot be shorter or longer * than these lengths in bytes. */ -# define QUIC_MIN_ENCODED_PREFERRED_ADDR_LEN 41 -# define QUIC_MAX_ENCODED_PREFERRED_ADDR_LEN 61 +#define QUIC_MIN_ENCODED_PREFERRED_ADDR_LEN 41 +#define QUIC_MAX_ENCODED_PREFERRED_ADDR_LEN 61 -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_vlint.h b/crypto/openssl/include/internal/quic_vlint.h index d4b70b229c32..61012f6da7d1 100644 --- a/crypto/openssl/include/internal/quic_vlint.h +++ b/crypto/openssl/include/internal/quic_vlint.h @@ -1,19 +1,19 @@ /* -* Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved. -* -* Licensed under the Apache License 2.0 (the "License"). You may not use -* this file except in compliance with the License. You can obtain a copy -* in the file LICENSE in the source distribution or at -* https://www.openssl.org/source/license.html -*/ + * Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ #ifndef OSSL_INTERNAL_QUIC_VLINT_H -# define OSSL_INTERNAL_QUIC_VLINT_H -# pragma once +#define OSSL_INTERNAL_QUIC_VLINT_H +#pragma once -# include "internal/e_os.h" +#include "internal/e_os.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC /* The smallest value requiring a 1, 2, 4, or 8-byte representation. */ #define OSSL_QUIC_VLINT_1B_MIN 0 @@ -28,7 +28,7 @@ #define OSSL_QUIC_VLINT_8B_MAX (((uint64_t)1 << 62) - 1) /* The largest value representable as a variable-length integer. */ -#define OSSL_QUIC_VLINT_MAX OSSL_QUIC_VLINT_8B_MAX +#define OSSL_QUIC_VLINT_MAX OSSL_QUIC_VLINT_8B_MAX /* * Returns the number of bytes needed to encode v in the QUIC variable-length @@ -122,6 +122,6 @@ uint64_t ossl_quic_vlint_decode_unchecked(const unsigned char *buf); */ int ossl_quic_vlint_decode(const unsigned char *buf, size_t buf_len, uint64_t *v); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_wire.h b/crypto/openssl/include/internal/quic_wire.h index cd01feb03628..f2efabaeba16 100644 --- a/crypto/openssl/include/internal/quic_wire.h +++ b/crypto/openssl/include/internal/quic_wire.h @@ -1,90 +1,78 @@ /* -* Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved. -* -* Licensed under the Apache License 2.0 (the "License"). You may not use -* this file except in compliance with the License. You can obtain a copy -* in the file LICENSE in the source distribution or at -* https://www.openssl.org/source/license.html -*/ + * Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ #ifndef OSSL_INTERNAL_QUIC_WIRE_H -# define OSSL_INTERNAL_QUIC_WIRE_H -# pragma once +#define OSSL_INTERNAL_QUIC_WIRE_H +#pragma once -# include "internal/e_os.h" -# include "internal/time.h" -# include "internal/quic_types.h" -# include "internal/packet_quic.h" +#include "internal/e_os.h" +#include "internal/time.h" +#include "internal/quic_types.h" +#include "internal/packet_quic.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC -# define OSSL_QUIC_FRAME_TYPE_PADDING 0x00 -# define OSSL_QUIC_FRAME_TYPE_PING 0x01 -# define OSSL_QUIC_FRAME_TYPE_ACK_WITHOUT_ECN 0x02 -# define OSSL_QUIC_FRAME_TYPE_ACK_WITH_ECN 0x03 -# define OSSL_QUIC_FRAME_TYPE_RESET_STREAM 0x04 -# define OSSL_QUIC_FRAME_TYPE_STOP_SENDING 0x05 -# define OSSL_QUIC_FRAME_TYPE_CRYPTO 0x06 -# define OSSL_QUIC_FRAME_TYPE_NEW_TOKEN 0x07 -# define OSSL_QUIC_FRAME_TYPE_MAX_DATA 0x10 -# define OSSL_QUIC_FRAME_TYPE_MAX_STREAM_DATA 0x11 -# define OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_BIDI 0x12 -# define OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_UNI 0x13 -# define OSSL_QUIC_FRAME_TYPE_DATA_BLOCKED 0x14 -# define OSSL_QUIC_FRAME_TYPE_STREAM_DATA_BLOCKED 0x15 -# define OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_BIDI 0x16 -# define OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_UNI 0x17 -# define OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID 0x18 -# define OSSL_QUIC_FRAME_TYPE_RETIRE_CONN_ID 0x19 -# define OSSL_QUIC_FRAME_TYPE_PATH_CHALLENGE 0x1A -# define OSSL_QUIC_FRAME_TYPE_PATH_RESPONSE 0x1B -# define OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_TRANSPORT 0x1C -# define OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_APP 0x1D -# define OSSL_QUIC_FRAME_TYPE_HANDSHAKE_DONE 0x1E +#define OSSL_QUIC_FRAME_TYPE_PADDING 0x00 +#define OSSL_QUIC_FRAME_TYPE_PING 0x01 +#define OSSL_QUIC_FRAME_TYPE_ACK_WITHOUT_ECN 0x02 +#define OSSL_QUIC_FRAME_TYPE_ACK_WITH_ECN 0x03 +#define OSSL_QUIC_FRAME_TYPE_RESET_STREAM 0x04 +#define OSSL_QUIC_FRAME_TYPE_STOP_SENDING 0x05 +#define OSSL_QUIC_FRAME_TYPE_CRYPTO 0x06 +#define OSSL_QUIC_FRAME_TYPE_NEW_TOKEN 0x07 +#define OSSL_QUIC_FRAME_TYPE_MAX_DATA 0x10 +#define OSSL_QUIC_FRAME_TYPE_MAX_STREAM_DATA 0x11 +#define OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_BIDI 0x12 +#define OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_UNI 0x13 +#define OSSL_QUIC_FRAME_TYPE_DATA_BLOCKED 0x14 +#define OSSL_QUIC_FRAME_TYPE_STREAM_DATA_BLOCKED 0x15 +#define OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_BIDI 0x16 +#define OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_UNI 0x17 +#define OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID 0x18 +#define OSSL_QUIC_FRAME_TYPE_RETIRE_CONN_ID 0x19 +#define OSSL_QUIC_FRAME_TYPE_PATH_CHALLENGE 0x1A +#define OSSL_QUIC_FRAME_TYPE_PATH_RESPONSE 0x1B +#define OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_TRANSPORT 0x1C +#define OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_APP 0x1D +#define OSSL_QUIC_FRAME_TYPE_HANDSHAKE_DONE 0x1E -# define OSSL_QUIC_FRAME_FLAG_STREAM_FIN 0x01 -# define OSSL_QUIC_FRAME_FLAG_STREAM_LEN 0x02 -# define OSSL_QUIC_FRAME_FLAG_STREAM_OFF 0x04 -# define OSSL_QUIC_FRAME_FLAG_STREAM_MASK ((uint64_t)0x07) +#define OSSL_QUIC_FRAME_FLAG_STREAM_FIN 0x01 +#define OSSL_QUIC_FRAME_FLAG_STREAM_LEN 0x02 +#define OSSL_QUIC_FRAME_FLAG_STREAM_OFF 0x04 +#define OSSL_QUIC_FRAME_FLAG_STREAM_MASK ((uint64_t)0x07) /* Low 3 bits of the type contain flags */ -# define OSSL_QUIC_FRAME_TYPE_STREAM 0x08 /* base ID */ -# define OSSL_QUIC_FRAME_TYPE_STREAM_FIN \ - (OSSL_QUIC_FRAME_TYPE_STREAM | \ - OSSL_QUIC_FRAME_FLAG_STREAM_FIN) -# define OSSL_QUIC_FRAME_TYPE_STREAM_LEN \ - (OSSL_QUIC_FRAME_TYPE_STREAM | \ - OSSL_QUIC_FRAME_FLAG_STREAM_LEN) -# define OSSL_QUIC_FRAME_TYPE_STREAM_LEN_FIN \ - (OSSL_QUIC_FRAME_TYPE_STREAM | \ - OSSL_QUIC_FRAME_FLAG_STREAM_LEN | \ - OSSL_QUIC_FRAME_FLAG_STREAM_FIN) -# define OSSL_QUIC_FRAME_TYPE_STREAM_OFF \ - (OSSL_QUIC_FRAME_TYPE_STREAM | \ - OSSL_QUIC_FRAME_FLAG_STREAM_OFF) -# define OSSL_QUIC_FRAME_TYPE_STREAM_OFF_FIN \ - (OSSL_QUIC_FRAME_TYPE_STREAM | \ - OSSL_QUIC_FRAME_FLAG_STREAM_OFF | \ - OSSL_QUIC_FRAME_FLAG_STREAM_FIN) -# define OSSL_QUIC_FRAME_TYPE_STREAM_OFF_LEN \ - (OSSL_QUIC_FRAME_TYPE_STREAM | \ - OSSL_QUIC_FRAME_FLAG_STREAM_OFF | \ - OSSL_QUIC_FRAME_FLAG_STREAM_LEN) -# define OSSL_QUIC_FRAME_TYPE_STREAM_OFF_LEN_FIN \ - (OSSL_QUIC_FRAME_TYPE_STREAM | \ - OSSL_QUIC_FRAME_FLAG_STREAM_OFF | \ - OSSL_QUIC_FRAME_FLAG_STREAM_LEN | \ - OSSL_QUIC_FRAME_FLAG_STREAM_FIN) +#define OSSL_QUIC_FRAME_TYPE_STREAM 0x08 /* base ID */ +#define OSSL_QUIC_FRAME_TYPE_STREAM_FIN \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_FIN) +#define OSSL_QUIC_FRAME_TYPE_STREAM_LEN \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_LEN) +#define OSSL_QUIC_FRAME_TYPE_STREAM_LEN_FIN \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_LEN | OSSL_QUIC_FRAME_FLAG_STREAM_FIN) +#define OSSL_QUIC_FRAME_TYPE_STREAM_OFF \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_OFF) +#define OSSL_QUIC_FRAME_TYPE_STREAM_OFF_FIN \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_OFF | OSSL_QUIC_FRAME_FLAG_STREAM_FIN) +#define OSSL_QUIC_FRAME_TYPE_STREAM_OFF_LEN \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_OFF | OSSL_QUIC_FRAME_FLAG_STREAM_LEN) +#define OSSL_QUIC_FRAME_TYPE_STREAM_OFF_LEN_FIN \ + (OSSL_QUIC_FRAME_TYPE_STREAM | OSSL_QUIC_FRAME_FLAG_STREAM_OFF | OSSL_QUIC_FRAME_FLAG_STREAM_LEN | OSSL_QUIC_FRAME_FLAG_STREAM_FIN) -# define OSSL_QUIC_FRAME_TYPE_IS_STREAM(x) \ +#define OSSL_QUIC_FRAME_TYPE_IS_STREAM(x) \ (((x) & ~OSSL_QUIC_FRAME_FLAG_STREAM_MASK) == OSSL_QUIC_FRAME_TYPE_STREAM) -# define OSSL_QUIC_FRAME_TYPE_IS_ACK(x) \ +#define OSSL_QUIC_FRAME_TYPE_IS_ACK(x) \ (((x) & ~(uint64_t)1) == OSSL_QUIC_FRAME_TYPE_ACK_WITHOUT_ECN) -# define OSSL_QUIC_FRAME_TYPE_IS_MAX_STREAMS(x) \ +#define OSSL_QUIC_FRAME_TYPE_IS_MAX_STREAMS(x) \ (((x) & ~(uint64_t)1) == OSSL_QUIC_FRAME_TYPE_MAX_STREAMS_BIDI) -# define OSSL_QUIC_FRAME_TYPE_IS_STREAMS_BLOCKED(x) \ +#define OSSL_QUIC_FRAME_TYPE_IS_STREAMS_BLOCKED(x) \ (((x) & ~(uint64_t)1) == OSSL_QUIC_FRAME_TYPE_STREAMS_BLOCKED_BIDI) -# define OSSL_QUIC_FRAME_TYPE_IS_CONN_CLOSE(x) \ +#define OSSL_QUIC_FRAME_TYPE_IS_CONN_CLOSE(x) \ (((x) & ~(uint64_t)1) == OSSL_QUIC_FRAME_TYPE_CONN_CLOSE_TRANSPORT) const char *ossl_quic_frame_type_to_string(uint64_t frame_type); @@ -105,23 +93,23 @@ ossl_quic_frame_type_is_ack_eliciting(uint64_t frame_type) } /* QUIC Transport Parameter Types */ -# define QUIC_TPARAM_ORIG_DCID 0x00 -# define QUIC_TPARAM_MAX_IDLE_TIMEOUT 0x01 -# define QUIC_TPARAM_STATELESS_RESET_TOKEN 0x02 -# define QUIC_TPARAM_MAX_UDP_PAYLOAD_SIZE 0x03 -# define QUIC_TPARAM_INITIAL_MAX_DATA 0x04 -# define QUIC_TPARAM_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL 0x05 -# define QUIC_TPARAM_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE 0x06 -# define QUIC_TPARAM_INITIAL_MAX_STREAM_DATA_UNI 0x07 -# define QUIC_TPARAM_INITIAL_MAX_STREAMS_BIDI 0x08 -# define QUIC_TPARAM_INITIAL_MAX_STREAMS_UNI 0x09 -# define QUIC_TPARAM_ACK_DELAY_EXP 0x0A -# define QUIC_TPARAM_MAX_ACK_DELAY 0x0B -# define QUIC_TPARAM_DISABLE_ACTIVE_MIGRATION 0x0C -# define QUIC_TPARAM_PREFERRED_ADDR 0x0D -# define QUIC_TPARAM_ACTIVE_CONN_ID_LIMIT 0x0E -# define QUIC_TPARAM_INITIAL_SCID 0x0F -# define QUIC_TPARAM_RETRY_SCID 0x10 +#define QUIC_TPARAM_ORIG_DCID 0x00 +#define QUIC_TPARAM_MAX_IDLE_TIMEOUT 0x01 +#define QUIC_TPARAM_STATELESS_RESET_TOKEN 0x02 +#define QUIC_TPARAM_MAX_UDP_PAYLOAD_SIZE 0x03 +#define QUIC_TPARAM_INITIAL_MAX_DATA 0x04 +#define QUIC_TPARAM_INITIAL_MAX_STREAM_DATA_BIDI_LOCAL 0x05 +#define QUIC_TPARAM_INITIAL_MAX_STREAM_DATA_BIDI_REMOTE 0x06 +#define QUIC_TPARAM_INITIAL_MAX_STREAM_DATA_UNI 0x07 +#define QUIC_TPARAM_INITIAL_MAX_STREAMS_BIDI 0x08 +#define QUIC_TPARAM_INITIAL_MAX_STREAMS_UNI 0x09 +#define QUIC_TPARAM_ACK_DELAY_EXP 0x0A +#define QUIC_TPARAM_MAX_ACK_DELAY 0x0B +#define QUIC_TPARAM_DISABLE_ACTIVE_MIGRATION 0x0C +#define QUIC_TPARAM_PREFERRED_ADDR 0x0D +#define QUIC_TPARAM_ACTIVE_CONN_ID_LIMIT 0x0E +#define QUIC_TPARAM_INITIAL_SCID 0x0F +#define QUIC_TPARAM_RETRY_SCID 0x10 /* * QUIC Frame Logical Representations @@ -153,12 +141,12 @@ typedef struct ossl_quic_frame_ack_st { * num_ack_ranges must be greater than zero, as an ACK frame must * acknowledge at least one packet number. */ - OSSL_QUIC_ACK_RANGE *ack_ranges; - size_t num_ack_ranges; + OSSL_QUIC_ACK_RANGE *ack_ranges; + size_t num_ack_ranges; - OSSL_TIME delay_time; - uint64_t ect0, ect1, ecnce; - unsigned int ecn_present : 1; + OSSL_TIME delay_time; + uint64_t ect0, ect1, ecnce; + unsigned int ecn_present : 1; } OSSL_QUIC_FRAME_ACK; /* Returns 1 if the given frame contains the given PN. */ @@ -166,10 +154,10 @@ int ossl_quic_frame_ack_contains_pn(const OSSL_QUIC_FRAME_ACK *ack, QUIC_PN pn); /* QUIC Frame: STREAM */ typedef struct ossl_quic_frame_stream_st { - uint64_t stream_id; /* Stream ID */ - uint64_t offset; /* Logical offset in stream */ - uint64_t len; /* Length of data in bytes */ - const unsigned char *data; + uint64_t stream_id; /* Stream ID */ + uint64_t offset; /* Logical offset in stream */ + uint64_t len; /* Length of data in bytes */ + const unsigned char *data; /* * On encode, this determines whether the len field should be encoded or @@ -180,47 +168,47 @@ typedef struct ossl_quic_frame_stream_st { * length. If not set, the frame runs to the end of the packet and len has * been set accordingly. */ - unsigned int has_explicit_len : 1; + unsigned int has_explicit_len : 1; /* 1 if this is the end of the stream */ - unsigned int is_fin : 1; + unsigned int is_fin : 1; } OSSL_QUIC_FRAME_STREAM; /* QUIC Frame: CRYPTO */ typedef struct ossl_quic_frame_crypto_st { - uint64_t offset; /* Logical offset in stream */ - uint64_t len; /* Length of the data in bytes */ - const unsigned char *data; + uint64_t offset; /* Logical offset in stream */ + uint64_t len; /* Length of the data in bytes */ + const unsigned char *data; } OSSL_QUIC_FRAME_CRYPTO; /* QUIC Frame: RESET_STREAM */ typedef struct ossl_quic_frame_reset_stream_st { - uint64_t stream_id; - uint64_t app_error_code; - uint64_t final_size; + uint64_t stream_id; + uint64_t app_error_code; + uint64_t final_size; } OSSL_QUIC_FRAME_RESET_STREAM; /* QUIC Frame: STOP_SENDING */ typedef struct ossl_quic_frame_stop_sending_st { - uint64_t stream_id; - uint64_t app_error_code; + uint64_t stream_id; + uint64_t app_error_code; } OSSL_QUIC_FRAME_STOP_SENDING; /* QUIC Frame: NEW_CONNECTION_ID */ typedef struct ossl_quic_frame_new_conn_id_st { - uint64_t seq_num; - uint64_t retire_prior_to; - QUIC_CONN_ID conn_id; - QUIC_STATELESS_RESET_TOKEN stateless_reset; + uint64_t seq_num; + uint64_t retire_prior_to; + QUIC_CONN_ID conn_id; + QUIC_STATELESS_RESET_TOKEN stateless_reset; } OSSL_QUIC_FRAME_NEW_CONN_ID; /* QUIC Frame: CONNECTION_CLOSE */ typedef struct ossl_quic_frame_conn_close_st { - unsigned int is_app : 1; /* 0: transport error, 1: app error */ - uint64_t error_code; /* 62-bit transport or app error code */ - uint64_t frame_type; /* transport errors only */ - char *reason; /* UTF-8 string, not necessarily zero-terminated */ - size_t reason_len; /* Length of reason in bytes */ + unsigned int is_app : 1; /* 0: transport error, 1: app error */ + uint64_t error_code; /* 62-bit transport or app error code */ + uint64_t frame_type; /* transport errors only */ + char *reason; /* UTF-8 string, not necessarily zero-terminated */ + size_t reason_len; /* Length of reason in bytes */ } OSSL_QUIC_FRAME_CONN_CLOSE; /* @@ -240,7 +228,7 @@ int ossl_quic_wire_encode_padding(WPACKET *pkt, size_t num_bytes); /* * Encodes a QUIC PING frame to the packet writer. This frame type takes * no arguments. -*/ + */ int ossl_quic_wire_encode_frame_ping(WPACKET *pkt); /* @@ -258,22 +246,22 @@ int ossl_quic_wire_encode_frame_ping(WPACKET *pkt); * the value used when decoding. */ int ossl_quic_wire_encode_frame_ack(WPACKET *pkt, - uint32_t ack_delay_exponent, - const OSSL_QUIC_FRAME_ACK *ack); + uint32_t ack_delay_exponent, + const OSSL_QUIC_FRAME_ACK *ack); /* * Encodes a QUIC RESET_STREAM frame to the packet writer, given a logical * representation of the RESET_STREAM frame. */ int ossl_quic_wire_encode_frame_reset_stream(WPACKET *pkt, - const OSSL_QUIC_FRAME_RESET_STREAM *f); + const OSSL_QUIC_FRAME_RESET_STREAM *f); /* * Encodes a QUIC STOP_SENDING frame to the packet writer, given a logical * representation of the STOP_SENDING frame. */ int ossl_quic_wire_encode_frame_stop_sending(WPACKET *pkt, - const OSSL_QUIC_FRAME_STOP_SENDING *f); + const OSSL_QUIC_FRAME_STOP_SENDING *f); /* * Encodes a QUIC CRYPTO frame header to the packet writer. @@ -282,7 +270,7 @@ int ossl_quic_wire_encode_frame_stop_sending(WPACKET *pkt, * immediately followed by f->len bytes of data. */ int ossl_quic_wire_encode_frame_crypto_hdr(WPACKET *hdr, - const OSSL_QUIC_FRAME_CRYPTO *f); + const OSSL_QUIC_FRAME_CRYPTO *f); /* * Returns the number of bytes which will be required to encode the given @@ -300,14 +288,14 @@ size_t ossl_quic_wire_get_encoded_frame_len_crypto_hdr(const OSSL_QUIC_FRAME_CRY * buffer. Returns NULL on failure. */ void *ossl_quic_wire_encode_frame_crypto(WPACKET *pkt, - const OSSL_QUIC_FRAME_CRYPTO *f); + const OSSL_QUIC_FRAME_CRYPTO *f); /* * Encodes a QUIC NEW_TOKEN frame to the packet writer. */ int ossl_quic_wire_encode_frame_new_token(WPACKET *pkt, - const unsigned char *token, - size_t token_len); + const unsigned char *token, + size_t token_len); /* * Encodes a QUIC STREAM frame's header to the packet writer. The f->stream_id, @@ -325,7 +313,7 @@ int ossl_quic_wire_encode_frame_new_token(WPACKET *pkt, * immediately followed by f->len bytes of stream data. */ int ossl_quic_wire_encode_frame_stream_hdr(WPACKET *pkt, - const OSSL_QUIC_FRAME_STREAM *f); + const OSSL_QUIC_FRAME_STREAM *f); /* * Returns the number of bytes which will be required to encode the given @@ -345,20 +333,20 @@ size_t ossl_quic_wire_get_encoded_frame_len_stream_hdr(const OSSL_QUIC_FRAME_STR * must fill the returned buffer. Returns NULL on failure. */ void *ossl_quic_wire_encode_frame_stream(WPACKET *pkt, - const OSSL_QUIC_FRAME_STREAM *f); + const OSSL_QUIC_FRAME_STREAM *f); /* * Encodes a QUIC MAX_DATA frame to the packet writer. */ int ossl_quic_wire_encode_frame_max_data(WPACKET *pkt, - uint64_t max_data); + uint64_t max_data); /* * Encodes a QUIC MAX_STREAM_DATA frame to the packet writer. */ int ossl_quic_wire_encode_frame_max_stream_data(WPACKET *pkt, - uint64_t stream_id, - uint64_t max_data); + uint64_t stream_id, + uint64_t max_data); /* * Encodes a QUIC MAX_STREAMS frame to the packet writer. @@ -368,21 +356,21 @@ int ossl_quic_wire_encode_frame_max_stream_data(WPACKET *pkt, * streams. */ int ossl_quic_wire_encode_frame_max_streams(WPACKET *pkt, - char is_uni, - uint64_t max_streams); + char is_uni, + uint64_t max_streams); /* * Encodes a QUIC DATA_BLOCKED frame to the packet writer. */ int ossl_quic_wire_encode_frame_data_blocked(WPACKET *pkt, - uint64_t max_data); + uint64_t max_data); /* * Encodes a QUIC STREAM_DATA_BLOCKED frame to the packet writer. */ int ossl_quic_wire_encode_frame_stream_data_blocked(WPACKET *pkt, - uint64_t stream_id, - uint64_t max_stream_data); + uint64_t stream_id, + uint64_t max_stream_data); /* * Encodes a QUIC STREAMS_BLOCKED frame to the packet writer. * @@ -391,8 +379,8 @@ int ossl_quic_wire_encode_frame_stream_data_blocked(WPACKET *pkt, * streams. */ int ossl_quic_wire_encode_frame_streams_blocked(WPACKET *pkt, - char is_uni, - uint64_t max_streams); + char is_uni, + uint64_t max_streams); /* * Encodes a QUIC NEW_CONNECTION_ID frame to the packet writer, given a logical @@ -402,25 +390,25 @@ int ossl_quic_wire_encode_frame_streams_blocked(WPACKET *pkt, * the call. */ int ossl_quic_wire_encode_frame_new_conn_id(WPACKET *pkt, - const OSSL_QUIC_FRAME_NEW_CONN_ID *f); + const OSSL_QUIC_FRAME_NEW_CONN_ID *f); /* * Encodes a QUIC RETIRE_CONNECTION_ID frame to the packet writer. */ int ossl_quic_wire_encode_frame_retire_conn_id(WPACKET *pkt, - uint64_t seq_num); + uint64_t seq_num); /* * Encodes a QUIC PATH_CHALLENGE frame to the packet writer. */ int ossl_quic_wire_encode_frame_path_challenge(WPACKET *pkt, - uint64_t data); + uint64_t data); /* * Encodes a QUIC PATH_RESPONSE frame to the packet writer. */ int ossl_quic_wire_encode_frame_path_response(WPACKET *pkt, - uint64_t data); + uint64_t data); /* * Encodes a QUIC CONNECTION_CLOSE frame to the packet writer, given a logical @@ -432,7 +420,7 @@ int ossl_quic_wire_encode_frame_path_response(WPACKET *pkt, * reason string need not be zero terminated. */ int ossl_quic_wire_encode_frame_conn_close(WPACKET *pkt, - const OSSL_QUIC_FRAME_CONN_CLOSE *f); + const OSSL_QUIC_FRAME_CONN_CLOSE *f); /* * Encodes a QUIC HANDSHAKE_DONE frame to the packet writer. This frame type @@ -451,25 +439,25 @@ int ossl_quic_wire_encode_frame_handshake_done(WPACKET *pkt); * Returns a pointer to the start of the payload on success, or NULL on failure. */ unsigned char *ossl_quic_wire_encode_transport_param_bytes(WPACKET *pkt, - uint64_t id, - const unsigned char *value, - size_t value_len); + uint64_t id, + const unsigned char *value, + size_t value_len); /* * Encodes a QUIC transport parameter TLV with the given ID into the WPACKET. * The payload is a QUIC variable-length integer with the given value. */ int ossl_quic_wire_encode_transport_param_int(WPACKET *pkt, - uint64_t id, - uint64_t value); + uint64_t id, + uint64_t value); /* * Encodes a QUIC transport parameter TLV with a given ID into the WPACKET. * The payload is a QUIC connection ID. */ int ossl_quic_wire_encode_transport_param_cid(WPACKET *wpkt, - uint64_t id, - const QUIC_CONN_ID *cid); + uint64_t id, + const QUIC_CONN_ID *cid); /* * QUIC Wire Format Decoding @@ -496,7 +484,7 @@ int ossl_quic_wire_encode_transport_param_cid(WPACKET *wpkt, * frame decoding function to call. */ int ossl_quic_wire_peek_frame_header(PACKET *pkt, uint64_t *type, - int *was_minimal); + int *was_minimal); /* * Like ossl_quic_wire_peek_frame_header, but advances the current position @@ -513,7 +501,7 @@ int ossl_quic_wire_skip_frame_header(PACKET *pkt, uint64_t *type); * The PACKET is not advanced. */ int ossl_quic_wire_peek_frame_ack_num_ranges(const PACKET *pkt, - uint64_t *total_ranges); + uint64_t *total_ranges); /* * Decodes a QUIC ACK frame. The ack_ranges field of the passed structure should @@ -543,21 +531,21 @@ int ossl_quic_wire_peek_frame_ack_num_ranges(const PACKET *pkt, * to encode the frame. */ int ossl_quic_wire_decode_frame_ack(PACKET *pkt, - uint32_t ack_delay_exponent, - OSSL_QUIC_FRAME_ACK *ack, - uint64_t *total_ranges); + uint32_t ack_delay_exponent, + OSSL_QUIC_FRAME_ACK *ack, + uint64_t *total_ranges); /* * Decodes a QUIC RESET_STREAM frame. */ int ossl_quic_wire_decode_frame_reset_stream(PACKET *pkt, - OSSL_QUIC_FRAME_RESET_STREAM *f); + OSSL_QUIC_FRAME_RESET_STREAM *f); /* * Decodes a QUIC STOP_SENDING frame. */ int ossl_quic_wire_decode_frame_stop_sending(PACKET *pkt, - OSSL_QUIC_FRAME_STOP_SENDING *f); + OSSL_QUIC_FRAME_STOP_SENDING *f); /* * Decodes a QUIC CRYPTO frame. @@ -568,15 +556,15 @@ int ossl_quic_wire_decode_frame_stop_sending(PACKET *pkt, * set to NULL. */ int ossl_quic_wire_decode_frame_crypto(PACKET *pkt, int nodata, - OSSL_QUIC_FRAME_CRYPTO *f); + OSSL_QUIC_FRAME_CRYPTO *f); /* * Decodes a QUIC NEW_TOKEN frame. *token is written with a pointer to the token * bytes and *token_len is written with the length of the token in bytes. */ -int ossl_quic_wire_decode_frame_new_token(PACKET *pkt, - const unsigned char **token, - size_t *token_len); +int ossl_quic_wire_decode_frame_new_token(PACKET *pkt, + const unsigned char **token, + size_t *token_len); /* * Decodes a QUIC STREAM frame. @@ -608,22 +596,22 @@ int ossl_quic_wire_decode_frame_new_token(PACKET *pkt, * stream. */ int ossl_quic_wire_decode_frame_stream(PACKET *pkt, int nodata, - OSSL_QUIC_FRAME_STREAM *f); + OSSL_QUIC_FRAME_STREAM *f); /* * Decodes a QUIC MAX_DATA frame. The Maximum Data field is written to * *max_data. */ int ossl_quic_wire_decode_frame_max_data(PACKET *pkt, - uint64_t *max_data); + uint64_t *max_data); /* * Decodes a QUIC MAX_STREAM_DATA frame. The Stream ID is written to *stream_id * and Maximum Stream Data field is written to *max_stream_data. */ int ossl_quic_wire_decode_frame_max_stream_data(PACKET *pkt, - uint64_t *stream_id, - uint64_t *max_stream_data); + uint64_t *stream_id, + uint64_t *max_stream_data); /* * Decodes a QUIC MAX_STREAMS frame. The Maximum Streams field is written to * *max_streams. @@ -633,22 +621,22 @@ int ossl_quic_wire_decode_frame_max_stream_data(PACKET *pkt, * determine this. */ int ossl_quic_wire_decode_frame_max_streams(PACKET *pkt, - uint64_t *max_streams); + uint64_t *max_streams); /* * Decodes a QUIC DATA_BLOCKED frame. The Maximum Data field is written to * *max_data. */ int ossl_quic_wire_decode_frame_data_blocked(PACKET *pkt, - uint64_t *max_data); + uint64_t *max_data); /* * Decodes a QUIC STREAM_DATA_BLOCKED frame. The Stream ID and Maximum Stream * Data fields are written to *stream_id and *max_stream_data respectively. */ int ossl_quic_wire_decode_frame_stream_data_blocked(PACKET *pkt, - uint64_t *stream_id, - uint64_t *max_stream_data); + uint64_t *stream_id, + uint64_t *max_stream_data); /* * Decodes a QUIC STREAMS_BLOCKED frame. The Maximum Streams field is written to @@ -659,8 +647,7 @@ int ossl_quic_wire_decode_frame_stream_data_blocked(PACKET *pkt, * determine this. */ int ossl_quic_wire_decode_frame_streams_blocked(PACKET *pkt, - uint64_t *max_streams); - + uint64_t *max_streams); /* * Decodes a QUIC NEW_CONNECTION_ID frame. The logical representation of the @@ -672,26 +659,26 @@ int ossl_quic_wire_decode_frame_streams_blocked(PACKET *pkt, * in bytes. */ int ossl_quic_wire_decode_frame_new_conn_id(PACKET *pkt, - OSSL_QUIC_FRAME_NEW_CONN_ID *f); + OSSL_QUIC_FRAME_NEW_CONN_ID *f); /* * Decodes a QUIC RETIRE_CONNECTION_ID frame. The Sequence Number field * is written to *seq_num. */ int ossl_quic_wire_decode_frame_retire_conn_id(PACKET *pkt, - uint64_t *seq_num); + uint64_t *seq_num); /* * Decodes a QUIC PATH_CHALLENGE frame. The Data field is written to *data. */ int ossl_quic_wire_decode_frame_path_challenge(PACKET *pkt, - uint64_t *data); + uint64_t *data); /* * Decodes a QUIC PATH_CHALLENGE frame. The Data field is written to *data. */ int ossl_quic_wire_decode_frame_path_response(PACKET *pkt, - uint64_t *data); + uint64_t *data); /* * Decodes a QUIC CONNECTION_CLOSE frame. The logical representation @@ -707,7 +694,7 @@ int ossl_quic_wire_decode_frame_path_response(PACKET *pkt, * Returns 1 on success or 0 on failure. */ int ossl_quic_wire_decode_frame_conn_close(PACKET *pkt, - OSSL_QUIC_FRAME_CONN_CLOSE *f); + OSSL_QUIC_FRAME_CONN_CLOSE *f); /* * Decodes one or more PADDING frames. PADDING frames have no arguments. @@ -743,8 +730,8 @@ int ossl_quic_wire_peek_transport_param(PACKET *pkt, uint64_t *id); * Returns NULL on failure. */ const unsigned char *ossl_quic_wire_decode_transport_param_bytes(PACKET *pkt, - uint64_t *id, - size_t *len); + uint64_t *id, + size_t *len); /* * Decodes a QUIC transport parameter TLV containing a variable-length integer. @@ -753,8 +740,8 @@ const unsigned char *ossl_quic_wire_decode_transport_param_bytes(PACKET *pkt, * written to *value. */ int ossl_quic_wire_decode_transport_param_int(PACKET *pkt, - uint64_t *id, - uint64_t *value); + uint64_t *id, + uint64_t *value); /* * Decodes a QUIC transport parameter TLV containing a connection ID. @@ -763,22 +750,22 @@ int ossl_quic_wire_decode_transport_param_int(PACKET *pkt, * written to *value. */ int ossl_quic_wire_decode_transport_param_cid(PACKET *pkt, - uint64_t *id, - QUIC_CONN_ID *cid); + uint64_t *id, + QUIC_CONN_ID *cid); /* * Decodes a QUIC transport parameter TLV containing a preferred_address. */ typedef struct quic_preferred_addr_st { - uint16_t ipv4_port, ipv6_port; - unsigned char ipv4[4], ipv6[16]; - QUIC_STATELESS_RESET_TOKEN stateless_reset; - QUIC_CONN_ID cid; + uint16_t ipv4_port, ipv6_port; + unsigned char ipv4[4], ipv6[16]; + QUIC_STATELESS_RESET_TOKEN stateless_reset; + QUIC_CONN_ID cid; } QUIC_PREFERRED_ADDR; int ossl_quic_wire_decode_transport_param_preferred_addr(PACKET *pkt, - QUIC_PREFERRED_ADDR *p); + QUIC_PREFERRED_ADDR *p); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/quic_wire_pkt.h b/crypto/openssl/include/internal/quic_wire_pkt.h index 8688253eaeef..657bad58b050 100644 --- a/crypto/openssl/include/internal/quic_wire_pkt.h +++ b/crypto/openssl/include/internal/quic_wire_pkt.h @@ -8,24 +8,24 @@ */ #ifndef OSSL_QUIC_WIRE_PKT_H -# define OSSL_QUIC_WIRE_PKT_H +#define OSSL_QUIC_WIRE_PKT_H -# include <openssl/ssl.h> -# include "internal/packet_quic.h" -# include "internal/quic_types.h" +#include <openssl/ssl.h> +#include "internal/packet_quic.h" +#include "internal/quic_types.h" -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC -# define QUIC_VERSION_NONE ((uint32_t)0) /* Used for version negotiation */ -# define QUIC_VERSION_1 ((uint32_t)1) /* QUIC v1 */ +#define QUIC_VERSION_NONE ((uint32_t)0) /* Used for version negotiation */ +#define QUIC_VERSION_1 ((uint32_t)1) /* QUIC v1 */ /* QUIC logical packet type. These do not match wire values. */ -# define QUIC_PKT_TYPE_INITIAL 1 -# define QUIC_PKT_TYPE_0RTT 2 -# define QUIC_PKT_TYPE_HANDSHAKE 3 -# define QUIC_PKT_TYPE_RETRY 4 -# define QUIC_PKT_TYPE_1RTT 5 -# define QUIC_PKT_TYPE_VERSION_NEG 6 +#define QUIC_PKT_TYPE_INITIAL 1 +#define QUIC_PKT_TYPE_0RTT 2 +#define QUIC_PKT_TYPE_HANDSHAKE 3 +#define QUIC_PKT_TYPE_RETRY 4 +#define QUIC_PKT_TYPE_1RTT 5 +#define QUIC_PKT_TYPE_VERSION_NEG 6 /* * Determine encryption level from packet type. Returns QUIC_ENC_LEVEL_NUM if @@ -35,16 +35,16 @@ static ossl_inline ossl_unused uint32_t ossl_quic_pkt_type_to_enc_level(uint32_t pkt_type) { switch (pkt_type) { - case QUIC_PKT_TYPE_INITIAL: - return QUIC_ENC_LEVEL_INITIAL; - case QUIC_PKT_TYPE_HANDSHAKE: - return QUIC_ENC_LEVEL_HANDSHAKE; - case QUIC_PKT_TYPE_0RTT: - return QUIC_ENC_LEVEL_0RTT; - case QUIC_PKT_TYPE_1RTT: - return QUIC_ENC_LEVEL_1RTT; - default: - return QUIC_ENC_LEVEL_NUM; + case QUIC_PKT_TYPE_INITIAL: + return QUIC_ENC_LEVEL_INITIAL; + case QUIC_PKT_TYPE_HANDSHAKE: + return QUIC_ENC_LEVEL_HANDSHAKE; + case QUIC_PKT_TYPE_0RTT: + return QUIC_ENC_LEVEL_0RTT; + case QUIC_PKT_TYPE_1RTT: + return QUIC_ENC_LEVEL_1RTT; + default: + return QUIC_ENC_LEVEL_NUM; } } @@ -52,16 +52,16 @@ static ossl_inline ossl_unused uint32_t ossl_quic_enc_level_to_pkt_type(uint32_t enc_level) { switch (enc_level) { - case QUIC_ENC_LEVEL_INITIAL: - return QUIC_PKT_TYPE_INITIAL; - case QUIC_ENC_LEVEL_HANDSHAKE: - return QUIC_PKT_TYPE_HANDSHAKE; - case QUIC_ENC_LEVEL_0RTT: - return QUIC_PKT_TYPE_0RTT; - case QUIC_ENC_LEVEL_1RTT: - return QUIC_PKT_TYPE_1RTT; - default: - return UINT32_MAX; + case QUIC_ENC_LEVEL_INITIAL: + return QUIC_PKT_TYPE_INITIAL; + case QUIC_ENC_LEVEL_HANDSHAKE: + return QUIC_PKT_TYPE_HANDSHAKE; + case QUIC_ENC_LEVEL_0RTT: + return QUIC_PKT_TYPE_0RTT; + case QUIC_ENC_LEVEL_1RTT: + return QUIC_PKT_TYPE_1RTT; + default: + return UINT32_MAX; } } @@ -70,11 +70,11 @@ static ossl_inline ossl_unused int ossl_quic_pkt_type_is_encrypted(uint32_t pkt_type) { switch (pkt_type) { - case QUIC_PKT_TYPE_RETRY: - case QUIC_PKT_TYPE_VERSION_NEG: - return 0; - default: - return 1; + case QUIC_PKT_TYPE_RETRY: + case QUIC_PKT_TYPE_VERSION_NEG: + return 0; + default: + return 1; } } @@ -140,9 +140,9 @@ ossl_quic_pkt_type_has_scid(uint32_t pkt_type) * Smallest possible QUIC packet size as per RFC (aside from version negotiation * packets). */ -# define QUIC_MIN_VALID_PKT_LEN_CRYPTO 21 -# define QUIC_MIN_VALID_PKT_LEN_VERSION_NEG 7 -# define QUIC_MIN_VALID_PKT_LEN QUIC_MIN_VALID_PKT_LEN_VERSION_NEG +#define QUIC_MIN_VALID_PKT_LEN_CRYPTO 21 +#define QUIC_MIN_VALID_PKT_LEN_VERSION_NEG 7 +#define QUIC_MIN_VALID_PKT_LEN QUIC_MIN_VALID_PKT_LEN_VERSION_NEG typedef struct quic_pkt_hdr_ptrs_st QUIC_PKT_HDR_PTRS; @@ -155,16 +155,16 @@ typedef struct quic_pkt_hdr_ptrs_st QUIC_PKT_HDR_PTRS; * destroyed using ossl_quic_hdr_protector_cleanup when no longer needed. */ typedef struct quic_hdr_protector_st { - OSSL_LIB_CTX *libctx; - const char *propq; - EVP_CIPHER_CTX *cipher_ctx; - EVP_CIPHER *cipher; - uint32_t cipher_id; + OSSL_LIB_CTX *libctx; + const char *propq; + EVP_CIPHER_CTX *cipher_ctx; + EVP_CIPHER *cipher; + uint32_t cipher_id; } QUIC_HDR_PROTECTOR; -# define QUIC_HDR_PROT_CIPHER_AES_128 1 -# define QUIC_HDR_PROT_CIPHER_AES_256 2 -# define QUIC_HDR_PROT_CIPHER_CHACHA 3 +#define QUIC_HDR_PROT_CIPHER_AES_128 1 +#define QUIC_HDR_PROT_CIPHER_AES_256 2 +#define QUIC_HDR_PROT_CIPHER_CHACHA 3 /* * Initialises a header protector. @@ -186,11 +186,11 @@ typedef struct quic_hdr_protector_st { * Returns 1 on success and 0 on failure. */ int ossl_quic_hdr_protector_init(QUIC_HDR_PROTECTOR *hpr, - OSSL_LIB_CTX *libctx, - const char *propq, - uint32_t cipher_id, - const unsigned char *quic_hp_key, - size_t quic_hp_key_len); + OSSL_LIB_CTX *libctx, + const char *propq, + uint32_t cipher_id, + const unsigned char *quic_hp_key, + size_t quic_hp_key_len); /* * Destroys a header protector. This is also safe to call on a zero-initialized @@ -212,7 +212,7 @@ void ossl_quic_hdr_protector_cleanup(QUIC_HDR_PROTECTOR *hpr); * Returns 1 on success and 0 on failure. */ int ossl_quic_hdr_protector_decrypt(QUIC_HDR_PROTECTOR *hpr, - QUIC_PKT_HDR_PTRS *ptrs); + QUIC_PKT_HDR_PTRS *ptrs); /* * Applies header protection to a packet. The packet payload must already have @@ -225,7 +225,7 @@ int ossl_quic_hdr_protector_decrypt(QUIC_HDR_PROTECTOR *hpr, * Returns 1 on success and 0 on failure. */ int ossl_quic_hdr_protector_encrypt(QUIC_HDR_PROTECTOR *hpr, - QUIC_PKT_HDR_PTRS *ptrs); + QUIC_PKT_HDR_PTRS *ptrs); /* * Removes header protection from a packet. The packet payload must currently @@ -248,20 +248,20 @@ int ossl_quic_hdr_protector_encrypt(QUIC_HDR_PROTECTOR *hpr, * Returns 1 on success and 0 on failure. */ int ossl_quic_hdr_protector_decrypt_fields(QUIC_HDR_PROTECTOR *hpr, - const unsigned char *sample, - size_t sample_len, - unsigned char *first_byte, - unsigned char *pn_bytes); + const unsigned char *sample, + size_t sample_len, + unsigned char *first_byte, + unsigned char *pn_bytes); /* * Works analogously to ossl_hdr_protector_decrypt_fields, but applies header * protection instead of removing it. */ int ossl_quic_hdr_protector_encrypt_fields(QUIC_HDR_PROTECTOR *hpr, - const unsigned char *sample, - size_t sample_len, - unsigned char *first_byte, - unsigned char *pn_bytes); + const unsigned char *sample, + size_t sample_len, + unsigned char *first_byte, + unsigned char *pn_bytes); /* * QUIC Packet Header @@ -310,29 +310,29 @@ int ossl_quic_hdr_protector_encrypt_fields(QUIC_HDR_PROTECTOR *hpr, */ typedef struct quic_pkt_hdr_st { /* [ALL] A QUIC_PKT_TYPE_* value. Always valid. */ - unsigned int type :8; + unsigned int type : 8; /* [S] Value of the spin bit. Valid if (type == 1RTT). */ - unsigned int spin_bit :1; + unsigned int spin_bit : 1; /* * [S] Value of the Key Phase bit in the short packet. * Valid if (type == 1RTT && !partial). */ - unsigned int key_phase :1; + unsigned int key_phase : 1; /* * [1i0h] Length of packet number in bytes. This is the decoded value. * Valid if ((type == 1RTT || (version && type != RETRY)) && !partial). */ - unsigned int pn_len :4; + unsigned int pn_len : 4; /* * [ALL] Set to 1 if this is a partial decode because the packet header * has not yet been deprotected. pn_len, pn and key_phase are not valid if * this is set. */ - unsigned int partial :1; + unsigned int partial : 1; /* * [ALL] Whether the fixed bit was set. Note that only Version Negotiation @@ -340,7 +340,7 @@ typedef struct quic_pkt_hdr_st { * other packet types (decode will fail if it is not set). Ignored when * encoding unless encoding a Version Negotiation packet. */ - unsigned int fixed :1; + unsigned int fixed : 1; /* * The unused bits in the low 4 bits of a Retry packet header's first byte. @@ -348,7 +348,7 @@ typedef struct quic_pkt_hdr_st { * representation in their header when decoding and encoding them again. * This is necessary to validate Retry packet headers. */ - unsigned int unused :4; + unsigned int unused : 4; /* * The 'Reserved' bits in an Initial, Handshake, 0-RTT or 1-RTT packet @@ -356,19 +356,19 @@ typedef struct quic_pkt_hdr_st { * that they are zero, as this must be done after packet protection is * successfully removed to avoid creating a timing channel. */ - unsigned int reserved :2; + unsigned int reserved : 2; /* [L] Version field. Valid if (type != 1RTT). */ - uint32_t version; + uint32_t version; /* [ALL] The destination connection ID. Always valid. */ - QUIC_CONN_ID dst_conn_id; + QUIC_CONN_ID dst_conn_id; /* * [L] The source connection ID. * Valid if (type != 1RTT). */ - QUIC_CONN_ID src_conn_id; + QUIC_CONN_ID src_conn_id; /* * [1i0h] Relatively-encoded packet number in raw, encoded form. The correct @@ -378,7 +378,7 @@ typedef struct quic_pkt_hdr_st { * * Valid if ((type == 1RTT || (version && type != RETRY)) && !partial). */ - unsigned char pn[4]; + unsigned char pn[4]; /* * [i] Token field in Initial packet. Points to memory inside the decoded @@ -387,8 +387,8 @@ typedef struct quic_pkt_hdr_st { * * Valid if (type == INITIAL). */ - const unsigned char *token; - size_t token_len; + const unsigned char *token; + size_t token_len; /* * [ALL] Payload length in bytes. @@ -399,7 +399,7 @@ typedef struct quic_pkt_hdr_st { * length, regardless of whether the packet type encoded or decoded uses an * explicit length indication. */ - size_t len; + size_t len; /* * Pointer to start of payload data in the packet. Points to memory inside @@ -424,7 +424,7 @@ typedef struct quic_pkt_hdr_st { * this case (i.e., the len field is the number of payload bytes plus the * number of bytes comprising the PN). */ - const unsigned char *data; + const unsigned char *data; } QUIC_PKT_HDR; /* @@ -433,15 +433,15 @@ typedef struct quic_pkt_hdr_st { * needing to partially re-decode the packet header. */ struct quic_pkt_hdr_ptrs_st { - unsigned char *raw_start; /* start of packet */ - unsigned char *raw_sample; /* start of sampling range */ - size_t raw_sample_len; /* maximum length of sampling range */ + unsigned char *raw_start; /* start of packet */ + unsigned char *raw_sample; /* start of sampling range */ + size_t raw_sample_len; /* maximum length of sampling range */ /* * Start of PN field. Guaranteed to be NULL unless at least four bytes are * available via this pointer. */ - unsigned char *raw_pn; + unsigned char *raw_pn; }; /* @@ -472,16 +472,16 @@ struct quic_pkt_hdr_ptrs_st { * Returns 1 on success and 0 on failure. */ -# define QUIC_PKT_HDR_DECODE_DECODE_ERR (1 << 0) -# define QUIC_PKT_HDR_DECODE_BAD_VERSION (1 << 1) +#define QUIC_PKT_HDR_DECODE_DECODE_ERR (1 << 0) +#define QUIC_PKT_HDR_DECODE_BAD_VERSION (1 << 1) int ossl_quic_wire_decode_pkt_hdr(PACKET *pkt, - size_t short_conn_id_len, - int partial, - int nodata, - QUIC_PKT_HDR *hdr, - QUIC_PKT_HDR_PTRS *ptrs, - uint64_t *fail_cause); + size_t short_conn_id_len, + int partial, + int nodata, + QUIC_PKT_HDR *hdr, + QUIC_PKT_HDR_PTRS *ptrs, + uint64_t *fail_cause); /* * Encodes a packet header. The packet is written to pkt. @@ -519,9 +519,9 @@ int ossl_quic_wire_decode_pkt_hdr(PACKET *pkt, * Returns 1 on success and 0 on failure. */ int ossl_quic_wire_encode_pkt_hdr(WPACKET *pkt, - size_t short_conn_id_len, - const QUIC_PKT_HDR *hdr, - QUIC_PKT_HDR_PTRS *ptrs); + size_t short_conn_id_len, + const QUIC_PKT_HDR *hdr, + QUIC_PKT_HDR_PTRS *ptrs); /* * Retrieves only the DCID from a packet header. This is intended for demuxer @@ -534,9 +534,9 @@ int ossl_quic_wire_encode_pkt_hdr(WPACKET *pkt, * Returns 1 on success and 0 on failure. */ int ossl_quic_wire_get_pkt_hdr_dst_conn_id(const unsigned char *buf, - size_t buf_len, - size_t short_conn_id_len, - QUIC_CONN_ID *dst_conn_id); + size_t buf_len, + size_t short_conn_id_len, + QUIC_CONN_ID *dst_conn_id); /* * Precisely predicts the encoded length of a packet header structure. @@ -546,7 +546,7 @@ int ossl_quic_wire_get_pkt_hdr_dst_conn_id(const unsigned char *buf, * ossl_quic_wire_encode_pkt_hdr() will succeed. */ int ossl_quic_wire_get_encoded_pkt_hdr_len(size_t short_conn_id_len, - const QUIC_PKT_HDR *hdr); + const QUIC_PKT_HDR *hdr); /* * Packet Number Encoding @@ -565,9 +565,9 @@ int ossl_quic_wire_get_encoded_pkt_hdr_len(size_t short_conn_id_len, * Returns 1 on success or 0 on failure. */ int ossl_quic_wire_decode_pkt_hdr_pn(const unsigned char *enc_pn, - size_t enc_pn_len, - QUIC_PN largest_pn, - QUIC_PN *res_pn); + size_t enc_pn_len, + QUIC_PN largest_pn, + QUIC_PN *res_pn); /* * Determine how many bytes should be used to encode a PN. Returns the number of @@ -584,15 +584,15 @@ int ossl_quic_wire_determine_pn_len(QUIC_PN pn, QUIC_PN largest_acked); * Returns 1 on success and 0 on failure. */ int ossl_quic_wire_encode_pkt_hdr_pn(QUIC_PN pn, - unsigned char *enc_pn, - size_t enc_pn_len); + unsigned char *enc_pn, + size_t enc_pn_len); /* * Retry Integrity Tags * ==================== */ -# define QUIC_RETRY_INTEGRITY_TAG_LEN 16 +#define QUIC_RETRY_INTEGRITY_TAG_LEN 16 /* * Validate a retry integrity tag. Returns 1 if the tag is valid. @@ -607,9 +607,9 @@ int ossl_quic_wire_encode_pkt_hdr_pn(QUIC_PN pn, * the body is too short. */ int ossl_quic_validate_retry_integrity_tag(OSSL_LIB_CTX *libctx, - const char *propq, - const QUIC_PKT_HDR *hdr, - const QUIC_CONN_ID *client_initial_dcid); + const char *propq, + const QUIC_PKT_HDR *hdr, + const QUIC_CONN_ID *client_initial_dcid); /* * Calculates a retry integrity tag. Returns 0 on error, for example if hdr does @@ -628,11 +628,11 @@ int ossl_quic_validate_retry_integrity_tag(OSSL_LIB_CTX *libctx, * Retry Integrity Tag. */ int ossl_quic_calculate_retry_integrity_tag(OSSL_LIB_CTX *libctx, - const char *propq, - const QUIC_PKT_HDR *hdr, - const QUIC_CONN_ID *client_initial_dcid, - unsigned char *tag); + const char *propq, + const QUIC_PKT_HDR *hdr, + const QUIC_CONN_ID *client_initial_dcid, + unsigned char *tag); -# endif +#endif #endif diff --git a/crypto/openssl/include/internal/rcu.h b/crypto/openssl/include/internal/rcu.h index 90160e8da71d..a89794c0c8ad 100644 --- a/crypto/openssl/include/internal/rcu.h +++ b/crypto/openssl/include/internal/rcu.h @@ -8,8 +8,8 @@ */ #ifndef OPENSSL_RCU_H -# define OPENSSL_RCU_H -# pragma once +#define OPENSSL_RCU_H +#pragma once #include "crypto/context.h" @@ -28,6 +28,6 @@ int ossl_rcu_call(CRYPTO_RCU_LOCK *lock, rcu_cb_fn cb, void *data); void *ossl_rcu_uptr_deref(void **p); void ossl_rcu_assign_uptr(void **p, void **v); #define ossl_rcu_deref(p) ossl_rcu_uptr_deref((void **)p) -#define ossl_rcu_assign_ptr(p,v) ossl_rcu_assign_uptr((void **)p, (void **)v) +#define ossl_rcu_assign_ptr(p, v) ossl_rcu_assign_uptr((void **)p, (void **)v) #endif diff --git a/crypto/openssl/include/internal/recordmethod.h b/crypto/openssl/include/internal/recordmethod.h index b36c74c7f3b7..eedded636c2f 100644 --- a/crypto/openssl/include/internal/recordmethod.h +++ b/crypto/openssl/include/internal/recordmethod.h @@ -8,10 +8,10 @@ */ #ifndef OSSL_INTERNAL_RECORDMETHOD_H -# define OSSL_INTERNAL_RECORDMETHOD_H -# pragma once +#define OSSL_INTERNAL_RECORDMETHOD_H +#pragma once -# include <openssl/ssl.h> +#include <openssl/ssl.h> /* * We use the term "record" here to refer to a packet of data. Records are @@ -36,18 +36,17 @@ typedef struct ossl_record_method_st OSSL_RECORD_METHOD; */ typedef struct ossl_record_layer_st OSSL_RECORD_LAYER; +#define OSSL_RECORD_ROLE_CLIENT 0 +#define OSSL_RECORD_ROLE_SERVER 1 -# define OSSL_RECORD_ROLE_CLIENT 0 -# define OSSL_RECORD_ROLE_SERVER 1 +#define OSSL_RECORD_DIRECTION_READ 0 +#define OSSL_RECORD_DIRECTION_WRITE 1 -# define OSSL_RECORD_DIRECTION_READ 0 -# define OSSL_RECORD_DIRECTION_WRITE 1 - -# define OSSL_RECORD_RETURN_SUCCESS 1 -# define OSSL_RECORD_RETURN_RETRY 0 -# define OSSL_RECORD_RETURN_NON_FATAL_ERR -1 -# define OSSL_RECORD_RETURN_FATAL -2 -# define OSSL_RECORD_RETURN_EOF -3 +#define OSSL_RECORD_RETURN_SUCCESS 1 +#define OSSL_RECORD_RETURN_RETRY 0 +#define OSSL_RECORD_RETURN_NON_FATAL_ERR -1 +#define OSSL_RECORD_RETURN_FATAL -2 +#define OSSL_RECORD_RETURN_EOF -3 /* * Template for creating a record. A record consists of the |type| of data it @@ -112,35 +111,35 @@ struct ossl_record_method_st { * now though, this works. */ int (*new_record_layer)(OSSL_LIB_CTX *libctx, - const char *propq, int vers, - int role, int direction, - int level, - uint16_t epoch, - unsigned char *secret, - size_t secretlen, - unsigned char *key, - size_t keylen, - unsigned char *iv, - size_t ivlen, - unsigned char *mackey, - size_t mackeylen, - const EVP_CIPHER *ciph, - size_t taglen, - int mactype, - const EVP_MD *md, - COMP_METHOD *comp, - const EVP_MD *kdfdigest, - BIO *prev, - BIO *transport, - BIO *next, - BIO_ADDR *local, - BIO_ADDR *peer, - const OSSL_PARAM *settings, - const OSSL_PARAM *options, - const OSSL_DISPATCH *fns, - void *cbarg, - void *rlarg, - OSSL_RECORD_LAYER **ret); + const char *propq, int vers, + int role, int direction, + int level, + uint16_t epoch, + unsigned char *secret, + size_t secretlen, + unsigned char *key, + size_t keylen, + unsigned char *iv, + size_t ivlen, + unsigned char *mackey, + size_t mackeylen, + const EVP_CIPHER *ciph, + size_t taglen, + int mactype, + const EVP_MD *md, + COMP_METHOD *comp, + const EVP_MD *kdfdigest, + BIO *prev, + BIO *transport, + BIO *next, + BIO_ADDR *local, + BIO_ADDR *peer, + const OSSL_PARAM *settings, + const OSSL_PARAM *options, + const OSSL_DISPATCH *fns, + void *cbarg, + void *rlarg, + OSSL_RECORD_LAYER **ret); int (*free)(OSSL_RECORD_LAYER *rl); /* Returns 1 if we have unprocessed data buffered or 0 otherwise */ @@ -172,7 +171,7 @@ struct ossl_record_method_st { * be used. This must always be less than or equal to |maxfrag|. */ size_t (*get_max_records)(OSSL_RECORD_LAYER *rl, uint8_t type, size_t len, - size_t maxfrag, size_t *preffrag); + size_t maxfrag, size_t *preffrag); /* * Write |numtempl| records from the array of record templates pointed to @@ -195,7 +194,7 @@ struct ossl_record_method_st { * -1 on failure */ int (*write_records)(OSSL_RECORD_LAYER *rl, OSSL_RECORD_TEMPLATE *templates, - size_t numtempl); + size_t numtempl); /* * Retry a previous call to write_records. The caller should continue to @@ -224,8 +223,8 @@ struct ossl_record_method_st { * multiple records in one go and buffer them. */ int (*read_record)(OSSL_RECORD_LAYER *rl, void **rechandle, int *rversion, - uint8_t *type, const unsigned char **data, size_t *datalen, - uint16_t *epoch, unsigned char *seq_num); + uint8_t *type, const unsigned char **data, size_t *datalen, + uint16_t *epoch, unsigned char *seq_num); /* * Release length bytes from a buffer associated with a record previously * read with read_record. Once all the bytes from a record are released, the @@ -279,7 +278,7 @@ struct ossl_record_method_st { * Get a short or long human readable description of the record layer state */ void (*get_state)(OSSL_RECORD_LAYER *rl, const char **shortstr, - const char **longstr); + const char **longstr); /* * Set new options or modify ones that were originally specified in the @@ -320,12 +319,11 @@ struct ossl_record_method_st { int (*free_buffers)(OSSL_RECORD_LAYER *rl); }; - /* Standard built-in record methods */ extern const OSSL_RECORD_METHOD ossl_tls_record_method; -# ifndef OPENSSL_NO_KTLS +#ifndef OPENSSL_NO_KTLS extern const OSSL_RECORD_METHOD ossl_ktls_record_method; -# endif +#endif extern const OSSL_RECORD_METHOD ossl_dtls_record_method; #endif /* !defined(OSSL_INTERNAL_RECORDMETHOD_H) */ diff --git a/crypto/openssl/include/internal/refcount.h b/crypto/openssl/include/internal/refcount.h index 8de230f343ac..61eb78ae4120 100644 --- a/crypto/openssl/include/internal/refcount.h +++ b/crypto/openssl/include/internal/refcount.h @@ -7,30 +7,30 @@ * https://www.openssl.org/source/license.html */ #ifndef OSSL_INTERNAL_REFCOUNT_H -# define OSSL_INTERNAL_REFCOUNT_H -# pragma once +#define OSSL_INTERNAL_REFCOUNT_H +#pragma once -# include <openssl/e_os2.h> -# include <openssl/trace.h> -# include <openssl/err.h> +#include <openssl/e_os2.h> +#include <openssl/trace.h> +#include <openssl/err.h> -# if defined(OPENSSL_THREADS) && !defined(OPENSSL_DEV_NO_ATOMICS) -# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ - && !defined(__STDC_NO_ATOMICS__) -# include <stdatomic.h> -# define HAVE_C11_ATOMICS -# endif +#if defined(OPENSSL_THREADS) && !defined(OPENSSL_DEV_NO_ATOMICS) +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ + && !defined(__STDC_NO_ATOMICS__) +#include <stdatomic.h> +#define HAVE_C11_ATOMICS +#endif -# if defined(HAVE_C11_ATOMICS) && defined(ATOMIC_INT_LOCK_FREE) \ - && ATOMIC_INT_LOCK_FREE > 0 +#if defined(HAVE_C11_ATOMICS) && defined(ATOMIC_INT_LOCK_FREE) \ + && ATOMIC_INT_LOCK_FREE > 0 -# define HAVE_ATOMICS 1 +#define HAVE_ATOMICS 1 -# if defined(__has_feature) -# if __has_feature(thread_sanitizer) -# define OSSL_TSAN_BUILD -# endif -# endif +#if defined(__has_feature) +#if __has_feature(thread_sanitizer) +#define OSSL_TSAN_BUILD +#endif +#endif typedef struct { _Atomic int val; @@ -54,17 +54,17 @@ static inline int CRYPTO_UP_REF(CRYPTO_REF_COUNT *refcnt, int *ret) */ static inline int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, int *ret) { -# ifdef OSSL_TSAN_BUILD +#ifdef OSSL_TSAN_BUILD /* * TSAN requires acq_rel as it indicates a false positive error when * the object that contains the refcount is freed otherwise. */ *ret = atomic_fetch_sub_explicit(&refcnt->val, 1, memory_order_acq_rel) - 1; -# else +#else *ret = atomic_fetch_sub_explicit(&refcnt->val, 1, memory_order_release) - 1; if (*ret == 0) atomic_thread_fence(memory_order_acquire); -# endif +#endif return 1; } @@ -74,9 +74,9 @@ static inline int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, int *ret) return 1; } -# elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) && __GCC_ATOMIC_INT_LOCK_FREE > 0 +#elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) && __GCC_ATOMIC_INT_LOCK_FREE > 0 -# define HAVE_ATOMICS 1 +#define HAVE_ATOMICS 1 typedef struct { int val; @@ -102,8 +102,8 @@ static __inline__ int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, int *ret) return 1; } -# elif defined(__ICL) && defined(_WIN32) -# define HAVE_ATOMICS 1 +#elif defined(__ICL) && defined(_WIN32) +#define HAVE_ATOMICS 1 typedef struct { volatile int val; @@ -127,19 +127,19 @@ static __inline int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, int *ret) return 1; } -# elif defined(_MSC_VER) && _MSC_VER>=1200 +#elif defined(_MSC_VER) && _MSC_VER >= 1200 -# define HAVE_ATOMICS 1 +#define HAVE_ATOMICS 1 typedef struct { volatile int val; } CRYPTO_REF_COUNT; -# if (defined(_M_ARM) && _M_ARM>=7 && !defined(_WIN32_WCE)) || defined(_M_ARM64) -# include <intrin.h> -# if defined(_M_ARM64) && !defined(_ARM_BARRIER_ISH) -# define _ARM_BARRIER_ISH _ARM64_BARRIER_ISH -# endif +#if (defined(_M_ARM) && _M_ARM >= 7 && !defined(_WIN32_WCE)) || defined(_M_ARM64) +#include <intrin.h> +#if defined(_M_ARM64) && !defined(_ARM_BARRIER_ISH) +#define _ARM_BARRIER_ISH _ARM64_BARRIER_ISH +#endif static __inline int CRYPTO_UP_REF(CRYPTO_REF_COUNT *refcnt, int *ret) { @@ -159,18 +159,18 @@ static __inline int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, int *ret) return 1; } -# else -# if !defined(_WIN32_WCE) -# pragma intrinsic(_InterlockedExchangeAdd) -# else -# if _WIN32_WCE >= 0x600 - extern long __cdecl _InterlockedExchangeAdd(long volatile*, long); -# else - /* under Windows CE we still have old-style Interlocked* functions */ - extern long __cdecl InterlockedExchangeAdd(long volatile*, long); -# define _InterlockedExchangeAdd InterlockedExchangeAdd -# endif -# endif +#else +#if !defined(_WIN32_WCE) +#pragma intrinsic(_InterlockedExchangeAdd) +#else +#if _WIN32_WCE >= 0x600 +extern long __cdecl _InterlockedExchangeAdd(long volatile *, long); +#else +/* under Windows CE we still have old-style Interlocked* functions */ +extern long __cdecl InterlockedExchangeAdd(long volatile *, long); +#define _InterlockedExchangeAdd InterlockedExchangeAdd +#endif +#endif static __inline int CRYPTO_UP_REF(CRYPTO_REF_COUNT *refcnt, int *ret) { @@ -190,46 +190,46 @@ static __inline int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, int *ret) return 1; } -# endif +#endif -# endif -# endif /* !OPENSSL_DEV_NO_ATOMICS */ +#endif +#endif /* !OPENSSL_DEV_NO_ATOMICS */ /* * All the refcounting implementations above define HAVE_ATOMICS, so if it's * still undefined here (such as when OPENSSL_DEV_NO_ATOMICS is defined), it * means we need to implement a fallback. This fallback uses locks. */ -# ifndef HAVE_ATOMICS +#ifndef HAVE_ATOMICS typedef struct { int val; -# ifdef OPENSSL_THREADS +#ifdef OPENSSL_THREADS CRYPTO_RWLOCK *lock; -# endif +#endif } CRYPTO_REF_COUNT; -# ifdef OPENSSL_THREADS +#ifdef OPENSSL_THREADS static ossl_unused ossl_inline int CRYPTO_UP_REF(CRYPTO_REF_COUNT *refcnt, - int *ret) + int *ret) { return CRYPTO_atomic_add(&refcnt->val, 1, ret, refcnt->lock); } static ossl_unused ossl_inline int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, - int *ret) + int *ret) { return CRYPTO_atomic_add(&refcnt->val, -1, ret, refcnt->lock); } static ossl_unused ossl_inline int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, - int *ret) + int *ret) { return CRYPTO_atomic_load_int(&refcnt->val, ret, refcnt->lock); } -# define CRYPTO_NEW_FREE_DEFINED 1 +#define CRYPTO_NEW_FREE_DEFINED 1 static ossl_unused ossl_inline int CRYPTO_NEW_REF(CRYPTO_REF_COUNT *refcnt, int n) { refcnt->val = n; @@ -241,16 +241,16 @@ static ossl_unused ossl_inline int CRYPTO_NEW_REF(CRYPTO_REF_COUNT *refcnt, int return 1; } -static ossl_unused ossl_inline void CRYPTO_FREE_REF(CRYPTO_REF_COUNT *refcnt) \ +static ossl_unused ossl_inline void CRYPTO_FREE_REF(CRYPTO_REF_COUNT *refcnt) { if (refcnt != NULL) CRYPTO_THREAD_lock_free(refcnt->lock); } -# else /* OPENSSL_THREADS */ +#else /* OPENSSL_THREADS */ static ossl_unused ossl_inline int CRYPTO_UP_REF(CRYPTO_REF_COUNT *refcnt, - int *ret) + int *ret) { refcnt->val++; *ret = refcnt->val; @@ -258,7 +258,7 @@ static ossl_unused ossl_inline int CRYPTO_UP_REF(CRYPTO_REF_COUNT *refcnt, } static ossl_unused ossl_inline int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, - int *ret) + int *ret) { refcnt->val--; *ret = refcnt->val; @@ -266,38 +266,38 @@ static ossl_unused ossl_inline int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, } static ossl_unused ossl_inline int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, - int *ret) + int *ret) { *ret = refcnt->val; return 1; } -# endif /* OPENSSL_THREADS */ -# endif +#endif /* OPENSSL_THREADS */ +#endif -# ifndef CRYPTO_NEW_FREE_DEFINED +#ifndef CRYPTO_NEW_FREE_DEFINED static ossl_unused ossl_inline int CRYPTO_NEW_REF(CRYPTO_REF_COUNT *refcnt, int n) { refcnt->val = n; return 1; } -static ossl_unused ossl_inline void CRYPTO_FREE_REF(CRYPTO_REF_COUNT *refcnt) \ +static ossl_unused ossl_inline void CRYPTO_FREE_REF(CRYPTO_REF_COUNT *refcnt) { } -# endif /* CRYPTO_NEW_FREE_DEFINED */ +#endif /* CRYPTO_NEW_FREE_DEFINED */ #undef CRYPTO_NEW_FREE_DEFINED -# if !defined(NDEBUG) && !defined(OPENSSL_NO_STDIO) -# define REF_ASSERT_ISNT(test) \ +#if !defined(NDEBUG) && !defined(OPENSSL_NO_STDIO) +#define REF_ASSERT_ISNT(test) \ (void)((test) ? (OPENSSL_die("refcount error", __FILE__, __LINE__), 1) : 0) -# else -# define REF_ASSERT_ISNT(i) -# endif +#else +#define REF_ASSERT_ISNT(i) +#endif -# define REF_PRINT_EX(text, count, object) \ +#define REF_PRINT_EX(text, count, object) \ OSSL_TRACE3(REF_COUNT, "%p:%4d:%s\n", (object), (count), (text)); -# define REF_PRINT_COUNT(text, val, object) \ +#define REF_PRINT_COUNT(text, val, object) \ REF_PRINT_EX(text, val, (void *)object) #endif diff --git a/crypto/openssl/include/internal/ring_buf.h b/crypto/openssl/include/internal/ring_buf.h index 436f1ca14628..cc70bfaeac9a 100644 --- a/crypto/openssl/include/internal/ring_buf.h +++ b/crypto/openssl/include/internal/ring_buf.h @@ -8,11 +8,11 @@ */ #ifndef OSSL_INTERNAL_RING_BUF_H -# define OSSL_INTERNAL_RING_BUF_H -# pragma once +#define OSSL_INTERNAL_RING_BUF_H +#pragma once -# include <openssl/e_os2.h> /* For 'ossl_inline' */ -# include "internal/safe_math.h" +#include <openssl/e_os2.h> /* For 'ossl_inline' */ +#include "internal/safe_math.h" /* * ================================================================== @@ -23,26 +23,26 @@ * but not yet culled will not be overwritten, and can be restored. */ struct ring_buf { - void *start; - size_t alloc; /* size of buffer allocation in bytes */ + void *start; + size_t alloc; /* size of buffer allocation in bytes */ /* * Logical offset of the head (where we append to). This is the current size * of the QUIC stream. This increases monotonically. */ - uint64_t head_offset; + uint64_t head_offset; /* * Logical offset of the cull tail. Data is no longer needed and is * deallocated as the cull tail advances, which occurs as data is * acknowledged. This increases monotonically. */ - uint64_t ctail_offset; + uint64_t ctail_offset; }; OSSL_SAFE_MATH_UNSIGNED(u64, uint64_t) -#define MAX_OFFSET (((uint64_t)1) << 62) /* QUIC-imposed limit */ +#define MAX_OFFSET (((uint64_t)1) << 62) /* QUIC-imposed limit */ static ossl_inline int ring_buf_init(struct ring_buf *r) { @@ -73,9 +73,9 @@ static ossl_inline size_t ring_buf_avail(struct ring_buf *r) } static ossl_inline int ring_buf_write_at(struct ring_buf *r, - uint64_t logical_offset, - const unsigned char *buf, - size_t buf_len) + uint64_t logical_offset, + const unsigned char *buf, + size_t buf_len) { size_t avail, idx, l; unsigned char *start = r->start; @@ -84,9 +84,9 @@ static ossl_inline int ring_buf_write_at(struct ring_buf *r, avail = ring_buf_avail(r); if (logical_offset < r->ctail_offset || safe_add_u64(logical_offset, buf_len, &err) - > safe_add_u64(r->head_offset, avail, &err) + > safe_add_u64(r->head_offset, avail, &err) || safe_add_u64(r->head_offset, buf_len, &err) - > MAX_OFFSET + > MAX_OFFSET || err) return 0; @@ -111,8 +111,8 @@ static ossl_inline int ring_buf_write_at(struct ring_buf *r, } static ossl_inline size_t ring_buf_push(struct ring_buf *r, - const unsigned char *buf, - size_t buf_len) + const unsigned char *buf, + size_t buf_len) { size_t pushed = 0, avail, idx, l; unsigned char *start = r->start; @@ -134,18 +134,18 @@ static ossl_inline size_t ring_buf_push(struct ring_buf *r, l = buf_len; memcpy(start + idx, buf, l); - r->head_offset += l; - buf += l; - buf_len -= l; - pushed += l; + r->head_offset += l; + buf += l; + buf_len -= l; + pushed += l; } return pushed; } static ossl_inline const unsigned char *ring_buf_get_ptr(const struct ring_buf *r, - uint64_t logical_offset, - size_t *max_len) + uint64_t logical_offset, + size_t *max_len) { unsigned char *start = r->start; size_t idx; @@ -170,9 +170,9 @@ static ossl_inline const unsigned char *ring_buf_get_ptr(const struct ring_buf * * The ring buffer state is not changed. */ static ossl_inline int ring_buf_get_buf_at(const struct ring_buf *r, - uint64_t logical_offset, - const unsigned char **buf, - size_t *buf_len) + uint64_t logical_offset, + const unsigned char **buf, + size_t *buf_len) { const unsigned char *start = r->start; size_t idx, l; @@ -181,24 +181,24 @@ static ossl_inline int ring_buf_get_buf_at(const struct ring_buf *r, return 0; if (r->alloc == 0) { - *buf = NULL; - *buf_len = 0; + *buf = NULL; + *buf_len = 0; return 1; } idx = logical_offset % r->alloc; - l = (size_t)(r->head_offset - logical_offset); + l = (size_t)(r->head_offset - logical_offset); if (l > r->alloc - idx) l = r->alloc - idx; - *buf = start + idx; - *buf_len = l; + *buf = start + idx; + *buf_len = l; return 1; } static ossl_inline void ring_buf_cpop_range(struct ring_buf *r, - uint64_t start, uint64_t end, - int cleanse) + uint64_t start, uint64_t end, + int cleanse) { assert(end >= start); @@ -229,9 +229,9 @@ static ossl_inline void ring_buf_cpop_range(struct ring_buf *r, } static ossl_inline int ring_buf_resize(struct ring_buf *r, size_t num_bytes, - int cleanse) + int cleanse) { - struct ring_buf rnew = {0}; + struct ring_buf rnew = { 0 }; const unsigned char *src = NULL; size_t src_len = 0, copied = 0; @@ -245,9 +245,9 @@ static ossl_inline int ring_buf_resize(struct ring_buf *r, size_t num_bytes, if (rnew.start == NULL) return 0; - rnew.alloc = num_bytes; - rnew.head_offset = r->head_offset - ring_buf_used(r); - rnew.ctail_offset = rnew.head_offset; + rnew.alloc = num_bytes; + rnew.head_offset = r->head_offset - ring_buf_used(r); + rnew.ctail_offset = rnew.head_offset; for (;;) { if (!ring_buf_get_buf_at(r, r->ctail_offset + copied, &src, &src_len)) { @@ -274,4 +274,4 @@ static ossl_inline int ring_buf_resize(struct ring_buf *r, size_t num_bytes, return 1; } -#endif /* OSSL_INTERNAL_RING_BUF_H */ +#endif /* OSSL_INTERNAL_RING_BUF_H */ diff --git a/crypto/openssl/include/internal/rio_notifier.h b/crypto/openssl/include/internal/rio_notifier.h index ec2035714f75..794fccf40a68 100644 --- a/crypto/openssl/include/internal/rio_notifier.h +++ b/crypto/openssl/include/internal/rio_notifier.h @@ -7,10 +7,10 @@ * https://www.openssl.org/source/license.html */ #ifndef OSSL_RIO_NOTIFIER_H -# define OSSL_RIO_NOTIFIER_H +#define OSSL_RIO_NOTIFIER_H -# include "internal/common.h" -# include "internal/sockets.h" +#include "internal/common.h" +#include "internal/sockets.h" /* * Pollable Notifier @@ -20,18 +20,18 @@ * OS's socket polling APIs to allow socket polling calls to be woken * artificially by other threads. */ -# define RIO_NOTIFIER_METHOD_SOCKET 1 -# define RIO_NOTIFIER_METHOD_SOCKETPAIR 2 +#define RIO_NOTIFIER_METHOD_SOCKET 1 +#define RIO_NOTIFIER_METHOD_SOCKETPAIR 2 -# if !defined(RIO_NOTIFIER_METHOD) -# if defined(OPENSSL_SYS_WINDOWS) -# define RIO_NOTIFIER_METHOD RIO_NOTIFIER_METHOD_SOCKET -# elif defined(OPENSSL_SYS_UNIX) -# define RIO_NOTIFIER_METHOD RIO_NOTIFIER_METHOD_SOCKETPAIR -# else -# define RIO_NOTIFIER_METHOD RIO_NOTIFIER_METHOD_SOCKET -# endif -# endif +#if !defined(RIO_NOTIFIER_METHOD) +#if defined(OPENSSL_SYS_WINDOWS) +#define RIO_NOTIFIER_METHOD RIO_NOTIFIER_METHOD_SOCKET +#elif defined(OPENSSL_SYS_UNIX) +#define RIO_NOTIFIER_METHOD RIO_NOTIFIER_METHOD_SOCKETPAIR +#else +#define RIO_NOTIFIER_METHOD RIO_NOTIFIER_METHOD_SOCKET +#endif +#endif typedef struct rio_notifier_st { int rfd, wfd; diff --git a/crypto/openssl/include/internal/safe_math.h b/crypto/openssl/include/internal/safe_math.h index ecfb281f40aa..dda5cc48f011 100644 --- a/crypto/openssl/include/internal/safe_math.h +++ b/crypto/openssl/include/internal/safe_math.h @@ -8,290 +8,290 @@ */ #ifndef OSSL_INTERNAL_SAFE_MATH_H -# define OSSL_INTERNAL_SAFE_MATH_H -# pragma once +#define OSSL_INTERNAL_SAFE_MATH_H +#pragma once -# include <openssl/e_os2.h> /* For 'ossl_inline' */ +#include <openssl/e_os2.h> /* For 'ossl_inline' */ -# ifndef OPENSSL_NO_BUILTIN_OVERFLOW_CHECKING -# ifdef __has_builtin -# define has(func) __has_builtin(func) -# elif defined(__GNUC__) -# if __GNUC__ > 5 -# define has(func) 1 -# endif -# endif -# endif /* OPENSSL_NO_BUILTIN_OVERFLOW_CHECKING */ +#ifndef OPENSSL_NO_BUILTIN_OVERFLOW_CHECKING +#ifdef __has_builtin +#define has(func) __has_builtin(func) +#elif defined(__GNUC__) +#if __GNUC__ > 5 +#define has(func) 1 +#endif +#endif +#endif /* OPENSSL_NO_BUILTIN_OVERFLOW_CHECKING */ -# ifndef has -# define has(func) 0 -# endif +#ifndef has +#define has(func) 0 +#endif /* * Safe addition helpers */ -# if has(__builtin_add_overflow) -# define OSSL_SAFE_MATH_ADDS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_add_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - type r; \ - \ - if (!__builtin_add_overflow(a, b, &r)) \ - return r; \ - *err |= 1; \ - return a < 0 ? min : max; \ +#if has(__builtin_add_overflow) +#define OSSL_SAFE_MATH_ADDS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_add_##type_name(type a, \ + type b, \ + int *err) \ + { \ + type r; \ + \ + if (!__builtin_add_overflow(a, b, &r)) \ + return r; \ + *err |= 1; \ + return a < 0 ? min : max; \ } -# define OSSL_SAFE_MATH_ADDU(type_name, type, max) \ - static ossl_inline ossl_unused type safe_add_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - type r; \ - \ - if (!__builtin_add_overflow(a, b, &r)) \ - return r; \ - *err |= 1; \ - return a + b; \ +#define OSSL_SAFE_MATH_ADDU(type_name, type, max) \ + static ossl_inline ossl_unused type safe_add_##type_name(type a, \ + type b, \ + int *err) \ + { \ + type r; \ + \ + if (!__builtin_add_overflow(a, b, &r)) \ + return r; \ + *err |= 1; \ + return a + b; \ } -# else /* has(__builtin_add_overflow) */ -# define OSSL_SAFE_MATH_ADDS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_add_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - if ((a < 0) ^ (b < 0) \ - || (a > 0 && b <= max - a) \ - || (a < 0 && b >= min - a) \ - || a == 0) \ - return a + b; \ - *err |= 1; \ - return a < 0 ? min : max; \ +#else /* has(__builtin_add_overflow) */ +#define OSSL_SAFE_MATH_ADDS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_add_##type_name(type a, \ + type b, \ + int *err) \ + { \ + if ((a < 0) ^ (b < 0) \ + || (a > 0 && b <= max - a) \ + || (a < 0 && b >= min - a) \ + || a == 0) \ + return a + b; \ + *err |= 1; \ + return a < 0 ? min : max; \ } -# define OSSL_SAFE_MATH_ADDU(type_name, type, max) \ - static ossl_inline ossl_unused type safe_add_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - if (b > max - a) \ - *err |= 1; \ - return a + b; \ +#define OSSL_SAFE_MATH_ADDU(type_name, type, max) \ + static ossl_inline ossl_unused type safe_add_##type_name(type a, \ + type b, \ + int *err) \ + { \ + if (b > max - a) \ + *err |= 1; \ + return a + b; \ } -# endif /* has(__builtin_add_overflow) */ +#endif /* has(__builtin_add_overflow) */ /* * Safe subtraction helpers */ -# if has(__builtin_sub_overflow) -# define OSSL_SAFE_MATH_SUBS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_sub_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - type r; \ - \ - if (!__builtin_sub_overflow(a, b, &r)) \ - return r; \ - *err |= 1; \ - return a < 0 ? min : max; \ +#if has(__builtin_sub_overflow) +#define OSSL_SAFE_MATH_SUBS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_sub_##type_name(type a, \ + type b, \ + int *err) \ + { \ + type r; \ + \ + if (!__builtin_sub_overflow(a, b, &r)) \ + return r; \ + *err |= 1; \ + return a < 0 ? min : max; \ } -# else /* has(__builtin_sub_overflow) */ -# define OSSL_SAFE_MATH_SUBS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_sub_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - if (!((a < 0) ^ (b < 0)) \ - || (b > 0 && a >= min + b) \ - || (b < 0 && a <= max + b) \ - || b == 0) \ - return a - b; \ - *err |= 1; \ - return a < 0 ? min : max; \ +#else /* has(__builtin_sub_overflow) */ +#define OSSL_SAFE_MATH_SUBS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_sub_##type_name(type a, \ + type b, \ + int *err) \ + { \ + if (!((a < 0) ^ (b < 0)) \ + || (b > 0 && a >= min + b) \ + || (b < 0 && a <= max + b) \ + || b == 0) \ + return a - b; \ + *err |= 1; \ + return a < 0 ? min : max; \ } -# endif /* has(__builtin_sub_overflow) */ +#endif /* has(__builtin_sub_overflow) */ -# define OSSL_SAFE_MATH_SUBU(type_name, type) \ - static ossl_inline ossl_unused type safe_sub_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - if (b > a) \ - *err |= 1; \ - return a - b; \ +#define OSSL_SAFE_MATH_SUBU(type_name, type) \ + static ossl_inline ossl_unused type safe_sub_##type_name(type a, \ + type b, \ + int *err) \ + { \ + if (b > a) \ + *err |= 1; \ + return a - b; \ } /* * Safe multiplication helpers */ -# if has(__builtin_mul_overflow) -# define OSSL_SAFE_MATH_MULS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_mul_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - type r; \ - \ - if (!__builtin_mul_overflow(a, b, &r)) \ - return r; \ - *err |= 1; \ - return (a < 0) ^ (b < 0) ? min : max; \ +#if has(__builtin_mul_overflow) +#define OSSL_SAFE_MATH_MULS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_mul_##type_name(type a, \ + type b, \ + int *err) \ + { \ + type r; \ + \ + if (!__builtin_mul_overflow(a, b, &r)) \ + return r; \ + *err |= 1; \ + return (a < 0) ^ (b < 0) ? min : max; \ } -# define OSSL_SAFE_MATH_MULU(type_name, type, max) \ - static ossl_inline ossl_unused type safe_mul_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - type r; \ - \ - if (!__builtin_mul_overflow(a, b, &r)) \ - return r; \ - *err |= 1; \ - return a * b; \ +#define OSSL_SAFE_MATH_MULU(type_name, type, max) \ + static ossl_inline ossl_unused type safe_mul_##type_name(type a, \ + type b, \ + int *err) \ + { \ + type r; \ + \ + if (!__builtin_mul_overflow(a, b, &r)) \ + return r; \ + *err |= 1; \ + return a * b; \ } -# else /* has(__builtin_mul_overflow) */ -# define OSSL_SAFE_MATH_MULS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_mul_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - if (a == 0 || b == 0) \ - return 0; \ - if (a == 1) \ - return b; \ - if (b == 1) \ - return a; \ - if (a != min && b != min) { \ - const type x = a < 0 ? -a : a; \ - const type y = b < 0 ? -b : b; \ - \ - if (x <= max / y) \ - return a * b; \ - } \ - *err |= 1; \ - return (a < 0) ^ (b < 0) ? min : max; \ +#else /* has(__builtin_mul_overflow) */ +#define OSSL_SAFE_MATH_MULS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_mul_##type_name(type a, \ + type b, \ + int *err) \ + { \ + if (a == 0 || b == 0) \ + return 0; \ + if (a == 1) \ + return b; \ + if (b == 1) \ + return a; \ + if (a != min && b != min) { \ + const type x = a < 0 ? -a : a; \ + const type y = b < 0 ? -b : b; \ + \ + if (x <= max / y) \ + return a * b; \ + } \ + *err |= 1; \ + return (a < 0) ^ (b < 0) ? min : max; \ } -# define OSSL_SAFE_MATH_MULU(type_name, type, max) \ - static ossl_inline ossl_unused type safe_mul_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - if (b != 0 && a > max / b) \ - *err |= 1; \ - return a * b; \ +#define OSSL_SAFE_MATH_MULU(type_name, type, max) \ + static ossl_inline ossl_unused type safe_mul_##type_name(type a, \ + type b, \ + int *err) \ + { \ + if (b != 0 && a > max / b) \ + *err |= 1; \ + return a * b; \ } -# endif /* has(__builtin_mul_overflow) */ +#endif /* has(__builtin_mul_overflow) */ /* * Safe division helpers */ -# define OSSL_SAFE_MATH_DIVS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_div_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - if (b == 0) { \ - *err |= 1; \ - return a < 0 ? min : max; \ - } \ - if (b == -1 && a == min) { \ - *err |= 1; \ - return max; \ - } \ - return a / b; \ +#define OSSL_SAFE_MATH_DIVS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_div_##type_name(type a, \ + type b, \ + int *err) \ + { \ + if (b == 0) { \ + *err |= 1; \ + return a < 0 ? min : max; \ + } \ + if (b == -1 && a == min) { \ + *err |= 1; \ + return max; \ + } \ + return a / b; \ } -# define OSSL_SAFE_MATH_DIVU(type_name, type, max) \ - static ossl_inline ossl_unused type safe_div_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - if (b != 0) \ - return a / b; \ - *err |= 1; \ - return max; \ +#define OSSL_SAFE_MATH_DIVU(type_name, type, max) \ + static ossl_inline ossl_unused type safe_div_##type_name(type a, \ + type b, \ + int *err) \ + { \ + if (b != 0) \ + return a / b; \ + *err |= 1; \ + return max; \ } /* * Safe modulus helpers */ -# define OSSL_SAFE_MATH_MODS(type_name, type, min, max) \ - static ossl_inline ossl_unused type safe_mod_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - if (b == 0) { \ - *err |= 1; \ - return 0; \ - } \ - if (b == -1 && a == min) { \ - *err |= 1; \ - return max; \ - } \ - return a % b; \ +#define OSSL_SAFE_MATH_MODS(type_name, type, min, max) \ + static ossl_inline ossl_unused type safe_mod_##type_name(type a, \ + type b, \ + int *err) \ + { \ + if (b == 0) { \ + *err |= 1; \ + return 0; \ + } \ + if (b == -1 && a == min) { \ + *err |= 1; \ + return max; \ + } \ + return a % b; \ } -# define OSSL_SAFE_MATH_MODU(type_name, type) \ - static ossl_inline ossl_unused type safe_mod_ ## type_name(type a, \ - type b, \ - int *err) \ - { \ - if (b != 0) \ - return a % b; \ - *err |= 1; \ - return 0; \ +#define OSSL_SAFE_MATH_MODU(type_name, type) \ + static ossl_inline ossl_unused type safe_mod_##type_name(type a, \ + type b, \ + int *err) \ + { \ + if (b != 0) \ + return a % b; \ + *err |= 1; \ + return 0; \ } /* * Safe negation helpers */ -# define OSSL_SAFE_MATH_NEGS(type_name, type, min) \ - static ossl_inline ossl_unused type safe_neg_ ## type_name(type a, \ - int *err) \ - { \ - if (a != min) \ - return -a; \ - *err |= 1; \ - return min; \ +#define OSSL_SAFE_MATH_NEGS(type_name, type, min) \ + static ossl_inline ossl_unused type safe_neg_##type_name(type a, \ + int *err) \ + { \ + if (a != min) \ + return -a; \ + *err |= 1; \ + return min; \ } -# define OSSL_SAFE_MATH_NEGU(type_name, type) \ - static ossl_inline ossl_unused type safe_neg_ ## type_name(type a, \ - int *err) \ - { \ - if (a == 0) \ - return a; \ - *err |= 1; \ - return 1 + ~a; \ +#define OSSL_SAFE_MATH_NEGU(type_name, type) \ + static ossl_inline ossl_unused type safe_neg_##type_name(type a, \ + int *err) \ + { \ + if (a == 0) \ + return a; \ + *err |= 1; \ + return 1 + ~a; \ } /* * Safe absolute value helpers */ -# define OSSL_SAFE_MATH_ABSS(type_name, type, min) \ - static ossl_inline ossl_unused type safe_abs_ ## type_name(type a, \ - int *err) \ - { \ - if (a != min) \ - return a < 0 ? -a : a; \ - *err |= 1; \ - return min; \ +#define OSSL_SAFE_MATH_ABSS(type_name, type, min) \ + static ossl_inline ossl_unused type safe_abs_##type_name(type a, \ + int *err) \ + { \ + if (a != min) \ + return a < 0 ? -a : a; \ + *err |= 1; \ + return min; \ } -# define OSSL_SAFE_MATH_ABSU(type_name, type) \ - static ossl_inline ossl_unused type safe_abs_ ## type_name(type a, \ - int *err) \ - { \ - return a; \ +#define OSSL_SAFE_MATH_ABSU(type_name, type) \ + static ossl_inline ossl_unused type safe_abs_##type_name(type a, \ + int *err) \ + { \ + return a; \ } /* @@ -316,59 +316,59 @@ * * The algorithm used is not perfect but it should be "good enough". */ -# define OSSL_SAFE_MATH_MULDIVS(type_name, type, max) \ - static ossl_inline ossl_unused type safe_muldiv_ ## type_name(type a, \ - type b, \ - type c, \ - int *err) \ - { \ - int e2 = 0; \ - type q, r, x, y; \ - \ - if (c == 0) { \ - *err |= 1; \ - return a == 0 || b == 0 ? 0 : max; \ - } \ - x = safe_mul_ ## type_name(a, b, &e2); \ - if (!e2) \ - return safe_div_ ## type_name(x, c, err); \ - if (b > a) { \ - x = b; \ - b = a; \ - a = x; \ - } \ - q = safe_div_ ## type_name(a, c, err); \ - r = safe_mod_ ## type_name(a, c, err); \ - x = safe_mul_ ## type_name(r, b, err); \ - y = safe_mul_ ## type_name(q, b, err); \ - q = safe_div_ ## type_name(x, c, err); \ - return safe_add_ ## type_name(y, q, err); \ +#define OSSL_SAFE_MATH_MULDIVS(type_name, type, max) \ + static ossl_inline ossl_unused type safe_muldiv_##type_name(type a, \ + type b, \ + type c, \ + int *err) \ + { \ + int e2 = 0; \ + type q, r, x, y; \ + \ + if (c == 0) { \ + *err |= 1; \ + return a == 0 || b == 0 ? 0 : max; \ + } \ + x = safe_mul_##type_name(a, b, &e2); \ + if (!e2) \ + return safe_div_##type_name(x, c, err); \ + if (b > a) { \ + x = b; \ + b = a; \ + a = x; \ + } \ + q = safe_div_##type_name(a, c, err); \ + r = safe_mod_##type_name(a, c, err); \ + x = safe_mul_##type_name(r, b, err); \ + y = safe_mul_##type_name(q, b, err); \ + q = safe_div_##type_name(x, c, err); \ + return safe_add_##type_name(y, q, err); \ } -# define OSSL_SAFE_MATH_MULDIVU(type_name, type, max) \ - static ossl_inline ossl_unused type safe_muldiv_ ## type_name(type a, \ - type b, \ - type c, \ - int *err) \ - { \ - int e2 = 0; \ - type x, y; \ - \ - if (c == 0) { \ - *err |= 1; \ - return a == 0 || b == 0 ? 0 : max; \ - } \ - x = safe_mul_ ## type_name(a, b, &e2); \ - if (!e2) \ - return x / c; \ - if (b > a) { \ - x = b; \ - b = a; \ - a = x; \ - } \ - x = safe_mul_ ## type_name(a % c, b, err); \ - y = safe_mul_ ## type_name(a / c, b, err); \ - return safe_add_ ## type_name(y, x / c, err); \ +#define OSSL_SAFE_MATH_MULDIVU(type_name, type, max) \ + static ossl_inline ossl_unused type safe_muldiv_##type_name(type a, \ + type b, \ + type c, \ + int *err) \ + { \ + int e2 = 0; \ + type x, y; \ + \ + if (c == 0) { \ + *err |= 1; \ + return a == 0 || b == 0 ? 0 : max; \ + } \ + x = safe_mul_##type_name(a, b, &e2); \ + if (!e2) \ + return x / c; \ + if (b > a) { \ + x = b; \ + b = a; \ + a = x; \ + } \ + x = safe_mul_##type_name(a % c, b, err); \ + y = safe_mul_##type_name(a / c, b, err); \ + return safe_add_##type_name(y, x / c, err); \ } /* @@ -377,69 +377,68 @@ * Which is usually (less safely) converted to (a + b - 1) / b * If you *know* that b != 0, then it's safe to ignore err. */ -#define OSSL_SAFE_MATH_DIV_ROUND_UP(type_name, type, max) \ - static ossl_inline ossl_unused type safe_div_round_up_ ## type_name \ - (type a, type b, int *errp) \ - { \ - type x; \ - int *err, err_local = 0; \ - \ - /* Allow errors to be ignored by callers */ \ - err = errp != NULL ? errp : &err_local; \ - /* Fast path, both positive */ \ - if (b > 0 && a > 0) { \ - /* Faster path: no overflow concerns */ \ - if (a < max - b) \ - return (a + b - 1) / b; \ - return a / b + (a % b != 0); \ - } \ - if (b == 0) { \ - *err |= 1; \ - return a == 0 ? 0 : max; \ - } \ - if (a == 0) \ - return 0; \ - /* Rather slow path because there are negatives involved */ \ - x = safe_mod_ ## type_name(a, b, err); \ - return safe_add_ ## type_name(safe_div_ ## type_name(a, b, err), \ - x != 0, err); \ +#define OSSL_SAFE_MATH_DIV_ROUND_UP(type_name, type, max) \ + static ossl_inline ossl_unused type safe_div_round_up_##type_name(type a, type b, int *errp) \ + { \ + type x; \ + int *err, err_local = 0; \ + \ + /* Allow errors to be ignored by callers */ \ + err = errp != NULL ? errp : &err_local; \ + /* Fast path, both positive */ \ + if (b > 0 && a > 0) { \ + /* Faster path: no overflow concerns */ \ + if (a < max - b) \ + return (a + b - 1) / b; \ + return a / b + (a % b != 0); \ + } \ + if (b == 0) { \ + *err |= 1; \ + return a == 0 ? 0 : max; \ + } \ + if (a == 0) \ + return 0; \ + /* Rather slow path because there are negatives involved */ \ + x = safe_mod_##type_name(a, b, err); \ + return safe_add_##type_name(safe_div_##type_name(a, b, err), \ + x != 0, err); \ } /* Calculate ranges of types */ -# define OSSL_SAFE_MATH_MINS(type) ((type)1 << (sizeof(type) * 8 - 1)) -# define OSSL_SAFE_MATH_MAXS(type) (~OSSL_SAFE_MATH_MINS(type)) -# define OSSL_SAFE_MATH_MAXU(type) (~(type)0) +#define OSSL_SAFE_MATH_MINS(type) ((type)1 << (sizeof(type) * 8 - 1)) +#define OSSL_SAFE_MATH_MAXS(type) (~OSSL_SAFE_MATH_MINS(type)) +#define OSSL_SAFE_MATH_MAXU(type) (~(type)0) /* * Wrapper macros to create all the functions of a given type */ -# define OSSL_SAFE_MATH_SIGNED(type_name, type) \ - OSSL_SAFE_MATH_ADDS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ - OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_SUBS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ - OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_MULS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ - OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_DIVS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ - OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_MODS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ - OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_DIV_ROUND_UP(type_name, type, \ - OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_MULDIVS(type_name, type, OSSL_SAFE_MATH_MAXS(type)) \ - OSSL_SAFE_MATH_NEGS(type_name, type, OSSL_SAFE_MATH_MINS(type)) \ +#define OSSL_SAFE_MATH_SIGNED(type_name, type) \ + OSSL_SAFE_MATH_ADDS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ + OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_SUBS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ + OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_MULS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ + OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_DIVS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ + OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_MODS(type_name, type, OSSL_SAFE_MATH_MINS(type), \ + OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_DIV_ROUND_UP(type_name, type, \ + OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_MULDIVS(type_name, type, OSSL_SAFE_MATH_MAXS(type)) \ + OSSL_SAFE_MATH_NEGS(type_name, type, OSSL_SAFE_MATH_MINS(type)) \ OSSL_SAFE_MATH_ABSS(type_name, type, OSSL_SAFE_MATH_MINS(type)) -# define OSSL_SAFE_MATH_UNSIGNED(type_name, type) \ - OSSL_SAFE_MATH_ADDU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ - OSSL_SAFE_MATH_SUBU(type_name, type) \ - OSSL_SAFE_MATH_MULU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ - OSSL_SAFE_MATH_DIVU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ - OSSL_SAFE_MATH_MODU(type_name, type) \ - OSSL_SAFE_MATH_DIV_ROUND_UP(type_name, type, \ - OSSL_SAFE_MATH_MAXU(type)) \ - OSSL_SAFE_MATH_MULDIVU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ - OSSL_SAFE_MATH_NEGU(type_name, type) \ +#define OSSL_SAFE_MATH_UNSIGNED(type_name, type) \ + OSSL_SAFE_MATH_ADDU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ + OSSL_SAFE_MATH_SUBU(type_name, type) \ + OSSL_SAFE_MATH_MULU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ + OSSL_SAFE_MATH_DIVU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ + OSSL_SAFE_MATH_MODU(type_name, type) \ + OSSL_SAFE_MATH_DIV_ROUND_UP(type_name, type, \ + OSSL_SAFE_MATH_MAXU(type)) \ + OSSL_SAFE_MATH_MULDIVU(type_name, type, OSSL_SAFE_MATH_MAXU(type)) \ + OSSL_SAFE_MATH_NEGU(type_name, type) \ OSSL_SAFE_MATH_ABSU(type_name, type) -#endif /* OSSL_INTERNAL_SAFE_MATH_H */ +#endif /* OSSL_INTERNAL_SAFE_MATH_H */ diff --git a/crypto/openssl/include/internal/sha3.h b/crypto/openssl/include/internal/sha3.h index aebdd6eb8f53..d67aa1e19f55 100644 --- a/crypto/openssl/include/internal/sha3.h +++ b/crypto/openssl/include/internal/sha3.h @@ -9,22 +9,22 @@ /* This header can move into provider when legacy support is removed */ #ifndef OSSL_INTERNAL_SHA3_H -# define OSSL_INTERNAL_SHA3_H -# pragma once +#define OSSL_INTERNAL_SHA3_H +#pragma once -# include <openssl/e_os2.h> -# include <stddef.h> +#include <openssl/e_os2.h> +#include <stddef.h> -# define KECCAK1600_WIDTH 1600 -# define SHA3_MDSIZE(bitlen) (bitlen / 8) -# define KMAC_MDSIZE(bitlen) 2 * (bitlen / 8) -# define SHA3_BLOCKSIZE(bitlen) (KECCAK1600_WIDTH - bitlen * 2) / 8 +#define KECCAK1600_WIDTH 1600 +#define SHA3_MDSIZE(bitlen) (bitlen / 8) +#define KMAC_MDSIZE(bitlen) 2 * (bitlen / 8) +#define SHA3_BLOCKSIZE(bitlen) (KECCAK1600_WIDTH - bitlen * 2) / 8 typedef struct keccak_st KECCAK1600_CTX; -typedef size_t (sha3_absorb_fn)(void *vctx, const void *in, size_t inlen); -typedef int (sha3_final_fn)(void *vctx, unsigned char *out, size_t outlen); -typedef int (sha3_squeeze_fn)(void *vctx, unsigned char *out, size_t outlen); +typedef size_t(sha3_absorb_fn)(void *vctx, const void *in, size_t inlen); +typedef int(sha3_final_fn)(void *vctx, unsigned char *out, size_t outlen); +typedef int(sha3_squeeze_fn)(void *vctx, unsigned char *out, size_t outlen); typedef struct prov_sha3_meth_st { sha3_absorb_fn *absorb; @@ -32,17 +32,17 @@ typedef struct prov_sha3_meth_st { sha3_squeeze_fn *squeeze; } PROV_SHA3_METHOD; -#define XOF_STATE_INIT 0 -#define XOF_STATE_ABSORB 1 -#define XOF_STATE_FINAL 2 +#define XOF_STATE_INIT 0 +#define XOF_STATE_ABSORB 1 +#define XOF_STATE_FINAL 2 #define XOF_STATE_SQUEEZE 3 struct keccak_st { uint64_t A[5][5]; unsigned char buf[KECCAK1600_WIDTH / 8 - 32]; - size_t block_size; /* cached ctx->digest->block_size */ - size_t md_size; /* output length, variable in XOF */ - size_t bufsz; /* used bytes in below buffer */ + size_t block_size; /* cached ctx->digest->block_size */ + size_t md_size; /* output length, variable in XOF */ + size_t bufsz; /* used bytes in below buffer */ unsigned char pad; PROV_SHA3_METHOD meth; int xof_state; @@ -51,12 +51,12 @@ struct keccak_st { void ossl_sha3_reset(KECCAK1600_CTX *ctx); int ossl_sha3_init(KECCAK1600_CTX *ctx, unsigned char pad, size_t bitlen); int ossl_keccak_init(KECCAK1600_CTX *ctx, unsigned char pad, - size_t typelen, size_t mdlen); + size_t typelen, size_t mdlen); int ossl_sha3_update(KECCAK1600_CTX *ctx, const void *_inp, size_t len); int ossl_sha3_final(KECCAK1600_CTX *ctx, unsigned char *out, size_t outlen); int ossl_sha3_squeeze(KECCAK1600_CTX *ctx, unsigned char *out, size_t outlen); size_t SHA3_absorb(uint64_t A[5][5], const unsigned char *inp, size_t len, - size_t r); + size_t r); #endif /* OSSL_INTERNAL_SHA3_H */ diff --git a/crypto/openssl/include/internal/sizes.h b/crypto/openssl/include/internal/sizes.h index 713a7466ae06..49c381e394e9 100644 --- a/crypto/openssl/include/internal/sizes.h +++ b/crypto/openssl/include/internal/sizes.h @@ -8,16 +8,16 @@ */ #ifndef OSSL_INTERNAL_SIZES_H -# define OSSL_INTERNAL_SIZES_H -# pragma once +#define OSSL_INTERNAL_SIZES_H +#pragma once /* * Max sizes used to allocate buffers with a fixed sizes, for example for * stack allocations, structure fields, ... */ -# define OSSL_MAX_NAME_SIZE 50 /* Algorithm name */ -# define OSSL_MAX_PROPQUERY_SIZE 256 /* Property query strings */ -# define OSSL_MAX_ALGORITHM_ID_SIZE 256 /* AlgorithmIdentifier DER */ -# define OSSL_MAX_CODEC_STRUCT_SIZE 32 /* DATA_STRUCTURE name */ +#define OSSL_MAX_NAME_SIZE 50 /* Algorithm name */ +#define OSSL_MAX_PROPQUERY_SIZE 256 /* Property query strings */ +#define OSSL_MAX_ALGORITHM_ID_SIZE 256 /* AlgorithmIdentifier DER */ +#define OSSL_MAX_CODEC_STRUCT_SIZE 32 /* DATA_STRUCTURE name */ #endif diff --git a/crypto/openssl/include/internal/skey.h b/crypto/openssl/include/internal/skey.h index 6d0c643c3f19..a4b6c6e6a9e5 100644 --- a/crypto/openssl/include/internal/skey.h +++ b/crypto/openssl/include/internal/skey.h @@ -8,11 +8,11 @@ */ #ifndef OSSL_CRYPTO_SKEY_H -# define OSSL_CRYPTO_SKEY_H +#define OSSL_CRYPTO_SKEY_H /* Known symmetric key type definitions */ -# define SKEY_TYPE_GENERIC 1 /* generic bytes container unknown key types */ -# define SKEY_TYPE_AES 2 /* AES keys */ +#define SKEY_TYPE_GENERIC 1 /* generic bytes container unknown key types */ +#define SKEY_TYPE_AES 2 /* AES keys */ struct prov_skey_st { /* diff --git a/crypto/openssl/include/internal/sm3.h b/crypto/openssl/include/internal/sm3.h index db1d61f0523c..32a05ae9ef71 100644 --- a/crypto/openssl/include/internal/sm3.h +++ b/crypto/openssl/include/internal/sm3.h @@ -10,26 +10,26 @@ /* This header can move into provider when legacy support is removed */ #ifndef OSSL_INTERNAL_SM3_H -# define OSSL_INTERNAL_SM3_H -# pragma once +#define OSSL_INTERNAL_SM3_H +#pragma once -# include <openssl/opensslconf.h> +#include <openssl/opensslconf.h> -# ifdef OPENSSL_NO_SM3 -# error SM3 is disabled. -# endif +#ifdef OPENSSL_NO_SM3 +#error SM3 is disabled. +#endif -# define SM3_DIGEST_LENGTH 32 -# define SM3_WORD unsigned int +#define SM3_DIGEST_LENGTH 32 +#define SM3_WORD unsigned int -# define SM3_CBLOCK 64 -# define SM3_LBLOCK (SM3_CBLOCK/4) +#define SM3_CBLOCK 64 +#define SM3_LBLOCK (SM3_CBLOCK / 4) typedef struct SM3state_st { - SM3_WORD A, B, C, D, E, F, G, H; - SM3_WORD Nl, Nh; - SM3_WORD data[SM3_LBLOCK]; - unsigned int num; + SM3_WORD A, B, C, D, E, F, G, H; + SM3_WORD Nl, Nh; + SM3_WORD data[SM3_LBLOCK]; + unsigned int num; } SM3_CTX; int ossl_sm3_init(SM3_CTX *c); diff --git a/crypto/openssl/include/internal/sockets.h b/crypto/openssl/include/internal/sockets.h index d28208b31340..877bbd7145b0 100644 --- a/crypto/openssl/include/internal/sockets.h +++ b/crypto/openssl/include/internal/sockets.h @@ -8,49 +8,49 @@ */ #ifndef OSSL_INTERNAL_SOCKETS_H -# define OSSL_INTERNAL_SOCKETS_H -# pragma once +#define OSSL_INTERNAL_SOCKETS_H +#pragma once -# include <openssl/opensslconf.h> -# include "internal/common.h" +#include <openssl/opensslconf.h> +#include "internal/common.h" -# if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) -# define NO_SYS_PARAM_H -# endif -# ifdef WIN32 -# define NO_SYS_UN_H -# endif -# ifdef OPENSSL_SYS_VMS -# define NO_SYS_PARAM_H -# define NO_SYS_UN_H -# endif +#if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) +#define NO_SYS_PARAM_H +#endif +#ifdef WIN32 +#define NO_SYS_UN_H +#endif +#ifdef OPENSSL_SYS_VMS +#define NO_SYS_PARAM_H +#define NO_SYS_UN_H +#endif -# ifdef OPENSSL_NO_SOCK +#ifdef OPENSSL_NO_SOCK -# elif defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) -# if defined(__DJGPP__) -# define WATT32 -# define WATT32_NO_OLDIES -# include <sys/socket.h> -# include <sys/un.h> -# include <tcp.h> -# include <netdb.h> -# include <arpa/inet.h> -# include <netinet/tcp.h> -# elif defined(_WIN32_WCE) && _WIN32_WCE<410 -# define getservbyname _masked_declaration_getservbyname -# endif -# if !defined(IPPROTO_IP) - /* winsock[2].h was included already? */ -# include "internal/e_winsock.h" -# endif -# ifdef getservbyname - /* this is used to be wcecompat/include/winsock_extras.h */ -# undef getservbyname +#elif defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) +#if defined(__DJGPP__) +#define WATT32 +#define WATT32_NO_OLDIES +#include <sys/socket.h> +#include <sys/un.h> +#include <tcp.h> +#include <netdb.h> +#include <arpa/inet.h> +#include <netinet/tcp.h> +#elif defined(_WIN32_WCE) && _WIN32_WCE < 410 +#define getservbyname _masked_declaration_getservbyname +#endif +#if !defined(IPPROTO_IP) +/* winsock[2].h was included already? */ +#include "internal/e_winsock.h" +#endif +#ifdef getservbyname +/* this is used to be wcecompat/include/winsock_extras.h */ +#undef getservbyname struct servent *PASCAL getservbyname(const char *, const char *); -# endif +#endif -# ifdef _WIN64 +#ifdef _WIN64 /* * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because * the value constitutes an index in per-process table of limited size @@ -58,155 +58,155 @@ struct servent *PASCAL getservbyname(const char *, const char *); * Windows run on happen to be two's complement, which allows to * interchange INVALID_SOCKET and -1. */ -# define socket(d,t,p) ((int)socket(d,t,p)) -# define accept(s,f,l) ((int)accept(s,f,l)) -# endif +#define socket(d, t, p) ((int)socket(d, t, p)) +#define accept(s, f, l) ((int)accept(s, f, l)) +#endif /* Windows have other names for shutdown() reasons */ -# ifndef SHUT_RD -# define SHUT_RD SD_RECEIVE -# endif -# ifndef SHUT_WR -# define SHUT_WR SD_SEND -# endif -# ifndef SHUT_RDWR -# define SHUT_RDWR SD_BOTH -# endif +#ifndef SHUT_RD +#define SHUT_RD SD_RECEIVE +#endif +#ifndef SHUT_WR +#define SHUT_WR SD_SEND +#endif +#ifndef SHUT_RDWR +#define SHUT_RDWR SD_BOTH +#endif -# else -# if defined(__APPLE__) - /* - * This must be defined before including <netinet/in6.h> to get - * IPV6_RECVPKTINFO - */ -# define __APPLE_USE_RFC_3542 -# endif +#else +#if defined(__APPLE__) +/* + * This must be defined before including <netinet/in6.h> to get + * IPV6_RECVPKTINFO + */ +#define __APPLE_USE_RFC_3542 +#endif -# ifndef NO_SYS_PARAM_H -# include <sys/param.h> -# endif -# ifdef OPENSSL_SYS_VXWORKS -# include <time.h> -# endif +#ifndef NO_SYS_PARAM_H +#include <sys/param.h> +#endif +#ifdef OPENSSL_SYS_VXWORKS +#include <time.h> +#endif -# include <netdb.h> -# if defined(OPENSSL_SYS_VMS) -typedef size_t socklen_t; /* Currently appears to be missing on VMS */ -# endif -# if defined(OPENSSL_SYS_VMS_NODECC) -# include <socket.h> -# include <in.h> -# include <inet.h> -# else -# include <sys/socket.h> -# if !defined(NO_SYS_UN_H) && defined(AF_UNIX) && !defined(OPENSSL_NO_UNIX_SOCK) -# include <sys/un.h> -# ifndef UNIX_PATH_MAX -# define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path) -# endif -# endif -# ifdef FILIO_H -# include <sys/filio.h> /* FIONBIO in some SVR4, e.g. unixware, solaris */ -# endif -# include <netinet/in.h> -# include <arpa/inet.h> -# include <netinet/tcp.h> -# endif +#include <netdb.h> +#if defined(OPENSSL_SYS_VMS) +typedef size_t socklen_t; /* Currently appears to be missing on VMS */ +#endif +#if defined(OPENSSL_SYS_VMS_NODECC) +#include <socket.h> +#include <in.h> +#include <inet.h> +#else +#include <sys/socket.h> +#if !defined(NO_SYS_UN_H) && defined(AF_UNIX) && !defined(OPENSSL_NO_UNIX_SOCK) +#include <sys/un.h> +#ifndef UNIX_PATH_MAX +#define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path) +#endif +#endif +#ifdef FILIO_H +#include <sys/filio.h> /* FIONBIO in some SVR4, e.g. unixware, solaris */ +#endif +#include <netinet/in.h> +#include <arpa/inet.h> +#include <netinet/tcp.h> +#endif -# ifdef OPENSSL_SYS_AIX -# include <sys/select.h> -# endif +#ifdef OPENSSL_SYS_AIX +#include <sys/select.h> +#endif -# ifdef OPENSSL_SYS_UNIX -# ifndef OPENSSL_SYS_TANDEM -# include <poll.h> -# endif -# include <errno.h> -# endif +#ifdef OPENSSL_SYS_UNIX +#ifndef OPENSSL_SYS_TANDEM +#include <poll.h> +#endif +#include <errno.h> +#endif -# ifndef VMS -# include <sys/ioctl.h> -# else -# if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000) - /* ioctl is only in VMS > 7.0 and when socketshr is not used */ -# include <sys/ioctl.h> -# endif -# include <unixio.h> -# if defined(TCPIP_TYPE_SOCKETSHR) -# include <socketshr.h> -# endif -# endif +#ifndef VMS +#include <sys/ioctl.h> +#else +#if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000) +/* ioctl is only in VMS > 7.0 and when socketshr is not used */ +#include <sys/ioctl.h> +#endif +#include <unixio.h> +#if defined(TCPIP_TYPE_SOCKETSHR) +#include <socketshr.h> +#endif +#endif -# ifndef INVALID_SOCKET -# define INVALID_SOCKET (-1) -# endif -# endif +#ifndef INVALID_SOCKET +#define INVALID_SOCKET (-1) +#endif +#endif /* * Some IPv6 implementations are broken, you can disable them in known * bad versions. */ -# if !defined(OPENSSL_USE_IPV6) -# if defined(AF_INET6) -# define OPENSSL_USE_IPV6 1 -# else -# define OPENSSL_USE_IPV6 0 -# endif -# endif +#if !defined(OPENSSL_USE_IPV6) +#if defined(AF_INET6) +#define OPENSSL_USE_IPV6 1 +#else +#define OPENSSL_USE_IPV6 0 +#endif +#endif /* * Some platforms define AF_UNIX, but don't support it */ -# if !defined(OPENSSL_NO_UNIX_SOCK) -# if !defined(AF_UNIX) || defined(NO_SYS_UN_H) -# define OPENSSL_NO_UNIX_SOCK -# endif -# endif +#if !defined(OPENSSL_NO_UNIX_SOCK) +#if !defined(AF_UNIX) || defined(NO_SYS_UN_H) +#define OPENSSL_NO_UNIX_SOCK +#endif +#endif -# define get_last_socket_error() errno -# define clear_socket_error() errno=0 -# define get_last_socket_error_is_eintr() (get_last_socket_error() == EINTR) +#define get_last_socket_error() errno +#define clear_socket_error() errno = 0 +#define get_last_socket_error_is_eintr() (get_last_socket_error() == EINTR) -# if defined(OPENSSL_SYS_WINDOWS) -# undef get_last_socket_error -# undef clear_socket_error -# undef get_last_socket_error_is_eintr -# define get_last_socket_error() WSAGetLastError() -# define clear_socket_error() WSASetLastError(0) -# define get_last_socket_error_is_eintr() (get_last_socket_error() == WSAEINTR) -# define readsocket(s,b,n) recv((s),(b),(n),0) -# define writesocket(s,b,n) send((s),(b),(n),0) -# elif defined(__DJGPP__) -# define closesocket(s) close_s(s) -# define readsocket(s,b,n) read_s(s,b,n) -# define writesocket(s,b,n) send(s,b,n,0) -# elif defined(OPENSSL_SYS_VMS) -# define ioctlsocket(a,b,c) ioctl(a,b,c) -# define closesocket(s) close(s) -# define readsocket(s,b,n) recv((s),(b),(n),0) -# define writesocket(s,b,n) send((s),(b),(n),0) -# elif defined(OPENSSL_SYS_VXWORKS) -# define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c)) -# define closesocket(s) close(s) -# define readsocket(s,b,n) read((s),(b),(n)) -# define writesocket(s,b,n) write((s),(char *)(b),(n)) -# elif defined(OPENSSL_SYS_TANDEM) -# define readsocket(s,b,n) read((s),(b),(n)) -# define writesocket(s,b,n) write((s),(b),(n)) -# define ioctlsocket(a,b,c) ioctl(a,b,c) -# define closesocket(s) close(s) -# else -# define ioctlsocket(a,b,c) ioctl(a,b,c) -# define closesocket(s) close(s) -# define readsocket(s,b,n) read((s),(b),(n)) -# define writesocket(s,b,n) write((s),(b),(n)) -# endif +#if defined(OPENSSL_SYS_WINDOWS) +#undef get_last_socket_error +#undef clear_socket_error +#undef get_last_socket_error_is_eintr +#define get_last_socket_error() WSAGetLastError() +#define clear_socket_error() WSASetLastError(0) +#define get_last_socket_error_is_eintr() (get_last_socket_error() == WSAEINTR) +#define readsocket(s, b, n) recv((s), (b), (n), 0) +#define writesocket(s, b, n) send((s), (b), (n), 0) +#elif defined(__DJGPP__) +#define closesocket(s) close_s(s) +#define readsocket(s, b, n) read_s(s, b, n) +#define writesocket(s, b, n) send(s, b, n, 0) +#elif defined(OPENSSL_SYS_VMS) +#define ioctlsocket(a, b, c) ioctl(a, b, c) +#define closesocket(s) close(s) +#define readsocket(s, b, n) recv((s), (b), (n), 0) +#define writesocket(s, b, n) send((s), (b), (n), 0) +#elif defined(OPENSSL_SYS_VXWORKS) +#define ioctlsocket(a, b, c) ioctl((a), (b), (int)(c)) +#define closesocket(s) close(s) +#define readsocket(s, b, n) read((s), (b), (n)) +#define writesocket(s, b, n) write((s), (char *)(b), (n)) +#elif defined(OPENSSL_SYS_TANDEM) +#define readsocket(s, b, n) read((s), (b), (n)) +#define writesocket(s, b, n) write((s), (b), (n)) +#define ioctlsocket(a, b, c) ioctl(a, b, c) +#define closesocket(s) close(s) +#else +#define ioctlsocket(a, b, c) ioctl(a, b, c) +#define closesocket(s) close(s) +#define readsocket(s, b, n) read((s), (b), (n)) +#define writesocket(s, b, n) write((s), (b), (n)) +#endif /* also in apps/include/apps.h */ -# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE) -# define openssl_fdset(a, b) FD_SET((unsigned int)(a), b) -# else -# define openssl_fdset(a, b) FD_SET(a, b) -# endif +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE) +#define openssl_fdset(a, b) FD_SET((unsigned int)(a), b) +#else +#define openssl_fdset(a, b) FD_SET(a, b) +#endif #endif diff --git a/crypto/openssl/include/internal/ssl.h b/crypto/openssl/include/internal/ssl.h index 689f3484ff7b..5093f779e241 100644 --- a/crypto/openssl/include/internal/ssl.h +++ b/crypto/openssl/include/internal/ssl.h @@ -10,17 +10,24 @@ #include <openssl/ssl.h> #ifndef OSSL_INTERNAL_SSL_H -# define OSSL_INTERNAL_SSL_H -# pragma once +#define OSSL_INTERNAL_SSL_H +#pragma once typedef void (*ossl_msg_cb)(int write_p, int version, int content_type, - const void *buf, size_t len, SSL *ssl, void *arg); + const void *buf, size_t len, SSL *ssl, void *arg); int ossl_ssl_get_error(const SSL *s, int i, int check_err); +/* + * Test to see if an SSL_CTX is using a QUIC method + * This is public in the master branch + * but made private for current stable branches + */ +int SSL_CTX_is_quic(const SSL_CTX *c); + /* Set if this is the QUIC handshake layer */ -# define TLS1_FLAGS_QUIC 0x2000 +#define TLS1_FLAGS_QUIC 0x2000 /* Set if this is our QUIC handshake layer */ -# define TLS1_FLAGS_QUIC_INTERNAL 0x4000 +#define TLS1_FLAGS_QUIC_INTERNAL 0x4000 #endif diff --git a/crypto/openssl/include/internal/ssl3_cbc.h b/crypto/openssl/include/internal/ssl3_cbc.h index 4fb5da1906e2..4c102693a0fb 100644 --- a/crypto/openssl/include/internal/ssl3_cbc.h +++ b/crypto/openssl/include/internal/ssl3_cbc.h @@ -11,30 +11,30 @@ /* tls_pad.c */ int ssl3_cbc_remove_padding_and_mac(size_t *reclen, - size_t origreclen, - unsigned char *recdata, - unsigned char **mac, - int *alloced, - size_t block_size, size_t mac_size, - OSSL_LIB_CTX *libctx); + size_t origreclen, + unsigned char *recdata, + unsigned char **mac, + int *alloced, + size_t block_size, size_t mac_size, + OSSL_LIB_CTX *libctx); int tls1_cbc_remove_padding_and_mac(size_t *reclen, - size_t origreclen, - unsigned char *recdata, - unsigned char **mac, - int *alloced, - size_t block_size, size_t mac_size, - int aead, - OSSL_LIB_CTX *libctx); + size_t origreclen, + unsigned char *recdata, + unsigned char **mac, + int *alloced, + size_t block_size, size_t mac_size, + int aead, + OSSL_LIB_CTX *libctx); /* ssl3_cbc.c */ __owur char ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx); __owur int ssl3_cbc_digest_record(const EVP_MD *md, - unsigned char *md_out, - size_t *md_out_size, - const unsigned char *header, - const unsigned char *data, - size_t data_size, - size_t data_plus_mac_plus_padding_size, - const unsigned char *mac_secret, - size_t mac_secret_length, char is_sslv3); + unsigned char *md_out, + size_t *md_out_size, + const unsigned char *header, + const unsigned char *data, + size_t data_size, + size_t data_plus_mac_plus_padding_size, + const unsigned char *mac_secret, + size_t mac_secret_length, char is_sslv3); diff --git a/crypto/openssl/include/internal/ssl_unwrap.h b/crypto/openssl/include/internal/ssl_unwrap.h index 86c134569883..ec6dbffa924a 100644 --- a/crypto/openssl/include/internal/ssl_unwrap.h +++ b/crypto/openssl/include/internal/ssl_unwrap.h @@ -8,123 +8,121 @@ */ #ifndef OSSL_SSL_UNWRAP_H -# define OSSL_SSL_UNWRAP_H +#define OSSL_SSL_UNWRAP_H -# include <openssl/ssl.h> -# include "internal/quic_predef.h" +#include <openssl/ssl.h> +#include "internal/quic_predef.h" -# define SSL_CONNECTION_FROM_SSL_ONLY_int(ssl, c) \ - ((ssl) == NULL ? NULL \ - : ((ssl)->type == SSL_TYPE_SSL_CONNECTION \ - ? (c SSL_CONNECTION *)(ssl) \ - : NULL)) -# define SSL_CONNECTION_NO_CONST -# define SSL_CONNECTION_FROM_SSL_ONLY(ssl) \ +#define SSL_CONNECTION_FROM_SSL_ONLY_int(ssl, c) \ + ((ssl) == NULL ? NULL \ + : ((ssl)->type == SSL_TYPE_SSL_CONNECTION \ + ? (c SSL_CONNECTION *)(ssl) \ + : NULL)) +#define SSL_CONNECTION_NO_CONST +#define SSL_CONNECTION_FROM_SSL_ONLY(ssl) \ SSL_CONNECTION_FROM_SSL_ONLY_int(ssl, SSL_CONNECTION_NO_CONST) -# define SSL_CONNECTION_FROM_CONST_SSL_ONLY(ssl) \ +#define SSL_CONNECTION_FROM_CONST_SSL_ONLY(ssl) \ SSL_CONNECTION_FROM_SSL_ONLY_int(ssl, const) -# define SSL_CONNECTION_GET_CTX(sc) ((sc)->ssl.ctx) -# define SSL_CONNECTION_GET_SSL(sc) (&(sc)->ssl) -# define SSL_CONNECTION_GET_USER_SSL(sc) ((sc)->user_ssl) -# ifndef OPENSSL_NO_QUIC +#define SSL_CONNECTION_GET_CTX(sc) ((sc)->ssl.ctx) +#define SSL_CONNECTION_GET_SSL(sc) (&(sc)->ssl) +#define SSL_CONNECTION_GET_USER_SSL(sc) ((sc)->user_ssl) +#ifndef OPENSSL_NO_QUIC struct ssl_connection_st *ossl_quic_obj_get0_handshake_layer(QUIC_OBJ *obj); -# define SSL_CONNECTION_FROM_SSL_int(ssl, c) \ - ((ssl) == NULL ? NULL \ - : ((ssl)->type == SSL_TYPE_SSL_CONNECTION \ - ? (c SSL_CONNECTION *)(ssl) \ - : (SSL_TYPE_IS_QUIC((ssl)->type) \ - ? (c SSL_CONNECTION *)ossl_quic_obj_get0_handshake_layer((QUIC_OBJ *)(ssl)) \ - : NULL))) -# define SSL_CONNECTION_FROM_SSL(ssl) \ +#define SSL_CONNECTION_FROM_SSL_int(ssl, c) \ + ((ssl) == NULL ? NULL \ + : ((ssl)->type == SSL_TYPE_SSL_CONNECTION \ + ? (c SSL_CONNECTION *)(ssl) \ + : (SSL_TYPE_IS_QUIC((ssl)->type) \ + ? (c SSL_CONNECTION *)ossl_quic_obj_get0_handshake_layer((QUIC_OBJ *)(ssl)) \ + : NULL))) +#define SSL_CONNECTION_FROM_SSL(ssl) \ SSL_CONNECTION_FROM_SSL_int(ssl, SSL_CONNECTION_NO_CONST) -# define SSL_CONNECTION_FROM_CONST_SSL(ssl) \ +#define SSL_CONNECTION_FROM_CONST_SSL(ssl) \ SSL_CONNECTION_FROM_SSL_int(ssl, const) -# else -# define SSL_CONNECTION_FROM_SSL(ssl) \ +#else +#define SSL_CONNECTION_FROM_SSL(ssl) \ SSL_CONNECTION_FROM_SSL_ONLY_int(ssl, SSL_CONNECTION_NO_CONST) -# define SSL_CONNECTION_FROM_CONST_SSL(ssl) \ +#define SSL_CONNECTION_FROM_CONST_SSL(ssl) \ SSL_CONNECTION_FROM_SSL_ONLY_int(ssl, const) -# endif +#endif -# ifndef OPENSSL_NO_QUIC +#ifndef OPENSSL_NO_QUIC -# define IS_QUIC_METHOD(m) \ - ((m) == OSSL_QUIC_client_method() || \ - (m) == OSSL_QUIC_client_thread_method() || \ - (m) == OSSL_QUIC_server_method()) +#define IS_QUIC_METHOD(m) \ + ((m) == OSSL_QUIC_client_method() || (m) == OSSL_QUIC_client_thread_method() || (m) == OSSL_QUIC_server_method()) -# define IS_QUIC_CTX(ctx) IS_QUIC_METHOD((ctx)->method) +#define IS_QUIC_CTX(ctx) IS_QUIC_METHOD((ctx)->method) -# define QUIC_CONNECTION_FROM_SSL_int(ssl, c) \ - ((ssl) == NULL ? NULL \ - : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \ - ? (c QUIC_CONNECTION *)(ssl) \ - : NULL)) +#define QUIC_CONNECTION_FROM_SSL_int(ssl, c) \ + ((ssl) == NULL ? NULL \ + : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \ + ? (c QUIC_CONNECTION *)(ssl) \ + : NULL)) -# define QUIC_XSO_FROM_SSL_int(ssl, c) \ - ((ssl) == NULL \ - ? NULL \ - : (((ssl)->type == SSL_TYPE_QUIC_XSO \ - ? (c QUIC_XSO *)(ssl) \ - : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \ - ? (c QUIC_XSO *)((QUIC_CONNECTION *)(ssl))->default_xso \ - : NULL)))) +#define QUIC_XSO_FROM_SSL_int(ssl, c) \ + ((ssl) == NULL \ + ? NULL \ + : (((ssl)->type == SSL_TYPE_QUIC_XSO \ + ? (c QUIC_XSO *)(ssl) \ + : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \ + ? (c QUIC_XSO *)((QUIC_CONNECTION *)(ssl))->default_xso \ + : NULL)))) -# define SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, c) \ - ((ssl) == NULL ? NULL \ - : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \ - ? (c SSL_CONNECTION *)((c QUIC_CONNECTION *)(ssl))->tls \ - : NULL)) +#define SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, c) \ + ((ssl) == NULL ? NULL \ + : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \ + ? (c SSL_CONNECTION *)((c QUIC_CONNECTION *)(ssl))->tls \ + : NULL)) -# define QUIC_LISTENER_FROM_SSL_int(ssl, c) \ - ((ssl) == NULL \ - ? NULL \ - : ((ssl)->type == SSL_TYPE_QUIC_LISTENER \ - ? (c QUIC_LISTENER *)(ssl) \ - : NULL)) +#define QUIC_LISTENER_FROM_SSL_int(ssl, c) \ + ((ssl) == NULL \ + ? NULL \ + : ((ssl)->type == SSL_TYPE_QUIC_LISTENER \ + ? (c QUIC_LISTENER *)(ssl) \ + : NULL)) -# define QUIC_DOMAIN_FROM_SSL_int(ssl, c) \ - ((ssl) == NULL \ - ? NULL \ - : ((ssl)->type == SSL_TYPE_QUIC_DOMAIN \ - ? (c QUIC_DOMAIN *)(ssl) \ - : NULL)) +#define QUIC_DOMAIN_FROM_SSL_int(ssl, c) \ + ((ssl) == NULL \ + ? NULL \ + : ((ssl)->type == SSL_TYPE_QUIC_DOMAIN \ + ? (c QUIC_DOMAIN *)(ssl) \ + : NULL)) -# define IS_QUIC_CS(ssl) ((ssl) != NULL \ - && ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \ - || (ssl)->type == SSL_TYPE_QUIC_XSO)) +#define IS_QUIC_CS(ssl) ((ssl) != NULL \ + && ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \ + || (ssl)->type == SSL_TYPE_QUIC_XSO)) -# define IS_QUIC(ssl) \ +#define IS_QUIC(ssl) \ ((ssl) != NULL && SSL_TYPE_IS_QUIC((ssl)->type)) -# else +#else -# define QUIC_CONNECTION_FROM_SSL_int(ssl, c) NULL -# define QUIC_XSO_FROM_SSL_int(ssl, c) NULL -# define QUIC_LISTENER_FROM_SSL_int(ssl, c) NULL -# define SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, c) NULL -# define IS_QUIC(ssl) 0 -# define IS_QUIC_CS(ssl) 0 -# define IS_QUIC_CTX(ctx) 0 -# define IS_QUIC_METHOD(m) 0 +#define QUIC_CONNECTION_FROM_SSL_int(ssl, c) NULL +#define QUIC_XSO_FROM_SSL_int(ssl, c) NULL +#define QUIC_LISTENER_FROM_SSL_int(ssl, c) NULL +#define SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, c) NULL +#define IS_QUIC(ssl) 0 +#define IS_QUIC_CS(ssl) 0 +#define IS_QUIC_CTX(ctx) 0 +#define IS_QUIC_METHOD(m) 0 -# endif +#endif -# define QUIC_CONNECTION_FROM_SSL(ssl) \ +#define QUIC_CONNECTION_FROM_SSL(ssl) \ QUIC_CONNECTION_FROM_SSL_int(ssl, SSL_CONNECTION_NO_CONST) -# define QUIC_CONNECTION_FROM_CONST_SSL(ssl) \ +#define QUIC_CONNECTION_FROM_CONST_SSL(ssl) \ QUIC_CONNECTION_FROM_SSL_int(ssl, const) -# define QUIC_XSO_FROM_SSL(ssl) \ +#define QUIC_XSO_FROM_SSL(ssl) \ QUIC_XSO_FROM_SSL_int(ssl, SSL_CONNECTION_NO_CONST) -# define QUIC_XSO_FROM_CONST_SSL(ssl) \ +#define QUIC_XSO_FROM_CONST_SSL(ssl) \ QUIC_XSO_FROM_SSL_int(ssl, const) -# define QUIC_LISTENER_FROM_SSL(ssl) \ +#define QUIC_LISTENER_FROM_SSL(ssl) \ QUIC_LISTENER_FROM_SSL_int(ssl, SSL_CONNECTION_NO_CONST) -# define QUIC_LISTENER_FROM_CONST_SSL(ssl) \ +#define QUIC_LISTENER_FROM_CONST_SSL(ssl) \ QUIC_LISTENER_FROM_SSL_int(ssl, const) -# define SSL_CONNECTION_FROM_QUIC_SSL(ssl) \ +#define SSL_CONNECTION_FROM_QUIC_SSL(ssl) \ SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, SSL_CONNECTION_NO_CONST) -# define SSL_CONNECTION_FROM_CONST_QUIC_SSL(ssl) \ +#define SSL_CONNECTION_FROM_CONST_QUIC_SSL(ssl) \ SSL_CONNECTION_FROM_CONST_QUIC_SSL_int(ssl, const) #endif diff --git a/crypto/openssl/include/internal/sslconf.h b/crypto/openssl/include/internal/sslconf.h index fd7f7e333183..a7cec01bf627 100644 --- a/crypto/openssl/include/internal/sslconf.h +++ b/crypto/openssl/include/internal/sslconf.h @@ -8,14 +8,14 @@ */ #ifndef OSSL_INTERNAL_SSLCONF_H -# define OSSL_INTERNAL_SSLCONF_H -# pragma once +#define OSSL_INTERNAL_SSLCONF_H +#pragma once typedef struct ssl_conf_cmd_st SSL_CONF_CMD; const SSL_CONF_CMD *conf_ssl_get(size_t idx, const char **name, size_t *cnt); int conf_ssl_name_find(const char *name, size_t *idx); void conf_ssl_get_cmd(const SSL_CONF_CMD *cmd, size_t idx, char **cmdstr, - char **arg); + char **arg); #endif diff --git a/crypto/openssl/include/internal/statem.h b/crypto/openssl/include/internal/statem.h index 261d7967cc9a..a41ed3227031 100644 --- a/crypto/openssl/include/internal/statem.h +++ b/crypto/openssl/include/internal/statem.h @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ #ifndef OSSL_INTERNAL_STATEM_H -# define OSSL_INTERNAL_STATEM_H +#define OSSL_INTERNAL_STATEM_H /***************************************************************************** * * @@ -82,10 +82,10 @@ typedef enum { } CON_FUNC_RETURN; typedef int (*ossl_statem_mutate_handshake_cb)(const unsigned char *msgin, - size_t inlen, - unsigned char **msgout, - size_t *outlen, - void *arg); + size_t inlen, + unsigned char **msgout, + size_t *outlen, + void *arg); typedef void (*ossl_statem_finish_mutate_handshake_cb)(void *arg); @@ -143,13 +143,13 @@ void ossl_statem_clear(SSL_CONNECTION *s); void ossl_statem_set_renegotiate(SSL_CONNECTION *s); void ossl_statem_send_fatal(SSL_CONNECTION *s, int al); void ossl_statem_fatal(SSL_CONNECTION *s, int al, int reason, - const char *fmt, ...); -# define SSLfatal_alert(s, al) ossl_statem_send_fatal((s), (al)) -# define SSLfatal(s, al, r) SSLfatal_data((s), (al), (r), NULL) -# define SSLfatal_data \ - (ERR_new(), \ - ERR_set_debug(OPENSSL_FILE, OPENSSL_LINE, OPENSSL_FUNC), \ - ossl_statem_fatal) + const char *fmt, ...); +#define SSLfatal_alert(s, al) ossl_statem_send_fatal((s), (al)) +#define SSLfatal(s, al, r) SSLfatal_data((s), (al), (r), NULL) +#define SSLfatal_data \ + (ERR_new(), \ + ERR_set_debug(OPENSSL_FILE, OPENSSL_LINE, OPENSSL_FUNC), \ + ossl_statem_fatal) int ossl_statem_in_error(const SSL_CONNECTION *s); void ossl_statem_set_in_init(SSL_CONNECTION *s, int init); @@ -166,8 +166,8 @@ __owur int ossl_statem_export_early_allowed(SSL_CONNECTION *s); int statem_flush(SSL_CONNECTION *s); int ossl_statem_set_mutator(SSL *s, - ossl_statem_mutate_handshake_cb mutate_handshake_cb, - ossl_statem_finish_mutate_handshake_cb finish_mutate_handshake_cb, - void *mutatearg); + ossl_statem_mutate_handshake_cb mutate_handshake_cb, + ossl_statem_finish_mutate_handshake_cb finish_mutate_handshake_cb, + void *mutatearg); #endif diff --git a/crypto/openssl/include/internal/symhacks.h b/crypto/openssl/include/internal/symhacks.h index 33bae51e49cc..01433c306152 100644 --- a/crypto/openssl/include/internal/symhacks.h +++ b/crypto/openssl/include/internal/symhacks.h @@ -8,20 +8,20 @@ */ #ifndef OSSL_INTERNAL_SYMHACKS_H -# define OSSL_INTERNAL_SYMHACKS_H -# pragma once +#define OSSL_INTERNAL_SYMHACKS_H +#pragma once -# include <openssl/e_os2.h> +#include <openssl/e_os2.h> -# if defined(OPENSSL_SYS_VMS) +#if defined(OPENSSL_SYS_VMS) /* ossl_provider_gettable_params vs OSSL_PROVIDER_gettable_params */ -# undef ossl_provider_gettable_params -# define ossl_provider_gettable_params ossl_int_prov_gettable_params +#undef ossl_provider_gettable_params +#define ossl_provider_gettable_params ossl_int_prov_gettable_params /* ossl_provider_get_params vs OSSL_PROVIDER_get_params */ -# undef ossl_provider_get_params -# define ossl_provider_get_params ossl_int_prov_get_params +#undef ossl_provider_get_params +#define ossl_provider_get_params ossl_int_prov_get_params -# endif +#endif -#endif /* ! defined HEADER_VMS_IDHACKS_H */ +#endif /* ! defined HEADER_VMS_IDHACKS_H */ diff --git a/crypto/openssl/include/internal/thread.h b/crypto/openssl/include/internal/thread.h index 8c5bad77635e..eaff038567ee 100644 --- a/crypto/openssl/include/internal/thread.h +++ b/crypto/openssl/include/internal/thread.h @@ -8,23 +8,23 @@ */ #ifndef OPENSSL_INTERNAL_THREAD_H -# define OPENSSL_INTERNAL_THREAD_H -# include <openssl/configuration.h> -# include <internal/thread_arch.h> -# include <openssl/e_os2.h> -# include <openssl/types.h> -# include <internal/cryptlib.h> -# include "crypto/context.h" +#define OPENSSL_INTERNAL_THREAD_H +#include <openssl/configuration.h> +#include <internal/thread_arch.h> +#include <openssl/e_os2.h> +#include <openssl/types.h> +#include <internal/cryptlib.h> +#include "crypto/context.h" void *ossl_crypto_thread_start(OSSL_LIB_CTX *ctx, CRYPTO_THREAD_ROUTINE start, - void *data); + void *data); int ossl_crypto_thread_join(void *task, CRYPTO_THREAD_RETVAL *retval); int ossl_crypto_thread_clean(void *vhandle); uint64_t ossl_get_avail_threads(OSSL_LIB_CTX *ctx); -# if defined(OPENSSL_THREADS) +#if defined(OPENSSL_THREADS) -# define OSSL_LIB_CTX_GET_THREADS(CTX) \ +#define OSSL_LIB_CTX_GET_THREADS(CTX) \ ossl_lib_ctx_get_data(CTX, OSSL_LIB_CTX_THREAD_INDEX); typedef struct openssl_threads_st { @@ -34,6 +34,6 @@ typedef struct openssl_threads_st { CRYPTO_CONDVAR *cond_finished; } OSSL_LIB_CTX_THREADS; -# endif /* defined(OPENSSL_THREADS) */ +#endif /* defined(OPENSSL_THREADS) */ #endif /* OPENSSL_INTERNAL_THREAD_H */ diff --git a/crypto/openssl/include/internal/thread_arch.h b/crypto/openssl/include/internal/thread_arch.h index aba9362e8d6f..d7fc08a8afaa 100644 --- a/crypto/openssl/include/internal/thread_arch.h +++ b/crypto/openssl/include/internal/thread_arch.h @@ -8,34 +8,33 @@ */ #ifndef OSSL_INTERNAL_THREAD_ARCH_H -# define OSSL_INTERNAL_THREAD_ARCH_H -# include <openssl/configuration.h> -# include <openssl/e_os2.h> -# include "internal/time.h" +#define OSSL_INTERNAL_THREAD_ARCH_H +#include <openssl/configuration.h> +#include <openssl/e_os2.h> +#include "internal/time.h" -# if defined(_WIN32) -# include <windows.h> -# endif +#if defined(_WIN32) +#include <windows.h> +#endif -# if defined(OPENSSL_THREADS) && defined(OPENSSL_SYS_UNIX) -# define OPENSSL_THREADS_POSIX -# elif defined(OPENSSL_THREADS) && defined(OPENSSL_SYS_VMS) -# define OPENSSL_THREADS_POSIX -# elif defined(OPENSSL_THREADS) && defined(OPENSSL_SYS_WINDOWS) && \ - defined(_WIN32_WINNT) -# if _WIN32_WINNT >= 0x0600 -# define OPENSSL_THREADS_WINNT -# elif _WIN32_WINNT >= 0x0501 -# define OPENSSL_THREADS_WINNT -# define OPENSSL_THREADS_WINNT_LEGACY -# else -# define OPENSSL_THREADS_NONE -# endif -# else -# define OPENSSL_THREADS_NONE -# endif +#if defined(OPENSSL_THREADS) && defined(OPENSSL_SYS_UNIX) +#define OPENSSL_THREADS_POSIX +#elif defined(OPENSSL_THREADS) && defined(OPENSSL_SYS_VMS) +#define OPENSSL_THREADS_POSIX +#elif defined(OPENSSL_THREADS) && defined(OPENSSL_SYS_WINDOWS) && defined(_WIN32_WINNT) +#if _WIN32_WINNT >= 0x0600 +#define OPENSSL_THREADS_WINNT +#elif _WIN32_WINNT >= 0x0501 +#define OPENSSL_THREADS_WINNT +#define OPENSSL_THREADS_WINNT_LEGACY +#else +#define OPENSSL_THREADS_NONE +#endif +#else +#define OPENSSL_THREADS_NONE +#endif -# include <openssl/crypto.h> +#include <openssl/crypto.h> typedef struct crypto_mutex_st CRYPTO_MUTEX; typedef struct crypto_condvar_st CRYPTO_CONDVAR; @@ -49,7 +48,7 @@ void ossl_crypto_mutex_free(CRYPTO_MUTEX **mutex); CRYPTO_CONDVAR *ossl_crypto_condvar_new(void); void ossl_crypto_condvar_wait(CRYPTO_CONDVAR *cv, CRYPTO_MUTEX *mutex); void ossl_crypto_condvar_wait_timeout(CRYPTO_CONDVAR *cv, CRYPTO_MUTEX *mutex, - OSSL_TIME deadline); + OSSL_TIME deadline); void ossl_crypto_condvar_broadcast(CRYPTO_CONDVAR *cv); void ossl_crypto_condvar_signal(CRYPTO_CONDVAR *cv); void ossl_crypto_condvar_free(CRYPTO_CONDVAR **cv); @@ -57,16 +56,16 @@ void ossl_crypto_condvar_free(CRYPTO_CONDVAR **cv); typedef uint32_t CRYPTO_THREAD_RETVAL; typedef CRYPTO_THREAD_RETVAL (*CRYPTO_THREAD_ROUTINE)(void *); typedef CRYPTO_THREAD_RETVAL (*CRYPTO_THREAD_ROUTINE_CB)(void *, - void (**)(void *), - void **); + void (**)(void *), + void **); -# define CRYPTO_THREAD_NO_STATE 0UL -# define CRYPTO_THREAD_FINISHED (1UL << 0) -# define CRYPTO_THREAD_JOIN_AWAIT (1UL << 1) -# define CRYPTO_THREAD_JOINED (1UL << 2) +#define CRYPTO_THREAD_NO_STATE 0UL +#define CRYPTO_THREAD_FINISHED (1UL << 0) +#define CRYPTO_THREAD_JOIN_AWAIT (1UL << 1) +#define CRYPTO_THREAD_JOINED (1UL << 2) -# define CRYPTO_THREAD_GET_STATE(THREAD, FLAG) ((THREAD)->state & (FLAG)) -# define CRYPTO_THREAD_GET_ERROR(THREAD, FLAG) (((THREAD)->state >> 16) & (FLAG)) +#define CRYPTO_THREAD_GET_STATE(THREAD, FLAG) ((THREAD)->state & (FLAG)) +#define CRYPTO_THREAD_GET_ERROR(THREAD, FLAG) (((THREAD)->state >> 16) & (FLAG)) typedef struct crypto_thread_st { uint32_t state; @@ -82,44 +81,44 @@ typedef struct crypto_thread_st { OSSL_LIB_CTX *ctx; } CRYPTO_THREAD; -# if defined(OPENSSL_THREADS) +#if defined(OPENSSL_THREADS) -# define CRYPTO_THREAD_UNSET_STATE(THREAD, FLAG) \ - do { \ - (THREAD)->state &= ~(FLAG); \ +#define CRYPTO_THREAD_UNSET_STATE(THREAD, FLAG) \ + do { \ + (THREAD)->state &= ~(FLAG); \ } while ((void)0, 0) -# define CRYPTO_THREAD_SET_STATE(THREAD, FLAG) \ - do { \ - (THREAD)->state |= (FLAG); \ +#define CRYPTO_THREAD_SET_STATE(THREAD, FLAG) \ + do { \ + (THREAD)->state |= (FLAG); \ } while ((void)0, 0) -# define CRYPTO_THREAD_SET_ERROR(THREAD, FLAG) \ - do { \ - (THREAD)->state |= ((FLAG) << 16); \ +#define CRYPTO_THREAD_SET_ERROR(THREAD, FLAG) \ + do { \ + (THREAD)->state |= ((FLAG) << 16); \ } while ((void)0, 0) -# define CRYPTO_THREAD_UNSET_ERROR(THREAD, FLAG) \ - do { \ - (THREAD)->state &= ~((FLAG) << 16); \ +#define CRYPTO_THREAD_UNSET_ERROR(THREAD, FLAG) \ + do { \ + (THREAD)->state &= ~((FLAG) << 16); \ } while ((void)0, 0) -# else +#else -# define CRYPTO_THREAD_UNSET_STATE(THREAD, FLAG) -# define CRYPTO_THREAD_SET_STATE(THREAD, FLAG) -# define CRYPTO_THREAD_SET_ERROR(THREAD, FLAG) -# define CRYPTO_THREAD_UNSET_ERROR(THREAD, FLAG) +#define CRYPTO_THREAD_UNSET_STATE(THREAD, FLAG) +#define CRYPTO_THREAD_SET_STATE(THREAD, FLAG) +#define CRYPTO_THREAD_SET_ERROR(THREAD, FLAG) +#define CRYPTO_THREAD_UNSET_ERROR(THREAD, FLAG) -# endif /* defined(OPENSSL_THREADS) */ +#endif /* defined(OPENSSL_THREADS) */ -CRYPTO_THREAD * ossl_crypto_thread_native_start(CRYPTO_THREAD_ROUTINE routine, - void *data, int joinable); +CRYPTO_THREAD *ossl_crypto_thread_native_start(CRYPTO_THREAD_ROUTINE routine, + void *data, int joinable); int ossl_crypto_thread_native_spawn(CRYPTO_THREAD *thread); int ossl_crypto_thread_native_join(CRYPTO_THREAD *thread, - CRYPTO_THREAD_RETVAL *retval); + CRYPTO_THREAD_RETVAL *retval); int ossl_crypto_thread_native_perform_join(CRYPTO_THREAD *thread, - CRYPTO_THREAD_RETVAL *retval); + CRYPTO_THREAD_RETVAL *retval); int ossl_crypto_thread_native_exit(void); int ossl_crypto_thread_native_is_self(CRYPTO_THREAD *thread); int ossl_crypto_thread_native_clean(CRYPTO_THREAD *thread); diff --git a/crypto/openssl/include/internal/thread_once.h b/crypto/openssl/include/internal/thread_once.h index d6cb2eeec3bc..8c969441f3d7 100644 --- a/crypto/openssl/include/internal/thread_once.h +++ b/crypto/openssl/include/internal/thread_once.h @@ -8,10 +8,10 @@ */ #ifndef OSSL_INTERNAL_THREAD_ONCE_H -# define OSSL_INTERNAL_THREAD_ONCE_H -# pragma once +#define OSSL_INTERNAL_THREAD_ONCE_H +#pragma once -# include <openssl/crypto.h> +#include <openssl/crypto.h> /* * Initialisation of global data should never happen via "RUN_ONCE" inside the @@ -19,7 +19,7 @@ * OSSL_LIB_CTX object. In this way data will get cleaned up correctly when the * module gets unloaded. */ -# if !defined(FIPS_MODULE) || defined(ALLOW_RUN_ONCE_IN_FIPS) +#if !defined(FIPS_MODULE) || defined(ALLOW_RUN_ONCE_IN_FIPS) /* * DEFINE_RUN_ONCE: Define an initialiser function that should be run exactly * once. It takes no arguments and returns an int result (1 for success or @@ -34,21 +34,21 @@ * return 0; * } */ -# define DEFINE_RUN_ONCE(init) \ - static int init(void); \ - int init##_ossl_ret_ = 0; \ - void init##_ossl_(void) \ - { \ - init##_ossl_ret_ = init(); \ - } \ +#define DEFINE_RUN_ONCE(init) \ + static int init(void); \ + int init##_ossl_ret_ = 0; \ + void init##_ossl_(void) \ + { \ + init##_ossl_ret_ = init(); \ + } \ static int init(void) /* * DECLARE_RUN_ONCE: Declare an initialiser function that should be run exactly * once that has been defined in another file via DEFINE_RUN_ONCE(). */ -# define DECLARE_RUN_ONCE(init) \ - extern int init##_ossl_ret_; \ +#define DECLARE_RUN_ONCE(init) \ + extern int init##_ossl_ret_; \ void init##_ossl_(void); /* @@ -66,13 +66,13 @@ * return 0; * } */ -# define DEFINE_RUN_ONCE_STATIC(init) \ - static int init(void); \ - static int init##_ossl_ret_ = 0; \ - static void init##_ossl_(void) \ - { \ - init##_ossl_ret_ = init(); \ - } \ +#define DEFINE_RUN_ONCE_STATIC(init) \ + static int init(void); \ + static int init##_ossl_ret_ = 0; \ + static void init##_ossl_(void) \ + { \ + init##_ossl_ret_ = init(); \ + } \ static int init(void) /* @@ -107,7 +107,7 @@ * return 0; * } */ -# define DEFINE_RUN_ONCE_STATIC_ALT(initalt, init) \ +#define DEFINE_RUN_ONCE_STATIC_ALT(initalt, init) \ static int initalt(void); \ static void initalt##_ossl_(void) \ { \ @@ -126,7 +126,7 @@ * * (*) by convention, since the init function must return 1 on success. */ -# define RUN_ONCE(once, init) \ +#define RUN_ONCE(once, init) \ (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0) /* @@ -144,8 +144,8 @@ * * (*) by convention, since the init function must return 1 on success. */ -# define RUN_ONCE_ALT(once, initalt, init) \ +#define RUN_ONCE_ALT(once, initalt, init) \ (CRYPTO_THREAD_run_once(once, initalt##_ossl_) ? init##_ossl_ret_ : 0) -# endif /* FIPS_MODULE */ +#endif /* FIPS_MODULE */ #endif /* OSSL_INTERNAL_THREAD_ONCE_H */ diff --git a/crypto/openssl/include/internal/time.h b/crypto/openssl/include/internal/time.h index 140dc1f33881..db1824842772 100644 --- a/crypto/openssl/include/internal/time.h +++ b/crypto/openssl/include/internal/time.h @@ -1,5 +1,5 @@ /* - * Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2022-2026 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,13 +8,13 @@ */ #ifndef OSSL_INTERNAL_TIME_H -# define OSSL_INTERNAL_TIME_H -# pragma once +#define OSSL_INTERNAL_TIME_H +#pragma once -# include <openssl/e_os2.h> /* uint64_t */ -# include "internal/e_os.h" -# include "internal/e_winsock.h" /* for struct timeval */ -# include "internal/safe_math.h" +#include <openssl/e_os2.h> /* uint64_t */ +#include "internal/e_os.h" +#include "internal/e_winsock.h" /* for struct timeval */ +#include "internal/safe_math.h" /* * Internal type defining a time. @@ -24,20 +24,20 @@ * a range of 584 years roughly. */ typedef struct { - uint64_t t; /* Ticks since the epoch */ + uint64_t t; /* Ticks since the epoch */ } OSSL_TIME; /* The precision of times allows this many values per second */ -# define OSSL_TIME_SECOND ((uint64_t)1000000000) +#define OSSL_TIME_SECOND ((uint64_t)1000000000) /* One millisecond. */ -# define OSSL_TIME_MS (OSSL_TIME_SECOND / 1000) +#define OSSL_TIME_MS (OSSL_TIME_SECOND / 1000) /* One microsecond. */ -# define OSSL_TIME_US (OSSL_TIME_MS / 1000) +#define OSSL_TIME_US (OSSL_TIME_MS / 1000) /* One nanosecond. */ -# define OSSL_TIME_NS (OSSL_TIME_US / 1000) +#define OSSL_TIME_NS (OSSL_TIME_US / 1000) #define ossl_seconds2time(s) ossl_ticks2time((s) * OSSL_TIME_SECOND) #define ossl_time2seconds(t) (ossl_time2ticks(t) / OSSL_TIME_SECOND) @@ -54,8 +54,8 @@ typedef struct { OSSL_SAFE_MATH_UNSIGNED(time, uint64_t) /* Convert a tick count into a time */ -static ossl_unused ossl_inline -OSSL_TIME ossl_ticks2time(uint64_t ticks) +static ossl_unused ossl_inline OSSL_TIME +ossl_ticks2time(uint64_t ticks) { OSSL_TIME r; @@ -64,8 +64,8 @@ OSSL_TIME ossl_ticks2time(uint64_t ticks) } /* Convert a time to a tick count */ -static ossl_unused ossl_inline -uint64_t ossl_time2ticks(OSSL_TIME t) +static ossl_unused ossl_inline uint64_t +ossl_time2ticks(OSSL_TIME t) { return t.t; } @@ -74,22 +74,20 @@ uint64_t ossl_time2ticks(OSSL_TIME t) OSSL_TIME ossl_time_now(void); /* The beginning and end of the time range */ -static ossl_unused ossl_inline -OSSL_TIME ossl_time_zero(void) +static ossl_unused ossl_inline OSSL_TIME +ossl_time_zero(void) { return ossl_ticks2time(0); } -static ossl_unused ossl_inline -OSSL_TIME ossl_time_infinite(void) +static ossl_unused ossl_inline OSSL_TIME +ossl_time_infinite(void) { return ossl_ticks2time(~(uint64_t)0); } - /* Convert time to timeval */ -static ossl_unused ossl_inline -struct timeval ossl_time_to_timeval(OSSL_TIME t) +static ossl_unused ossl_inline struct timeval ossl_time_to_timeval(OSSL_TIME t) { struct timeval tv; int err = 0; @@ -112,8 +110,8 @@ struct timeval ossl_time_to_timeval(OSSL_TIME t) } /* Convert timeval to time */ -static ossl_unused ossl_inline -OSSL_TIME ossl_time_from_timeval(struct timeval tv) +static ossl_unused ossl_inline OSSL_TIME +ossl_time_from_timeval(struct timeval tv) { OSSL_TIME t; @@ -127,14 +125,15 @@ OSSL_TIME ossl_time_from_timeval(struct timeval tv) /* Convert OSSL_TIME to time_t */ static ossl_unused ossl_inline -time_t ossl_time_to_time_t(OSSL_TIME t) + time_t + ossl_time_to_time_t(OSSL_TIME t) { return (time_t)(t.t / OSSL_TIME_SECOND); } /* Convert time_t to OSSL_TIME */ -static ossl_unused ossl_inline -OSSL_TIME ossl_time_from_time_t(time_t t) +static ossl_unused ossl_inline OSSL_TIME +ossl_time_from_time_t(time_t t) { OSSL_TIME ot; @@ -144,8 +143,7 @@ OSSL_TIME ossl_time_from_time_t(time_t t) } /* Compare two time values, return -1 if less, 1 if greater and 0 if equal */ -static ossl_unused ossl_inline -int ossl_time_compare(OSSL_TIME a, OSSL_TIME b) +static ossl_unused ossl_inline int ossl_time_compare(OSSL_TIME a, OSSL_TIME b) { if (a.t > b.t) return 1; @@ -155,21 +153,19 @@ int ossl_time_compare(OSSL_TIME a, OSSL_TIME b) } /* Returns true if an OSSL_TIME is ossl_time_zero(). */ -static ossl_unused ossl_inline -int ossl_time_is_zero(OSSL_TIME t) +static ossl_unused ossl_inline int ossl_time_is_zero(OSSL_TIME t) { return ossl_time_compare(t, ossl_time_zero()) == 0; } /* Returns true if an OSSL_TIME is ossl_time_infinite(). */ -static ossl_unused ossl_inline -int ossl_time_is_infinite(OSSL_TIME t) +static ossl_unused ossl_inline int ossl_time_is_infinite(OSSL_TIME t) { return ossl_time_compare(t, ossl_time_infinite()) == 0; } -static ossl_unused ossl_inline -OSSL_TIME ossl_time_add(OSSL_TIME a, OSSL_TIME b) +static ossl_unused ossl_inline OSSL_TIME +ossl_time_add(OSSL_TIME a, OSSL_TIME b) { OSSL_TIME r; int err = 0; @@ -178,8 +174,8 @@ OSSL_TIME ossl_time_add(OSSL_TIME a, OSSL_TIME b) return err ? ossl_time_infinite() : r; } -static ossl_unused ossl_inline -OSSL_TIME ossl_time_subtract(OSSL_TIME a, OSSL_TIME b) +static ossl_unused ossl_inline OSSL_TIME +ossl_time_subtract(OSSL_TIME a, OSSL_TIME b) { OSSL_TIME r; int err = 0; @@ -189,15 +185,15 @@ OSSL_TIME ossl_time_subtract(OSSL_TIME a, OSSL_TIME b) } /* Returns |a - b|. */ -static ossl_unused ossl_inline -OSSL_TIME ossl_time_abs_difference(OSSL_TIME a, OSSL_TIME b) +static ossl_unused ossl_inline OSSL_TIME +ossl_time_abs_difference(OSSL_TIME a, OSSL_TIME b) { return a.t > b.t ? ossl_time_subtract(a, b) : ossl_time_subtract(b, a); } -static ossl_unused ossl_inline -OSSL_TIME ossl_time_multiply(OSSL_TIME a, uint64_t b) +static ossl_unused ossl_inline OSSL_TIME +ossl_time_multiply(OSSL_TIME a, uint64_t b) { OSSL_TIME r; int err = 0; @@ -206,8 +202,8 @@ OSSL_TIME ossl_time_multiply(OSSL_TIME a, uint64_t b) return err ? ossl_time_infinite() : r; } -static ossl_unused ossl_inline -OSSL_TIME ossl_time_divide(OSSL_TIME a, uint64_t b) +static ossl_unused ossl_inline OSSL_TIME +ossl_time_divide(OSSL_TIME a, uint64_t b) { OSSL_TIME r; int err = 0; @@ -216,8 +212,8 @@ OSSL_TIME ossl_time_divide(OSSL_TIME a, uint64_t b) return err ? ossl_time_zero() : r; } -static ossl_unused ossl_inline -OSSL_TIME ossl_time_muldiv(OSSL_TIME a, uint64_t b, uint64_t c) +static ossl_unused ossl_inline OSSL_TIME +ossl_time_muldiv(OSSL_TIME a, uint64_t b, uint64_t c) { OSSL_TIME r; int err = 0; @@ -227,15 +223,15 @@ OSSL_TIME ossl_time_muldiv(OSSL_TIME a, uint64_t b, uint64_t c) } /* Return higher of the two given time values. */ -static ossl_unused ossl_inline -OSSL_TIME ossl_time_max(OSSL_TIME a, OSSL_TIME b) +static ossl_unused ossl_inline OSSL_TIME +ossl_time_max(OSSL_TIME a, OSSL_TIME b) { return a.t > b.t ? a : b; } /* Return the lower of the two given time values. */ -static ossl_unused ossl_inline -OSSL_TIME ossl_time_min(OSSL_TIME a, OSSL_TIME b) +static ossl_unused ossl_inline OSSL_TIME +ossl_time_min(OSSL_TIME a, OSSL_TIME b) { return a.t < b.t ? a : b; } diff --git a/crypto/openssl/include/internal/tlsgroups.h b/crypto/openssl/include/internal/tlsgroups.h index 14f2f47f76cd..1fd41993ea79 100644 --- a/crypto/openssl/include/internal/tlsgroups.h +++ b/crypto/openssl/include/internal/tlsgroups.h @@ -8,59 +8,59 @@ */ #ifndef OSSL_INTERNAL_TLSGROUPS_H -# define OSSL_INTERNAL_TLSGROUPS_H -# pragma once +#define OSSL_INTERNAL_TLSGROUPS_H +#pragma once -# define OSSL_TLS_GROUP_ID_sect163k1 0x0001 -# define OSSL_TLS_GROUP_ID_sect163r1 0x0002 -# define OSSL_TLS_GROUP_ID_sect163r2 0x0003 -# define OSSL_TLS_GROUP_ID_sect193r1 0x0004 -# define OSSL_TLS_GROUP_ID_sect193r2 0x0005 -# define OSSL_TLS_GROUP_ID_sect233k1 0x0006 -# define OSSL_TLS_GROUP_ID_sect233r1 0x0007 -# define OSSL_TLS_GROUP_ID_sect239k1 0x0008 -# define OSSL_TLS_GROUP_ID_sect283k1 0x0009 -# define OSSL_TLS_GROUP_ID_sect283r1 0x000A -# define OSSL_TLS_GROUP_ID_sect409k1 0x000B -# define OSSL_TLS_GROUP_ID_sect409r1 0x000C -# define OSSL_TLS_GROUP_ID_sect571k1 0x000D -# define OSSL_TLS_GROUP_ID_sect571r1 0x000E -# define OSSL_TLS_GROUP_ID_secp160k1 0x000F -# define OSSL_TLS_GROUP_ID_secp160r1 0x0010 -# define OSSL_TLS_GROUP_ID_secp160r2 0x0011 -# define OSSL_TLS_GROUP_ID_secp192k1 0x0012 -# define OSSL_TLS_GROUP_ID_secp192r1 0x0013 -# define OSSL_TLS_GROUP_ID_secp224k1 0x0014 -# define OSSL_TLS_GROUP_ID_secp224r1 0x0015 -# define OSSL_TLS_GROUP_ID_secp256k1 0x0016 -# define OSSL_TLS_GROUP_ID_secp256r1 0x0017 -# define OSSL_TLS_GROUP_ID_secp384r1 0x0018 -# define OSSL_TLS_GROUP_ID_secp521r1 0x0019 -# define OSSL_TLS_GROUP_ID_brainpoolP256r1 0x001A -# define OSSL_TLS_GROUP_ID_brainpoolP384r1 0x001B -# define OSSL_TLS_GROUP_ID_brainpoolP512r1 0x001C -# define OSSL_TLS_GROUP_ID_x25519 0x001D -# define OSSL_TLS_GROUP_ID_x448 0x001E -# define OSSL_TLS_GROUP_ID_brainpoolP256r1_tls13 0x001F -# define OSSL_TLS_GROUP_ID_brainpoolP384r1_tls13 0x0020 -# define OSSL_TLS_GROUP_ID_brainpoolP512r1_tls13 0x0021 -# define OSSL_TLS_GROUP_ID_gc256A 0x0022 -# define OSSL_TLS_GROUP_ID_gc256B 0x0023 -# define OSSL_TLS_GROUP_ID_gc256C 0x0024 -# define OSSL_TLS_GROUP_ID_gc256D 0x0025 -# define OSSL_TLS_GROUP_ID_gc512A 0x0026 -# define OSSL_TLS_GROUP_ID_gc512B 0x0027 -# define OSSL_TLS_GROUP_ID_gc512C 0x0028 -# define OSSL_TLS_GROUP_ID_ffdhe2048 0x0100 -# define OSSL_TLS_GROUP_ID_ffdhe3072 0x0101 -# define OSSL_TLS_GROUP_ID_ffdhe4096 0x0102 -# define OSSL_TLS_GROUP_ID_ffdhe6144 0x0103 -# define OSSL_TLS_GROUP_ID_ffdhe8192 0x0104 -# define OSSL_TLS_GROUP_ID_mlkem512 0x0200 -# define OSSL_TLS_GROUP_ID_mlkem768 0x0201 -# define OSSL_TLS_GROUP_ID_mlkem1024 0x0202 -# define OSSL_TLS_GROUP_ID_SecP256r1MLKEM768 0x11EB -# define OSSL_TLS_GROUP_ID_X25519MLKEM768 0x11EC -# define OSSL_TLS_GROUP_ID_SecP384r1MLKEM1024 0x11ED +#define OSSL_TLS_GROUP_ID_sect163k1 0x0001 +#define OSSL_TLS_GROUP_ID_sect163r1 0x0002 +#define OSSL_TLS_GROUP_ID_sect163r2 0x0003 +#define OSSL_TLS_GROUP_ID_sect193r1 0x0004 +#define OSSL_TLS_GROUP_ID_sect193r2 0x0005 +#define OSSL_TLS_GROUP_ID_sect233k1 0x0006 +#define OSSL_TLS_GROUP_ID_sect233r1 0x0007 +#define OSSL_TLS_GROUP_ID_sect239k1 0x0008 +#define OSSL_TLS_GROUP_ID_sect283k1 0x0009 +#define OSSL_TLS_GROUP_ID_sect283r1 0x000A +#define OSSL_TLS_GROUP_ID_sect409k1 0x000B +#define OSSL_TLS_GROUP_ID_sect409r1 0x000C +#define OSSL_TLS_GROUP_ID_sect571k1 0x000D +#define OSSL_TLS_GROUP_ID_sect571r1 0x000E +#define OSSL_TLS_GROUP_ID_secp160k1 0x000F +#define OSSL_TLS_GROUP_ID_secp160r1 0x0010 +#define OSSL_TLS_GROUP_ID_secp160r2 0x0011 +#define OSSL_TLS_GROUP_ID_secp192k1 0x0012 +#define OSSL_TLS_GROUP_ID_secp192r1 0x0013 +#define OSSL_TLS_GROUP_ID_secp224k1 0x0014 +#define OSSL_TLS_GROUP_ID_secp224r1 0x0015 +#define OSSL_TLS_GROUP_ID_secp256k1 0x0016 +#define OSSL_TLS_GROUP_ID_secp256r1 0x0017 +#define OSSL_TLS_GROUP_ID_secp384r1 0x0018 +#define OSSL_TLS_GROUP_ID_secp521r1 0x0019 +#define OSSL_TLS_GROUP_ID_brainpoolP256r1 0x001A +#define OSSL_TLS_GROUP_ID_brainpoolP384r1 0x001B +#define OSSL_TLS_GROUP_ID_brainpoolP512r1 0x001C +#define OSSL_TLS_GROUP_ID_x25519 0x001D +#define OSSL_TLS_GROUP_ID_x448 0x001E +#define OSSL_TLS_GROUP_ID_brainpoolP256r1_tls13 0x001F +#define OSSL_TLS_GROUP_ID_brainpoolP384r1_tls13 0x0020 +#define OSSL_TLS_GROUP_ID_brainpoolP512r1_tls13 0x0021 +#define OSSL_TLS_GROUP_ID_gc256A 0x0022 +#define OSSL_TLS_GROUP_ID_gc256B 0x0023 +#define OSSL_TLS_GROUP_ID_gc256C 0x0024 +#define OSSL_TLS_GROUP_ID_gc256D 0x0025 +#define OSSL_TLS_GROUP_ID_gc512A 0x0026 +#define OSSL_TLS_GROUP_ID_gc512B 0x0027 +#define OSSL_TLS_GROUP_ID_gc512C 0x0028 +#define OSSL_TLS_GROUP_ID_ffdhe2048 0x0100 +#define OSSL_TLS_GROUP_ID_ffdhe3072 0x0101 +#define OSSL_TLS_GROUP_ID_ffdhe4096 0x0102 +#define OSSL_TLS_GROUP_ID_ffdhe6144 0x0103 +#define OSSL_TLS_GROUP_ID_ffdhe8192 0x0104 +#define OSSL_TLS_GROUP_ID_mlkem512 0x0200 +#define OSSL_TLS_GROUP_ID_mlkem768 0x0201 +#define OSSL_TLS_GROUP_ID_mlkem1024 0x0202 +#define OSSL_TLS_GROUP_ID_SecP256r1MLKEM768 0x11EB +#define OSSL_TLS_GROUP_ID_X25519MLKEM768 0x11EC +#define OSSL_TLS_GROUP_ID_SecP384r1MLKEM1024 0x11ED #endif diff --git a/crypto/openssl/include/internal/to_hex.h b/crypto/openssl/include/internal/to_hex.h index e37e9f0b4390..36f4671c66b9 100644 --- a/crypto/openssl/include/internal/to_hex.h +++ b/crypto/openssl/include/internal/to_hex.h @@ -8,8 +8,8 @@ */ #ifndef OSSL_INTERNAL_TO_HEX_H -# define OSSL_INTERNAL_TO_HEX_H -# pragma once +#define OSSL_INTERNAL_TO_HEX_H +#pragma once static ossl_inline size_t to_hex(char *buf, uint8_t n, const char hexdig[17]) { diff --git a/crypto/openssl/include/internal/tsan_assist.h b/crypto/openssl/include/internal/tsan_assist.h index a840df0b24ce..87dbaba78f12 100644 --- a/crypto/openssl/include/internal/tsan_assist.h +++ b/crypto/openssl/include/internal/tsan_assist.h @@ -48,38 +48,37 @@ */ #ifndef OSSL_INTERNAL_TSAN_ASSIST_H -# define OSSL_INTERNAL_TSAN_ASSIST_H -# pragma once +#define OSSL_INTERNAL_TSAN_ASSIST_H +#pragma once -# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ && !defined(__STDC_NO_ATOMICS__) -# include <stdatomic.h> +#include <stdatomic.h> -# if defined(ATOMIC_POINTER_LOCK_FREE) \ - && ATOMIC_POINTER_LOCK_FREE >= 2 -# define TSAN_QUALIFIER _Atomic -# define tsan_load(ptr) atomic_load_explicit((ptr), memory_order_relaxed) -# define tsan_store(ptr, val) atomic_store_explicit((ptr), (val), memory_order_relaxed) -# define tsan_add(ptr, n) atomic_fetch_add_explicit((ptr), (n), memory_order_relaxed) -# define tsan_ld_acq(ptr) atomic_load_explicit((ptr), memory_order_acquire) -# define tsan_st_rel(ptr, val) atomic_store_explicit((ptr), (val), memory_order_release) -# endif +#if defined(ATOMIC_POINTER_LOCK_FREE) \ + && ATOMIC_POINTER_LOCK_FREE >= 2 +#define TSAN_QUALIFIER _Atomic +#define tsan_load(ptr) atomic_load_explicit((ptr), memory_order_relaxed) +#define tsan_store(ptr, val) atomic_store_explicit((ptr), (val), memory_order_relaxed) +#define tsan_add(ptr, n) atomic_fetch_add_explicit((ptr), (n), memory_order_relaxed) +#define tsan_ld_acq(ptr) atomic_load_explicit((ptr), memory_order_acquire) +#define tsan_st_rel(ptr, val) atomic_store_explicit((ptr), (val), memory_order_release) +#endif -# elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) +#elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) -# if defined(__GCC_ATOMIC_POINTER_LOCK_FREE) \ - && __GCC_ATOMIC_POINTER_LOCK_FREE >= 2 -# define TSAN_QUALIFIER volatile -# define tsan_load(ptr) __atomic_load_n((ptr), __ATOMIC_RELAXED) -# define tsan_store(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_RELAXED) -# define tsan_add(ptr, n) __atomic_fetch_add((ptr), (n), __ATOMIC_RELAXED) -# define tsan_ld_acq(ptr) __atomic_load_n((ptr), __ATOMIC_ACQUIRE) -# define tsan_st_rel(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_RELEASE) -# endif +#if defined(__GCC_ATOMIC_POINTER_LOCK_FREE) \ + && __GCC_ATOMIC_POINTER_LOCK_FREE >= 2 +#define TSAN_QUALIFIER volatile +#define tsan_load(ptr) __atomic_load_n((ptr), __ATOMIC_RELAXED) +#define tsan_store(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_RELAXED) +#define tsan_add(ptr, n) __atomic_fetch_add((ptr), (n), __ATOMIC_RELAXED) +#define tsan_ld_acq(ptr) __atomic_load_n((ptr), __ATOMIC_ACQUIRE) +#define tsan_st_rel(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_RELEASE) +#endif -# elif defined(_MSC_VER) && _MSC_VER>=1200 \ - && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \ - defined(_M_ARM64) || (defined(_M_ARM) && _M_ARM >= 7 && !defined(_WIN32_WCE))) +#elif defined(_MSC_VER) && _MSC_VER >= 1200 \ + && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || defined(_M_ARM64) || (defined(_M_ARM) && _M_ARM >= 7 && !defined(_WIN32_WCE))) /* * There is subtle dependency on /volatile:<iso|ms> command-line option. * "ms" implies same semantic as memory_order_acquire for loads and @@ -91,63 +90,63 @@ * with additional instructions and penalties, it kind of makes sense to * default to "iso"... */ -# define TSAN_QUALIFIER volatile -# if defined(_M_ARM) || defined(_M_ARM64) -# define _InterlockedExchangeAdd _InterlockedExchangeAdd_nf -# pragma intrinsic(_InterlockedExchangeAdd_nf) -# pragma intrinsic(__iso_volatile_load32, __iso_volatile_store32) -# ifdef _WIN64 -# define _InterlockedExchangeAdd64 _InterlockedExchangeAdd64_nf -# pragma intrinsic(_InterlockedExchangeAdd64_nf) -# pragma intrinsic(__iso_volatile_load64, __iso_volatile_store64) -# define tsan_load(ptr) (sizeof(*(ptr)) == 8 ? __iso_volatile_load64(ptr) \ - : __iso_volatile_load32(ptr)) -# define tsan_store(ptr, val) (sizeof(*(ptr)) == 8 ? __iso_volatile_store64((ptr), (val)) \ - : __iso_volatile_store32((ptr), (val))) -# else -# define tsan_load(ptr) __iso_volatile_load32(ptr) -# define tsan_store(ptr, val) __iso_volatile_store32((ptr), (val)) -# endif -# else -# define tsan_load(ptr) (*(ptr)) -# define tsan_store(ptr, val) (*(ptr) = (val)) -# endif -# pragma intrinsic(_InterlockedExchangeAdd) -# ifdef _WIN64 -# pragma intrinsic(_InterlockedExchangeAdd64) -# define tsan_add(ptr, n) (sizeof(*(ptr)) == 8 ? _InterlockedExchangeAdd64((ptr), (n)) \ - : _InterlockedExchangeAdd((ptr), (n))) -# else -# define tsan_add(ptr, n) _InterlockedExchangeAdd((ptr), (n)) -# endif -# if !defined(_ISO_VOLATILE) -# define tsan_ld_acq(ptr) (*(ptr)) -# define tsan_st_rel(ptr, val) (*(ptr) = (val)) -# endif +#define TSAN_QUALIFIER volatile +#if defined(_M_ARM) || defined(_M_ARM64) +#define _InterlockedExchangeAdd _InterlockedExchangeAdd_nf +#pragma intrinsic(_InterlockedExchangeAdd_nf) +#pragma intrinsic(__iso_volatile_load32, __iso_volatile_store32) +#ifdef _WIN64 +#define _InterlockedExchangeAdd64 _InterlockedExchangeAdd64_nf +#pragma intrinsic(_InterlockedExchangeAdd64_nf) +#pragma intrinsic(__iso_volatile_load64, __iso_volatile_store64) +#define tsan_load(ptr) (sizeof(*(ptr)) == 8 ? __iso_volatile_load64(ptr) \ + : __iso_volatile_load32(ptr)) +#define tsan_store(ptr, val) (sizeof(*(ptr)) == 8 ? __iso_volatile_store64((ptr), (val)) \ + : __iso_volatile_store32((ptr), (val))) +#else +#define tsan_load(ptr) __iso_volatile_load32(ptr) +#define tsan_store(ptr, val) __iso_volatile_store32((ptr), (val)) +#endif +#else +#define tsan_load(ptr) (*(ptr)) +#define tsan_store(ptr, val) (*(ptr) = (val)) +#endif +#pragma intrinsic(_InterlockedExchangeAdd) +#ifdef _WIN64 +#pragma intrinsic(_InterlockedExchangeAdd64) +#define tsan_add(ptr, n) (sizeof(*(ptr)) == 8 ? _InterlockedExchangeAdd64((ptr), (n)) \ + : _InterlockedExchangeAdd((ptr), (n))) +#else +#define tsan_add(ptr, n) _InterlockedExchangeAdd((ptr), (n)) +#endif +#if !defined(_ISO_VOLATILE) +#define tsan_ld_acq(ptr) (*(ptr)) +#define tsan_st_rel(ptr, val) (*(ptr) = (val)) +#endif -# endif +#endif -# ifndef TSAN_QUALIFIER +#ifndef TSAN_QUALIFIER -# ifdef OPENSSL_THREADS -# define TSAN_QUALIFIER volatile -# define TSAN_REQUIRES_LOCKING -# else /* OPENSSL_THREADS */ -# define TSAN_QUALIFIER -# endif /* OPENSSL_THREADS */ +#ifdef OPENSSL_THREADS +#define TSAN_QUALIFIER volatile +#define TSAN_REQUIRES_LOCKING +#else /* OPENSSL_THREADS */ +#define TSAN_QUALIFIER +#endif /* OPENSSL_THREADS */ -# define tsan_load(ptr) (*(ptr)) -# define tsan_store(ptr, val) (*(ptr) = (val)) -# define tsan_add(ptr, n) (*(ptr) += (n)) +#define tsan_load(ptr) (*(ptr)) +#define tsan_store(ptr, val) (*(ptr) = (val)) +#define tsan_add(ptr, n) (*(ptr) += (n)) /* * Lack of tsan_ld_acq and tsan_ld_rel means that compiler support is not * sophisticated enough to support them. Code that relies on them should be * protected with #ifdef tsan_ld_acq with locked fallback. */ -# endif +#endif -# define tsan_counter(ptr) tsan_add((ptr), 1) -# define tsan_decr(ptr) tsan_add((ptr), -1) +#define tsan_counter(ptr) tsan_add((ptr), 1) +#define tsan_decr(ptr) tsan_add((ptr), -1) #endif diff --git a/crypto/openssl/include/internal/uint_set.h b/crypto/openssl/include/internal/uint_set.h index dcb29b33f3cc..fd8ba4b6afa3 100644 --- a/crypto/openssl/include/internal/uint_set.h +++ b/crypto/openssl/include/internal/uint_set.h @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ #ifndef OSSL_UINT_SET_H -# define OSSL_UINT_SET_H +#define OSSL_UINT_SET_H #include "openssl/params.h" #include "internal/list.h" @@ -25,13 +25,13 @@ * Discussion of implementation details can be found in uint_set.c. */ typedef struct uint_range_st { - uint64_t start, end; + uint64_t start, end; } UINT_RANGE; typedef struct uint_set_item_st UINT_SET_ITEM; struct uint_set_item_st { OSSL_LIST_MEMBER(uint_set, UINT_SET_ITEM); - UINT_RANGE range; + UINT_RANGE range; }; DEFINE_LIST_OF(uint_set, UINT_SET_ITEM); diff --git a/crypto/openssl/include/internal/unicode.h b/crypto/openssl/include/internal/unicode.h index a6de8352d680..4ef53cd69c2f 100644 --- a/crypto/openssl/include/internal/unicode.h +++ b/crypto/openssl/include/internal/unicode.h @@ -8,8 +8,8 @@ */ #ifndef OSSL_INTERNAL_UNICODE_H -# define OSSL_INTERNAL_UNICODE_H -# pragma once +#define OSSL_INTERNAL_UNICODE_H +#pragma once typedef enum { SURROGATE_MIN = 0xd800UL, |
