diff --git a/Package.swift b/Package.swift index 4992797b..c586f366 100644 --- a/Package.swift +++ b/Package.swift @@ -20,7 +20,7 @@ // Sources/CCryptoBoringSSL directory. The source repository is at // https://boringssl.googlesource.com/boringssl. // -// BoringSSL Commit: abfd5ebc87ddca0fab9fca067c9d7edbc355eae8 +// BoringSSL Commit: 7ae2b910c13017b63f1a8bd6c8decfce692869b0 import PackageDescription diff --git a/Sources/CCryptoBoringSSL/CMakeLists.txt b/Sources/CCryptoBoringSSL/CMakeLists.txt index 4b21ee1e..ddf47863 100644 --- a/Sources/CCryptoBoringSSL/CMakeLists.txt +++ b/Sources/CCryptoBoringSSL/CMakeLists.txt @@ -44,6 +44,7 @@ add_library(CCryptoBoringSSL STATIC "crypto/bio/bio.c" "crypto/bio/bio_mem.c" "crypto/bio/connect.c" + "crypto/bio/errno.c" "crypto/bio/fd.c" "crypto/bio/file.c" "crypto/bio/hexdump.c" @@ -74,9 +75,10 @@ add_library(CCryptoBoringSSL STATIC "crypto/cipher_extra/tls_cbc.c" "crypto/conf/conf.c" "crypto/cpu_aarch64_apple.c" - "crypto/cpu_aarch64_freebsd.c" "crypto/cpu_aarch64_fuchsia.c" "crypto/cpu_aarch64_linux.c" + "crypto/cpu_aarch64_openbsd.c" + "crypto/cpu_aarch64_sysreg.c" "crypto/cpu_aarch64_win.c" "crypto/cpu_arm.c" "crypto/cpu_arm_freebsd.c" @@ -84,6 +86,7 @@ add_library(CCryptoBoringSSL STATIC "crypto/cpu_intel.c" "crypto/crypto.c" "crypto/curve25519/curve25519.c" + "crypto/curve25519/curve25519_64_adx.c" "crypto/curve25519/spake25519.c" "crypto/des/des.c" "crypto/dh_extra/dh_asn1.c" @@ -168,6 +171,7 @@ add_library(CCryptoBoringSSL STATIC "crypto/fipsmodule/ecdh/ecdh.c" "crypto/fipsmodule/ecdsa/ecdsa.c" "crypto/fipsmodule/fips_shared_support.c" + "crypto/fipsmodule/hkdf/hkdf.c" "crypto/fipsmodule/hmac/hmac.c" "crypto/fipsmodule/md4/md4.c" "crypto/fipsmodule/md5/md5.c" @@ -193,7 +197,6 @@ add_library(CCryptoBoringSSL STATIC "crypto/fipsmodule/sha/sha256.c" "crypto/fipsmodule/sha/sha512.c" "crypto/fipsmodule/tls/kdf.c" - "crypto/hkdf/hkdf.c" "crypto/hpke/hpke.c" "crypto/hrss/hrss.c" "crypto/kyber/keccak.c" @@ -221,13 +224,14 @@ add_library(CCryptoBoringSSL STATIC "crypto/pool/pool.c" "crypto/rand_extra/deterministic.c" "crypto/rand_extra/forkunsafe.c" - "crypto/rand_extra/fuchsia.c" + "crypto/rand_extra/getentropy.c" + "crypto/rand_extra/ios.c" "crypto/rand_extra/passive.c" "crypto/rand_extra/rand_extra.c" + "crypto/rand_extra/trusty.c" "crypto/rand_extra/windows.c" "crypto/rc4/rc4.c" - "crypto/refcount_c11.c" - "crypto/refcount_lock.c" + "crypto/refcount.c" "crypto/rsa_extra/rsa_asn1.c" "crypto/rsa_extra/rsa_crypt.c" "crypto/rsa_extra/rsa_print.c" diff --git a/Sources/CCryptoBoringSSL/crypto/asn1/a_gentm.c b/Sources/CCryptoBoringSSL/crypto/asn1/a_gentm.c index a0b92ba7..d6bc8259 100644 --- a/Sources/CCryptoBoringSSL/crypto/asn1/a_gentm.c +++ b/Sources/CCryptoBoringSSL/crypto/asn1/a_gentm.c @@ -60,6 +60,7 @@ #include #include +#include #include #include @@ -123,9 +124,12 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, } char buf[16]; - BIO_snprintf(buf, sizeof(buf), "%04d%02d%02d%02d%02d%02dZ", - data.tm_year + 1900, data.tm_mon + 1, data.tm_mday, data.tm_hour, - data.tm_min, data.tm_sec); + int ret = snprintf(buf, sizeof(buf), "%04d%02d%02d%02d%02d%02dZ", + data.tm_year + 1900, data.tm_mon + 1, data.tm_mday, + data.tm_hour, data.tm_min, data.tm_sec); + if (ret != (int)(sizeof(buf) - 1)) { + abort(); // |snprintf| should neither truncate nor write fewer bytes. + } int free_s = 0; if (s == NULL) { diff --git a/Sources/CCryptoBoringSSL/crypto/asn1/a_mbstr.c b/Sources/CCryptoBoringSSL/crypto/asn1/a_mbstr.c index fc042425..51d1cb45 100644 --- a/Sources/CCryptoBoringSSL/crypto/asn1/a_mbstr.c +++ b/Sources/CCryptoBoringSSL/crypto/asn1/a_mbstr.c @@ -73,18 +73,19 @@ // horrible: it has to be :-( The 'ncopy' form checks minimum and maximum // size limits too. -int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, - int inform, unsigned long mask) { - return ASN1_mbstring_ncopy(out, in, len, inform, mask, 0, 0); +int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, + ossl_ssize_t len, int inform, unsigned long mask) { + return ASN1_mbstring_ncopy(out, in, len, inform, mask, /*minsize=*/0, + /*maxsize=*/0); } OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_BMPSTRING) OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_UNIVERSALSTRING) OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_UTF8STRING) -int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, - int inform, unsigned long mask, long minsize, - long maxsize) { +int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, + ossl_ssize_t len, int inform, unsigned long mask, + ossl_ssize_t minsize, ossl_ssize_t maxsize) { if (len == -1) { len = strlen((const char *)in); } @@ -164,14 +165,14 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, utf8_len += cbb_get_utf8_len(c); if (maxsize > 0 && nchar > (size_t)maxsize) { OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_LONG); - ERR_add_error_dataf("maxsize=%ld", maxsize); + ERR_add_error_dataf("maxsize=%zu", (size_t)maxsize); return -1; } } if (minsize > 0 && nchar < (size_t)minsize) { OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_SHORT); - ERR_add_error_dataf("minsize=%ld", minsize); + ERR_add_error_dataf("minsize=%zu", (size_t)minsize); return -1; } diff --git a/Sources/CCryptoBoringSSL/crypto/asn1/a_strex.c b/Sources/CCryptoBoringSSL/crypto/asn1/a_strex.c index 9c409bf0..7e1fade0 100644 --- a/Sources/CCryptoBoringSSL/crypto/asn1/a_strex.c +++ b/Sources/CCryptoBoringSSL/crypto/asn1/a_strex.c @@ -89,18 +89,18 @@ static int do_esc_char(uint32_t c, unsigned long flags, char *do_quotes, char buf[16]; // Large enough for "\\W01234567". unsigned char u8 = (unsigned char)c; if (c > 0xffff) { - BIO_snprintf(buf, sizeof(buf), "\\W%08" PRIX32, c); + snprintf(buf, sizeof(buf), "\\W%08" PRIX32, c); } else if (c > 0xff) { - BIO_snprintf(buf, sizeof(buf), "\\U%04" PRIX32, c); + snprintf(buf, sizeof(buf), "\\U%04" PRIX32, c); } else if ((flags & ASN1_STRFLGS_ESC_MSB) && c > 0x7f) { - BIO_snprintf(buf, sizeof(buf), "\\%02X", c); + snprintf(buf, sizeof(buf), "\\%02X", c); } else if ((flags & ASN1_STRFLGS_ESC_CTRL) && is_control_character(c)) { - BIO_snprintf(buf, sizeof(buf), "\\%02X", c); + snprintf(buf, sizeof(buf), "\\%02X", c); } else if (flags & ASN1_STRFLGS_ESC_2253) { // See RFC 2253, sections 2.4 and 4. if (c == '\\' || c == '"') { // Quotes and backslashes are always escaped, quoted or not. - BIO_snprintf(buf, sizeof(buf), "\\%c", (int)c); + snprintf(buf, sizeof(buf), "\\%c", (int)c); } else if (c == ',' || c == '+' || c == '<' || c == '>' || c == ';' || (is_first && (c == ' ' || c == '#')) || (is_last && (c == ' '))) { @@ -111,13 +111,13 @@ static int do_esc_char(uint32_t c, unsigned long flags, char *do_quotes, } return maybe_write(out, &u8, 1) ? 1 : -1; } - BIO_snprintf(buf, sizeof(buf), "\\%c", (int)c); + snprintf(buf, sizeof(buf), "\\%c", (int)c); } else { return maybe_write(out, &u8, 1) ? 1 : -1; } } else if ((flags & ESC_FLAGS) && c == '\\') { // If any escape flags are set, also escape backslashes. - BIO_snprintf(buf, sizeof(buf), "\\%c", (int)c); + snprintf(buf, sizeof(buf), "\\%c", (int)c); } else { return maybe_write(out, &u8, 1) ? 1 : -1; } diff --git a/Sources/CCryptoBoringSSL/crypto/asn1/a_strnid.c b/Sources/CCryptoBoringSSL/crypto/asn1/a_strnid.c index 4e0f0c61..4850963d 100644 --- a/Sources/CCryptoBoringSSL/crypto/asn1/a_strnid.c +++ b/Sources/CCryptoBoringSSL/crypto/asn1/a_strnid.c @@ -72,7 +72,7 @@ DEFINE_LHASH_OF(ASN1_STRING_TABLE) static LHASH_OF(ASN1_STRING_TABLE) *string_tables = NULL; -static struct CRYPTO_STATIC_MUTEX string_tables_lock = CRYPTO_STATIC_MUTEX_INIT; +static CRYPTO_MUTEX string_tables_lock = CRYPTO_MUTEX_INIT; void ASN1_STRING_set_default_mask(unsigned long mask) {} @@ -87,7 +87,7 @@ static const ASN1_STRING_TABLE *asn1_string_table_get(int nid); // a corresponding OID. For example certificates and certificate requests. ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in, - int len, int inform, int nid) { + ossl_ssize_t len, int inform, int nid) { ASN1_STRING *str = NULL; int ret; if (!out) { @@ -176,11 +176,11 @@ static const ASN1_STRING_TABLE *asn1_string_table_get(int nid) { return tbl; } - CRYPTO_STATIC_MUTEX_lock_read(&string_tables_lock); + CRYPTO_MUTEX_lock_read(&string_tables_lock); if (string_tables != NULL) { tbl = lh_ASN1_STRING_TABLE_retrieve(string_tables, &key); } - CRYPTO_STATIC_MUTEX_unlock_read(&string_tables_lock); + CRYPTO_MUTEX_unlock_read(&string_tables_lock); // Note returning |tbl| without the lock is only safe because // |ASN1_STRING_TABLE_add| cannot modify or delete existing entries. If we // wish to support that, this function must copy the result under a lock. @@ -196,7 +196,7 @@ int ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize, } int ret = 0; - CRYPTO_STATIC_MUTEX_lock_write(&string_tables_lock); + CRYPTO_MUTEX_lock_write(&string_tables_lock); if (string_tables == NULL) { string_tables = lh_ASN1_STRING_TABLE_new(table_hash, table_cmp); @@ -232,7 +232,7 @@ int ASN1_STRING_TABLE_add(int nid, long minsize, long maxsize, ret = 1; err: - CRYPTO_STATIC_MUTEX_unlock_write(&string_tables_lock); + CRYPTO_MUTEX_unlock_write(&string_tables_lock); return ret; } diff --git a/Sources/CCryptoBoringSSL/crypto/asn1/a_time.c b/Sources/CCryptoBoringSSL/crypto/asn1/a_time.c index 5f9eabf0..76aa5704 100644 --- a/Sources/CCryptoBoringSSL/crypto/asn1/a_time.c +++ b/Sources/CCryptoBoringSSL/crypto/asn1/a_time.c @@ -61,6 +61,7 @@ #include #include +#include #include #include @@ -82,6 +83,10 @@ ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t time) { return ASN1_TIME_adj(s, time, 0, 0); } +static int fits_in_utc_time(const struct tm *tm) { + return 50 <= tm->tm_year && tm->tm_year < 150; +} + ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, int64_t posix_time, int offset_day, long offset_sec) { struct tm tm; @@ -95,7 +100,7 @@ ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, int64_t posix_time, int offset_day, return NULL; } } - if ((tm.tm_year >= 50) && (tm.tm_year < 150)) { + if (fits_in_utc_time(&tm)) { return ASN1_UTCTIME_adj(s, posix_time, offset_day, offset_sec); } return ASN1_GENERALIZEDTIME_adj(s, posix_time, offset_day, offset_sec); @@ -171,6 +176,34 @@ int ASN1_TIME_set_string(ASN1_TIME *s, const char *str) { ASN1_GENERALIZEDTIME_set_string(s, str); } +int ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str) { + CBS cbs; + CBS_init(&cbs, (const uint8_t*)str, strlen(str)); + int type; + struct tm tm; + if (CBS_parse_utc_time(&cbs, /*out_tm=*/NULL, + /*allow_timezone_offset=*/0)) { + type = V_ASN1_UTCTIME; + } else if (CBS_parse_generalized_time(&cbs, &tm, + /*allow_timezone_offset=*/0)) { + type = V_ASN1_GENERALIZEDTIME; + if (fits_in_utc_time(&tm)) { + type = V_ASN1_UTCTIME; + CBS_skip(&cbs, 2); + } + } else { + return 0; + } + + if (s != NULL) { + if (!ASN1_STRING_set(s, CBS_data(&cbs), CBS_len(&cbs))) { + return 0; + } + s->type = type; + } + return 1; +} + static int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *t, int allow_timezone_offset) { if (t == NULL) { diff --git a/Sources/CCryptoBoringSSL/crypto/asn1/a_utctm.c b/Sources/CCryptoBoringSSL/crypto/asn1/a_utctm.c index f7f08d7d..8bb97463 100644 --- a/Sources/CCryptoBoringSSL/crypto/asn1/a_utctm.c +++ b/Sources/CCryptoBoringSSL/crypto/asn1/a_utctm.c @@ -60,6 +60,7 @@ #include #include +#include #include #include @@ -83,11 +84,14 @@ int ASN1_UTCTIME_check(const ASN1_UTCTIME *d) { } int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str) { + // Although elsewhere we allow timezone offsets with UTCTime, to be compatible + // with some existing misissued certificates, this function is used to + // construct new certificates and can be stricter. size_t len = strlen(str); CBS cbs; CBS_init(&cbs, (const uint8_t *)str, len); if (!CBS_parse_utc_time(&cbs, /*out_tm=*/NULL, - /*allow_timezone_offset=*/1)) { + /*allow_timezone_offset=*/0)) { return 0; } if (s != NULL) { @@ -121,9 +125,12 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, int64_t posix_time, int offset_d } char buf[14]; - BIO_snprintf(buf, sizeof(buf), "%02d%02d%02d%02d%02d%02dZ", - data.tm_year % 100, data.tm_mon + 1, data.tm_mday, data.tm_hour, - data.tm_min, data.tm_sec); + int ret = snprintf(buf, sizeof(buf), "%02d%02d%02d%02d%02d%02dZ", + data.tm_year % 100, data.tm_mon + 1, data.tm_mday, + data.tm_hour, data.tm_min, data.tm_sec); + if (ret != (int)(sizeof(buf) - 1)) { + abort(); // |snprintf| should neither truncate nor write fewer bytes. + } int free_s = 0; if (s == NULL) { diff --git a/Sources/CCryptoBoringSSL/crypto/bio/bio.c b/Sources/CCryptoBoringSSL/crypto/bio/bio.c index c70639e4..69598b4d 100644 --- a/Sources/CCryptoBoringSSL/crypto/bio/bio.c +++ b/Sources/CCryptoBoringSSL/crypto/bio/bio.c @@ -628,14 +628,14 @@ void BIO_set_retry_special(BIO *bio) { int BIO_set_write_buffer_size(BIO *bio, int buffer_size) { return 0; } -static struct CRYPTO_STATIC_MUTEX g_index_lock = CRYPTO_STATIC_MUTEX_INIT; +static CRYPTO_MUTEX g_index_lock = CRYPTO_MUTEX_INIT; static int g_index = BIO_TYPE_START; int BIO_get_new_index(void) { - CRYPTO_STATIC_MUTEX_lock_write(&g_index_lock); + CRYPTO_MUTEX_lock_write(&g_index_lock); // If |g_index| exceeds 255, it will collide with the flags bits. int ret = g_index > 255 ? -1 : g_index++; - CRYPTO_STATIC_MUTEX_unlock_write(&g_index_lock); + CRYPTO_MUTEX_unlock_write(&g_index_lock); return ret; } diff --git a/Sources/CCryptoBoringSSL/crypto/bio/bio_mem.c b/Sources/CCryptoBoringSSL/crypto/bio/bio_mem.c index 8a1e5858..d8ae01b7 100644 --- a/Sources/CCryptoBoringSSL/crypto/bio/bio_mem.c +++ b/Sources/CCryptoBoringSSL/crypto/bio/bio_mem.c @@ -206,7 +206,6 @@ static int mem_gets(BIO *bio, char *buf, int size) { static long mem_ctrl(BIO *bio, int cmd, long num, void *ptr) { long ret = 1; - char **pptr; BUF_MEM *b = (BUF_MEM *)bio->ptr; @@ -232,8 +231,8 @@ static long mem_ctrl(BIO *bio, int cmd, long num, void *ptr) { case BIO_CTRL_INFO: ret = (long)b->length; if (ptr != NULL) { - pptr = (char **)ptr; - *pptr = (char *)&b->data[0]; + char **pptr = ptr; + *pptr = b->data; } break; case BIO_C_SET_BUF_MEM: @@ -243,8 +242,8 @@ static long mem_ctrl(BIO *bio, int cmd, long num, void *ptr) { break; case BIO_C_GET_BUF_MEM_PTR: if (ptr != NULL) { - pptr = (char **)ptr; - *pptr = (char *)b; + BUF_MEM **pptr = ptr; + *pptr = b; } break; case BIO_CTRL_GET_CLOSE: @@ -294,15 +293,15 @@ int BIO_mem_contents(const BIO *bio, const uint8_t **out_contents, } long BIO_get_mem_data(BIO *bio, char **contents) { - return BIO_ctrl(bio, BIO_CTRL_INFO, 0, (char *) contents); + return BIO_ctrl(bio, BIO_CTRL_INFO, 0, contents); } int BIO_get_mem_ptr(BIO *bio, BUF_MEM **out) { - return (int)BIO_ctrl(bio, BIO_C_GET_BUF_MEM_PTR, 0, (char *) out); + return (int)BIO_ctrl(bio, BIO_C_GET_BUF_MEM_PTR, 0, out); } int BIO_set_mem_buf(BIO *bio, BUF_MEM *b, int take_ownership) { - return (int)BIO_ctrl(bio, BIO_C_SET_BUF_MEM, take_ownership, (char *) b); + return (int)BIO_ctrl(bio, BIO_C_SET_BUF_MEM, take_ownership, b); } int BIO_set_mem_eof_return(BIO *bio, int eof_value) { diff --git a/Sources/CCryptoBoringSSL/crypto/bio/connect.c b/Sources/CCryptoBoringSSL/crypto/bio/connect.c index 65012203..774d7411 100644 --- a/Sources/CCryptoBoringSSL/crypto/bio/connect.c +++ b/Sources/CCryptoBoringSSL/crypto/bio/connect.c @@ -56,7 +56,7 @@ #include -#if !defined(OPENSSL_TRUSTY) +#if !defined(OPENSSL_NO_SOCK) #include #include @@ -233,7 +233,7 @@ static int conn_state(BIO *bio, BIO_CONNECT *c) { BIO_clear_retry_flags(bio); ret = connect(bio->num, (struct sockaddr*) &c->them, c->them_length); if (ret < 0) { - if (bio_fd_should_retry(ret)) { + if (bio_socket_should_retry(ret)) { BIO_set_flags(bio, (BIO_FLAGS_IO_SPECIAL | BIO_FLAGS_SHOULD_RETRY)); c->state = BIO_CONN_S_BLOCKED_CONNECT; bio->retry_reason = BIO_RR_CONNECT; @@ -252,7 +252,7 @@ static int conn_state(BIO *bio, BIO_CONNECT *c) { case BIO_CONN_S_BLOCKED_CONNECT: i = bio_sock_error(bio->num); if (i) { - if (bio_fd_should_retry(ret)) { + if (bio_socket_should_retry(ret)) { BIO_set_flags(bio, (BIO_FLAGS_IO_SPECIAL | BIO_FLAGS_SHOULD_RETRY)); c->state = BIO_CONN_S_BLOCKED_CONNECT; bio->retry_reason = BIO_RR_CONNECT; @@ -366,7 +366,7 @@ static int conn_read(BIO *bio, char *out, int out_len) { ret = (int)recv(bio->num, out, out_len, 0); BIO_clear_retry_flags(bio); if (ret <= 0) { - if (bio_fd_should_retry(ret)) { + if (bio_socket_should_retry(ret)) { BIO_set_retry_read(bio); } } @@ -390,7 +390,7 @@ static int conn_write(BIO *bio, const char *in, int in_len) { ret = (int)send(bio->num, in, in_len, 0); BIO_clear_retry_flags(bio); if (ret <= 0) { - if (bio_fd_should_retry(ret)) { + if (bio_socket_should_retry(ret)) { BIO_set_retry_write(bio); } } @@ -532,7 +532,7 @@ int BIO_set_conn_port(BIO *bio, const char *port_str) { int BIO_set_conn_int_port(BIO *bio, const int *port) { char buf[DECIMAL_SIZE(int) + 1]; - BIO_snprintf(buf, sizeof(buf), "%d", *port); + snprintf(buf, sizeof(buf), "%d", *port); return BIO_set_conn_port(bio, buf); } @@ -544,4 +544,4 @@ int BIO_do_connect(BIO *bio) { return (int)BIO_ctrl(bio, BIO_C_DO_STATE_MACHINE, 0, NULL); } -#endif // OPENSSL_TRUSTY +#endif // OPENSSL_NO_SOCK diff --git a/Sources/CCryptoBoringSSL/crypto/bio/errno.c b/Sources/CCryptoBoringSSL/crypto/bio/errno.c new file mode 100644 index 00000000..7fdb819c --- /dev/null +++ b/Sources/CCryptoBoringSSL/crypto/bio/errno.c @@ -0,0 +1,92 @@ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] */ + +#include + +#include + +#include "internal.h" + + +int bio_errno_should_retry(int return_value) { + if (return_value != -1) { + return 0; + } + + return +#ifdef EWOULDBLOCK + errno == EWOULDBLOCK || +#endif +#ifdef ENOTCONN + errno == ENOTCONN || +#endif +#ifdef EINTR + errno == EINTR || +#endif +#ifdef EAGAIN + errno == EAGAIN || +#endif +#ifdef EPROTO + errno == EPROTO || +#endif +#ifdef EINPROGRESS + errno == EINPROGRESS || +#endif +#ifdef EALREADY + errno == EALREADY || +#endif + 0; +} diff --git a/Sources/CCryptoBoringSSL/crypto/bio/fd.c b/Sources/CCryptoBoringSSL/crypto/bio/fd.c index 4f082b84..8336096c 100644 --- a/Sources/CCryptoBoringSSL/crypto/bio/fd.c +++ b/Sources/CCryptoBoringSSL/crypto/bio/fd.c @@ -56,7 +56,7 @@ #include -#if !defined(OPENSSL_TRUSTY) +#if !defined(OPENSSL_NO_POSIX_IO) #include #include @@ -65,9 +65,6 @@ #include #else #include -OPENSSL_MSVC_PRAGMA(warning(push, 3)) -#include -OPENSSL_MSVC_PRAGMA(warning(pop)) #endif #include @@ -77,59 +74,18 @@ OPENSSL_MSVC_PRAGMA(warning(pop)) #include "../internal.h" -static int bio_fd_non_fatal_error(int err) { - if ( -#ifdef EWOULDBLOCK - err == EWOULDBLOCK || -#endif -#ifdef WSAEWOULDBLOCK - err == WSAEWOULDBLOCK || -#endif -#ifdef ENOTCONN - err == ENOTCONN || -#endif -#ifdef EINTR - err == EINTR || -#endif -#ifdef EAGAIN - err == EAGAIN || -#endif -#ifdef EPROTO - err == EPROTO || -#endif -#ifdef EINPROGRESS - err == EINPROGRESS || -#endif -#ifdef EALREADY - err == EALREADY || -#endif - 0) { - return 1; - } - return 0; -} - #if defined(OPENSSL_WINDOWS) - #define BORINGSSL_ERRNO (int)GetLastError() #define BORINGSSL_CLOSE _close #define BORINGSSL_LSEEK _lseek #define BORINGSSL_READ _read #define BORINGSSL_WRITE _write #else - #define BORINGSSL_ERRNO errno #define BORINGSSL_CLOSE close #define BORINGSSL_LSEEK lseek #define BORINGSSL_READ read #define BORINGSSL_WRITE write #endif -int bio_fd_should_retry(int i) { - if (i == -1) { - return bio_fd_non_fatal_error(BORINGSSL_ERRNO); - } - return 0; -} - BIO *BIO_new_fd(int fd, int close_flag) { BIO *ret = BIO_new(BIO_s_fd()); if (ret == NULL) { @@ -161,7 +117,7 @@ static int fd_read(BIO *b, char *out, int outl) { ret = (int)BORINGSSL_READ(b->num, out, outl); BIO_clear_retry_flags(b); if (ret <= 0) { - if (bio_fd_should_retry(ret)) { + if (bio_errno_should_retry(ret)) { BIO_set_retry_read(b); } } @@ -173,7 +129,7 @@ static int fd_write(BIO *b, const char *in, int inl) { int ret = (int)BORINGSSL_WRITE(b->num, in, inl); BIO_clear_retry_flags(b); if (ret <= 0) { - if (bio_fd_should_retry(ret)) { + if (bio_errno_should_retry(ret)) { BIO_set_retry_write(b); } } @@ -268,6 +224,8 @@ static const BIO_METHOD methods_fdp = { const BIO_METHOD *BIO_s_fd(void) { return &methods_fdp; } +#endif // OPENSSL_NO_POSIX_IO + int BIO_set_fd(BIO *bio, int fd, int close_flag) { return (int)BIO_int_ctrl(bio, BIO_C_SET_FD, close_flag, fd); } @@ -275,5 +233,3 @@ int BIO_set_fd(BIO *bio, int fd, int close_flag) { int BIO_get_fd(BIO *bio, int *out_fd) { return (int)BIO_ctrl(bio, BIO_C_GET_FD, 0, (char *) out_fd); } - -#endif // OPENSSL_TRUSTY diff --git a/Sources/CCryptoBoringSSL/crypto/bio/file.c b/Sources/CCryptoBoringSSL/crypto/bio/file.c index 91264208..454e1e94 100644 --- a/Sources/CCryptoBoringSSL/crypto/bio/file.c +++ b/Sources/CCryptoBoringSSL/crypto/bio/file.c @@ -73,8 +73,6 @@ #include -#if !defined(OPENSSL_TRUSTY) - #include #include #include @@ -89,11 +87,20 @@ #define BIO_FP_WRITE 0x04 #define BIO_FP_APPEND 0x08 +#if !defined(OPENSSL_NO_FILESYSTEM) +#define fopen_if_available fopen +#else +static FILE *fopen_if_available(const char *path, const char *mode) { + errno = ENOENT; + return NULL; +} +#endif + BIO *BIO_new_file(const char *filename, const char *mode) { BIO *ret; FILE *file; - file = fopen(filename, mode); + file = fopen_if_available(filename, mode); if (file == NULL) { OPENSSL_PUT_SYSTEM_ERROR(); @@ -172,7 +179,6 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr) { long ret = 1; FILE *fp = (FILE *)b->ptr; FILE **fpp; - char p[4]; switch (cmd) { case BIO_CTRL_RESET: @@ -197,27 +203,28 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr) { case BIO_C_SET_FILENAME: file_free(b); b->shutdown = (int)num & BIO_CLOSE; + const char *mode; if (num & BIO_FP_APPEND) { if (num & BIO_FP_READ) { - OPENSSL_strlcpy(p, "a+", sizeof(p)); + mode = "a+"; } else { - OPENSSL_strlcpy(p, "a", sizeof(p)); + mode = "a"; } } else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE)) { - OPENSSL_strlcpy(p, "r+", sizeof(p)); + mode = "r+"; } else if (num & BIO_FP_WRITE) { - OPENSSL_strlcpy(p, "w", sizeof(p)); + mode = "w"; } else if (num & BIO_FP_READ) { - OPENSSL_strlcpy(p, "r", sizeof(p)); + mode = "r"; } else { OPENSSL_PUT_ERROR(BIO, BIO_R_BAD_FOPEN_MODE); ret = 0; break; } - fp = fopen(ptr, p); + fp = fopen_if_available(ptr, mode); if (fp == NULL) { OPENSSL_PUT_SYSTEM_ERROR(); - ERR_add_error_data(5, "fopen('", ptr, "','", p, "')"); + ERR_add_error_data(5, "fopen('", ptr, "','", mode, "')"); OPENSSL_PUT_ERROR(BIO, ERR_R_SYS_LIB); ret = 0; break; @@ -310,5 +317,3 @@ long BIO_tell(BIO *bio) { return BIO_ctrl(bio, BIO_C_FILE_TELL, 0, NULL); } long BIO_seek(BIO *bio, long offset) { return BIO_ctrl(bio, BIO_C_FILE_SEEK, offset, NULL); } - -#endif // OPENSSL_TRUSTY diff --git a/Sources/CCryptoBoringSSL/crypto/bio/internal.h b/Sources/CCryptoBoringSSL/crypto/bio/internal.h index a72afe84..940cb52b 100644 --- a/Sources/CCryptoBoringSSL/crypto/bio/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/bio/internal.h @@ -59,6 +59,7 @@ #include +#if !defined(OPENSSL_NO_SOCK) #if !defined(OPENSSL_WINDOWS) #if defined(OPENSSL_PNACL) // newlib uses u_short in socket.h without defining it. @@ -72,13 +73,16 @@ OPENSSL_MSVC_PRAGMA(warning(push, 3)) OPENSSL_MSVC_PRAGMA(warning(pop)) typedef int socklen_t; #endif +#endif // !OPENSSL_NO_SOCK #if defined(__cplusplus) extern "C" { #endif -// BIO_ip_and_port_to_socket_and_addr creates a socket and fills in |*out_addr| +#if !defined(OPENSSL_NO_SOCK) + +// bio_ip_and_port_to_socket_and_addr creates a socket and fills in |*out_addr| // and |*out_addr_length| with the correct values for connecting to |hostname| // on |port_str|. It returns one on success or zero on error. int bio_ip_and_port_to_socket_and_addr(int *out_sock, @@ -87,21 +91,27 @@ int bio_ip_and_port_to_socket_and_addr(int *out_sock, const char *hostname, const char *port_str); -// BIO_socket_nbio sets whether |sock| is non-blocking. It returns one on +// bio_socket_nbio sets whether |sock| is non-blocking. It returns one on // success and zero otherwise. int bio_socket_nbio(int sock, int on); -// BIO_clear_socket_error clears the last system socket error. +// bio_clear_socket_error clears the last system socket error. // // TODO(fork): remove all callers of this. void bio_clear_socket_error(void); -// BIO_sock_error returns the last socket error on |sock|. +// bio_sock_error returns the last socket error on |sock|. int bio_sock_error(int sock); -// BIO_fd_should_retry returns non-zero if |return_value| indicates an error +// bio_socket_should_retry returns non-zero if |return_value| indicates an error +// and the last socket error indicates that it's non-fatal. +int bio_socket_should_retry(int return_value); + +#endif // !OPENSSL_NO_SOCK + +// bio_errno_should_retry returns non-zero if |return_value| indicates an error // and |errno| indicates that it's non-fatal. -int bio_fd_should_retry(int return_value); +int bio_errno_should_retry(int return_value); #if defined(__cplusplus) diff --git a/Sources/CCryptoBoringSSL/crypto/bio/socket.c b/Sources/CCryptoBoringSSL/crypto/bio/socket.c index 2901023d..a521df86 100644 --- a/Sources/CCryptoBoringSSL/crypto/bio/socket.c +++ b/Sources/CCryptoBoringSSL/crypto/bio/socket.c @@ -56,7 +56,7 @@ #include -#if !defined(OPENSSL_TRUSTY) +#if !defined(OPENSSL_NO_SOCK) #include #include @@ -104,7 +104,7 @@ static int sock_read(BIO *b, char *out, int outl) { #endif BIO_clear_retry_flags(b); if (ret <= 0) { - if (bio_fd_should_retry(ret)) { + if (bio_socket_should_retry(ret)) { BIO_set_retry_read(b); } } @@ -120,7 +120,7 @@ static int sock_write(BIO *b, const char *in, int inl) { #endif BIO_clear_retry_flags(b); if (ret <= 0) { - if (bio_fd_should_retry(ret)) { + if (bio_socket_should_retry(ret)) { BIO_set_retry_write(b); } } @@ -186,4 +186,4 @@ BIO *BIO_new_socket(int fd, int close_flag) { return ret; } -#endif // OPENSSL_TRUSTY +#endif // OPENSSL_NO_SOCK diff --git a/Sources/CCryptoBoringSSL/crypto/bio/socket_helper.c b/Sources/CCryptoBoringSSL/crypto/bio/socket_helper.c index 3877bcce..0df3b737 100644 --- a/Sources/CCryptoBoringSSL/crypto/bio/socket_helper.c +++ b/Sources/CCryptoBoringSSL/crypto/bio/socket_helper.c @@ -20,7 +20,7 @@ #include #include -#if !defined(OPENSSL_TRUSTY) +#if !defined(OPENSSL_NO_SOCK) #include #include @@ -121,4 +121,13 @@ int bio_sock_error(int sock) { return error; } -#endif // OPENSSL_TRUSTY +int bio_socket_should_retry(int return_value) { +#if defined(OPENSSL_WINDOWS) + return return_value == -1 && WSAGetLastError() == WSAEWOULDBLOCK; +#else + // On POSIX platforms, sockets and fds are the same. + return bio_errno_should_retry(return_value); +#endif +} + +#endif // OPENSSL_NO_SOCK diff --git a/Sources/CCryptoBoringSSL/crypto/blake2/blake2.c b/Sources/CCryptoBoringSSL/crypto/blake2/blake2.c index 3fa1a090..dc6ae9e5 100644 --- a/Sources/CCryptoBoringSSL/crypto/blake2/blake2.c +++ b/Sources/CCryptoBoringSSL/crypto/blake2/blake2.c @@ -55,10 +55,13 @@ static void blake2b_mix(uint64_t v[16], int a, int b, int c, int d, uint64_t x, v[b] = CRYPTO_rotr_u64(v[b] ^ v[c], 63); } -static void blake2b_transform( - BLAKE2B_CTX *b2b, - const uint64_t block_words[BLAKE2B_CBLOCK / sizeof(uint64_t)], - size_t num_bytes, int is_final_block) { +static uint64_t blake2b_load(const uint8_t block[BLAKE2B_CBLOCK], size_t i) { + return CRYPTO_load_u64_le(block + 8 * i); +} + +static void blake2b_transform(BLAKE2B_CTX *b2b, + const uint8_t block[BLAKE2B_CBLOCK], + size_t num_bytes, int is_final_block) { // https://tools.ietf.org/html/rfc7693#section-3.2 uint64_t v[16]; static_assert(sizeof(v) == sizeof(b2b->h) + sizeof(kIV), ""); @@ -78,14 +81,22 @@ static void blake2b_transform( for (int round = 0; round < 12; round++) { const uint8_t *const s = &kSigma[16 * (round % 10)]; - blake2b_mix(v, 0, 4, 8, 12, block_words[s[0]], block_words[s[1]]); - blake2b_mix(v, 1, 5, 9, 13, block_words[s[2]], block_words[s[3]]); - blake2b_mix(v, 2, 6, 10, 14, block_words[s[4]], block_words[s[5]]); - blake2b_mix(v, 3, 7, 11, 15, block_words[s[6]], block_words[s[7]]); - blake2b_mix(v, 0, 5, 10, 15, block_words[s[8]], block_words[s[9]]); - blake2b_mix(v, 1, 6, 11, 12, block_words[s[10]], block_words[s[11]]); - blake2b_mix(v, 2, 7, 8, 13, block_words[s[12]], block_words[s[13]]); - blake2b_mix(v, 3, 4, 9, 14, block_words[s[14]], block_words[s[15]]); + blake2b_mix(v, 0, 4, 8, 12, blake2b_load(block, s[0]), + blake2b_load(block, s[1])); + blake2b_mix(v, 1, 5, 9, 13, blake2b_load(block, s[2]), + blake2b_load(block, s[3])); + blake2b_mix(v, 2, 6, 10, 14, blake2b_load(block, s[4]), + blake2b_load(block, s[5])); + blake2b_mix(v, 3, 7, 11, 15, blake2b_load(block, s[6]), + blake2b_load(block, s[7])); + blake2b_mix(v, 0, 5, 10, 15, blake2b_load(block, s[8]), + blake2b_load(block, s[9])); + blake2b_mix(v, 1, 6, 11, 12, blake2b_load(block, s[10]), + blake2b_load(block, s[11])); + blake2b_mix(v, 2, 7, 8, 13, blake2b_load(block, s[12]), + blake2b_load(block, s[13])); + blake2b_mix(v, 3, 4, 9, 14, blake2b_load(block, s[14]), + blake2b_load(block, s[15])); } for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(b2b->h); i++) { @@ -111,11 +122,11 @@ void BLAKE2B256_Update(BLAKE2B_CTX *b2b, const void *in_data, size_t len) { } const uint8_t *data = in_data; - size_t todo = sizeof(b2b->block.bytes) - b2b->block_used; + size_t todo = sizeof(b2b->block) - b2b->block_used; if (todo > len) { todo = len; } - OPENSSL_memcpy(&b2b->block.bytes[b2b->block_used], data, todo); + OPENSSL_memcpy(&b2b->block[b2b->block_used], data, todo); b2b->block_used += todo; data += todo; len -= todo; @@ -126,26 +137,24 @@ void BLAKE2B256_Update(BLAKE2B_CTX *b2b, const void *in_data, size_t len) { // More input remains therefore we must have filled |b2b->block|. assert(b2b->block_used == BLAKE2B_CBLOCK); - blake2b_transform(b2b, b2b->block.words, BLAKE2B_CBLOCK, + blake2b_transform(b2b, b2b->block, BLAKE2B_CBLOCK, /*is_final_block=*/0); b2b->block_used = 0; while (len > BLAKE2B_CBLOCK) { - uint64_t block_words[BLAKE2B_CBLOCK / sizeof(uint64_t)]; - OPENSSL_memcpy(block_words, data, sizeof(block_words)); - blake2b_transform(b2b, block_words, BLAKE2B_CBLOCK, /*is_final_block=*/0); + blake2b_transform(b2b, data, BLAKE2B_CBLOCK, /*is_final_block=*/0); data += BLAKE2B_CBLOCK; len -= BLAKE2B_CBLOCK; } - OPENSSL_memcpy(b2b->block.bytes, data, len); + OPENSSL_memcpy(b2b->block, data, len); b2b->block_used = len; } void BLAKE2B256_Final(uint8_t out[BLAKE2B256_DIGEST_LENGTH], BLAKE2B_CTX *b2b) { - OPENSSL_memset(&b2b->block.bytes[b2b->block_used], 0, - sizeof(b2b->block.bytes) - b2b->block_used); - blake2b_transform(b2b, b2b->block.words, b2b->block_used, + OPENSSL_memset(&b2b->block[b2b->block_used], 0, + sizeof(b2b->block) - b2b->block_used); + blake2b_transform(b2b, b2b->block, b2b->block_used, /*is_final_block=*/1); static_assert(BLAKE2B256_DIGEST_LENGTH <= sizeof(b2b->h), ""); memcpy(out, b2b->h, BLAKE2B256_DIGEST_LENGTH); diff --git a/Sources/CCryptoBoringSSL/crypto/bytestring/cbs.c b/Sources/CCryptoBoringSSL/crypto/bytestring/cbs.c index 396c99fc..e9d31ba7 100644 --- a/Sources/CCryptoBoringSSL/crypto/bytestring/cbs.c +++ b/Sources/CCryptoBoringSSL/crypto/bytestring/cbs.c @@ -694,7 +694,7 @@ int CBS_is_unsigned_asn1_integer(const CBS *cbs) { static int add_decimal(CBB *out, uint64_t v) { char buf[DECIMAL_SIZE(uint64_t) + 1]; - BIO_snprintf(buf, sizeof(buf), "%" PRIu64, v); + snprintf(buf, sizeof(buf), "%" PRIu64, v); return CBB_add_bytes(out, (const uint8_t *)buf, strlen(buf)); } diff --git a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv4-ios.ios.arm.S b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv4-ios.ios.arm.S index d10fee5d..5b5fb533 100644 --- a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv4-ios.ios.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv4-ios.ios.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__APPLE__) #include @ Silence ARMv8 deprecated IT instruction warnings. This file is used by both @@ -1497,11 +1489,7 @@ OPENSSL_armcap_P: .indirect_symbol _OPENSSL_armcap_P .long 0 #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__APPLE__) #endif // defined(__arm__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv4-linux.linux.arm.S b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv4-linux.linux.arm.S index 5abe26b4..f30874c3 100644 --- a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv4-linux.linux.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv4-linux.linux.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) #include @ Silence ARMv8 deprecated IT instruction warnings. This file is used by both @@ -1489,11 +1481,7 @@ ChaCha20_neon: .size ChaCha20_neon,.-ChaCha20_neon .comm OPENSSL_armcap_P,4,4 #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv8-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv8-ios.ios.aarch64.S index 2e631a7a..ef7d2fee 100644 --- a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv8-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv8-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) #include @@ -38,7 +30,7 @@ Lone: _ChaCha20_ctr32: AARCH64_VALID_CALL_TARGET cbz x2,Labort -#if __has_feature(hwaddress_sanitizer) && __clang_major__ >= 10 +#if defined(OPENSSL_HWASAN) && __clang_major__ >= 10 adrp x5,:pg_hi21_nc:_OPENSSL_armcap_P #else adrp x5,_OPENSSL_armcap_P@PAGE @@ -1991,11 +1983,7 @@ Ldone_512_neon: AARCH64_VALIDATE_LINK_REGISTER ret -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv8-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv8-linux.linux.aarch64.S index dcfd01b8..9a5155e6 100644 --- a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv8-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-armv8-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) #include @@ -38,7 +30,7 @@ ChaCha20_ctr32: AARCH64_VALID_CALL_TARGET cbz x2,.Labort -#if __has_feature(hwaddress_sanitizer) && __clang_major__ >= 10 +#if defined(OPENSSL_HWASAN) && __clang_major__ >= 10 adrp x5,:pg_hi21_nc:OPENSSL_armcap_P #else adrp x5,OPENSSL_armcap_P @@ -1991,11 +1983,7 @@ ChaCha20_512_neon: AARCH64_VALIDATE_LINK_REGISTER ret .size ChaCha20_512_neon,.-ChaCha20_512_neon -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-x86-linux.linux.x86.S b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-x86-linux.linux.x86.S index d716c78c..f2793520 100644 --- a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-x86-linux.linux.x86.S +++ b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-x86-linux.linux.x86.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) .text .globl ChaCha20_ctr32 .hidden ChaCha20_ctr32 @@ -979,11 +972,7 @@ ChaCha20_ssse3: .byte 44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32 .byte 60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111 .byte 114,103,62,0 -#endif // !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-x86_64-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-x86_64-linux.linux.x86_64.S index 102c46d0..4af8fd8d 100644 --- a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-x86_64-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-x86_64-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .extern OPENSSL_ia32cap_P @@ -55,6 +48,7 @@ .align 64 ChaCha20_ctr32: .cfi_startproc +_CET_ENDBR cmpq $0,%rdx je .Lno_data movq OPENSSL_ia32cap_P+4(%rip),%r10 @@ -1634,10 +1628,6 @@ ChaCha20_8x: .cfi_endproc .size ChaCha20_8x,.-ChaCha20_8x #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-x86_64-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-x86_64-mac.mac.x86_64.S index 5b498a39..828d15de 100644 --- a/Sources/CCryptoBoringSSL/crypto/chacha/chacha-x86_64-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/chacha/chacha-x86_64-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text @@ -54,6 +47,7 @@ L$sixteen: .p2align 6 _ChaCha20_ctr32: +_CET_ENDBR cmpq $0,%rdx je L$no_data movq _OPENSSL_ia32cap_P+4(%rip),%r10 @@ -1626,10 +1620,6 @@ L$8x_epilogue: .byte 0xf3,0xc3 -#endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits #endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CCryptoBoringSSL/crypto/chacha/chacha.c b/Sources/CCryptoBoringSSL/crypto/chacha/chacha.c index de15c8e7..8d255109 100644 --- a/Sources/CCryptoBoringSSL/crypto/chacha/chacha.c +++ b/Sources/CCryptoBoringSSL/crypto/chacha/chacha.c @@ -91,7 +91,25 @@ void CRYPTO_chacha_20(uint8_t *out, const uint8_t *in, size_t in_len, } #endif - ChaCha20_ctr32(out, in, in_len, key_ptr, counter_nonce); + while (in_len > 0) { + // The assembly functions do not have defined overflow behavior. While + // overflow is almost always a bug in the caller, we prefer our functions to + // behave the same across platforms, so divide into multiple calls to avoid + // this case. + uint64_t todo = 64 * ((UINT64_C(1) << 32) - counter_nonce[0]); + if (todo > in_len) { + todo = in_len; + } + + ChaCha20_ctr32(out, in, (size_t)todo, key_ptr, counter_nonce); + in += todo; + out += todo; + in_len -= todo; + + // We're either done and will next break out of the loop, or we stopped at + // the wraparound point and the counter should continue at zero. + counter_nonce[0] = 0; + } } #else diff --git a/Sources/CCryptoBoringSSL/crypto/chacha/internal.h b/Sources/CCryptoBoringSSL/crypto/chacha/internal.h index b66bd3f0..e1f3b533 100644 --- a/Sources/CCryptoBoringSSL/crypto/chacha/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/chacha/internal.h @@ -32,7 +32,14 @@ void CRYPTO_hchacha20(uint8_t out[32], const uint8_t key[32], defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)) #define CHACHA20_ASM -// ChaCha20_ctr32 is defined in asm/chacha-*.pl. +// ChaCha20_ctr32 encrypts |in_len| bytes from |in| and writes the result to +// |out|. If |in| and |out| alias, they must be equal. +// +// |counter[0]| is the initial 32-bit block counter, and the remainder is the +// 96-bit nonce. If the counter overflows, the output is undefined. The function +// will produce output, but the output may vary by machine and may not be +// self-consistent. (On some architectures, the assembly implements a mix of +// 64-bit and 32-bit counters.) void ChaCha20_ctr32(uint8_t *out, const uint8_t *in, size_t in_len, const uint32_t key[8], const uint32_t counter[4]); #endif diff --git a/Sources/CCryptoBoringSSL/crypto/cipher_extra/aes128gcmsiv-x86_64-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/cipher_extra/aes128gcmsiv-x86_64-linux.linux.x86_64.S index cd08c5dd..692855b0 100644 --- a/Sources/CCryptoBoringSSL/crypto/cipher_extra/aes128gcmsiv-x86_64-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/cipher_extra/aes128gcmsiv-x86_64-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .section .rodata .align 16 @@ -80,6 +73,7 @@ GFMUL: .align 16 aesgcmsiv_htable_init: .cfi_startproc +_CET_ENDBR vmovdqa (%rsi),%xmm0 vmovdqa %xmm0,%xmm1 vmovdqa %xmm0,(%rdi) @@ -106,6 +100,7 @@ aesgcmsiv_htable_init: .align 16 aesgcmsiv_htable6_init: .cfi_startproc +_CET_ENDBR vmovdqa (%rsi),%xmm0 vmovdqa %xmm0,%xmm1 vmovdqa %xmm0,(%rdi) @@ -128,6 +123,7 @@ aesgcmsiv_htable6_init: .align 16 aesgcmsiv_htable_polyval: .cfi_startproc +_CET_ENDBR testq %rdx,%rdx jnz .Lhtable_polyval_start .byte 0xf3,0xc3 @@ -345,6 +341,7 @@ aesgcmsiv_htable_polyval: .align 16 aesgcmsiv_polyval_horner: .cfi_startproc +_CET_ENDBR testq %rcx,%rcx jnz .Lpolyval_horner_start .byte 0xf3,0xc3 @@ -378,6 +375,7 @@ aesgcmsiv_polyval_horner: .align 16 aes128gcmsiv_aes_ks: .cfi_startproc +_CET_ENDBR vmovdqu (%rdi),%xmm1 vmovdqa %xmm1,(%rsi) @@ -434,6 +432,7 @@ aes128gcmsiv_aes_ks: .align 16 aes256gcmsiv_aes_ks: .cfi_startproc +_CET_ENDBR vmovdqu (%rdi),%xmm1 vmovdqu 16(%rdi),%xmm3 vmovdqa %xmm1,(%rsi) @@ -481,6 +480,7 @@ aes256gcmsiv_aes_ks: .align 16 aes128gcmsiv_aes_ks_enc_x1: .cfi_startproc +_CET_ENDBR vmovdqa (%rcx),%xmm1 vmovdqa 0(%rdi),%xmm4 @@ -623,6 +623,7 @@ aes128gcmsiv_aes_ks_enc_x1: .align 16 aes128gcmsiv_kdf: .cfi_startproc +_CET_ENDBR @@ -716,6 +717,7 @@ aes128gcmsiv_kdf: .align 16 aes128gcmsiv_enc_msg_x4: .cfi_startproc +_CET_ENDBR testq %r8,%r8 jnz .L128_enc_msg_x4_start .byte 0xf3,0xc3 @@ -895,6 +897,7 @@ aes128gcmsiv_enc_msg_x4: .align 16 aes128gcmsiv_enc_msg_x8: .cfi_startproc +_CET_ENDBR testq %r8,%r8 jnz .L128_enc_msg_x8_start .byte 0xf3,0xc3 @@ -1156,6 +1159,7 @@ aes128gcmsiv_enc_msg_x8: .align 16 aes128gcmsiv_dec: .cfi_startproc +_CET_ENDBR testq $~15,%r9 jnz .L128_dec_start .byte 0xf3,0xc3 @@ -1648,6 +1652,7 @@ aes128gcmsiv_dec: .align 16 aes128gcmsiv_ecb_enc_block: .cfi_startproc +_CET_ENDBR vmovdqa (%rdi),%xmm1 vpxor (%rdx),%xmm1,%xmm1 @@ -1673,6 +1678,7 @@ aes128gcmsiv_ecb_enc_block: .align 16 aes256gcmsiv_aes_ks_enc_x1: .cfi_startproc +_CET_ENDBR vmovdqa con1(%rip),%xmm0 vmovdqa mask(%rip),%xmm15 vmovdqa (%rdi),%xmm8 @@ -1856,6 +1862,7 @@ aes256gcmsiv_aes_ks_enc_x1: .align 16 aes256gcmsiv_ecb_enc_block: .cfi_startproc +_CET_ENDBR vmovdqa (%rdi),%xmm1 vpxor (%rdx),%xmm1,%xmm1 vaesenc 16(%rdx),%xmm1,%xmm1 @@ -1882,6 +1889,7 @@ aes256gcmsiv_ecb_enc_block: .align 16 aes256gcmsiv_enc_msg_x4: .cfi_startproc +_CET_ENDBR testq %r8,%r8 jnz .L256_enc_msg_x4_start .byte 0xf3,0xc3 @@ -2083,6 +2091,7 @@ aes256gcmsiv_enc_msg_x4: .align 16 aes256gcmsiv_enc_msg_x8: .cfi_startproc +_CET_ENDBR testq %r8,%r8 jnz .L256_enc_msg_x8_start .byte 0xf3,0xc3 @@ -2372,6 +2381,7 @@ aes256gcmsiv_enc_msg_x8: .align 16 aes256gcmsiv_dec: .cfi_startproc +_CET_ENDBR testq $~15,%r9 jnz .L256_dec_start .byte 0xf3,0xc3 @@ -2932,6 +2942,7 @@ aes256gcmsiv_dec: .align 16 aes256gcmsiv_kdf: .cfi_startproc +_CET_ENDBR @@ -3078,10 +3089,6 @@ aes256gcmsiv_kdf: .cfi_endproc .size aes256gcmsiv_kdf, .-aes256gcmsiv_kdf #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/cipher_extra/aes128gcmsiv-x86_64-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/cipher_extra/aes128gcmsiv-x86_64-mac.mac.x86_64.S index 567f419e..70ae4ca9 100644 --- a/Sources/CCryptoBoringSSL/crypto/cipher_extra/aes128gcmsiv-x86_64-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/cipher_extra/aes128gcmsiv-x86_64-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .section __DATA,__const .p2align 4 @@ -80,6 +73,7 @@ GFMUL: .p2align 4 _aesgcmsiv_htable_init: +_CET_ENDBR vmovdqa (%rsi),%xmm0 vmovdqa %xmm0,%xmm1 vmovdqa %xmm0,(%rdi) @@ -106,6 +100,7 @@ _aesgcmsiv_htable_init: .p2align 4 _aesgcmsiv_htable6_init: +_CET_ENDBR vmovdqa (%rsi),%xmm0 vmovdqa %xmm0,%xmm1 vmovdqa %xmm0,(%rdi) @@ -128,6 +123,7 @@ _aesgcmsiv_htable6_init: .p2align 4 _aesgcmsiv_htable_polyval: +_CET_ENDBR testq %rdx,%rdx jnz L$htable_polyval_start .byte 0xf3,0xc3 @@ -345,6 +341,7 @@ L$htable_polyval_out: .p2align 4 _aesgcmsiv_polyval_horner: +_CET_ENDBR testq %rcx,%rcx jnz L$polyval_horner_start .byte 0xf3,0xc3 @@ -378,6 +375,7 @@ L$polyval_horner_loop: .p2align 4 _aes128gcmsiv_aes_ks: +_CET_ENDBR vmovdqu (%rdi),%xmm1 vmovdqa %xmm1,(%rsi) @@ -434,6 +432,7 @@ L$ks128_loop: .p2align 4 _aes256gcmsiv_aes_ks: +_CET_ENDBR vmovdqu (%rdi),%xmm1 vmovdqu 16(%rdi),%xmm3 vmovdqa %xmm1,(%rsi) @@ -481,6 +480,7 @@ L$ks256_loop: .p2align 4 _aes128gcmsiv_aes_ks_enc_x1: +_CET_ENDBR vmovdqa (%rcx),%xmm1 vmovdqa 0(%rdi),%xmm4 @@ -623,6 +623,7 @@ _aes128gcmsiv_aes_ks_enc_x1: .p2align 4 _aes128gcmsiv_kdf: +_CET_ENDBR @@ -716,6 +717,7 @@ _aes128gcmsiv_kdf: .p2align 4 _aes128gcmsiv_enc_msg_x4: +_CET_ENDBR testq %r8,%r8 jnz L$128_enc_msg_x4_start .byte 0xf3,0xc3 @@ -891,6 +893,7 @@ L$128_enc_msg_x4_out: .p2align 4 _aes128gcmsiv_enc_msg_x8: +_CET_ENDBR testq %r8,%r8 jnz L$128_enc_msg_x8_start .byte 0xf3,0xc3 @@ -1146,6 +1149,7 @@ L$128_enc_msg_x8_out: .p2align 4 _aes128gcmsiv_dec: +_CET_ENDBR testq $~15,%r9 jnz L$128_dec_start .byte 0xf3,0xc3 @@ -1638,6 +1642,7 @@ L$128_dec_out: .p2align 4 _aes128gcmsiv_ecb_enc_block: +_CET_ENDBR vmovdqa (%rdi),%xmm1 vpxor (%rdx),%xmm1,%xmm1 @@ -1663,6 +1668,7 @@ _aes128gcmsiv_ecb_enc_block: .p2align 4 _aes256gcmsiv_aes_ks_enc_x1: +_CET_ENDBR vmovdqa con1(%rip),%xmm0 vmovdqa mask(%rip),%xmm15 vmovdqa (%rdi),%xmm8 @@ -1846,6 +1852,7 @@ _aes256gcmsiv_aes_ks_enc_x1: .p2align 4 _aes256gcmsiv_ecb_enc_block: +_CET_ENDBR vmovdqa (%rdi),%xmm1 vpxor (%rdx),%xmm1,%xmm1 vaesenc 16(%rdx),%xmm1,%xmm1 @@ -1872,6 +1879,7 @@ _aes256gcmsiv_ecb_enc_block: .p2align 4 _aes256gcmsiv_enc_msg_x4: +_CET_ENDBR testq %r8,%r8 jnz L$256_enc_msg_x4_start .byte 0xf3,0xc3 @@ -2073,6 +2081,7 @@ L$256_enc_msg_x4_out: .p2align 4 _aes256gcmsiv_enc_msg_x8: +_CET_ENDBR testq %r8,%r8 jnz L$256_enc_msg_x8_start .byte 0xf3,0xc3 @@ -2362,6 +2371,7 @@ L$256_enc_msg_x8_out: .p2align 4 _aes256gcmsiv_dec: +_CET_ENDBR testq $~15,%r9 jnz L$256_dec_start .byte 0xf3,0xc3 @@ -2922,6 +2932,7 @@ L$256_dec_out: .p2align 4 _aes256gcmsiv_kdf: +_CET_ENDBR @@ -3067,10 +3078,6 @@ _aes256gcmsiv_kdf: .byte 0xf3,0xc3 -#endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits #endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_armv8-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_armv8-ios.ios.aarch64.S index e198e186..c39f8c08 100644 --- a/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_armv8-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_armv8-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) #include .section __TEXT,__const @@ -3016,11 +3008,7 @@ Lopen_128_hash_64: b Lopen_128_hash_64 .cfi_endproc -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_armv8-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_armv8-linux.linux.aarch64.S index 2e6d5ea4..45387193 100644 --- a/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_armv8-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_armv8-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) #include .section .rodata @@ -3016,11 +3008,7 @@ chacha20_poly1305_open: b .Lopen_128_hash_64 .cfi_endproc .size chacha20_poly1305_open,.-chacha20_poly1305_open -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_x86_64-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_x86_64-linux.linux.x86_64.S index fc3a19d4..d1fd9551 100644 --- a/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_x86_64-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_x86_64-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .extern OPENSSL_ia32cap_P .hidden OPENSSL_ia32cap_P @@ -232,6 +225,7 @@ poly_hash_ad_internal: .align 64 chacha20_poly1305_open: .cfi_startproc +_CET_ENDBR pushq %rbp .cfi_adjust_cfa_offset 8 .cfi_offset %rbp,-16 @@ -2117,6 +2111,7 @@ chacha20_poly1305_open: .align 64 chacha20_poly1305_seal: .cfi_startproc +_CET_ENDBR pushq %rbp .cfi_adjust_cfa_offset 8 .cfi_offset %rbp,-16 @@ -8923,10 +8918,6 @@ chacha20_poly1305_seal_avx2: .cfi_endproc .size chacha20_poly1305_seal_avx2, .-chacha20_poly1305_seal_avx2 #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_x86_64-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_x86_64-mac.mac.x86_64.S index 6820c003..181154cb 100644 --- a/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_x86_64-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/cipher_extra/chacha20_poly1305_x86_64-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text @@ -231,6 +224,7 @@ L$hash_ad_done: .p2align 6 _chacha20_poly1305_open: +_CET_ENDBR pushq %rbp pushq %rbx @@ -2102,6 +2096,7 @@ L$open_sse_128_xor_hash: .p2align 6 _chacha20_poly1305_seal: +_CET_ENDBR pushq %rbp pushq %rbx @@ -8879,10 +8874,6 @@ L$seal_avx2_exit: jmp L$seal_sse_tail_16 -#endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits #endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CCryptoBoringSSL/crypto/cipher_extra/e_tls.c b/Sources/CCryptoBoringSSL/crypto/cipher_extra/e_tls.c index 60aac35b..035f45ad 100644 --- a/Sources/CCryptoBoringSSL/crypto/cipher_extra/e_tls.c +++ b/Sources/CCryptoBoringSSL/crypto/cipher_extra/e_tls.c @@ -400,6 +400,14 @@ static int aead_aes_128_cbc_sha1_tls_implicit_iv_init( EVP_sha1(), 1); } +static int aead_aes_128_cbc_sha256_tls_init(EVP_AEAD_CTX *ctx, + const uint8_t *key, size_t key_len, + size_t tag_len, + enum evp_aead_direction_t dir) { + return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_aes_128_cbc(), + EVP_sha256(), 0); +} + static int aead_aes_256_cbc_sha1_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len, size_t tag_len, enum evp_aead_direction_t dir) { @@ -442,13 +450,6 @@ static int aead_tls_get_iv(const EVP_AEAD_CTX *ctx, const uint8_t **out_iv, return 1; } -static int aead_null_sha1_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key, - size_t key_len, size_t tag_len, - enum evp_aead_direction_t dir) { - return aead_tls_init(ctx, key, key_len, tag_len, dir, EVP_enc_null(), - EVP_sha1(), 1 /* implicit iv */); -} - static const EVP_AEAD aead_aes_128_cbc_sha1_tls = { SHA_DIGEST_LENGTH + 16, // key len (SHA1 + AES128) 16, // nonce len (IV) @@ -483,6 +484,23 @@ static const EVP_AEAD aead_aes_128_cbc_sha1_tls_implicit_iv = { aead_tls_tag_len, }; +static const EVP_AEAD aead_aes_128_cbc_sha256_tls = { + SHA256_DIGEST_LENGTH + 16, // key len (SHA256 + AES128) + 16, // nonce len (IV) + 16 + SHA256_DIGEST_LENGTH, // overhead (padding + SHA256) + SHA256_DIGEST_LENGTH, // max tag length + 0, // seal_scatter_supports_extra_in + + NULL, // init + aead_aes_128_cbc_sha256_tls_init, + aead_tls_cleanup, + aead_tls_open, + aead_tls_seal_scatter, + NULL, // open_gather + NULL, // get_iv + aead_tls_tag_len, +}; + static const EVP_AEAD aead_aes_256_cbc_sha1_tls = { SHA_DIGEST_LENGTH + 32, // key len (SHA1 + AES256) 16, // nonce len (IV) @@ -551,23 +569,6 @@ static const EVP_AEAD aead_des_ede3_cbc_sha1_tls_implicit_iv = { aead_tls_tag_len, }; -static const EVP_AEAD aead_null_sha1_tls = { - SHA_DIGEST_LENGTH, // key len - 0, // nonce len - SHA_DIGEST_LENGTH, // overhead (SHA1) - SHA_DIGEST_LENGTH, // max tag length - 0, // seal_scatter_supports_extra_in - - NULL, // init - aead_null_sha1_tls_init, - aead_tls_cleanup, - aead_tls_open, - aead_tls_seal_scatter, - NULL, // open_gather - NULL, // get_iv - aead_tls_tag_len, -}; - const EVP_AEAD *EVP_aead_aes_128_cbc_sha1_tls(void) { return &aead_aes_128_cbc_sha1_tls; } @@ -576,6 +577,10 @@ const EVP_AEAD *EVP_aead_aes_128_cbc_sha1_tls_implicit_iv(void) { return &aead_aes_128_cbc_sha1_tls_implicit_iv; } +const EVP_AEAD *EVP_aead_aes_128_cbc_sha256_tls(void) { + return &aead_aes_128_cbc_sha256_tls; +} + const EVP_AEAD *EVP_aead_aes_256_cbc_sha1_tls(void) { return &aead_aes_256_cbc_sha1_tls; } @@ -591,5 +596,3 @@ const EVP_AEAD *EVP_aead_des_ede3_cbc_sha1_tls(void) { const EVP_AEAD *EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv(void) { return &aead_des_ede3_cbc_sha1_tls_implicit_iv; } - -const EVP_AEAD *EVP_aead_null_sha1_tls(void) { return &aead_null_sha1_tls; } diff --git a/Sources/CCryptoBoringSSL/crypto/cipher_extra/internal.h b/Sources/CCryptoBoringSSL/crypto/cipher_extra/internal.h index dd83f140..a6882d4d 100644 --- a/Sources/CCryptoBoringSSL/crypto/cipher_extra/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/cipher_extra/internal.h @@ -109,6 +109,14 @@ OPENSSL_EXPORT int EVP_sha1_final_with_secret_suffix( SHA_CTX *ctx, uint8_t out[SHA_DIGEST_LENGTH], const uint8_t *in, size_t len, size_t max_len); +// EVP_sha256_final_with_secret_suffix acts like +// |EVP_sha1_final_with_secret_suffix|, but for SHA-256. +// +// This function is exported for unit tests. +OPENSSL_EXPORT int EVP_sha256_final_with_secret_suffix( + SHA256_CTX *ctx, uint8_t out[SHA256_DIGEST_LENGTH], const uint8_t *in, + size_t len, size_t max_len); + // EVP_tls_cbc_digest_record computes the MAC of a decrypted, padded TLS // record. // diff --git a/Sources/CCryptoBoringSSL/crypto/cipher_extra/tls_cbc.c b/Sources/CCryptoBoringSSL/crypto/cipher_extra/tls_cbc.c index 102b0dd9..571b9040 100644 --- a/Sources/CCryptoBoringSSL/crypto/cipher_extra/tls_cbc.c +++ b/Sources/CCryptoBoringSSL/crypto/cipher_extra/tls_cbc.c @@ -267,24 +267,115 @@ int EVP_sha1_final_with_secret_suffix(SHA_CTX *ctx, return 1; } -int EVP_tls_cbc_record_digest_supported(const EVP_MD *md) { - return EVP_MD_type(md) == NID_sha1; -} - -int EVP_tls_cbc_digest_record(const EVP_MD *md, uint8_t *md_out, - size_t *md_out_size, const uint8_t header[13], - const uint8_t *data, size_t data_size, - size_t data_plus_mac_plus_padding_size, - const uint8_t *mac_secret, - unsigned mac_secret_length) { - if (EVP_MD_type(md) != NID_sha1) { - // EVP_tls_cbc_record_digest_supported should have been called first to - // check that the hash function is supported. - assert(0); - *md_out_size = 0; - return 0; +int EVP_sha256_final_with_secret_suffix(SHA256_CTX *ctx, + uint8_t out[SHA256_DIGEST_LENGTH], + const uint8_t *in, size_t len, + size_t max_len) { + // Bound the input length so |total_bits| below fits in four bytes. This is + // redundant with TLS record size limits. This also ensures |input_idx| below + // does not overflow. + size_t max_len_bits = max_len << 3; + if (ctx->Nh != 0 || + (max_len_bits >> 3) != max_len || // Overflow + ctx->Nl + max_len_bits < max_len_bits || + ctx->Nl + max_len_bits > UINT32_MAX) { + return 0; } + // We need to hash the following into |ctx|: + // + // - ctx->data[:ctx->num] + // - in[:len] + // - A 0x80 byte + // - However many zero bytes are needed to pad up to a block. + // - Eight bytes of length. + size_t num_blocks = (ctx->num + len + 1 + 8 + SHA256_CBLOCK - 1) >> 6; + size_t last_block = num_blocks - 1; + size_t max_blocks = (ctx->num + max_len + 1 + 8 + SHA256_CBLOCK - 1) >> 6; + + // The bounds above imply |total_bits| fits in four bytes. + size_t total_bits = ctx->Nl + (len << 3); + uint8_t length_bytes[4]; + length_bytes[0] = (uint8_t)(total_bits >> 24); + length_bytes[1] = (uint8_t)(total_bits >> 16); + length_bytes[2] = (uint8_t)(total_bits >> 8); + length_bytes[3] = (uint8_t)total_bits; + + // We now construct and process each expected block in constant-time. + uint8_t block[SHA256_CBLOCK] = {0}; + uint32_t result[8] = {0}; + // input_idx is the index into |in| corresponding to the current block. + // However, we allow this index to overflow beyond |max_len|, to simplify the + // 0x80 byte. + size_t input_idx = 0; + for (size_t i = 0; i < max_blocks; i++) { + // Fill |block| with data from the partial block in |ctx| and |in|. We copy + // as if we were hashing up to |max_len| and then zero the excess later. + size_t block_start = 0; + if (i == 0) { + OPENSSL_memcpy(block, ctx->data, ctx->num); + block_start = ctx->num; + } + if (input_idx < max_len) { + size_t to_copy = SHA256_CBLOCK - block_start; + if (to_copy > max_len - input_idx) { + to_copy = max_len - input_idx; + } + OPENSSL_memcpy(block + block_start, in + input_idx, to_copy); + } + + // Zero any bytes beyond |len| and add the 0x80 byte. + for (size_t j = block_start; j < SHA256_CBLOCK; j++) { + // input[idx] corresponds to block[j]. + size_t idx = input_idx + j - block_start; + // The barriers on |len| are not strictly necessary. However, without + // them, GCC compiles this code by incorporating |len| into the loop + // counter and subtracting it out later. This is still constant-time, but + // it frustrates attempts to validate this. + uint8_t is_in_bounds = constant_time_lt_8(idx, value_barrier_w(len)); + uint8_t is_padding_byte = constant_time_eq_8(idx, value_barrier_w(len)); + block[j] &= is_in_bounds; + block[j] |= 0x80 & is_padding_byte; + } + + input_idx += SHA256_CBLOCK - block_start; + + // Fill in the length if this is the last block. + crypto_word_t is_last_block = constant_time_eq_w(i, last_block); + for (size_t j = 0; j < 4; j++) { + block[SHA256_CBLOCK - 4 + j] |= is_last_block & length_bytes[j]; + } + + // Process the block and save the hash state if it is the final value. + SHA256_Transform(ctx, block); + for (size_t j = 0; j < 8; j++) { + result[j] |= is_last_block & ctx->h[j]; + } + } + + // Write the output. + for (size_t i = 0; i < 8; i++) { + CRYPTO_store_u32_be(out + 4 * i, result[i]); + } + return 1; +} + +int EVP_tls_cbc_record_digest_supported(const EVP_MD *md) { + switch (EVP_MD_type(md)) { + case NID_sha1: + case NID_sha256: + return 1; + default: + return 0; + } +} + +static int tls_cbc_digest_record_sha1(uint8_t *md_out, size_t *md_out_size, + const uint8_t header[13], + const uint8_t *data, size_t data_size, + size_t data_plus_mac_plus_padding_size, + const uint8_t *mac_secret, + unsigned mac_secret_length) { if (mac_secret_length > SHA_CBLOCK) { // HMAC pads small keys with zeros and hashes large keys down. This function // should never reach the large key case. @@ -336,3 +427,88 @@ int EVP_tls_cbc_digest_record(const EVP_MD *md, uint8_t *md_out, *md_out_size = SHA_DIGEST_LENGTH; return 1; } + +static int tls_cbc_digest_record_sha256(uint8_t *md_out, size_t *md_out_size, + const uint8_t header[13], + const uint8_t *data, size_t data_size, + size_t data_plus_mac_plus_padding_size, + const uint8_t *mac_secret, + unsigned mac_secret_length) { + if (mac_secret_length > SHA256_CBLOCK) { + // HMAC pads small keys with zeros and hashes large keys down. This function + // should never reach the large key case. + assert(0); + return 0; + } + + // Compute the initial HMAC block. + uint8_t hmac_pad[SHA256_CBLOCK]; + OPENSSL_memset(hmac_pad, 0, sizeof(hmac_pad)); + OPENSSL_memcpy(hmac_pad, mac_secret, mac_secret_length); + for (size_t i = 0; i < SHA256_CBLOCK; i++) { + hmac_pad[i] ^= 0x36; + } + + SHA256_CTX ctx; + SHA256_Init(&ctx); + SHA256_Update(&ctx, hmac_pad, SHA256_CBLOCK); + SHA256_Update(&ctx, header, 13); + + // There are at most 256 bytes of padding, so we can compute the public + // minimum length for |data_size|. + size_t min_data_size = 0; + if (data_plus_mac_plus_padding_size > SHA256_DIGEST_LENGTH + 256) { + min_data_size = + data_plus_mac_plus_padding_size - SHA256_DIGEST_LENGTH - 256; + } + + // Hash the public minimum length directly. This reduces the number of blocks + // that must be computed in constant-time. + SHA256_Update(&ctx, data, min_data_size); + + // Hash the remaining data without leaking |data_size|. + uint8_t mac_out[SHA256_DIGEST_LENGTH]; + if (!EVP_sha256_final_with_secret_suffix( + &ctx, mac_out, data + min_data_size, data_size - min_data_size, + data_plus_mac_plus_padding_size - min_data_size)) { + return 0; + } + + // Complete the HMAC in the standard manner. + SHA256_Init(&ctx); + for (size_t i = 0; i < SHA256_CBLOCK; i++) { + hmac_pad[i] ^= 0x6a; + } + + SHA256_Update(&ctx, hmac_pad, SHA256_CBLOCK); + SHA256_Update(&ctx, mac_out, SHA256_DIGEST_LENGTH); + SHA256_Final(md_out, &ctx); + *md_out_size = SHA256_DIGEST_LENGTH; + return 1; +} + +int EVP_tls_cbc_digest_record(const EVP_MD *md, uint8_t *md_out, + size_t *md_out_size, const uint8_t header[13], + const uint8_t *data, size_t data_size, + size_t data_plus_mac_plus_padding_size, + const uint8_t *mac_secret, + unsigned mac_secret_length) { + switch (EVP_MD_type(md)) { + case NID_sha1: + return tls_cbc_digest_record_sha1( + md_out, md_out_size, header, data, data_size, + data_plus_mac_plus_padding_size, mac_secret, mac_secret_length); + + case NID_sha256: + return tls_cbc_digest_record_sha256( + md_out, md_out_size, header, data, data_size, + data_plus_mac_plus_padding_size, mac_secret, mac_secret_length); + + default: + // EVP_tls_cbc_record_digest_supported should have been called first to + // check that the hash function is supported. + assert(0); + *md_out_size = 0; + return 0; + } +} diff --git a/Sources/CCryptoBoringSSL/crypto/conf/conf.c b/Sources/CCryptoBoringSSL/crypto/conf/conf.c index c8acc9f0..6e5b8a85 100644 --- a/Sources/CCryptoBoringSSL/crypto/conf/conf.c +++ b/Sources/CCryptoBoringSSL/crypto/conf/conf.c @@ -68,21 +68,10 @@ #include "conf_def.h" #include "internal.h" #include "../internal.h" -#include "../lhash/internal.h" -DEFINE_LHASH_OF(CONF_VALUE) - -struct conf_st { - LHASH_OF(CONF_VALUE) *data; -}; - static const char kDefaultSectionName[] = "default"; -// The maximum length we can grow a value to after variable expansion. 64k -// should be more than enough for all reasonable uses. -#define MAX_CONF_VALUE_LENGTH 65536 - static uint32_t conf_value_hash(const CONF_VALUE *v) { const uint32_t section_hash = v->section ? OPENSSL_strhash(v->section) : 0; const uint32_t name_hash = v->name ? OPENSSL_strhash(v->name) : 0; @@ -139,24 +128,23 @@ CONF_VALUE *CONF_VALUE_new(void) { } static void value_free_contents(CONF_VALUE *value) { - if (value->section) { - OPENSSL_free(value->section); - } + OPENSSL_free(value->section); if (value->name) { OPENSSL_free(value->name); - if (value->value) { - OPENSSL_free(value->value); - } + OPENSSL_free(value->value); } else { - if (value->value) { - sk_CONF_VALUE_free((STACK_OF(CONF_VALUE)*)value->value); - } + // TODO(davidben): When |value->name| is NULL, |CONF_VALUE| is actually an + // entirely different structure. This is fragile and confusing. Make a + // proper |CONF_SECTION| type that doesn't require this. + sk_CONF_VALUE_free((STACK_OF(CONF_VALUE) *)value->value); } } static void value_free(CONF_VALUE *value) { - value_free_contents(value); - OPENSSL_free(value); + if (value != NULL) { + value_free_contents(value); + OPENSSL_free(value); + } } static void value_free_arg(CONF_VALUE *value, void *arg) { value_free(value); } @@ -192,28 +180,21 @@ static CONF_VALUE *NCONF_new_section(const CONF *conf, const char *section) { if (!lh_CONF_VALUE_insert(conf->data, &old_value, v)) { goto err; } - if (old_value) { - value_free(old_value); - } + value_free(old_value); ok = 1; err: if (!ok) { - if (sk != NULL) { - sk_CONF_VALUE_free(sk); - } - if (v != NULL) { - OPENSSL_free(v); - } + sk_CONF_VALUE_free(sk); + OPENSSL_free(v); v = NULL; } return v; } static int str_copy(CONF *conf, char *section, char **pto, char *from) { - int q, r, rr = 0, to = 0, len = 0; - char *s, *e, *rp, *rrp, *np, *cp, v; - const char *p; + int q, to = 0, len = 0; + char v; BUF_MEM *buf; buf = BUF_MEM_new(); @@ -242,22 +223,6 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from) { if (*from == q) { from++; } - } else if (IS_DQUOTE(conf, *from)) { - q = *from; - from++; - while (!IS_EOF(conf, *from)) { - if (*from == q) { - if (*(from + 1) == q) { - from++; - } else { - break; - } - } - buf->data[to++] = *(from++); - } - if (*from == q) { - from++; - } } else if (IS_ESC(conf, *from)) { from++; v = *(from++); @@ -276,102 +241,23 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from) { } else if (IS_EOF(conf, *from)) { break; } else if (*from == '$') { - // try to expand it - rrp = NULL; - s = &(from[1]); - if (*s == '{') { - q = '}'; - } else if (*s == '(') { - q = ')'; - } else { - q = 0; - } - - if (q) { - s++; - } - cp = section; - e = np = s; - while (IS_ALPHA_NUMERIC(conf, *e)) { - e++; - } - if (e[0] == ':' && e[1] == ':') { - cp = np; - rrp = e; - rr = *e; - *rrp = '\0'; - e += 2; - np = e; - while (IS_ALPHA_NUMERIC(conf, *e)) { - e++; - } - } - r = *e; - *e = '\0'; - rp = e; - if (q) { - if (r != q) { - OPENSSL_PUT_ERROR(CONF, CONF_R_NO_CLOSE_BRACE); - goto err; - } - e++; - } - // So at this point we have - // np which is the start of the name string which is - // '\0' terminated. - // cp which is the start of the section string which is - // '\0' terminated. - // e is the 'next point after'. - // r and rr are the chars replaced by the '\0' - // rp and rrp is where 'r' and 'rr' came from. - p = NCONF_get_string(conf, cp, np); - if (rrp != NULL) { - *rrp = rr; - } - *rp = r; - if (p == NULL) { - OPENSSL_PUT_ERROR(CONF, CONF_R_VARIABLE_HAS_NO_VALUE); - goto err; - } - size_t newsize = strlen(p) + buf->length - (e - from); - if (newsize > MAX_CONF_VALUE_LENGTH) { - OPENSSL_PUT_ERROR(CONF, CONF_R_VARIABLE_EXPANSION_TOO_LONG); - goto err; - } - if (!BUF_MEM_grow_clean(buf, newsize)) { - goto err; - } - while (*p) { - buf->data[to++] = *(p++); - } - - /* Since we change the pointer 'from', we also have - to change the perceived length of the string it - points at. /RL */ - len -= e - from; - from = e; - - /* In case there were no braces or parenthesis around - the variable reference, we have to put back the - character that was replaced with a '\0'. /RL */ - *rp = r; + // Historically, $foo would expand to a previously-parsed value. This + // feature has been removed as it was unused and is a DoS vector. + OPENSSL_PUT_ERROR(CONF, CONF_R_VARIABLE_EXPANSION_NOT_SUPPORTED); + goto err; } else { buf->data[to++] = *(from++); } } buf->data[to] = '\0'; - if (*pto != NULL) { - OPENSSL_free(*pto); - } + OPENSSL_free(*pto); *pto = buf->data; OPENSSL_free(buf); return 1; err: - if (buf != NULL) { - BUF_MEM_free(buf); - } + BUF_MEM_free(buf); return 0; } @@ -472,33 +358,8 @@ static char *scan_quote(CONF *conf, char *p) { return p; } - -static char *scan_dquote(CONF *conf, char *p) { - int q = *p; - - p++; - while (!(IS_EOF(conf, *p))) { - if (*p == q) { - if (*(p + 1) == q) { - p++; - } else { - break; - } - } - p++; - } - if (*p == q) { - p++; - } - return p; -} - static void clear_comments(CONF *conf, char *p) { for (;;) { - if (IS_FCOMMENT(conf, *p)) { - *p = '\0'; - return; - } if (!IS_WS(conf, *p)) { break; } @@ -510,10 +371,6 @@ static void clear_comments(CONF *conf, char *p) { *p = '\0'; return; } - if (IS_DQUOTE(conf, *p)) { - p = scan_dquote(conf, p); - continue; - } if (IS_QUOTE(conf, *p)) { p = scan_quote(conf, p); continue; @@ -530,7 +387,7 @@ static void clear_comments(CONF *conf, char *p) { } } -static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) { +int NCONF_load_bio(CONF *conf, BIO *in, long *out_error_line) { static const size_t CONFBUFSIZE = 512; int bufnum = 0, i, ii; BUF_MEM *buff = NULL; @@ -707,37 +564,23 @@ static int def_load_bio(CONF *conf, BIO *in, long *out_error_line) { v = NULL; } } - if (buff != NULL) { - BUF_MEM_free(buff); - } - if (section != NULL) { - OPENSSL_free(section); - } + BUF_MEM_free(buff); + OPENSSL_free(section); return 1; err: - if (buff != NULL) { - BUF_MEM_free(buff); - } - if (section != NULL) { - OPENSSL_free(section); - } + BUF_MEM_free(buff); + OPENSSL_free(section); if (out_error_line != NULL) { *out_error_line = eline; } - BIO_snprintf(btmp, sizeof btmp, "%ld", eline); + snprintf(btmp, sizeof btmp, "%ld", eline); ERR_add_error_data(2, "line ", btmp); if (v != NULL) { - if (v->name != NULL) { - OPENSSL_free(v->name); - } - if (v->value != NULL) { - OPENSSL_free(v->value); - } - if (v != NULL) { - OPENSSL_free(v); - } + OPENSSL_free(v->name); + OPENSSL_free(v->value); + OPENSSL_free(v); } return 0; } @@ -751,16 +594,12 @@ int NCONF_load(CONF *conf, const char *filename, long *out_error_line) { return 0; } - ret = def_load_bio(conf, in, out_error_line); + ret = NCONF_load_bio(conf, in, out_error_line); BIO_free(in); return ret; } -int NCONF_load_bio(CONF *conf, BIO *bio, long *out_error_line) { - return def_load_bio(conf, bio, out_error_line); -} - int CONF_parse_list(const char *list, char sep, int remove_whitespace, int (*list_cb)(const char *elem, size_t len, void *usr), void *arg) { diff --git a/Sources/CCryptoBoringSSL/crypto/conf/conf_def.h b/Sources/CCryptoBoringSSL/crypto/conf/conf_def.h index f01a79b2..d2c285ae 100644 --- a/Sources/CCryptoBoringSSL/crypto/conf/conf_def.h +++ b/Sources/CCryptoBoringSSL/crypto/conf/conf_def.h @@ -55,8 +55,9 @@ * [including the GNU Public Licence.] */ -/* THIS FILE WAS AUTOMAGICALLY GENERATED! - Please modify and use keysets.pl to regenerate it. */ +// This file was historically generated by keysets.pl in OpenSSL. +// +// TODO(davidben): Replace it with something more readable. #define CONF_NUMBER 1 #define CONF_UPPER 2 @@ -66,9 +67,7 @@ #define CONF_WS 16 #define CONF_ESC 32 #define CONF_QUOTE 64 -#define CONF_DQUOTE 1024 #define CONF_COMMENT 128 -#define CONF_FCOMMENT 2048 #define CONF_EOF 8 #define CONF_HIGHBIT 4096 #define CONF_ALPHA (CONF_UPPER|CONF_LOWER) @@ -78,7 +77,6 @@ #define KEYTYPES(c) CONF_type_default #define IS_COMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_COMMENT) -#define IS_FCOMMENT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_FCOMMENT) #define IS_EOF(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_EOF) #define IS_ESC(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_ESC) #define IS_NUMBER(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_NUMBER) @@ -87,8 +85,6 @@ #define IS_ALPHA_NUMERIC_PUNCT(c,a) \ (KEYTYPES(c)[(a)&0xff]&CONF_ALPHA_NUMERIC_PUNCT) #define IS_QUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_QUOTE) -#define IS_DQUOTE(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_DQUOTE) -#define IS_HIGHBIT(c,a) (KEYTYPES(c)[(a)&0xff]&CONF_HIGHBIT) static const unsigned short CONF_type_default[256]={ 0x0008,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, diff --git a/Sources/CCryptoBoringSSL/crypto/conf/internal.h b/Sources/CCryptoBoringSSL/crypto/conf/internal.h index c876608e..750857f2 100644 --- a/Sources/CCryptoBoringSSL/crypto/conf/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/conf/internal.h @@ -17,11 +17,19 @@ #include +#include "../lhash/internal.h" + #if defined(__cplusplus) extern "C" { #endif +DEFINE_LHASH_OF(CONF_VALUE) + +struct conf_st { + LHASH_OF(CONF_VALUE) *data; +}; + // CONF_VALUE_new returns a freshly allocated and zeroed |CONF_VALUE|. CONF_VALUE *CONF_VALUE_new(void); diff --git a/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_apple.c b/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_apple.c index dbc22a0f..b478e41b 100644 --- a/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_apple.c +++ b/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_apple.c @@ -23,8 +23,6 @@ #include -extern uint32_t OPENSSL_armcap_P; - static int has_hw_feature(const char *name) { int value; size_t len = sizeof(value); @@ -65,6 +63,9 @@ void OPENSSL_cpuid_setup(void) { // available in macOS 12. For compatibility with macOS 11, we also support // the old names. The old names don't have values for features like FEAT_AES, // so instead we detect them statically above. + // + // If querying new sysctls, update the Chromium sandbox definition. See + // https://crrev.com/c/4415225. if (has_hw_feature("hw.optional.arm.FEAT_SHA512") || has_hw_feature("hw.optional.armv8_2_sha512")) { OPENSSL_armcap_P |= ARMV8_SHA512; diff --git a/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_fuchsia.c b/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_fuchsia.c index a12f0219..fd36f097 100644 --- a/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_fuchsia.c +++ b/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_fuchsia.c @@ -23,7 +23,6 @@ #include -extern uint32_t OPENSSL_armcap_P; void OPENSSL_cpuid_setup(void) { uint32_t hwcap; diff --git a/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_linux.c b/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_linux.c index e41f71ee..43e418b3 100644 --- a/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_linux.c +++ b/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_linux.c @@ -22,8 +22,6 @@ #include -extern uint32_t OPENSSL_armcap_P; - void OPENSSL_cpuid_setup(void) { unsigned long hwcap = getauxval(AT_HWCAP); diff --git a/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_freebsd.c b/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_openbsd.c similarity index 52% rename from Sources/CCryptoBoringSSL/crypto/cpu_aarch64_freebsd.c rename to Sources/CCryptoBoringSSL/crypto/cpu_aarch64_openbsd.c index fd849356..09b19738 100644 --- a/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_freebsd.c +++ b/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_openbsd.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2022, Google Inc. +/* Copyright (c) 2022, Robert Nagy * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -12,51 +12,50 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "internal.h" +#include -#if defined(OPENSSL_AARCH64) && defined(OPENSSL_FREEBSD) && \ +#if defined(OPENSSL_AARCH64) && defined(OPENSSL_OPENBSD) && \ !defined(OPENSSL_STATIC_ARMCAP) +#include +#include #include -#include #include -extern uint32_t OPENSSL_armcap_P; +#include "internal.h" -// ID_AA64ISAR0_*_VAL are defined starting FreeBSD 13.0. When FreeBSD -// 12.x is out of support, these compatibility macros can be removed. - -#ifndef ID_AA64ISAR0_AES_VAL -#define ID_AA64ISAR0_AES_VAL ID_AA64ISAR0_AES -#endif -#ifndef ID_AA64ISAR0_SHA1_VAL -#define ID_AA64ISAR0_SHA1_VAL ID_AA64ISAR0_SHA1 -#endif -#ifndef ID_AA64ISAR0_SHA2_VAL -#define ID_AA64ISAR0_SHA2_VAL ID_AA64ISAR0_SHA2 -#endif void OPENSSL_cpuid_setup(void) { - uint64_t id_aa64isar0 = READ_SPECIALREG(id_aa64isar0_el1); + int isar0_mib[] = { CTL_MACHDEP, CPU_ID_AA64ISAR0 }; + uint64_t cpu_id = 0; + size_t len = sizeof(cpu_id); + + if (sysctl(isar0_mib, 2, &cpu_id, &len, NULL, 0) < 0) { + return; + } OPENSSL_armcap_P |= ARMV7_NEON; - if (ID_AA64ISAR0_AES_VAL(id_aa64isar0) >= ID_AA64ISAR0_AES_BASE) { + if (ID_AA64ISAR0_AES(cpu_id) >= ID_AA64ISAR0_AES_BASE) { OPENSSL_armcap_P |= ARMV8_AES; } - if (ID_AA64ISAR0_AES_VAL(id_aa64isar0) >= ID_AA64ISAR0_AES_PMULL) { + + if (ID_AA64ISAR0_AES(cpu_id) >= ID_AA64ISAR0_AES_PMULL) { OPENSSL_armcap_P |= ARMV8_PMULL; } - if (ID_AA64ISAR0_SHA1_VAL(id_aa64isar0) >= ID_AA64ISAR0_SHA1_BASE) { + + if (ID_AA64ISAR0_SHA1(cpu_id) >= ID_AA64ISAR0_SHA1_BASE) { OPENSSL_armcap_P |= ARMV8_SHA1; } - if (ID_AA64ISAR0_SHA2_VAL(id_aa64isar0) >= ID_AA64ISAR0_SHA2_BASE) { + + if (ID_AA64ISAR0_SHA2(cpu_id) >= ID_AA64ISAR0_SHA2_BASE) { OPENSSL_armcap_P |= ARMV8_SHA256; } - if (ID_AA64ISAR0_SHA2_VAL(id_aa64isar0) >= ID_AA64ISAR0_SHA2_512) { + + if (ID_AA64ISAR0_SHA2(cpu_id) >= ID_AA64ISAR0_SHA2_512) { OPENSSL_armcap_P |= ARMV8_SHA512; } } -#endif // OPENSSL_AARCH64 && OPENSSL_FREEBSD && !OPENSSL_STATIC_ARMCAP +#endif // OPENSSL_AARCH64 && OPENSSL_OPENBSD && !OPENSSL_STATIC_ARMCAP diff --git a/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_sysreg.c b/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_sysreg.c new file mode 100644 index 00000000..92c533a5 --- /dev/null +++ b/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_sysreg.c @@ -0,0 +1,93 @@ +/* Copyright (c) 2023, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#include "internal.h" + +// While Arm system registers are normally not available to userspace, FreeBSD +// expects userspace to simply read them. It traps the reads and fills in CPU +// capabilities. +#if defined(OPENSSL_AARCH64) && !defined(OPENSSL_STATIC_ARMCAP) && \ + (defined(ANDROID_BAREMETAL) || defined(OPENSSL_FREEBSD)) + +#include + +#define ID_AA64PFR0_EL1_ADVSIMD 5 + +#define ID_AA64ISAR0_EL1_AES 1 +#define ID_AA64ISAR0_EL1_SHA1 2 +#define ID_AA64ISAR0_EL1_SHA2 3 + +#define NBITS_ID_FIELD 4 + +#define READ_SYSREG(name) \ + ({ \ + uint64_t _r; \ + __asm__("mrs %0, " name : "=r"(_r)); \ + _r; \ + }) + +static unsigned get_id_field(uint64_t reg, unsigned field) { + return (reg >> (field * NBITS_ID_FIELD)) & ((1 << NBITS_ID_FIELD) - 1); +} + +static int get_signed_id_field(uint64_t reg, unsigned field) { + unsigned value = get_id_field(reg, field); + if (value & (1 << (NBITS_ID_FIELD - 1))) { + return (int)(value | (UINT64_MAX << NBITS_ID_FIELD)); + } else { + return (int)value; + } +} + +static uint32_t read_armcap(void) { + uint32_t armcap = ARMV7_NEON; + + uint64_t id_aa64pfr0_el1 = READ_SYSREG("id_aa64pfr0_el1"); + + if (get_signed_id_field(id_aa64pfr0_el1, ID_AA64PFR0_EL1_ADVSIMD) < 0) { + // If AdvSIMD ("NEON") is missing, don't report other features either. + // This matches OpenSSL. + return 0; + } + + uint64_t id_aa64isar0_el1 = READ_SYSREG("id_aa64isar0_el1"); + + unsigned aes = get_id_field(id_aa64isar0_el1, ID_AA64ISAR0_EL1_AES); + if (aes > 0) { + armcap |= ARMV8_AES; + } + if (aes > 1) { + armcap |= ARMV8_PMULL; + } + + unsigned sha1 = get_id_field(id_aa64isar0_el1, ID_AA64ISAR0_EL1_SHA1); + if (sha1 > 0) { + armcap |= ARMV8_SHA1; + } + + unsigned sha2 = get_id_field(id_aa64isar0_el1, ID_AA64ISAR0_EL1_SHA2); + if (sha2 > 0) { + armcap |= ARMV8_SHA256; + } + if (sha2 > 1) { + armcap |= ARMV8_SHA512; + } + + return armcap; +} + +void OPENSSL_cpuid_setup(void) { OPENSSL_armcap_P |= read_armcap(); } + +#endif // OPENSSL_AARCH64 && !OPENSSL_STATIC_ARMCAP && + // (ANDROID_BAREMETAL || OPENSSL_FREEBSD) diff --git a/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_win.c b/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_win.c index 436577c7..60e29451 100644 --- a/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_win.c +++ b/Sources/CCryptoBoringSSL/crypto/cpu_aarch64_win.c @@ -22,7 +22,7 @@ #include -extern uint32_t OPENSSL_armcap_P; + void OPENSSL_cpuid_setup(void) { // We do not need to check for the presence of NEON, as Armv8-A always has it OPENSSL_armcap_P |= ARMV7_NEON; diff --git a/Sources/CCryptoBoringSSL/crypto/cpu_arm.c b/Sources/CCryptoBoringSSL/crypto/cpu_arm.c index 9ee1e706..7dce59a9 100644 --- a/Sources/CCryptoBoringSSL/crypto/cpu_arm.c +++ b/Sources/CCryptoBoringSSL/crypto/cpu_arm.c @@ -20,8 +20,6 @@ #include -extern uint32_t OPENSSL_armcap_P; - int CRYPTO_is_NEON_capable_at_runtime(void) { return (OPENSSL_armcap_P & ARMV7_NEON) != 0; } diff --git a/Sources/CCryptoBoringSSL/crypto/cpu_arm_freebsd.c b/Sources/CCryptoBoringSSL/crypto/cpu_arm_freebsd.c index a5e20777..9bcdccfa 100644 --- a/Sources/CCryptoBoringSSL/crypto/cpu_arm_freebsd.c +++ b/Sources/CCryptoBoringSSL/crypto/cpu_arm_freebsd.c @@ -22,7 +22,6 @@ #include #include -extern uint32_t OPENSSL_armcap_P; void OPENSSL_cpuid_setup(void) { unsigned long hwcap = 0, hwcap2 = 0; diff --git a/Sources/CCryptoBoringSSL/crypto/cpu_arm_linux.c b/Sources/CCryptoBoringSSL/crypto/cpu_arm_linux.c index 0bc4d555..44f5f2ad 100644 --- a/Sources/CCryptoBoringSSL/crypto/cpu_arm_linux.c +++ b/Sources/CCryptoBoringSSL/crypto/cpu_arm_linux.c @@ -95,8 +95,6 @@ err: return ret; } -extern uint32_t OPENSSL_armcap_P; - static int g_needs_hwcap2_workaround; void OPENSSL_cpuid_setup(void) { diff --git a/Sources/CCryptoBoringSSL/crypto/curve25519/asm/x25519-asm-arm.S b/Sources/CCryptoBoringSSL/crypto/curve25519/asm/x25519-asm-arm.S index 3bea19b7..6406ab74 100644 --- a/Sources/CCryptoBoringSSL/crypto/curve25519/asm/x25519-asm-arm.S +++ b/Sources/CCryptoBoringSSL/crypto/curve25519/asm/x25519-asm-arm.S @@ -19,17 +19,9 @@ * domain licensed but the standard ISC license is included above to keep * licensing simple. */ -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__ELF__) - -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) .fpu neon .text @@ -2131,11 +2123,7 @@ mov sp,r12 vpop {q4,q5,q6,q7} bx lr -#endif /* !OPENSSL_NO_ASM && __ARMEL__ && __ELF__ */ - -#if defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif +#endif /* !OPENSSL_NO_ASM && OPENSSL_ARM && __ELF__ */ #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/curve25519/curve25519.c b/Sources/CCryptoBoringSSL/crypto/curve25519/curve25519.c index e3f35e69..928592f7 100644 --- a/Sources/CCryptoBoringSSL/crypto/curve25519/curve25519.c +++ b/Sources/CCryptoBoringSSL/crypto/curve25519/curve25519.c @@ -19,8 +19,6 @@ // // The field functions are shared by Ed25519 and X25519 where possible. -#include - #include #include @@ -31,15 +29,16 @@ #include "internal.h" #include "../internal.h" - // Various pre-computed constants. #include "./curve25519_tables.h" -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(BORINGSSL_HAS_UINT128) #include "../../third_party/fiat/curve25519_64.h" +#elif defined(OPENSSL_64_BIT) +#include "../../third_party/fiat/curve25519_64_msvc.h" #else #include "../../third_party/fiat/curve25519_32.h" -#endif // BORINGSSL_CURVE25519_64BIT +#endif // Low-level intrinsic operations @@ -64,7 +63,7 @@ static uint64_t load_4(const uint8_t *in) { // Field operations. -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) typedef uint64_t fe_limb_t; #define FE_NUM_LIMBS 5 @@ -144,7 +143,7 @@ typedef uint32_t fe_limb_t; } \ } while (0) -#endif // BORINGSSL_CURVE25519_64BIT +#endif // OPENSSL_64_BIT static_assert(sizeof(fe) == sizeof(fe_limb_t) * FE_NUM_LIMBS, "fe_limb_t[FE_NUM_LIMBS] is inconsistent with fe"); @@ -313,11 +312,6 @@ static void fe_copy_lt(fe_loose *h, const fe *f) { static_assert(sizeof(fe_loose) == sizeof(fe), "fe and fe_loose mismatch"); OPENSSL_memmove(h, f, sizeof(fe)); } -#if !defined(OPENSSL_SMALL) -static void fe_copy_ll(fe_loose *h, const fe_loose *f) { - OPENSSL_memmove(h, f, sizeof(fe_loose)); -} -#endif // !defined(OPENSSL_SMALL) static void fe_loose_invert(fe *out, const fe_loose *z) { fe t0; @@ -696,16 +690,6 @@ void x25519_ge_sub(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q) { fe_add(&r->T, &trZ, &trT); } -static uint8_t equal(signed char b, signed char c) { - uint8_t ub = b; - uint8_t uc = c; - uint8_t x = ub ^ uc; // 0: yes; 1..255: no - uint32_t y = x; // 0: yes; 1..255: no - y -= 1; // 4294967295: yes; 0..254: no - y >>= 31; // 1: yes; 0: no - return y; -} - static void cmov(ge_precomp *t, const ge_precomp *u, uint8_t b) { fe_cmov(&t->yplusx, &u->yplusx, b); fe_cmov(&t->yminusx, &u->yminusx, b); @@ -752,7 +736,7 @@ void x25519_ge_scalarmult_small_precomp( ge_precomp_0(&e); for (j = 1; j < 16; j++) { - cmov(&e, &multiples[j-1], equal(index, j)); + cmov(&e, &multiples[j-1], 1&constant_time_eq_w(index, j)); } ge_cached cached; @@ -774,35 +758,36 @@ void x25519_ge_scalarmult_base(ge_p3 *h, const uint8_t a[32]) { #else -static uint8_t negative(signed char b) { - uint32_t x = b; - x >>= 31; // 1: yes; 0: no - return x; -} +static void table_select(ge_precomp *t, const int pos, const signed char b) { + uint8_t bnegative = constant_time_msb_w(b); + uint8_t babs = b - ((bnegative & b) << 1); + + uint8_t t_bytes[3][32] = { + {constant_time_is_zero_w(b) & 1}, {constant_time_is_zero_w(b) & 1}, {0}}; +#if defined(__clang__) // materialize for vectorization, 6% speedup + __asm__("" : "+m" (t_bytes) : /*no inputs*/); +#endif + static_assert(sizeof(t_bytes) == sizeof(k25519Precomp[pos][0]), ""); + for (int i = 0; i < 8; i++) { + constant_time_conditional_memxor(t_bytes, k25519Precomp[pos][i], + sizeof(t_bytes), + constant_time_eq_w(babs, 1 + i)); + } + + fe yplusx, yminusx, xy2d; + fe_frombytes_strict(&yplusx, t_bytes[0]); + fe_frombytes_strict(&yminusx, t_bytes[1]); + fe_frombytes_strict(&xy2d, t_bytes[2]); + + fe_copy_lt(&t->yplusx, &yplusx); + fe_copy_lt(&t->yminusx, &yminusx); + fe_copy_lt(&t->xy2d, &xy2d); -static void table_select(ge_precomp *t, int pos, signed char b) { ge_precomp minust; - uint8_t bnegative = negative(b); - uint8_t babs = b - ((uint8_t)((-bnegative) & b) << 1); - - ge_precomp_0(t); - cmov(t, &k25519Precomp[pos][0], equal(babs, 1)); - cmov(t, &k25519Precomp[pos][1], equal(babs, 2)); - cmov(t, &k25519Precomp[pos][2], equal(babs, 3)); - cmov(t, &k25519Precomp[pos][3], equal(babs, 4)); - cmov(t, &k25519Precomp[pos][4], equal(babs, 5)); - cmov(t, &k25519Precomp[pos][5], equal(babs, 6)); - cmov(t, &k25519Precomp[pos][6], equal(babs, 7)); - cmov(t, &k25519Precomp[pos][7], equal(babs, 8)); - fe_copy_ll(&minust.yplusx, &t->yminusx); - fe_copy_ll(&minust.yminusx, &t->yplusx); - - // NOTE: the input table is canonical, but types don't encode it - fe tmp; - fe_carry(&tmp, &t->xy2d); - fe_neg(&minust.xy2d, &tmp); - - cmov(t, &minust, bnegative); + fe_copy_lt(&minust.yplusx, &yminusx); + fe_copy_lt(&minust.yminusx, &yplusx); + fe_neg(&minust.xy2d, &xy2d); + cmov(t, &minust, bnegative>>7); } // h = a * B @@ -812,6 +797,18 @@ static void table_select(ge_precomp *t, int pos, signed char b) { // Preconditions: // a[31] <= 127 void x25519_ge_scalarmult_base(ge_p3 *h, const uint8_t a[32]) { +#if defined(BORINGSSL_FE25519_ADX) + if (CRYPTO_is_BMI1_capable() && CRYPTO_is_BMI2_capable() && + CRYPTO_is_ADX_capable()) { + uint8_t t[4][32]; + x25519_ge_scalarmult_base_adx(t, a); + fiat_25519_from_bytes(h->X.v, t[0]); + fiat_25519_from_bytes(h->Y.v, t[1]); + fiat_25519_from_bytes(h->Z.v, t[2]); + fiat_25519_from_bytes(h->T.v, t[3]); + return; + } +#endif signed char e[64]; signed char carry; ge_p1p1 r; @@ -914,7 +911,7 @@ void x25519_ge_scalarmult(ge_p2 *r, const uint8_t *scalar, const ge_p3 *A) { ge_cached selected; ge_cached_0(&selected); for (j = 0; j < 16; j++) { - cmov_cached(&selected, &Ai[j], equal(j, index)); + cmov_cached(&selected, &Ai[j], 1&constant_time_eq_w(index, j)); } x25519_ge_add(&t, &u, &selected); @@ -2081,6 +2078,12 @@ static void x25519_scalar_mult(uint8_t out[32], const uint8_t scalar[32], x25519_NEON(out, scalar, point); return; } +#elif defined(BORINGSSL_FE25519_ADX) + if (CRYPTO_is_BMI1_capable() && CRYPTO_is_BMI2_capable() && + CRYPTO_is_ADX_capable()) { + x25519_scalar_mult_adx(out, scalar, point); + return; + } #endif x25519_scalar_mult_generic(out, scalar, point); @@ -2114,7 +2117,8 @@ int X25519(uint8_t out_shared_key[32], const uint8_t private_key[32], static const uint8_t kZeros[32] = {0}; x25519_scalar_mult(out_shared_key, private_key, peer_public_value); // The all-zero output results when the input is a point of small order. - return CRYPTO_memcmp(kZeros, out_shared_key, 32) != 0; + return constant_time_declassify_int( + CRYPTO_memcmp(kZeros, out_shared_key, 32)) != 0; } void X25519_public_from_private(uint8_t out_public_value[32], @@ -2145,4 +2149,5 @@ void X25519_public_from_private(uint8_t out_public_value[32], fe_loose_invert(&zminusy_inv, &zminusy); fe_mul_tlt(&zminusy_inv, &zplusy, &zminusy_inv); fe_tobytes(out_public_value, &zminusy_inv); + CONSTTIME_DECLASSIFY(out_public_value, 32); } diff --git a/Sources/CCryptoBoringSSL/crypto/curve25519/curve25519_64_adx.c b/Sources/CCryptoBoringSSL/crypto/curve25519/curve25519_64_adx.c new file mode 100644 index 00000000..27689896 --- /dev/null +++ b/Sources/CCryptoBoringSSL/crypto/curve25519/curve25519_64_adx.c @@ -0,0 +1,18 @@ +/* Copyright (c) 2023, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#include "internal.h" +#if defined(BORINGSSL_FE25519_ADX) +#include "../../third_party/fiat/curve25519_64_adx.h" +#endif diff --git a/Sources/CCryptoBoringSSL/crypto/curve25519/curve25519_tables.h b/Sources/CCryptoBoringSSL/crypto/curve25519/curve25519_tables.h index 310581cf..6636a36a 100644 --- a/Sources/CCryptoBoringSSL/crypto/curve25519/curve25519_tables.h +++ b/Sources/CCryptoBoringSSL/crypto/curve25519/curve25519_tables.h @@ -17,7 +17,7 @@ static const fe d = {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 929955233495203, 466365720129213, 1662059464998953, 2033849074728123, 1442794654840575 #else @@ -27,7 +27,7 @@ static const fe d = {{ }}; static const fe sqrtm1 = {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 1718705420411056, 234908883556509, 2233514472574048, 2117202627021982, 765476049583133 #else @@ -37,7 +37,7 @@ static const fe sqrtm1 = {{ }}; static const fe d2 = {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 1859910466990425, 932731440258426, 1072319116312658, 1815898335770999, 633789495995903 #else @@ -142,7493 +142,2885 @@ static const uint8_t k25519SmallPrecomp[15 * 2 * 32] = { #else // k25519Precomp[i][j] = (j+1)*256^i*B -static const ge_precomp k25519Precomp[32][8] = { +const uint8_t k25519Precomp[32][8][3][32] = { { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1288382639258501, 245678601348599, 269427782077623, - 1462984067271730, 137412439391563 -#else - 25967493, 19198397, 29566455, 3660896, 54414519, 4014786, - 27544626, 21800161, 61029707, 2047604 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 62697248952638, 204681361388450, 631292143396476, - 338455783676468, 1213667448819585 -#else - 54563134, 934261, 64385954, 3049989, 66381436, 9406985, - 12720692, 5043384, 19500929, 18085054 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 301289933810280, 1259582250014073, 1422107436869536, - 796239922652654, 1953934009299142 -#else - 58370664, 4489569, 9688441, 18769238, 10184608, 21191052, - 29287918, 11864899, 42594502, 29115885 -#endif - }}, + {0x85, 0x3b, 0x8c, 0xf5, 0xc6, 0x93, 0xbc, 0x2f, 0x19, 0xe, 0x8c, + 0xfb, 0xc6, 0x2d, 0x93, 0xcf, 0xc2, 0x42, 0x3d, 0x64, 0x98, 0x48, + 0xb, 0x27, 0x65, 0xba, 0xd4, 0x33, 0x3a, 0x9d, 0xcf, 0x7}, + {0x3e, 0x91, 0x40, 0xd7, 0x5, 0x39, 0x10, 0x9d, 0xb3, 0xbe, 0x40, + 0xd1, 0x5, 0x9f, 0x39, 0xfd, 0x9, 0x8a, 0x8f, 0x68, 0x34, 0x84, + 0xc1, 0xa5, 0x67, 0x12, 0xf8, 0x98, 0x92, 0x2f, 0xfd, 0x44}, + {0x68, 0xaa, 0x7a, 0x87, 0x5, 0x12, 0xc9, 0xab, 0x9e, 0xc4, 0xaa, + 0xcc, 0x23, 0xe8, 0xd9, 0x26, 0x8c, 0x59, 0x43, 0xdd, 0xcb, 0x7d, + 0x1b, 0x5a, 0xa8, 0x65, 0xc, 0x9f, 0x68, 0x7b, 0x11, 0x6f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1380971894829527, 790832306631236, 2067202295274102, - 1995808275510000, 1566530869037010 -#else - 54292951, 20578084, 45527620, 11784319, 41753206, 30803714, - 55390960, 29739860, 66750418, 23343128 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 463307831301544, 432984605774163, 1610641361907204, - 750899048855000, 1894842303421586 -#else - 45405608, 6903824, 27185491, 6451973, 37531140, 24000426, - 51492312, 11189267, 40279186, 28235350 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 748439484463711, 1033211726465151, 1396005112841647, - 1611506220286469, 1972177495910992 -#else - 26966623, 11152617, 32442495, 15396054, 14353839, 20802097, - 63980037, 24013313, 51636816, 29387734 -#endif - }}, + {0xd7, 0x71, 0x3c, 0x93, 0xfc, 0xe7, 0x24, 0x92, 0xb5, 0xf5, 0xf, + 0x7a, 0x96, 0x9d, 0x46, 0x9f, 0x2, 0x7, 0xd6, 0xe1, 0x65, 0x9a, + 0xa6, 0x5a, 0x2e, 0x2e, 0x7d, 0xa8, 0x3f, 0x6, 0xc, 0x59}, + {0xa8, 0xd5, 0xb4, 0x42, 0x60, 0xa5, 0x99, 0x8a, 0xf6, 0xac, 0x60, + 0x4e, 0xc, 0x81, 0x2b, 0x8f, 0xaa, 0x37, 0x6e, 0xb1, 0x6b, 0x23, + 0x9e, 0xe0, 0x55, 0x25, 0xc9, 0x69, 0xa6, 0x95, 0xb5, 0x6b}, + {0x5f, 0x7a, 0x9b, 0xa5, 0xb3, 0xa8, 0xfa, 0x43, 0x78, 0xcf, 0x9a, + 0x5d, 0xdd, 0x6b, 0xc1, 0x36, 0x31, 0x6a, 0x3d, 0xb, 0x84, 0xa0, + 0xf, 0x50, 0x73, 0xb, 0xa5, 0x3e, 0xb1, 0xf5, 0x1a, 0x70}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1601611775252272, 1720807796594148, 1132070835939856, - 1260455018889551, 2147779492816911 -#else - 15636272, 23865875, 24204772, 25642034, 616976, 16869170, - 27787599, 18782243, 28944399, 32004408 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 316559037616741, 2177824224946892, 1459442586438991, - 1461528397712656, 751590696113597 -#else - 16568933, 4717097, 55552716, 32452109, 15682895, 21747389, - 16354576, 21778470, 7689661, 11199574 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1850748884277385, 1200145853858453, 1068094770532492, - 672251375690438, 1586055907191707 -#else - 30464137, 27578307, 55329429, 17883566, 23220364, 15915852, - 7512774, 10017326, 49359771, 23634074 -#endif - }}, + {0x30, 0x97, 0xee, 0x4c, 0xa8, 0xb0, 0x25, 0xaf, 0x8a, 0x4b, 0x86, + 0xe8, 0x30, 0x84, 0x5a, 0x2, 0x32, 0x67, 0x1, 0x9f, 0x2, 0x50, + 0x1b, 0xc1, 0xf4, 0xf8, 0x80, 0x9a, 0x1b, 0x4e, 0x16, 0x7a}, + {0x65, 0xd2, 0xfc, 0xa4, 0xe8, 0x1f, 0x61, 0x56, 0x7d, 0xba, 0xc1, + 0xe5, 0xfd, 0x53, 0xd3, 0x3b, 0xbd, 0xd6, 0x4b, 0x21, 0x1a, 0xf3, + 0x31, 0x81, 0x62, 0xda, 0x5b, 0x55, 0x87, 0x15, 0xb9, 0x2a}, + {0x89, 0xd8, 0xd0, 0xd, 0x3f, 0x93, 0xae, 0x14, 0x62, 0xda, 0x35, + 0x1c, 0x22, 0x23, 0x94, 0x58, 0x4c, 0xdb, 0xf2, 0x8c, 0x45, 0xe5, + 0x70, 0xd1, 0xc6, 0xb4, 0xb9, 0x12, 0xaf, 0x26, 0x28, 0x5a}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 934282339813791, 1846903124198670, 1172395437954843, - 1007037127761661, 1830588347719256 -#else - 50071967, 13921891, 10945806, 27521001, 27105051, 17470053, - 38182653, 15006022, 3284568, 27277892 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1694390458783935, 1735906047636159, 705069562067493, - 648033061693059, 696214010414170 -#else - 23599295, 25248385, 55915199, 25867015, 13236773, 10506355, - 7464579, 9656445, 13059162, 10374397 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1121406372216585, 192876649532226, 190294192191717, - 1994165897297032, 2245000007398739 -#else - 7798537, 16710257, 3033922, 2874086, 28997861, 2835604, - 32406664, 29715387, 66467155, 33453106 -#endif - }}, + {0x9f, 0x9, 0xfc, 0x8e, 0xb9, 0x51, 0x73, 0x28, 0x38, 0x25, 0xfd, + 0x7d, 0xf4, 0xc6, 0x65, 0x67, 0x65, 0x92, 0xa, 0xfb, 0x3d, 0x8d, + 0x34, 0xca, 0x27, 0x87, 0xe5, 0x21, 0x3, 0x91, 0xe, 0x68}, + {0xbf, 0x18, 0x68, 0x5, 0xa, 0x5, 0xfe, 0x95, 0xa9, 0xfa, 0x60, + 0x56, 0x71, 0x89, 0x7e, 0x32, 0x73, 0x50, 0xa0, 0x6, 0xcd, 0xe3, + 0xe8, 0xc3, 0x9a, 0xa4, 0x45, 0x74, 0x4c, 0x3f, 0x93, 0x27}, + {0x9, 0xff, 0x76, 0xc4, 0xe9, 0xfb, 0x13, 0x5a, 0x72, 0xc1, 0x5c, + 0x7b, 0x45, 0x39, 0x9e, 0x6e, 0x94, 0x44, 0x2b, 0x10, 0xf9, 0xdc, + 0xdb, 0x5d, 0x2b, 0x3e, 0x55, 0x63, 0xbf, 0xc, 0x9d, 0x7f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 769950342298419, 132954430919746, 844085933195555, - 974092374476333, 726076285546016 -#else - 10861363, 11473154, 27284546, 1981175, 37044515, 12577860, - 32867885, 14515107, 51670560, 10819379 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 425251763115706, 608463272472562, 442562545713235, - 837766094556764, 374555092627893 -#else - 4708026, 6336745, 20377586, 9066809, 55836755, 6594695, - 41455196, 12483687, 54440373, 5581305 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1086255230780037, 274979815921559, 1960002765731872, - 929474102396301, 1190409889297339 -#else - 19563141, 16186464, 37722007, 4097518, 10237984, 29206317, - 28542349, 13850243, 43430843, 17738489 -#endif - }}, + {0x33, 0xbb, 0xa5, 0x8, 0x44, 0xbc, 0x12, 0xa2, 0x2, 0xed, 0x5e, + 0xc7, 0xc3, 0x48, 0x50, 0x8d, 0x44, 0xec, 0xbf, 0x5a, 0xc, 0xeb, + 0x1b, 0xdd, 0xeb, 0x6, 0xe2, 0x46, 0xf1, 0xcc, 0x45, 0x29}, + {0xba, 0xd6, 0x47, 0xa4, 0xc3, 0x82, 0x91, 0x7f, 0xb7, 0x29, 0x27, + 0x4b, 0xd1, 0x14, 0x0, 0xd5, 0x87, 0xa0, 0x64, 0xb8, 0x1c, 0xf1, + 0x3c, 0xe3, 0xf3, 0x55, 0x1b, 0xeb, 0x73, 0x7e, 0x4a, 0x15}, + {0x85, 0x82, 0x2a, 0x81, 0xf1, 0xdb, 0xbb, 0xbc, 0xfc, 0xd1, 0xbd, + 0xd0, 0x7, 0x8, 0xe, 0x27, 0x2d, 0xa7, 0xbd, 0x1b, 0xb, 0x67, + 0x1b, 0xb4, 0x9a, 0xb6, 0x3b, 0x6b, 0x69, 0xbe, 0xaa, 0x43}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1388594989461809, 316767091099457, 394298842192982, - 1230079486801005, 1440737038838979 -#else - 51736881, 20691677, 32573249, 4720197, 40672342, 5875510, - 47920237, 18329612, 57289923, 21468654 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 7380825640100, 146210432690483, 304903576448906, - 1198869323871120, 997689833219095 -#else - 58559652, 109982, 15149363, 2178705, 22900618, 4543417, 3044240, - 17864545, 1762327, 14866737 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1181317918772081, 114573476638901, 262805072233344, - 265712217171332, 294181933805782 -#else - 48909169, 17603008, 56635573, 1707277, 49922944, 3916100, - 38872452, 3959420, 27914454, 4383652 -#endif - }}, + {0x31, 0x71, 0x15, 0x77, 0xeb, 0xee, 0xc, 0x3a, 0x88, 0xaf, 0xc8, + 0x0, 0x89, 0x15, 0x27, 0x9b, 0x36, 0xa7, 0x59, 0xda, 0x68, 0xb6, + 0x65, 0x80, 0xbd, 0x38, 0xcc, 0xa2, 0xb6, 0x7b, 0xe5, 0x51}, + {0xa4, 0x8c, 0x7d, 0x7b, 0xb6, 0x6, 0x98, 0x49, 0x39, 0x27, 0xd2, + 0x27, 0x84, 0xe2, 0x5b, 0x57, 0xb9, 0x53, 0x45, 0x20, 0xe7, 0x5c, + 0x8, 0xbb, 0x84, 0x78, 0x41, 0xae, 0x41, 0x4c, 0xb6, 0x38}, + {0x71, 0x4b, 0xea, 0x2, 0x67, 0x32, 0xac, 0x85, 0x1, 0xbb, 0xa1, + 0x41, 0x3, 0xe0, 0x70, 0xbe, 0x44, 0xc1, 0x3b, 0x8, 0x4b, 0xa2, + 0xe4, 0x53, 0xe3, 0x61, 0xd, 0x9f, 0x1a, 0xe9, 0xb8, 0x10}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 665000864555967, 2065379846933859, 370231110385876, - 350988370788628, 1233371373142985 -#else - 5153727, 9909285, 1723747, 30776558, 30523604, 5516873, - 19480852, 5230134, 43156425, 18378665 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2019367628972465, 676711900706637, 110710997811333, - 1108646842542025, 517791959672113 -#else - 36839857, 30090922, 7665485, 10083793, 28475525, 1649722, - 20654025, 16520125, 30598449, 7715701 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 965130719900578, 247011430587952, 526356006571389, - 91986625355052, 2157223321444601 -#else - 28881826, 14381568, 9657904, 3680757, 46927229, 7843315, - 35708204, 1370707, 29794553, 32145132 -#endif - }}, + {0xbf, 0xa3, 0x4e, 0x94, 0xd0, 0x5c, 0x1a, 0x6b, 0xd2, 0xc0, 0x9d, + 0xb3, 0x3a, 0x35, 0x70, 0x74, 0x49, 0x2e, 0x54, 0x28, 0x82, 0x52, + 0xb2, 0x71, 0x7e, 0x92, 0x3c, 0x28, 0x69, 0xea, 0x1b, 0x46}, + {0xb1, 0x21, 0x32, 0xaa, 0x9a, 0x2c, 0x6f, 0xba, 0xa7, 0x23, 0xba, + 0x3b, 0x53, 0x21, 0xa0, 0x6c, 0x3a, 0x2c, 0x19, 0x92, 0x4f, 0x76, + 0xea, 0x9d, 0xe0, 0x17, 0x53, 0x2e, 0x5d, 0xdd, 0x6e, 0x1d}, + {0xa2, 0xb3, 0xb8, 0x1, 0xc8, 0x6d, 0x83, 0xf1, 0x9a, 0xa4, 0x3e, + 0x5, 0x47, 0x5f, 0x3, 0xb3, 0xf3, 0xad, 0x77, 0x58, 0xba, 0x41, + 0x9c, 0x52, 0xa7, 0x90, 0xf, 0x6a, 0x1c, 0xbb, 0x9f, 0x7a}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2068619540119183, 1966274918058806, 957728544705549, - 729906502578991, 159834893065166 -#else - 14499471, 30824833, 33917750, 29299779, 28494861, 14271267, - 30290735, 10876454, 33954766, 2381725 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2073601412052185, 31021124762708, 264500969797082, - 248034690651703, 1030252227928288 -#else - 59913433, 30899068, 52378708, 462250, 39384538, 3941371, - 60872247, 3696004, 34808032, 15351954 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 551790716293402, 1989538725166328, 801169423371717, - 2052451893578887, 678432056995012 -#else - 27431194, 8222322, 16448760, 29646437, 48401861, 11938354, - 34147463, 30583916, 29551812, 10109425 -#endif - }}, + {0x8f, 0x3e, 0xdd, 0x4, 0x66, 0x59, 0xb7, 0x59, 0x2c, 0x70, 0x88, + 0xe2, 0x77, 0x3, 0xb3, 0x6c, 0x23, 0xc3, 0xd9, 0x5e, 0x66, 0x9c, + 0x33, 0xb1, 0x2f, 0xe5, 0xbc, 0x61, 0x60, 0xe7, 0x15, 0x9}, + {0xd9, 0x34, 0x92, 0xf3, 0xed, 0x5d, 0xa7, 0xe2, 0xf9, 0x58, 0xb5, + 0xe1, 0x80, 0x76, 0x3d, 0x96, 0xfb, 0x23, 0x3c, 0x6e, 0xac, 0x41, + 0x27, 0x2c, 0xc3, 0x1, 0xe, 0x32, 0xa1, 0x24, 0x90, 0x3a}, + {0x1a, 0x91, 0xa2, 0xc9, 0xd9, 0xf5, 0xc1, 0xe7, 0xd7, 0xa7, 0xcc, + 0x8b, 0x78, 0x71, 0xa3, 0xb8, 0x32, 0x2a, 0xb6, 0xe, 0x19, 0x12, + 0x64, 0x63, 0x95, 0x4e, 0xcc, 0x2e, 0x5c, 0x7c, 0x90, 0x26}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1368953770187805, 790347636712921, 437508475667162, - 2142576377050580, 1932081720066286 -#else - 53451805, 20399000, 35825113, 11777097, 21447386, 6519384, - 64730580, 31926875, 10092782, 28790261 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 953638594433374, 1092333936795051, 1419774766716690, - 805677984380077, 859228993502513 -#else - 27939166, 14210322, 4677035, 16277044, 44144402, 21156292, - 34600109, 12005537, 49298737, 12803509 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1200766035879111, 20142053207432, 1465634435977050, - 1645256912097844, 295121984874596 -#else - 17228999, 17892808, 65875336, 300139, 65883994, 21839654, - 30364212, 24516238, 18016356, 4397660 -#endif - }}, + {0x1d, 0x9c, 0x2f, 0x63, 0xe, 0xdd, 0xcc, 0x2e, 0x15, 0x31, 0x89, + 0x76, 0x96, 0xb6, 0xd0, 0x51, 0x58, 0x7a, 0x63, 0xa8, 0x6b, 0xb7, + 0xdf, 0x52, 0x39, 0xef, 0xe, 0xa0, 0x49, 0x7d, 0xd3, 0x6d}, + {0x5e, 0x51, 0xaa, 0x49, 0x54, 0x63, 0x5b, 0xed, 0x3a, 0x82, 0xc6, + 0xb, 0x9f, 0xc4, 0x65, 0xa8, 0xc4, 0xd1, 0x42, 0x5b, 0xe9, 0x1f, + 0xc, 0x85, 0xb9, 0x15, 0xd3, 0x3, 0x6f, 0x6d, 0xd7, 0x30}, + {0xc7, 0xe4, 0x6, 0x21, 0x17, 0x44, 0x44, 0x6c, 0x69, 0x7f, 0x8d, + 0x92, 0x80, 0xd6, 0x53, 0xfb, 0x26, 0x3f, 0x4d, 0x69, 0xa4, 0x9e, + 0x73, 0xb4, 0xb0, 0x4b, 0x86, 0x2e, 0x11, 0x97, 0xc6, 0x10}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1735718747031557, 1248237894295956, 1204753118328107, - 976066523550493, 65943769534592 -#else - 56150021, 25864224, 4776340, 18600194, 27850027, 17952220, - 40489757, 14544524, 49631360, 982638 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1060098822528990, 1586825862073490, 212301317240126, - 1975302711403555, 666724059764335 -#else - 29253598, 15796703, 64244882, 23645547, 10057022, 3163536, - 7332899, 29434304, 46061167, 9934962 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1091990273418756, 1572899409348578, 80968014455247, - 306009358661350, 1520450739132526 -#else - 5793284, 16271923, 42977250, 23438027, 29188559, 1206517, - 52360934, 4559894, 36984942, 22656481 -#endif - }}, + {0x5, 0xc8, 0x58, 0x83, 0xa0, 0x2a, 0xa6, 0xc, 0x47, 0x42, 0x20, + 0x7a, 0xe3, 0x4a, 0x3d, 0x6a, 0xdc, 0xed, 0x11, 0x3b, 0xa6, 0xd3, + 0x64, 0x74, 0xef, 0x6, 0x8, 0x55, 0xaf, 0x9b, 0xbf, 0x3}, + {0xde, 0x5f, 0xbe, 0x7d, 0x27, 0xc4, 0x93, 0x64, 0xa2, 0x7e, 0xad, + 0x19, 0xad, 0x4f, 0x5d, 0x26, 0x90, 0x45, 0x30, 0x46, 0xc8, 0xdf, + 0x0, 0xe, 0x9, 0xfe, 0x66, 0xed, 0xab, 0x1c, 0xe6, 0x25}, + {0x4, 0x66, 0x58, 0xcc, 0x28, 0xe1, 0x13, 0x3f, 0x7e, 0x74, 0x59, + 0xb4, 0xec, 0x73, 0x58, 0x6f, 0xf5, 0x68, 0x12, 0xcc, 0xed, 0x3d, + 0xb6, 0xa0, 0x2c, 0xe2, 0x86, 0x45, 0x63, 0x78, 0x6d, 0x56}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1480517209436112, 1511153322193952, 1244343858991172, - 304788150493241, 369136856496443 -#else - 39464912, 22061425, 16282656, 22517939, 28414020, 18542168, - 24191033, 4541697, 53770555, 5500567 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2151330273626164, 762045184746182, 1688074332551515, - 823046109005759, 907602769079491 -#else - 12650548, 32057319, 9052870, 11355358, 49428827, 25154267, - 49678271, 12264342, 10874051, 13524335 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2047386910586836, 168470092900250, 1552838872594810, - 340951180073789, 360819374702533 -#else - 25556948, 30508442, 714650, 2510400, 23394682, 23139102, - 33119037, 5080568, 44580805, 5376627 -#endif - }}, + {0xd0, 0x2f, 0x5a, 0xc6, 0x85, 0x42, 0x5, 0xa1, 0xc3, 0x67, 0x16, + 0xf3, 0x2a, 0x11, 0x64, 0x6c, 0x58, 0xee, 0x1a, 0x73, 0x40, 0xe2, + 0xa, 0x68, 0x2a, 0xb2, 0x93, 0x47, 0xf3, 0xa5, 0xfb, 0x14}, + {0x34, 0x8, 0xc1, 0x9c, 0x9f, 0xa4, 0x37, 0x16, 0x51, 0xc4, 0x9b, + 0xa8, 0xd5, 0x56, 0x8e, 0xbc, 0xdb, 0xd2, 0x7f, 0x7f, 0xf, 0xec, + 0xb5, 0x1c, 0xd9, 0x35, 0xcc, 0x5e, 0xca, 0x5b, 0x97, 0x33}, + {0xd4, 0xf7, 0x85, 0x69, 0x16, 0x46, 0xd7, 0x3c, 0x57, 0x0, 0xc8, + 0xc9, 0x84, 0x5e, 0x3e, 0x59, 0x1e, 0x13, 0x61, 0x7b, 0xb6, 0xf2, + 0xc3, 0x2f, 0x6c, 0x52, 0xfc, 0x83, 0xea, 0x9c, 0x82, 0x14}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1982622644432056, 2014393600336956, 128909208804214, - 1617792623929191, 105294281913815 -#else - 41020600, 29543379, 50095164, 30016803, 60382070, 1920896, - 44787559, 24106988, 4535767, 1569007 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 980234343912898, 1712256739246056, 588935272190264, - 204298813091998, 841798321043288 -#else - 64853442, 14606629, 45416424, 25514613, 28430648, 8775819, - 36614302, 3044289, 31848280, 12543772 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 197561292938973, 454817274782871, 1963754960082318, - 2113372252160468, 971377527342673 -#else - 45080285, 2943892, 35251351, 6777305, 13784462, 29262229, - 39731668, 31491700, 7718481, 14474653 -#endif - }}, + {0xb8, 0xec, 0x71, 0x4e, 0x2f, 0xb, 0xe7, 0x21, 0xe3, 0x77, 0xa4, + 0x40, 0xb9, 0xdd, 0x56, 0xe6, 0x80, 0x4f, 0x1d, 0xce, 0xce, 0x56, + 0x65, 0xbf, 0x7e, 0x7b, 0x5d, 0x53, 0xc4, 0x3b, 0xfc, 0x5}, + {0xc2, 0x95, 0xdd, 0x97, 0x84, 0x7b, 0x43, 0xff, 0xa7, 0xb5, 0x4e, + 0xaa, 0x30, 0x4e, 0x74, 0x6c, 0x8b, 0xe8, 0x85, 0x3c, 0x61, 0x5d, + 0xc, 0x9e, 0x73, 0x81, 0x75, 0x5f, 0x1e, 0xc7, 0xd9, 0x2f}, + {0xdd, 0xde, 0xaf, 0x52, 0xae, 0xb3, 0xb8, 0x24, 0xcf, 0x30, 0x3b, + 0xed, 0x8c, 0x63, 0x95, 0x34, 0x95, 0x81, 0xbe, 0xa9, 0x83, 0xbc, + 0xa4, 0x33, 0x4, 0x1f, 0x65, 0x5c, 0x47, 0x67, 0x37, 0x37}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 164699448829328, 3127451757672, 1199504971548753, - 1766155447043652, 1899238924683527 -#else - 2385296, 2454213, 44477544, 46602, 62670929, 17874016, 656964, - 26317767, 24316167, 28300865 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 732262946680281, 1674412764227063, 2182456405662809, - 1350894754474250, 558458873295247 -#else - 13741529, 10911568, 33875447, 24950694, 46931033, 32521134, - 33040650, 20129900, 46379407, 8321685 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2103305098582922, 1960809151316468, 715134605001343, - 1454892949167181, 40827143824949 -#else - 21060490, 31341688, 15712756, 29218333, 1639039, 10656336, - 23845965, 21679594, 57124405, 608371 -#endif - }}, + {0x90, 0x65, 0x24, 0x14, 0xcb, 0x95, 0x40, 0x63, 0x35, 0x55, 0xc1, + 0x16, 0x40, 0x14, 0x12, 0xef, 0x60, 0xbc, 0x10, 0x89, 0xc, 0x14, + 0x38, 0x9e, 0x8c, 0x7c, 0x90, 0x30, 0x57, 0x90, 0xf5, 0x6b}, + {0xd9, 0xad, 0xd1, 0x40, 0xfd, 0x99, 0xba, 0x2f, 0x27, 0xd0, 0xf4, + 0x96, 0x6f, 0x16, 0x7, 0xb3, 0xae, 0x3b, 0xf0, 0x15, 0x52, 0xf0, + 0x63, 0x43, 0x99, 0xf9, 0x18, 0x3b, 0x6c, 0xa5, 0xbe, 0x1f}, + {0x8a, 0x5b, 0x41, 0xe1, 0xf1, 0x78, 0xa7, 0xf, 0x7e, 0xa7, 0xc3, + 0xba, 0xf7, 0x9f, 0x40, 0x6, 0x50, 0x9a, 0xa2, 0x9a, 0xb8, 0xd7, + 0x52, 0x6f, 0x56, 0x5a, 0x63, 0x7a, 0xf6, 0x1c, 0x52, 0x2}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1239289043050212, 1744654158124578, 758702410031698, - 1796762995074688, 1603056663766 -#else - 53436132, 18466845, 56219170, 25997372, 61071954, 11305546, - 1123968, 26773855, 27229398, 23887 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2232056027107988, 987343914584615, 2115594492994461, - 1819598072792159, 1119305654014850 -#else - 43864724, 33260226, 55364135, 14712570, 37643165, 31524814, - 12797023, 27114124, 65475458, 16678953 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 320153677847348, 939613871605645, 641883205761567, - 1930009789398224, 329165806634126 -#else - 37608244, 4770661, 51054477, 14001337, 7830047, 9564805, - 65600720, 28759386, 49939598, 4904952 -#endif - }}, + {0xe4, 0x5e, 0x2f, 0x77, 0x20, 0x67, 0x14, 0xb1, 0xce, 0x9a, 0x7, + 0x96, 0xb1, 0x94, 0xf8, 0xe8, 0x4a, 0x82, 0xac, 0x0, 0x4d, 0x22, + 0xf8, 0x4a, 0xc4, 0x6c, 0xcd, 0xf7, 0xd9, 0x53, 0x17, 0x0}, + {0x94, 0x52, 0x9d, 0xa, 0xb, 0xee, 0x3f, 0x51, 0x66, 0x5a, 0xdf, + 0xf, 0x5c, 0xe7, 0x98, 0x8f, 0xce, 0x7, 0xe1, 0xbf, 0x88, 0x86, + 0x61, 0xd4, 0xed, 0x2c, 0x38, 0x71, 0x7e, 0xa, 0xa0, 0x3f}, + {0x34, 0xdb, 0x3d, 0x96, 0x2d, 0x23, 0x69, 0x3c, 0x58, 0x38, 0x97, + 0xb4, 0xda, 0x87, 0xde, 0x1d, 0x85, 0xf2, 0x91, 0xa0, 0xf9, 0xd1, + 0xd7, 0xaa, 0xb6, 0xed, 0x48, 0xa0, 0x2f, 0xfe, 0xb5, 0x12}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 980930490474130, 1242488692177893, 1251446316964684, - 1086618677993530, 1961430968465772 -#else - 24059538, 14617003, 19037157, 18514524, 19766092, 18648003, - 5169210, 16191880, 2128236, 29227599 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 276821765317453, 1536835591188030, 1305212741412361, - 61473904210175, 2051377036983058 -#else - 50127693, 4124965, 58568254, 22900634, 30336521, 19449185, - 37302527, 916032, 60226322, 30567899 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 833449923882501, 1750270368490475, 1123347002068295, - 185477424765687, 278090826653186 -#else - 44477957, 12419371, 59974635, 26081060, 50629959, 16739174, - 285431, 2763829, 15736322, 4143876 -#endif - }}, + {0x92, 0x1e, 0x6f, 0xad, 0x26, 0x7c, 0x2b, 0xdf, 0x13, 0x89, 0x4b, + 0x50, 0x23, 0xd3, 0x66, 0x4b, 0xc3, 0x8b, 0x1c, 0x75, 0xc0, 0x9d, + 0x40, 0x8c, 0xb8, 0xc7, 0x96, 0x7, 0xc2, 0x93, 0x7e, 0x6f}, + {0x4d, 0xe3, 0xfc, 0x96, 0xc4, 0xfb, 0xf0, 0x71, 0xed, 0x5b, 0xf3, + 0xad, 0x6b, 0x82, 0xb9, 0x73, 0x61, 0xc5, 0x28, 0xff, 0x61, 0x72, + 0x4, 0xd2, 0x6f, 0x20, 0xb1, 0x6f, 0xf9, 0x76, 0x9b, 0x74}, + {0x5, 0xae, 0xa6, 0xae, 0x4, 0xf6, 0x5a, 0x1f, 0x99, 0x9c, 0xe4, + 0xbe, 0xf1, 0x51, 0x23, 0xc1, 0x66, 0x6b, 0xff, 0xee, 0xb5, 0x8, + 0xa8, 0x61, 0x51, 0x21, 0xe0, 0x1, 0xf, 0xc1, 0xce, 0xf}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 794524995833413, 1849907304548286, 53348672473145, - 1272368559505217, 1147304168324779 -#else - 2379333, 11839345, 62998462, 27565766, 11274297, 794957, 212801, - 18959769, 23527083, 17096164 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1504846112759364, 1203096289004681, 562139421471418, - 274333017451844, 1284344053775441 -#else - 33431108, 22423954, 49269897, 17927531, 8909498, 8376530, - 34483524, 4087880, 51919953, 19138217 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 483048732424432, 2116063063343382, 30120189902313, - 292451576741007, 1156379271702225 -#else - 1767664, 7197987, 53903638, 31531796, 54017513, 448825, 5799055, - 4357868, 62334673, 17231393 -#endif - }}, + {0x45, 0x4e, 0x24, 0xc4, 0x9d, 0xd2, 0xf2, 0x3d, 0xa, 0xde, 0xd8, + 0x93, 0x74, 0xe, 0x2, 0x2b, 0x4d, 0x21, 0xc, 0x82, 0x7e, 0x6, + 0xc8, 0x6c, 0xa, 0xb9, 0xea, 0x6f, 0x16, 0x79, 0x37, 0x41}, + {0x44, 0x1e, 0xfe, 0x49, 0xa6, 0x58, 0x4d, 0x64, 0x7e, 0x77, 0xad, + 0x31, 0xa2, 0xae, 0xfc, 0x21, 0xd2, 0xd0, 0x7f, 0x88, 0x5a, 0x1c, + 0x44, 0x2, 0xf3, 0x11, 0xc5, 0x83, 0x71, 0xaa, 0x1, 0x49}, + {0xf0, 0xf8, 0x1a, 0x8c, 0x54, 0xb7, 0xb1, 0x8, 0xb4, 0x99, 0x62, + 0x24, 0x7c, 0x7a, 0xf, 0xce, 0x39, 0xd9, 0x6, 0x1e, 0xf9, 0xb0, + 0x60, 0xf7, 0x13, 0x12, 0x6d, 0x72, 0x7b, 0x88, 0xbb, 0x41}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 928372153029038, 2147692869914564, 1455665844462196, - 1986737809425946, 185207050258089 -#else - 6721966, 13833823, 43585476, 32003117, 26354292, 21691111, - 23365146, 29604700, 7390889, 2759800 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 137732961814206, 706670923917341, 1387038086865771, - 1965643813686352, 1384777115696347 -#else - 4409022, 2052381, 23373853, 10530217, 7676779, 20668478, - 21302352, 29290375, 1244379, 20634787 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 481144981981577, 2053319313589856, 2065402289827512, - 617954271490316, 1106602634668125 -#else - 62687625, 7169618, 4982368, 30596842, 30256824, 30776892, - 14086412, 9208236, 15886429, 16489664 -#endif - }}, + {0xae, 0x91, 0x66, 0x7c, 0x59, 0x4c, 0x23, 0x7e, 0xc8, 0xb4, 0x85, + 0xa, 0x3d, 0x9d, 0x88, 0x64, 0xe7, 0xfa, 0x4a, 0x35, 0xc, 0xc9, + 0xe2, 0xda, 0x1d, 0x9e, 0x6a, 0xc, 0x7, 0x1e, 0x87, 0xa}, + {0xbe, 0x46, 0x43, 0x74, 0x44, 0x7d, 0xe8, 0x40, 0x25, 0x2b, 0xb5, + 0x15, 0xd4, 0xda, 0x48, 0x1d, 0x3e, 0x60, 0x3b, 0xa1, 0x18, 0x8a, + 0x3a, 0x7c, 0xf7, 0xbd, 0xcd, 0x2f, 0xc1, 0x28, 0xb7, 0x4e}, + {0x89, 0x89, 0xbc, 0x4b, 0x99, 0xb5, 0x1, 0x33, 0x60, 0x42, 0xdd, + 0x5b, 0x3a, 0xae, 0x6b, 0x73, 0x3c, 0x9e, 0xd5, 0x19, 0xe2, 0xad, + 0x61, 0xd, 0x64, 0xd4, 0x85, 0x26, 0xf, 0x30, 0xe7, 0x3e}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 696298019648792, 893299659040895, 1148636718636009, - 26734077349617, 2203955659340681 -#else - 1996056, 10375649, 14346367, 13311202, 60234729, 17116020, - 53415665, 398368, 36502409, 32841498 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 657390353372855, 998499966885562, 991893336905797, - 810470207106761, 343139804608786 -#else - 41801399, 9795879, 64331450, 14878808, 33577029, 14780362, - 13348553, 12076947, 36272402, 5113181 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 791736669492960, 934767652997115, 824656780392914, - 1759463253018643, 361530362383518 -#else - 49338080, 11797795, 31950843, 13929123, 41220562, 12288343, - 36767763, 26218045, 13847710, 5387222 -#endif - }}, + {0x18, 0x75, 0x1e, 0x84, 0x47, 0x79, 0xfa, 0x43, 0xd7, 0x46, 0x9c, + 0x63, 0x59, 0xfa, 0xc6, 0xe5, 0x74, 0x2b, 0x5, 0xe3, 0x1d, 0x5e, + 0x6, 0xa1, 0x30, 0x90, 0xb8, 0xcf, 0xa2, 0xc6, 0x47, 0x7d}, + {0xb7, 0xd6, 0x7d, 0x9e, 0xe4, 0x55, 0xd2, 0xf5, 0xac, 0x1e, 0xb, + 0x61, 0x5c, 0x11, 0x16, 0x80, 0xca, 0x87, 0xe1, 0x92, 0x5d, 0x97, + 0x99, 0x3c, 0xc2, 0x25, 0x91, 0x97, 0x62, 0x57, 0x81, 0x13}, + {0xe0, 0xd6, 0xf0, 0x8e, 0x14, 0xd0, 0xda, 0x3f, 0x3c, 0x6f, 0x54, + 0x91, 0x9a, 0x74, 0x3e, 0x9d, 0x57, 0x81, 0xbb, 0x26, 0x10, 0x62, + 0xec, 0x71, 0x80, 0xec, 0xc9, 0x34, 0x8d, 0xf5, 0x8c, 0x14}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2022541353055597, 2094700262587466, 1551008075025686, - 242785517418164, 695985404963562 -#else - 48526701, 30138214, 17824842, 31213466, 22744342, 23111821, - 8763060, 3617786, 47508202, 10370990 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1287487199965223, 2215311941380308, 1552928390931986, - 1664859529680196, 1125004975265243 -#else - 20246567, 19185054, 22358228, 33010720, 18507282, 23140436, - 14554436, 24808340, 32232923, 16763880 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 677434665154918, 989582503122485, 1817429540898386, - 1052904935475344, 1143826298169798 -#else - 9648486, 10094563, 26416693, 14745928, 36734546, 27081810, - 11094160, 15689506, 3140038, 17044340 -#endif - }}, + {0x6d, 0x75, 0xe4, 0x9a, 0x7d, 0x2f, 0x57, 0xe2, 0x7f, 0x48, 0xf3, + 0x88, 0xbb, 0x45, 0xc3, 0x56, 0x8d, 0xa8, 0x60, 0x69, 0x6d, 0xb, + 0xd1, 0x9f, 0xb9, 0xa1, 0xae, 0x4e, 0xad, 0xeb, 0x8f, 0x27}, + {0x27, 0xf0, 0x34, 0x79, 0xf6, 0x92, 0xa4, 0x46, 0xa9, 0xa, 0x84, + 0xf6, 0xbe, 0x84, 0x99, 0x46, 0x54, 0x18, 0x61, 0x89, 0x2a, 0xbc, + 0xa1, 0x5c, 0xd4, 0xbb, 0x5d, 0xbd, 0x1e, 0xfa, 0xf2, 0x3f}, + {0x66, 0x39, 0x93, 0x8c, 0x1f, 0x68, 0xaa, 0xb1, 0x98, 0xc, 0x29, + 0x20, 0x9c, 0x94, 0x21, 0x8c, 0x52, 0x3c, 0x9d, 0x21, 0x91, 0x52, + 0x11, 0x39, 0x7b, 0x67, 0x9c, 0xfe, 0x2, 0xdd, 0x4, 0x41}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 367266328308408, 318431188922404, 695629353755355, - 634085657580832, 24581612564426 -#else - 50948792, 5472694, 31895588, 4744994, 8823515, 10365685, - 39884064, 9448612, 38334410, 366294 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 773360688841258, 1815381330538070, 363773437667376, - 539629987070205, 783280434248437 -#else - 19153450, 11523972, 56012374, 27051289, 42461232, 5420646, - 28344573, 8041113, 719605, 11671788 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 180820816194166, 168937968377394, 748416242794470, - 1227281252254508, 1567587861004268 -#else - 8678006, 2694440, 60300850, 2517371, 4964326, 11152271, - 51675948, 18287915, 27000812, 23358879 -#endif - }}, + {0xb8, 0x6a, 0x9, 0xdb, 0x6, 0x4e, 0x21, 0x81, 0x35, 0x4f, 0xe4, + 0xc, 0xc9, 0xb6, 0xa8, 0x21, 0xf5, 0x2a, 0x9e, 0x40, 0x2a, 0xc1, + 0x24, 0x65, 0x81, 0xa4, 0xfc, 0x8e, 0xa4, 0xb5, 0x65, 0x1}, + {0x2a, 0x42, 0x24, 0x11, 0x5e, 0xbf, 0xb2, 0x72, 0xb5, 0x3a, 0xa3, + 0x98, 0x33, 0xc, 0xfa, 0xa1, 0x66, 0xb6, 0x52, 0xfa, 0x1, 0x61, + 0xcb, 0x94, 0xd5, 0x53, 0xaf, 0xaf, 0x0, 0x3b, 0x86, 0x2c}, + {0x76, 0x6a, 0x84, 0xa0, 0x74, 0xa4, 0x90, 0xf1, 0xc0, 0x7c, 0x2f, + 0xcd, 0x84, 0xf9, 0xef, 0x12, 0x8f, 0x2b, 0xaa, 0x58, 0x6, 0x29, + 0x5e, 0x69, 0xb8, 0xc8, 0xfe, 0xbf, 0xd9, 0x67, 0x1b, 0x59}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 478775558583645, 2062896624554807, 699391259285399, - 358099408427873, 1277310261461761 -#else - 51950941, 7134311, 8639287, 30739555, 59873175, 10421741, - 564065, 5336097, 6750977, 19033406 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1984740906540026, 1079164179400229, 1056021349262661, - 1659958556483663, 1088529069025527 -#else - 11836410, 29574944, 26297893, 16080799, 23455045, 15735944, - 1695823, 24735310, 8169719, 16220347 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 580736401511151, 1842931091388998, 1177201471228238, - 2075460256527244, 1301133425678027 -#else - 48993007, 8653646, 17578566, 27461813, 59083086, 17541668, - 55964556, 30926767, 61118155, 19388398 -#endif - }}, + {0x5d, 0xb5, 0x18, 0x9f, 0x71, 0xb3, 0xb9, 0x99, 0x1e, 0x64, 0x8c, + 0xa1, 0xfa, 0xe5, 0x65, 0xe4, 0xed, 0x5, 0x9f, 0xc2, 0x36, 0x11, + 0x8, 0x61, 0x8b, 0x12, 0x30, 0x70, 0x86, 0x4f, 0x9b, 0x48}, + {0xfa, 0x9b, 0xb4, 0x80, 0x1c, 0xd, 0x2f, 0x31, 0x8a, 0xec, 0xf3, + 0xab, 0x5e, 0x51, 0x79, 0x59, 0x88, 0x1c, 0xf0, 0x9e, 0xc0, 0x33, + 0x70, 0x72, 0xcb, 0x7b, 0x8f, 0xca, 0xc7, 0x2e, 0xe0, 0x3d}, + {0xef, 0x92, 0xeb, 0x3a, 0x2d, 0x10, 0x32, 0xd2, 0x61, 0xa8, 0x16, + 0x61, 0xb4, 0x53, 0x62, 0xe1, 0x24, 0xaa, 0xb, 0x19, 0xe7, 0xab, + 0x7e, 0x3d, 0xbf, 0xbe, 0x6c, 0x49, 0xba, 0xfb, 0xf5, 0x49}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1515728832059182, 1575261009617579, 1510246567196186, - 191078022609704, 116661716289141 -#else - 43800366, 22586119, 15213227, 23473218, 36255258, 22504427, - 27884328, 2847284, 2655861, 1738395 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1295295738269652, 1714742313707026, 545583042462581, - 2034411676262552, 1513248090013606 -#else - 39571412, 19301410, 41772562, 25551651, 57738101, 8129820, - 21651608, 30315096, 48021414, 22549153 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 230710545179830, 30821514358353, 760704303452229, - 390668103790604, 573437871383156 -#else - 1533110, 3437855, 23735889, 459276, 29970501, 11335377, - 26030092, 5821408, 10478196, 8544890 -#endif - }}, + {0x2e, 0x57, 0x9c, 0x1e, 0x8c, 0x62, 0x5d, 0x15, 0x41, 0x47, 0x88, + 0xc5, 0xac, 0x86, 0x4d, 0x8a, 0xeb, 0x63, 0x57, 0x51, 0xf6, 0x52, + 0xa3, 0x91, 0x5b, 0x51, 0x67, 0x88, 0xc2, 0xa6, 0xa1, 0x6}, + {0xd4, 0xcf, 0x5b, 0x8a, 0x10, 0x9a, 0x94, 0x30, 0xeb, 0x73, 0x64, + 0xbc, 0x70, 0xdd, 0x40, 0xdc, 0x1c, 0xd, 0x7c, 0x30, 0xc1, 0x94, + 0xc2, 0x92, 0x74, 0x6e, 0xfa, 0xcb, 0x6d, 0xa8, 0x4, 0x56}, + {0xb6, 0x64, 0x17, 0x7c, 0xd4, 0xd1, 0x88, 0x72, 0x51, 0x8b, 0x41, + 0xe0, 0x40, 0x11, 0x54, 0x72, 0xd1, 0xf6, 0xac, 0x18, 0x60, 0x1a, + 0x3, 0x9f, 0xc6, 0x42, 0x27, 0xfe, 0x89, 0x9e, 0x98, 0x20}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1169380107545646, 263167233745614, 2022901299054448, - 819900753251120, 2023898464874585 -#else - 32173102, 17425121, 24896206, 3921497, 22579056, 30143578, - 19270448, 12217473, 17789017, 30158437 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2102254323485823, 1570832666216754, 34696906544624, - 1993213739807337, 70638552271463 -#else - 36555903, 31326030, 51530034, 23407230, 13243888, 517024, - 15479401, 29701199, 30460519, 1052596 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 894132856735058, 548675863558441, 845349339503395, - 1942269668326667, 1615682209874691 -#else - 55493970, 13323617, 32618793, 8175907, 51878691, 12596686, - 27491595, 28942073, 3179267, 24075541 -#endif - }}, + {0x2e, 0xec, 0xea, 0x85, 0x8b, 0x27, 0x74, 0x16, 0xdf, 0x2b, 0xcb, + 0x7a, 0x7, 0xdc, 0x21, 0x56, 0x5a, 0xf4, 0xcb, 0x61, 0x16, 0x4c, + 0xa, 0x64, 0xd3, 0x95, 0x5, 0xf7, 0x50, 0x99, 0xb, 0x73}, + {0x7f, 0xcc, 0x2d, 0x3a, 0xfd, 0x77, 0x97, 0x49, 0x92, 0xd8, 0x4f, + 0xa5, 0x2c, 0x7c, 0x85, 0x32, 0xa0, 0xe3, 0x7, 0xd2, 0x64, 0xd8, + 0x79, 0xa2, 0x29, 0x7e, 0xa6, 0xc, 0x1d, 0xed, 0x3, 0x4}, + {0x52, 0xc5, 0x4e, 0x87, 0x35, 0x2d, 0x4b, 0xc9, 0x8d, 0x6f, 0x24, + 0x98, 0xcf, 0xc8, 0xe6, 0xc5, 0xce, 0x35, 0xc0, 0x16, 0xfa, 0x46, + 0xcb, 0xf7, 0xcc, 0x3d, 0x30, 0x8, 0x43, 0x45, 0xd7, 0x5b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1287670217537834, 1222355136884920, 1846481788678694, - 1150426571265110, 1613523400722047 -#else - 31947050, 19187781, 62468280, 18214510, 51982886, 27514722, - 52352086, 17142691, 19072639, 24043372 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 793388516527298, 1315457083650035, 1972286999342417, - 1901825953052455, 338269477222410 -#else - 11685058, 11822410, 3158003, 19601838, 33402193, 29389366, - 5977895, 28339415, 473098, 5040608 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 550201530671806, 778605267108140, 2063911101902983, - 115500557286349, 2041641272971022 -#else - 46817982, 8198641, 39698732, 11602122, 1290375, 30754672, - 28326861, 1721092, 47550222, 30422825 -#endif - }}, + {0x2a, 0x79, 0xe7, 0x15, 0x21, 0x93, 0xc4, 0x85, 0xc9, 0xdd, 0xcd, + 0xbd, 0xa2, 0x89, 0x4c, 0xc6, 0x62, 0xd7, 0xa3, 0xad, 0xa8, 0x3d, + 0x1e, 0x9d, 0x2c, 0xf8, 0x67, 0x30, 0x12, 0xdb, 0xb7, 0x5b}, + {0xc2, 0x4c, 0xb2, 0x28, 0x95, 0xd1, 0x9a, 0x7f, 0x81, 0xc1, 0x35, + 0x63, 0x65, 0x54, 0x6b, 0x7f, 0x36, 0x72, 0xc0, 0x4f, 0x6e, 0xb6, + 0xb8, 0x66, 0x83, 0xad, 0x80, 0x73, 0x0, 0x78, 0x3a, 0x13}, + {0xbe, 0x62, 0xca, 0xc6, 0x67, 0xf4, 0x61, 0x9, 0xee, 0x52, 0x19, + 0x21, 0xd6, 0x21, 0xec, 0x4, 0x70, 0x47, 0xd5, 0x9b, 0x77, 0x60, + 0x23, 0x18, 0xd2, 0xe0, 0xf0, 0x58, 0x6d, 0xca, 0xd, 0x74}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 717255318455100, 519313764361315, 2080406977303708, - 541981206705521, 774328150311600 -#else - 7881532, 10687937, 7578723, 7738378, 48157852, 31000479, - 21820785, 8076149, 39240368, 11538388 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 261715221532238, 1795354330069993, 1496878026850283, - 499739720521052, 389031152673770 -#else - 47173198, 3899860, 18283497, 26752864, 51380203, 22305220, - 8754524, 7446702, 61432810, 5797015 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1997217696294013, 1717306351628065, 1684313917746180, - 1644426076011410, 1857378133465451 -#else - 55813245, 29760862, 51326753, 25589858, 12708868, 25098233, - 2014098, 24503858, 64739691, 27677090 -#endif - }}, + {0x3c, 0x43, 0x78, 0x4, 0x57, 0x8c, 0x1a, 0x23, 0x9d, 0x43, 0x81, + 0xc2, 0xe, 0x27, 0xb5, 0xb7, 0x9f, 0x7, 0xd9, 0xe3, 0xea, 0x99, + 0xaa, 0xdb, 0xd9, 0x3, 0x2b, 0x6c, 0x25, 0xf5, 0x3, 0x2c}, + {0x4e, 0xce, 0xcf, 0x52, 0x7, 0xee, 0x48, 0xdf, 0xb7, 0x8, 0xec, + 0x6, 0xf3, 0xfa, 0xff, 0xc3, 0xc4, 0x59, 0x54, 0xb9, 0x2a, 0xb, + 0x71, 0x5, 0x8d, 0xa3, 0x3e, 0x96, 0xfa, 0x25, 0x1d, 0x16}, + {0x7d, 0xa4, 0x53, 0x7b, 0x75, 0x18, 0xf, 0x79, 0x79, 0x58, 0xc, + 0xcf, 0x30, 0x1, 0x7b, 0x30, 0xf9, 0xf7, 0x7e, 0x25, 0x77, 0x3d, + 0x90, 0x31, 0xaf, 0xbb, 0x96, 0xbd, 0xbd, 0x68, 0x94, 0x69}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1475434724792648, 76931896285979, 1116729029771667, - 2002544139318042, 725547833803938 -#else - 44636488, 21985690, 39426843, 1146374, 18956691, 16640559, - 1192730, 29840233, 15123618, 10811505 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2022306639183567, 726296063571875, 315345054448644, - 1058733329149221, 1448201136060677 -#else - 14352079, 30134717, 48166819, 10822654, 32750596, 4699007, - 67038501, 15776355, 38222085, 21579878 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1710065158525665, 1895094923036397, 123988286168546, - 1145519900776355, 1607510767693874 -#else - 38867681, 25481956, 62129901, 28239114, 29416930, 1847569, - 46454691, 17069576, 4714546, 23953777 -#endif - }}, + {0x48, 0x19, 0xa9, 0x6a, 0xe6, 0x3d, 0xdd, 0xd8, 0xcc, 0xd2, 0xc0, + 0x2f, 0xc2, 0x64, 0x50, 0x48, 0x2f, 0xea, 0xfd, 0x34, 0x66, 0x24, + 0x48, 0x9b, 0x3a, 0x2e, 0x4a, 0x6c, 0x4e, 0x1c, 0x3e, 0x29}, + {0xcf, 0xfe, 0xda, 0xf4, 0x46, 0x2f, 0x1f, 0xbd, 0xf7, 0xd6, 0x7f, + 0xa4, 0x14, 0x1, 0xef, 0x7c, 0x7f, 0xb3, 0x47, 0x4a, 0xda, 0xfd, + 0x1f, 0xd3, 0x85, 0x57, 0x90, 0x73, 0xa4, 0x19, 0x52, 0x52}, + {0xe1, 0x12, 0x51, 0x92, 0x4b, 0x13, 0x6e, 0x37, 0xa0, 0x5d, 0xa1, + 0xdc, 0xb5, 0x78, 0x37, 0x70, 0x11, 0x31, 0x1c, 0x46, 0xaf, 0x89, + 0x45, 0xb0, 0x23, 0x28, 0x3, 0x7f, 0x44, 0x5c, 0x60, 0x5b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 561605375422540, 1071733543815037, 131496498800990, - 1946868434569999, 828138133964203 -#else - 15200332, 8368572, 19679101, 15970074, 35236190, 1959450, - 24611599, 29010600, 55362987, 12340219 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1548495173745801, 442310529226540, 998072547000384, - 553054358385281, 644824326376171 -#else - 12876937, 23074376, 33134380, 6590940, 60801088, 14872439, - 9613953, 8241152, 15370987, 9608631 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1445526537029440, 2225519789662536, 914628859347385, - 1064754194555068, 1660295614401091 -#else - 62965568, 21540023, 8446280, 33162829, 4407737, 13629032, - 59383996, 15866073, 38898243, 24740332 -#endif - }}, + {0x4c, 0xf0, 0xe7, 0xf0, 0xc6, 0xfe, 0xe9, 0x3b, 0x62, 0x49, 0xe3, + 0x75, 0x9e, 0x57, 0x6a, 0x86, 0x1a, 0xe6, 0x1d, 0x1e, 0x16, 0xef, + 0x42, 0x55, 0xd5, 0xbd, 0x5a, 0xcc, 0xf4, 0xfe, 0x12, 0x2f}, + {0x89, 0x7c, 0xc4, 0x20, 0x59, 0x80, 0x65, 0xb9, 0xcc, 0x8f, 0x3b, + 0x92, 0xc, 0x10, 0xf0, 0xe7, 0x77, 0xef, 0xe2, 0x2, 0x65, 0x25, + 0x1, 0x0, 0xee, 0xb3, 0xae, 0xa8, 0xce, 0x6d, 0xa7, 0x24}, + {0x40, 0xc7, 0xc0, 0xdf, 0xb2, 0x22, 0x45, 0xa, 0x7, 0xa4, 0xc9, + 0x40, 0x7f, 0x6e, 0xd0, 0x10, 0x68, 0xf6, 0xcf, 0x78, 0x41, 0x14, + 0xcf, 0xc6, 0x90, 0x37, 0xa4, 0x18, 0x25, 0x7b, 0x60, 0x5e}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1199690223111956, 24028135822341, 66638289244341, - 57626156285975, 565093967979607 -#else - 26660628, 17876777, 8393733, 358047, 59707573, 992987, 43204631, - 858696, 20571223, 8420556 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 876926774220824, 554618976488214, 1012056309841565, - 839961821554611, 1414499340307677 -#else - 14620696, 13067227, 51661590, 8264466, 14106269, 15080814, - 33531827, 12516406, 45534429, 21077682 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 703047626104145, 1266841406201770, 165556500219173, - 486991595001879, 1011325891650656 -#else - 236881, 10476226, 57258, 18877408, 6472997, 2466984, 17258519, - 7256740, 8791136, 15069930 -#endif - }}, + {0x14, 0xcf, 0x96, 0xa5, 0x1c, 0x43, 0x2c, 0xa0, 0x0, 0xe4, 0xd3, + 0xae, 0x40, 0x2d, 0xc4, 0xe3, 0xdb, 0x26, 0xf, 0x2e, 0x80, 0x26, + 0x45, 0xd2, 0x68, 0x70, 0x45, 0x9e, 0x13, 0x33, 0x1f, 0x20}, + {0x18, 0x18, 0xdf, 0x6c, 0x8f, 0x1d, 0xb3, 0x58, 0xa2, 0x58, 0x62, + 0xc3, 0x4f, 0xa7, 0xcf, 0x35, 0x6e, 0x1d, 0xe6, 0x66, 0x4f, 0xff, + 0xb3, 0xe1, 0xf7, 0xd5, 0xcd, 0x6c, 0xab, 0xac, 0x67, 0x50}, + {0x51, 0x9d, 0x3, 0x8, 0x6b, 0x7f, 0x52, 0xfd, 0x6, 0x0, 0x7c, + 0x1, 0x64, 0x49, 0xb1, 0x18, 0xa8, 0xa4, 0x25, 0x2e, 0xb0, 0xe, + 0x22, 0xd5, 0x75, 0x3, 0x46, 0x62, 0x88, 0xba, 0x7c, 0x39}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1622861044480487, 1156394801573634, 1869132565415504, - 327103985777730, 2095342781472284 -#else - 1276391, 24182514, 22949634, 17231625, 43615824, 27852245, - 14711874, 4874229, 36445724, 31223040 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 334886927423922, 489511099221528, 129160865966726, - 1720809113143481, 619700195649254 -#else - 5855666, 4990204, 53397016, 7294283, 59304582, 1924646, - 65685689, 25642053, 34039526, 9234252 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1646545795166119, 1758370782583567, 714746174550637, - 1472693650165135, 898994790308209 -#else - 20590503, 24535444, 31529743, 26201766, 64402029, 10650547, - 31559055, 21944845, 18979185, 13396066 -#endif - }}, + {0xe7, 0x79, 0x13, 0xc8, 0xfb, 0xc3, 0x15, 0x78, 0xf1, 0x2a, 0xe1, + 0xdd, 0x20, 0x94, 0x61, 0xa6, 0xd5, 0xfd, 0xa8, 0x85, 0xf8, 0xc0, + 0xa9, 0xff, 0x52, 0xc2, 0xe1, 0xc1, 0x22, 0x40, 0x1b, 0x77}, + {0xb2, 0x59, 0x59, 0xf0, 0x93, 0x30, 0xc1, 0x30, 0x76, 0x79, 0xa9, + 0xe9, 0x8d, 0xa1, 0x3a, 0xe2, 0x26, 0x5e, 0x1d, 0x72, 0x91, 0xd4, + 0x2f, 0x22, 0x3a, 0x6c, 0x6e, 0x76, 0x20, 0xd3, 0x39, 0x23}, + {0xa7, 0x2f, 0x3a, 0x51, 0x86, 0xd9, 0x7d, 0xd8, 0x8, 0xcf, 0xd4, + 0xf9, 0x71, 0x9b, 0xac, 0xf5, 0xb3, 0x83, 0xa2, 0x1e, 0x1b, 0xc3, + 0x6b, 0xd0, 0x76, 0x1a, 0x97, 0x19, 0x92, 0x18, 0x1a, 0x33}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 333403773039279, 295772542452938, 1693106465353610, - 912330357530760, 471235657950362 -#else - 24474287, 4968103, 22267082, 4407354, 24063882, 25229252, - 48291976, 13594781, 33514650, 7021958 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1811196219982022, 1068969825533602, 289602974833439, - 1988956043611592, 863562343398367 -#else - 55541958, 26988926, 45743778, 15928891, 40950559, 4315420, - 41160136, 29637754, 45628383, 12868081 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 906282429780072, 2108672665779781, 432396390473936, - 150625823801893, 1708930497638539 -#else - 38473832, 13504660, 19988037, 31421671, 21078224, 6443208, - 45662757, 2244499, 54653067, 25465048 -#endif - }}, + {0xaf, 0x72, 0x75, 0x9d, 0x3a, 0x2f, 0x51, 0x26, 0x9e, 0x4a, 0x7, + 0x68, 0x88, 0xe2, 0xcb, 0x5b, 0xc4, 0xf7, 0x80, 0x11, 0xc1, 0xc1, + 0xed, 0x84, 0x7b, 0xa6, 0x49, 0xf6, 0x9f, 0x61, 0xc9, 0x1a}, + {0xc6, 0x80, 0x4f, 0xfb, 0x45, 0x6f, 0x16, 0xf5, 0xcf, 0x75, 0xc7, + 0x61, 0xde, 0xc7, 0x36, 0x9c, 0x1c, 0xd9, 0x41, 0x90, 0x1b, 0xe8, + 0xd4, 0xe3, 0x21, 0xfe, 0xbd, 0x83, 0x6b, 0x7c, 0x16, 0x31}, + {0x68, 0x10, 0x4b, 0x52, 0x42, 0x38, 0x2b, 0xf2, 0x87, 0xe9, 0x9c, + 0xee, 0x3b, 0x34, 0x68, 0x50, 0xc8, 0x50, 0x62, 0x4a, 0x84, 0x71, + 0x9d, 0xfc, 0x11, 0xb1, 0x8, 0x1f, 0x34, 0x36, 0x24, 0x61}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 925664675702328, 21416848568684, 1831436641861340, - 601157008940113, 371818055044496 -#else - 36513336, 13793478, 61256044, 319135, 41385692, 27290532, - 33086545, 8957937, 51875216, 5540520 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1479786007267725, 1738881859066675, 68646196476567, - 2146507056100328, 1247662817535471 -#else - 55478669, 22050529, 58989363, 25911358, 2620055, 1022908, - 43398120, 31985447, 50980335, 18591624 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 52035296774456, 939969390708103, 312023458773250, - 59873523517659, 1231345905848899 -#else - 23152952, 775386, 27395463, 14006635, 57407746, 4649511, - 1689819, 892185, 55595587, 18348483 -#endif - }}, + {0x38, 0x26, 0x2d, 0x1a, 0xe3, 0x49, 0x63, 0x8b, 0x35, 0xfd, 0xd3, + 0x9b, 0x0, 0xb7, 0xdf, 0x9d, 0xa4, 0x6b, 0xa0, 0xa3, 0xb8, 0xf1, + 0x8b, 0x7f, 0x45, 0x4, 0xd9, 0x78, 0x31, 0xaa, 0x22, 0x15}, + {0x8d, 0x89, 0x4e, 0x87, 0xdb, 0x41, 0x9d, 0xd9, 0x20, 0xdc, 0x7, + 0x6c, 0xf1, 0xa5, 0xfe, 0x9, 0xbc, 0x9b, 0xf, 0xd0, 0x67, 0x2c, + 0x3d, 0x79, 0x40, 0xff, 0x5e, 0x9e, 0x30, 0xe2, 0xeb, 0x46}, + {0x38, 0x49, 0x61, 0x69, 0x53, 0x2f, 0x38, 0x2c, 0x10, 0x6d, 0x2d, + 0xb7, 0x9a, 0x40, 0xfe, 0xda, 0x27, 0xf2, 0x46, 0xb6, 0x91, 0x33, + 0xc8, 0xe8, 0x6c, 0x30, 0x24, 0x5, 0xf5, 0x70, 0xfe, 0x45}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 643355106415761, 290186807495774, 2013561737429023, - 319648069511546, 393736678496162 -#else - 9770129, 9586738, 26496094, 4324120, 1556511, 30004408, - 27453818, 4763127, 47929250, 5867133 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 129358342392716, 1932811617704777, 1176749390799681, - 398040349861790, 1170779668090425 -#else - 34343820, 1927589, 31726409, 28801137, 23962433, 17534932, - 27846558, 5931263, 37359161, 17445976 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2051980782668029, 121859921510665, 2048329875753063, - 1235229850149665, 519062146124755 -#else - 27461885, 30576896, 22380809, 1815854, 44075111, 30522493, - 7283489, 18406359, 47582163, 7734628 -#endif - }}, + {0x91, 0x14, 0x95, 0xc8, 0x20, 0x49, 0xf2, 0x62, 0xa2, 0xc, 0x63, + 0x3f, 0xc8, 0x7, 0xf0, 0x5, 0xb8, 0xd4, 0xc9, 0xf5, 0xd2, 0x45, + 0xbb, 0x6f, 0x45, 0x22, 0x7a, 0xb5, 0x6d, 0x9f, 0x61, 0x16}, + {0x8c, 0xb, 0xc, 0x96, 0xa6, 0x75, 0x48, 0xda, 0x20, 0x2f, 0xe, + 0xef, 0x76, 0xd0, 0x68, 0x5b, 0xd4, 0x8f, 0xb, 0x3d, 0xcf, 0x51, + 0xfb, 0x7, 0xd4, 0x92, 0xe3, 0xa0, 0x23, 0x16, 0x8d, 0x42}, + {0xfd, 0x8, 0xa3, 0x1, 0x44, 0x4a, 0x4f, 0x8, 0xac, 0xca, 0xa5, + 0x76, 0xc3, 0x19, 0x22, 0xa8, 0x7d, 0xbc, 0xd1, 0x43, 0x46, 0xde, + 0xb8, 0xde, 0xc6, 0x38, 0xbd, 0x60, 0x2d, 0x59, 0x81, 0x1d}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1608170971973096, 415809060360428, 1350468408164766, - 2038620059057678, 1026904485989112 -#else - 59098600, 23963614, 55988460, 6196037, 29344158, 20123547, - 7585294, 30377806, 18549496, 15302069 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1837656083115103, 1510134048812070, 906263674192061, - 1821064197805734, 565375124676301 -#else - 34450527, 27383209, 59436070, 22502750, 6258877, 13504381, - 10458790, 27135971, 58236621, 8424745 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 578027192365650, 2034800251375322, 2128954087207123, - 478816193810521, 2196171989962750 -#else - 24687186, 8613276, 36441818, 30320886, 1863891, 31723888, - 19206233, 7134917, 55824382, 32725512 -#endif - }}, + {0xe8, 0xc5, 0x85, 0x7b, 0x9f, 0xb6, 0x65, 0x87, 0xb2, 0xba, 0x68, + 0xd1, 0x8b, 0x67, 0xf0, 0x6f, 0x9b, 0xf, 0x33, 0x1d, 0x7c, 0xe7, + 0x70, 0x3a, 0x7c, 0x8e, 0xaf, 0xb0, 0x51, 0x6d, 0x5f, 0x3a}, + {0x5f, 0xac, 0xd, 0xa6, 0x56, 0x87, 0x36, 0x61, 0x57, 0xdc, 0xab, + 0xeb, 0x6a, 0x2f, 0xe0, 0x17, 0x7d, 0xf, 0xce, 0x4c, 0x2d, 0x3f, + 0x19, 0x7f, 0xf0, 0xdc, 0xec, 0x89, 0x77, 0x4a, 0x23, 0x20}, + {0x52, 0xb2, 0x78, 0x71, 0xb6, 0xd, 0xd2, 0x76, 0x60, 0xd1, 0x1e, + 0xd5, 0xf9, 0x34, 0x1c, 0x7, 0x70, 0x11, 0xe4, 0xb3, 0x20, 0x4a, + 0x2a, 0xf6, 0x66, 0xe3, 0xff, 0x3c, 0x35, 0x82, 0xd6, 0x7c}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1633188840273139, 852787172373708, 1548762607215796, - 1266275218902681, 1107218203325133 -#else - 11334899, 24336410, 8025292, 12707519, 17523892, 23078361, - 10243737, 18868971, 62042829, 16498836 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 462189358480054, 1784816734159228, 1611334301651368, - 1303938263943540, 707589560319424 -#else - 8911542, 6887158, 57524604, 26595841, 11145640, 24010752, - 17303924, 19430194, 6536640, 10543906 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1038829280972848, 38176604650029, 753193246598573, - 1136076426528122, 595709990562434 -#else - 38162480, 15479762, 49642029, 568875, 65611181, 11223453, - 64439674, 16928857, 39873154, 8876770 -#endif - }}, + {0xf3, 0xf4, 0xac, 0x68, 0x60, 0xcd, 0x65, 0xa6, 0xd3, 0xe3, 0xd7, + 0x3c, 0x18, 0x2d, 0xd9, 0x42, 0xd9, 0x25, 0x60, 0x33, 0x9d, 0x38, + 0x59, 0x57, 0xff, 0xd8, 0x2c, 0x2b, 0x3b, 0x25, 0xf0, 0x3e}, + {0xb6, 0xfa, 0x87, 0xd8, 0x5b, 0xa4, 0xe1, 0xb, 0x6e, 0x3b, 0x40, + 0xba, 0x32, 0x6a, 0x84, 0x2a, 0x0, 0x60, 0x6e, 0xe9, 0x12, 0x10, + 0x92, 0xd9, 0x43, 0x9, 0xdc, 0x3b, 0x86, 0xc8, 0x38, 0x28}, + {0x30, 0x50, 0x46, 0x4a, 0xcf, 0xb0, 0x6b, 0xd1, 0xab, 0x77, 0xc5, + 0x15, 0x41, 0x6b, 0x49, 0xfa, 0x9d, 0x41, 0xab, 0xf4, 0x8a, 0xae, + 0xcf, 0x82, 0x12, 0x28, 0xa8, 0x6, 0xa6, 0xb8, 0xdc, 0x21}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1408451820859834, 2194984964010833, 2198361797561729, - 1061962440055713, 1645147963442934 -#else - 41365946, 20987567, 51458897, 32707824, 34082177, 32758143, - 33627041, 15824473, 66504438, 24514614 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 4701053362120, 1647641066302348, 1047553002242085, - 1923635013395977, 206970314902065 -#else - 10330056, 70051, 7957388, 24551765, 9764901, 15609756, 27698697, - 28664395, 1657393, 3084098 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1750479161778571, 1362553355169293, 1891721260220598, - 966109370862782, 1024913988299801 -#else - 10477963, 26084172, 12119565, 20303627, 29016246, 28188843, - 31280318, 14396151, 36875289, 15272408 -#endif - }}, + {0xba, 0x31, 0x77, 0xbe, 0xfa, 0x0, 0x8d, 0x9a, 0x89, 0x18, 0x9e, + 0x62, 0x7e, 0x60, 0x3, 0x82, 0x7f, 0xd9, 0xf3, 0x43, 0x37, 0x2, + 0xcc, 0xb2, 0x8b, 0x67, 0x6f, 0x6c, 0xbf, 0xd, 0x84, 0x5d}, + {0xc8, 0x9f, 0x9d, 0x8c, 0x46, 0x4, 0x60, 0x5c, 0xcb, 0xa3, 0x2a, + 0xd4, 0x6e, 0x9, 0x40, 0x25, 0x9c, 0x2f, 0xee, 0x12, 0x4c, 0x4d, + 0x5b, 0x12, 0xab, 0x1d, 0xa3, 0x94, 0x81, 0xd0, 0xc3, 0xb}, + {0x8b, 0xe1, 0x9f, 0x30, 0xd, 0x38, 0x6e, 0x70, 0xc7, 0x65, 0xe1, + 0xb9, 0xa6, 0x2d, 0xb0, 0x6e, 0xab, 0x20, 0xae, 0x7d, 0x99, 0xba, + 0xbb, 0x57, 0xdd, 0x96, 0xc1, 0x2a, 0x23, 0x76, 0x42, 0x3a}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 212699049131723, 1117950018299775, 1873945661751056, - 1403802921984058, 130896082652698 -#else - 54820555, 3169462, 28813183, 16658753, 25116432, 27923966, - 41934906, 20918293, 42094106, 1950503 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 636808533673210, 1262201711667560, 390951380330599, - 1663420692697294, 561951321757406 -#else - 40928506, 9489186, 11053416, 18808271, 36055143, 5825629, - 58724558, 24786899, 15341278, 8373727 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 520731594438141, 1446301499955692, 273753264629267, - 1565101517999256, 1019411827004672 -#else - 28685821, 7759505, 52730348, 21551571, 35137043, 4079241, - 298136, 23321830, 64230656, 15190419 -#endif - }}, + {0xcb, 0x7e, 0x44, 0xdb, 0x72, 0xc1, 0xf8, 0x3b, 0xbd, 0x2d, 0x28, + 0xc6, 0x1f, 0xc4, 0xcf, 0x5f, 0xfe, 0x15, 0xaa, 0x75, 0xc0, 0xff, + 0xac, 0x80, 0xf9, 0xa9, 0xe1, 0x24, 0xe8, 0xc9, 0x70, 0x7}, + {0xfa, 0x84, 0x70, 0x8a, 0x2c, 0x43, 0x42, 0x4b, 0x45, 0xe5, 0xb9, + 0xdf, 0xe3, 0x19, 0x8a, 0x89, 0x5d, 0xe4, 0x58, 0x9c, 0x21, 0x0, + 0x9f, 0xbe, 0xd1, 0xeb, 0x6d, 0xa1, 0xce, 0x77, 0xf1, 0x1f}, + {0xfd, 0xb5, 0xb5, 0x45, 0x9a, 0xd9, 0x61, 0xcf, 0x24, 0x79, 0x3a, + 0x1b, 0xe9, 0x84, 0x9, 0x86, 0x89, 0x3e, 0x3e, 0x30, 0x19, 0x9, + 0x30, 0xe7, 0x1e, 0xb, 0x50, 0x41, 0xfd, 0x64, 0xf2, 0x39}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 926527492029409, 1191853477411379, 734233225181171, - 184038887541270, 1790426146325343 -#else - 34175969, 13806335, 52771379, 17760000, 43104243, 10940927, - 8669718, 2742393, 41075551, 26679428 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1464651961852572, 1483737295721717, 1519450561335517, - 1161429831763785, 405914998179977 -#else - 65528476, 21825014, 41129205, 22109408, 49696989, 22641577, - 9291593, 17306653, 54954121, 6048604 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 996126634382301, 796204125879525, 127517800546509, - 344155944689303, 615279846169038 -#else - 36803549, 14843443, 1539301, 11864366, 20201677, 1900163, - 13934231, 5128323, 11213262, 9168384 -#endif - }}, + {0xe1, 0x7b, 0x9, 0xfe, 0xab, 0x4a, 0x9b, 0xd1, 0x29, 0x19, 0xe0, + 0xdf, 0xe1, 0xfc, 0x6d, 0xa4, 0xff, 0xf1, 0xa6, 0x2c, 0x94, 0x8, + 0xc9, 0xc3, 0x4e, 0xf1, 0x35, 0x2c, 0x27, 0x21, 0xc6, 0x65}, + {0x9c, 0xe2, 0xe7, 0xdb, 0x17, 0x34, 0xad, 0xa7, 0x9c, 0x13, 0x9c, + 0x2b, 0x6a, 0x37, 0x94, 0xbd, 0xa9, 0x7b, 0x59, 0x93, 0x8e, 0x1b, + 0xe9, 0xa0, 0x40, 0x98, 0x88, 0x68, 0x34, 0xd7, 0x12, 0x17}, + {0xdd, 0x93, 0x31, 0xce, 0xf8, 0x89, 0x2b, 0xe7, 0xbb, 0xc0, 0x25, + 0xa1, 0x56, 0x33, 0x10, 0x4d, 0x83, 0xfe, 0x1c, 0x2e, 0x3d, 0xa9, + 0x19, 0x4, 0x72, 0xe2, 0x9c, 0xb1, 0xa, 0x80, 0xf9, 0x22}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 738724080975276, 2188666632415296, 1961313708559162, - 1506545807547587, 1151301638969740 -#else - 40828332, 11007846, 19408960, 32613674, 48515898, 29225851, - 62020803, 22449281, 20470156, 17155731 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 622917337413835, 1218989177089035, 1284857712846592, - 970502061709359, 351025208117090 -#else - 43972811, 9282191, 14855179, 18164354, 59746048, 19145871, - 44324911, 14461607, 14042978, 5230683 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2067814584765580, 1677855129927492, 2086109782475197, - 235286517313238, 1416314046739645 -#else - 29969548, 30812838, 50396996, 25001989, 9175485, 31085458, - 21556950, 3506042, 61174973, 21104723 -#endif - }}, + {0xac, 0xfd, 0x6e, 0x9a, 0xdd, 0x9f, 0x2, 0x42, 0x41, 0x49, 0xa5, + 0x34, 0xbe, 0xce, 0x12, 0xb9, 0x7b, 0xf3, 0xbd, 0x87, 0xb9, 0x64, + 0xf, 0x64, 0xb4, 0xca, 0x98, 0x85, 0xd3, 0xa4, 0x71, 0x41}, + {0xcb, 0xf8, 0x9e, 0x3e, 0x8a, 0x36, 0x5a, 0x60, 0x15, 0x47, 0x50, + 0xa5, 0x22, 0xc0, 0xe9, 0xe3, 0x8f, 0x24, 0x24, 0x5f, 0xb0, 0x48, + 0x3d, 0x55, 0xe5, 0x26, 0x76, 0x64, 0xcd, 0x16, 0xf4, 0x13}, + {0x8c, 0x4c, 0xc9, 0x99, 0xaa, 0x58, 0x27, 0xfa, 0x7, 0xb8, 0x0, + 0xb0, 0x6f, 0x6f, 0x0, 0x23, 0x92, 0x53, 0xda, 0xad, 0xdd, 0x91, + 0xd2, 0xfb, 0xab, 0xd1, 0x4b, 0x57, 0xfa, 0x14, 0x82, 0x50}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 586844262630358, 307444381952195, 458399356043426, - 602068024507062, 1028548203415243 -#else - 63964118, 8744660, 19704003, 4581278, 46678178, 6830682, - 45824694, 8971512, 38569675, 15326562 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 678489922928203, 2016657584724032, 90977383049628, - 1026831907234582, 615271492942522 -#else - 47644235, 10110287, 49846336, 30050539, 43608476, 1355668, - 51585814, 15300987, 46594746, 9168259 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 301225714012278, 1094837270268560, 1202288391010439, - 644352775178361, 1647055902137983 -#else - 61755510, 4488612, 43305616, 16314346, 7780487, 17915493, - 38160505, 9601604, 33087103, 24543045 -#endif - }}, + {0xd6, 0x3, 0xd0, 0x53, 0xbb, 0x15, 0x1a, 0x46, 0x65, 0xc9, 0xf3, + 0xbc, 0x88, 0x28, 0x10, 0xb2, 0x5a, 0x3a, 0x68, 0x6c, 0x75, 0x76, + 0xc5, 0x27, 0x47, 0xb4, 0x6c, 0xc8, 0xa4, 0x58, 0x77, 0x3a}, + {0x4b, 0xfe, 0xd6, 0x3e, 0x15, 0x69, 0x2, 0xc2, 0xc4, 0x77, 0x1d, + 0x51, 0x39, 0x67, 0x5a, 0xa6, 0x94, 0xaf, 0x14, 0x2c, 0x46, 0x26, + 0xde, 0xcb, 0x4b, 0xa7, 0xab, 0x6f, 0xec, 0x60, 0xf9, 0x22}, + {0x76, 0x50, 0xae, 0x93, 0xf6, 0x11, 0x81, 0x54, 0xa6, 0x54, 0xfd, + 0x1d, 0xdf, 0x21, 0xae, 0x1d, 0x65, 0x5e, 0x11, 0xf3, 0x90, 0x8c, + 0x24, 0x12, 0x94, 0xf4, 0xe7, 0x8d, 0x5f, 0xd1, 0x9f, 0x5d}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1210746697896478, 1416608304244708, 686487477217856, - 1245131191434135, 1051238336855737 -#else - 47665694, 18041531, 46311396, 21109108, 37284416, 10229460, - 39664535, 18553900, 61111993, 15664671 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1135604073198207, 1683322080485474, 769147804376683, - 2086688130589414, 900445683120379 -#else - 23294591, 16921819, 44458082, 25083453, 27844203, 11461195, - 13099750, 31094076, 18151675, 13417686 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1971518477615628, 401909519527336, 448627091057375, - 1409486868273821, 1214789035034363 -#else - 42385932, 29377914, 35958184, 5988918, 40250079, 6685064, - 1661597, 21002991, 15271675, 18101767 -#endif - }}, + {0x1e, 0x52, 0xd7, 0xee, 0x2a, 0x4d, 0x24, 0x3f, 0x15, 0x96, 0x2e, + 0x43, 0x28, 0x90, 0x3a, 0x8e, 0xd4, 0x16, 0x9c, 0x2e, 0x77, 0xba, + 0x64, 0xe1, 0xd8, 0x98, 0xeb, 0x47, 0xfa, 0x87, 0xc1, 0x3b}, + {0x7f, 0x72, 0x63, 0x6d, 0xd3, 0x8, 0x14, 0x3, 0x33, 0xb5, 0xc7, + 0xd7, 0xef, 0x9a, 0x37, 0x6a, 0x4b, 0xe2, 0xae, 0xcc, 0xc5, 0x8f, + 0xe1, 0xa9, 0xd3, 0xbe, 0x8f, 0x4f, 0x91, 0x35, 0x2f, 0x33}, + {0xc, 0xc2, 0x86, 0xea, 0x15, 0x1, 0x47, 0x6d, 0x25, 0xd1, 0x46, + 0x6c, 0xcb, 0xb7, 0x8a, 0x99, 0x88, 0x1, 0x66, 0x3a, 0xb5, 0x32, + 0x78, 0xd7, 0x3, 0xba, 0x6f, 0x90, 0xce, 0x81, 0xd, 0x45}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1364039144731711, 1897497433586190, 2203097701135459, - 145461396811251, 1349844460790699 -#else - 11433023, 20325767, 8239630, 28274915, 65123427, 32828713, - 48410099, 2167543, 60187563, 20114249 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1045230323257973, 818206601145807, 630513189076103, - 1672046528998132, 807204017562437 -#else - 35672693, 15575145, 30436815, 12192228, 44645511, 9395378, - 57191156, 24915434, 12215109, 12028277 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 439961968385997, 386362664488986, 1382706320807688, - 309894000125359, 2207801346498567 -#else - 14098381, 6555944, 23007258, 5757252, 51681032, 20603929, - 30123439, 4617780, 50208775, 32898803 -#endif - }}, + {0x3f, 0x74, 0xae, 0x1c, 0x96, 0xd8, 0x74, 0xd0, 0xed, 0x63, 0x1c, + 0xee, 0xf5, 0x18, 0x6d, 0xf8, 0x29, 0xed, 0xf4, 0xe7, 0x5b, 0xc5, + 0xbd, 0x97, 0x8, 0xb1, 0x3a, 0x66, 0x79, 0xd2, 0xba, 0x4c}, + {0x75, 0x52, 0x20, 0xa6, 0xa1, 0xb6, 0x7b, 0x6e, 0x83, 0x8e, 0x3c, + 0x41, 0xd7, 0x21, 0x4f, 0xaa, 0xb2, 0x5c, 0x8f, 0xe8, 0x55, 0xd1, + 0x56, 0x6f, 0xe1, 0x5b, 0x34, 0xa6, 0x4b, 0x5d, 0xe2, 0x2d}, + {0xcd, 0x1f, 0xd7, 0xa0, 0x24, 0x90, 0xd1, 0x80, 0xf8, 0x8a, 0x28, + 0xfb, 0xa, 0xc2, 0x25, 0xc5, 0x19, 0x64, 0x3a, 0x5f, 0x4b, 0x97, + 0xa3, 0xb1, 0x33, 0x72, 0x0, 0xe2, 0xef, 0xbc, 0x7f, 0x7d}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1229004686397588, 920643968530863, 123975893911178, - 681423993215777, 1400559197080973 -#else - 63082644, 18313596, 11893167, 13718664, 52299402, 1847384, - 51288865, 10154008, 23973261, 20869958 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2003766096898049, 170074059235165, 1141124258967971, - 1485419893480973, 1573762821028725 -#else - 40577025, 29858441, 65199965, 2534300, 35238307, 17004076, - 18341389, 22134481, 32013173, 23450893 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 729905708611432, 1270323270673202, 123353058984288, - 426460209632942, 2195574535456672 -#else - 41629544, 10876442, 55337778, 18929291, 54739296, 1838103, - 21911214, 6354752, 4425632, 32716610 -#endif - }}, + {0x94, 0x90, 0xc2, 0xf3, 0xc5, 0x5d, 0x7c, 0xcd, 0xab, 0x5, 0x91, + 0x2a, 0x9a, 0xa2, 0x81, 0xc7, 0x58, 0x30, 0x1c, 0x42, 0x36, 0x1d, + 0xc6, 0x80, 0xd7, 0xd4, 0xd8, 0xdc, 0x96, 0xd1, 0x9c, 0x4f}, + {0x1, 0x28, 0x6b, 0x26, 0x6a, 0x1e, 0xef, 0xfa, 0x16, 0x9f, 0x73, + 0xd5, 0xc4, 0x68, 0x6c, 0x86, 0x2c, 0x76, 0x3, 0x1b, 0xbc, 0x2f, + 0x8a, 0xf6, 0x8d, 0x5a, 0xb7, 0x87, 0x5e, 0x43, 0x75, 0x59}, + {0x68, 0x37, 0x7b, 0x6a, 0xd8, 0x97, 0x92, 0x19, 0x63, 0x7a, 0xd1, + 0x1a, 0x24, 0x58, 0xd0, 0xd0, 0x17, 0xc, 0x1c, 0x5c, 0xad, 0x9c, + 0x2, 0xba, 0x7, 0x3, 0x7a, 0x38, 0x84, 0xd0, 0xcd, 0x7c}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1271140255321235, 2044363183174497, 52125387634689, - 1445120246694705, 942541986339084 -#else - 56675475, 18941465, 22229857, 30463385, 53917697, 776728, - 49693489, 21533969, 4725004, 14044970 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1761608437466135, 583360847526804, 1586706389685493, - 2157056599579261, 1170692369685772 -#else - 19268631, 26250011, 1555348, 8692754, 45634805, 23643767, - 6347389, 32142648, 47586572, 17444675 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 871476219910823, 1878769545097794, 2241832391238412, - 548957640601001, 690047440233174 -#else - 42244775, 12986007, 56209986, 27995847, 55796492, 33405905, - 19541417, 8180106, 9282262, 10282508 -#endif - }}, + {0x93, 0xcc, 0x60, 0x67, 0x18, 0x84, 0xc, 0x9b, 0x99, 0x2a, 0xb3, + 0x1a, 0x7a, 0x0, 0xae, 0xcd, 0x18, 0xda, 0xb, 0x62, 0x86, 0xec, + 0x8d, 0xa8, 0x44, 0xca, 0x90, 0x81, 0x84, 0xca, 0x93, 0x35}, + {0x17, 0x4, 0x26, 0x6d, 0x2c, 0x42, 0xa6, 0xdc, 0xbd, 0x40, 0x82, + 0x94, 0x50, 0x3d, 0x15, 0xae, 0x77, 0xc6, 0x68, 0xfb, 0xb4, 0xc1, + 0xc0, 0xa9, 0x53, 0xcf, 0xd0, 0x61, 0xed, 0xd0, 0x8b, 0x42}, + {0xa7, 0x9a, 0x84, 0x5e, 0x9a, 0x18, 0x13, 0x92, 0xcd, 0xfa, 0xd8, + 0x65, 0x35, 0xc3, 0xd8, 0xd4, 0xd1, 0xbb, 0xfd, 0x53, 0x5b, 0x54, + 0x52, 0x8c, 0xe6, 0x63, 0x2d, 0xda, 0x8, 0x83, 0x39, 0x27}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 297194732135507, 1366347803776820, 1301185512245601, - 561849853336294, 1533554921345731 -#else - 40903763, 4428546, 58447668, 20360168, 4098401, 19389175, - 15522534, 8372215, 5542595, 22851749 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 999628998628371, 1132836708493400, 2084741674517453, - 469343353015612, 678782988708035 -#else - 56546323, 14895632, 26814552, 16880582, 49628109, 31065071, - 64326972, 6993760, 49014979, 10114654 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2189427607417022, 699801937082607, 412764402319267, - 1478091893643349, 2244675696854460 -#else - 47001790, 32625013, 31422703, 10427861, 59998115, 6150668, - 38017109, 22025285, 25953724, 33448274 -#endif - }}, + {0x53, 0x24, 0x70, 0xa, 0x4c, 0xe, 0xa1, 0xb9, 0xde, 0x1b, 0x7d, + 0xd5, 0x66, 0x58, 0xa2, 0xf, 0xf7, 0xda, 0x27, 0xcd, 0xb5, 0xd9, + 0xb9, 0xff, 0xfd, 0x33, 0x2c, 0x49, 0x45, 0x29, 0x2c, 0x57}, + {0x13, 0xd4, 0x5e, 0x43, 0x28, 0x8d, 0xc3, 0x42, 0xc9, 0xcc, 0x78, + 0x32, 0x60, 0xf3, 0x50, 0xbd, 0xef, 0x3, 0xda, 0x79, 0x1a, 0xab, + 0x7, 0xbb, 0x55, 0x33, 0x8c, 0xbe, 0xae, 0x97, 0x95, 0x26}, + {0xbe, 0x30, 0xcd, 0xd6, 0x45, 0xc7, 0x7f, 0xc7, 0xfb, 0xae, 0xba, + 0xe3, 0xd3, 0xe8, 0xdf, 0xe4, 0xc, 0xda, 0x5d, 0xaa, 0x30, 0x88, + 0x2c, 0xa2, 0x80, 0xca, 0x5b, 0xc0, 0x98, 0x54, 0x98, 0x7f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1712292055966563, 204413590624874, 1405738637332841, - 408981300829763, 861082219276721 -#else - 62874467, 25515139, 57989738, 3045999, 2101609, 20947138, - 19390019, 6094296, 63793585, 12831124 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 508561155940631, 966928475686665, 2236717801150132, - 424543858577297, 2089272956986143 -#else - 51110167, 7578151, 5310217, 14408357, 33560244, 33329692, - 31575953, 6326196, 7381791, 31132593 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 221245220129925, 1156020201681217, 491145634799213, - 542422431960839, 828100817819207 -#else - 46206085, 3296810, 24736065, 17226043, 18374253, 7318640, - 6295303, 8082724, 51746375, 12339663 -#endif - }}, + {0x63, 0x63, 0xbf, 0xf, 0x52, 0x15, 0x56, 0xd3, 0xa6, 0xfb, 0x4d, + 0xcf, 0x45, 0x5a, 0x4, 0x8, 0xc2, 0xa0, 0x3f, 0x87, 0xbc, 0x4f, + 0xc2, 0xee, 0xe7, 0x12, 0x9b, 0xd6, 0x3c, 0x65, 0xf2, 0x30}, + {0x17, 0xe1, 0xb, 0x9f, 0x88, 0xce, 0x49, 0x38, 0x88, 0xa2, 0x54, + 0x7b, 0x1b, 0xad, 0x5, 0x80, 0x1c, 0x92, 0xfc, 0x23, 0x9f, 0xc3, + 0xa3, 0x3d, 0x4, 0xf3, 0x31, 0xa, 0x47, 0xec, 0xc2, 0x76}, + {0x85, 0xc, 0xc1, 0xaa, 0x38, 0xc9, 0x8, 0x8a, 0xcb, 0x6b, 0x27, + 0xdb, 0x60, 0x9b, 0x17, 0x46, 0x70, 0xac, 0x6f, 0xe, 0x1e, 0xc0, + 0x20, 0xa9, 0xda, 0x73, 0x64, 0x59, 0xf1, 0x73, 0x12, 0x2f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 153756971240384, 1299874139923977, 393099165260502, - 1058234455773022, 996989038681183 -#else - 27724736, 2291157, 6088201, 19369634, 1792726, 5857634, - 13848414, 15768922, 25091167, 14856294 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 559086812798481, 573177704212711, 1629737083816402, - 1399819713462595, 1646954378266038 -#else - 48242193, 8331042, 24373479, 8541013, 66406866, 24284974, - 12927299, 20858939, 44926390, 24541532 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1887963056288059, 228507035730124, 1468368348640282, - 930557653420194, 613513962454686 -#else - 55685435, 28132841, 11632844, 3405020, 30536730, 21880393, - 39848098, 13866389, 30146206, 9142070 -#endif - }}, + {0xc0, 0xb, 0xa7, 0x55, 0xd7, 0x8b, 0x48, 0x30, 0xe7, 0x42, 0xd4, + 0xf1, 0xa4, 0xb5, 0xd6, 0x6, 0x62, 0x61, 0x59, 0xbc, 0x9e, 0xa6, + 0xd1, 0xea, 0x84, 0xf7, 0xc5, 0xed, 0x97, 0x19, 0xac, 0x38}, + {0x11, 0x1e, 0xe0, 0x8a, 0x7c, 0xfc, 0x39, 0x47, 0x9f, 0xab, 0x6a, + 0x4a, 0x90, 0x74, 0x52, 0xfd, 0x2e, 0x8f, 0x72, 0x87, 0x82, 0x8a, + 0xd9, 0x41, 0xf2, 0x69, 0x5b, 0xd8, 0x2a, 0x57, 0x9e, 0x5d}, + {0x3b, 0xb1, 0x51, 0xa7, 0x17, 0xb5, 0x66, 0x6, 0x8c, 0x85, 0x9b, + 0x7e, 0x86, 0x6, 0x7d, 0x74, 0x49, 0xde, 0x4d, 0x45, 0x11, 0xc0, + 0xac, 0xac, 0x9c, 0xe6, 0xe9, 0xbf, 0x9c, 0xcd, 0xdf, 0x22}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1224529808187553, 1577022856702685, 2206946542980843, - 625883007765001, 279930793512158 -#else - 3924129, 18246916, 53291741, 23499471, 12291819, 32886066, - 39406089, 9326383, 58871006, 4171293 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1076287717051609, 1114455570543035, 187297059715481, - 250446884292121, 1885187512550540 -#else - 51186905, 16037936, 6713787, 16606682, 45496729, 2790943, - 26396185, 3731949, 345228, 28091483 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 902497362940219, 76749815795675, 1657927525633846, - 1420238379745202, 1340321636548352 -#else - 45781307, 13448258, 25284571, 1143661, 20614966, 24705045, - 2031538, 21163201, 50855680, 19972348 -#endif - }}, + {0xa1, 0xe0, 0x3b, 0x10, 0xb4, 0x59, 0xec, 0x56, 0x69, 0xf9, 0x59, + 0xd2, 0xec, 0xba, 0xe3, 0x2e, 0x32, 0xcd, 0xf5, 0x13, 0x94, 0xb2, + 0x7c, 0x79, 0x72, 0xe4, 0xcd, 0x24, 0x78, 0x87, 0xe9, 0xf}, + {0xd9, 0xc, 0xd, 0xc3, 0xe0, 0xd2, 0xdb, 0x8d, 0x33, 0x43, 0xbb, + 0xac, 0x5f, 0x66, 0x8e, 0xad, 0x1f, 0x96, 0x2a, 0x32, 0x8c, 0x25, + 0x6b, 0x8f, 0xc7, 0xc1, 0x48, 0x54, 0xc0, 0x16, 0x29, 0x6b}, + {0x3b, 0x91, 0xba, 0xa, 0xd1, 0x34, 0xdb, 0x7e, 0xe, 0xac, 0x6d, + 0x2e, 0x82, 0xcd, 0xa3, 0x4e, 0x15, 0xf8, 0x78, 0x65, 0xff, 0x3d, + 0x8, 0x66, 0x17, 0xa, 0xf0, 0x7f, 0x30, 0x3f, 0x30, 0x4c}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1129576631190784, 1281994010027327, 996844254743018, - 257876363489249, 1150850742055018 -#else - 31016192, 16832003, 26371391, 19103199, 62081514, 14854136, - 17477601, 3842657, 28012650, 17149012 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 628740660038789, 1943038498527841, 467786347793886, - 1093341428303375, 235413859513003 -#else - 62033029, 9368965, 58546785, 28953529, 51858910, 6970559, - 57918991, 16292056, 58241707, 3507939 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 237425418909360, 469614029179605, 1512389769174935, - 1241726368345357, 441602891065214 -#else - 29439664, 3537914, 23333589, 6997794, 49553303, 22536363, - 51899661, 18503164, 57943934, 6580395 -#endif - }}, + {0x0, 0x45, 0xd9, 0xd, 0x58, 0x3, 0xfc, 0x29, 0x93, 0xec, 0xbb, + 0x6f, 0xa4, 0x7a, 0xd2, 0xec, 0xf8, 0xa7, 0xe2, 0xc2, 0x5f, 0x15, + 0xa, 0x13, 0xd5, 0xa1, 0x6, 0xb7, 0x1a, 0x15, 0x6b, 0x41}, + {0x85, 0x8c, 0xb2, 0x17, 0xd6, 0x3b, 0xa, 0xd3, 0xea, 0x3b, 0x77, + 0x39, 0xb7, 0x77, 0xd3, 0xc5, 0xbf, 0x5c, 0x6a, 0x1e, 0x8c, 0xe7, + 0xc6, 0xc6, 0xc4, 0xb7, 0x2a, 0x8b, 0xf7, 0xb8, 0x61, 0xd}, + {0xb0, 0x36, 0xc1, 0xe9, 0xef, 0xd7, 0xa8, 0x56, 0x20, 0x4b, 0xe4, + 0x58, 0xcd, 0xe5, 0x7, 0xbd, 0xab, 0xe0, 0x57, 0x1b, 0xda, 0x2f, + 0xe6, 0xaf, 0xd2, 0xe8, 0x77, 0x42, 0xf7, 0x2a, 0x1a, 0x19}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1736417953058555, 726531315520508, 1833335034432527, - 1629442561574747, 624418919286085 -#else - 54923003, 25874643, 16438268, 10826160, 58412047, 27318820, - 17860443, 24280586, 65013061, 9304566 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1960754663920689, 497040957888962, 1909832851283095, - 1271432136996826, 2219780368020940 -#else - 20714545, 29217521, 29088194, 7406487, 11426967, 28458727, - 14792666, 18945815, 5289420, 33077305 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1537037379417136, 1358865369268262, 2130838645654099, - 828733687040705, 1999987652890901 -#else - 50443312, 22903641, 60948518, 20248671, 9192019, 31751970, - 17271489, 12349094, 26939669, 29802138 -#endif - }}, + {0xfb, 0xe, 0x46, 0x4f, 0x43, 0x2b, 0xe6, 0x9f, 0xd6, 0x7, 0x36, + 0xa6, 0xd4, 0x3, 0xd3, 0xde, 0x24, 0xda, 0xa0, 0xb7, 0xe, 0x21, + 0x52, 0xf0, 0x93, 0x5b, 0x54, 0x0, 0xbe, 0x7d, 0x7e, 0x23}, + {0x31, 0x14, 0x3c, 0xc5, 0x4b, 0xf7, 0x16, 0xce, 0xde, 0xed, 0x72, + 0x20, 0xce, 0x25, 0x97, 0x2b, 0xe7, 0x3e, 0xb2, 0xb5, 0x6f, 0xc3, + 0xb9, 0xb8, 0x8, 0xc9, 0x5c, 0xb, 0x45, 0xe, 0x2e, 0x7e}, + {0x30, 0xb4, 0x1, 0x67, 0xed, 0x75, 0x35, 0x1, 0x10, 0xfd, 0xb, + 0x9f, 0xe6, 0x94, 0x10, 0x23, 0x22, 0x7f, 0xe4, 0x83, 0x15, 0xf, + 0x32, 0x75, 0xe3, 0x55, 0x11, 0xb1, 0x99, 0xa6, 0xaf, 0x71}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 629042105241814, 1098854999137608, 887281544569320, - 1423102019874777, 7911258951561 -#else - 54218966, 9373457, 31595848, 16374215, 21471720, 13221525, - 39825369, 21205872, 63410057, 117886 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1811562332665373, 1501882019007673, 2213763501088999, - 359573079719636, 36370565049116 -#else - 22263325, 26994382, 3984569, 22379786, 51994855, 32987646, - 28311252, 5358056, 43789084, 541963 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 218907117361280, 1209298913016966, 1944312619096112, - 1130690631451061, 1342327389191701 -#else - 16259200, 3261970, 2309254, 18019958, 50223152, 28972515, - 24134069, 16848603, 53771797, 20002236 -#endif - }}, + {0xd6, 0x50, 0x3b, 0x47, 0x1c, 0x3c, 0x42, 0xea, 0x10, 0xef, 0x38, + 0x3b, 0x1f, 0x7a, 0xe8, 0x51, 0x95, 0xbe, 0xc9, 0xb2, 0x5f, 0xbf, + 0x84, 0x9b, 0x1c, 0x9a, 0xf8, 0x78, 0xbc, 0x1f, 0x73, 0x0}, + {0x1d, 0xb6, 0x53, 0x39, 0x9b, 0x6f, 0xce, 0x65, 0xe6, 0x41, 0xa1, + 0xaf, 0xea, 0x39, 0x58, 0xc6, 0xfe, 0x59, 0xf7, 0xa9, 0xfd, 0x5f, + 0x43, 0xf, 0x8e, 0xc2, 0xb1, 0xc2, 0xe9, 0x42, 0x11, 0x2}, + {0x80, 0x18, 0xf8, 0x48, 0x18, 0xc7, 0x30, 0xe4, 0x19, 0xc1, 0xce, + 0x5e, 0x22, 0xc, 0x96, 0xbf, 0xe3, 0x15, 0xba, 0x6b, 0x83, 0xe0, + 0xda, 0xb6, 0x8, 0x58, 0xe1, 0x47, 0x33, 0x6f, 0x4d, 0x4c}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1369976867854704, 1396479602419169, 1765656654398856, - 2203659200586299, 998327836117241 -#else - 9378160, 20414246, 44262881, 20809167, 28198280, 26310334, - 64709179, 32837080, 690425, 14876244 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2230701885562825, 1348173180338974, 2172856128624598, - 1426538746123771, 444193481326151 -#else - 24977353, 33240048, 58884894, 20089345, 28432342, 32378079, - 54040059, 21257083, 44727879, 6618998 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 784210426627951, 918204562375674, 1284546780452985, - 1324534636134684, 1872449409642708 -#else - 65570671, 11685645, 12944378, 13682314, 42719353, 19141238, - 8044828, 19737104, 32239828, 27901670 -#endif - }}, + {0x70, 0x19, 0x8f, 0x98, 0xfc, 0xdd, 0xc, 0x2f, 0x1b, 0xf5, 0xb9, + 0xb0, 0x27, 0x62, 0x91, 0x6b, 0xbe, 0x76, 0x91, 0x77, 0xc4, 0xb6, + 0xc7, 0x6e, 0xa8, 0x9f, 0x8f, 0xa8, 0x0, 0x95, 0xbf, 0x38}, + {0xc9, 0x1f, 0x7d, 0xc1, 0xcf, 0xec, 0xf7, 0x18, 0x14, 0x3c, 0x40, + 0x51, 0xa6, 0xf5, 0x75, 0x6c, 0xdf, 0xc, 0xee, 0xf7, 0x2b, 0x71, + 0xde, 0xdb, 0x22, 0x7a, 0xe4, 0xa7, 0xaa, 0xdd, 0x3f, 0x19}, + {0x6f, 0x87, 0xe8, 0x37, 0x3c, 0xc9, 0xd2, 0x1f, 0x2c, 0x46, 0xd1, + 0x18, 0x5a, 0x1e, 0xf6, 0xa2, 0x76, 0x12, 0x24, 0x39, 0x82, 0xf5, + 0x80, 0x50, 0x69, 0x49, 0xd, 0xbf, 0x9e, 0xb9, 0x6f, 0x6a}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 319638829540294, 596282656808406, 2037902696412608, - 1557219121643918, 341938082688094 -#else - 48505798, 4762989, 66182614, 8885303, 38696384, 30367116, - 9781646, 23204373, 32779358, 5095274 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1901860206695915, 2004489122065736, 1625847061568236, - 973529743399879, 2075287685312905 -#else - 34100715, 28339925, 34843976, 29869215, 9460460, 24227009, - 42507207, 14506723, 21639561, 30924196 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1371853944110545, 1042332820512553, 1949855697918254, - 1791195775521505, 37487364849293 -#else - 50707921, 20442216, 25239337, 15531969, 3987758, 29055114, - 65819361, 26690896, 17874573, 558605 -#endif - }}, + {0xc6, 0x23, 0xe4, 0xb6, 0xb5, 0x22, 0xb1, 0xee, 0x8e, 0xff, 0x86, + 0xf2, 0x10, 0x70, 0x9d, 0x93, 0x8c, 0x5d, 0xcf, 0x1d, 0x83, 0x2a, + 0xa9, 0x90, 0x10, 0xeb, 0xc5, 0x42, 0x9f, 0xda, 0x6f, 0x13}, + {0xeb, 0x55, 0x8, 0x56, 0xbb, 0xc1, 0x46, 0x6a, 0x9d, 0xf0, 0x93, + 0xf8, 0x38, 0xbb, 0x16, 0x24, 0xc1, 0xac, 0x71, 0x8f, 0x37, 0x11, + 0x1d, 0xd7, 0xea, 0x96, 0x18, 0xa3, 0x14, 0x69, 0xf7, 0x75}, + {0xd1, 0xbd, 0x5, 0xa3, 0xb1, 0xdf, 0x4c, 0xf9, 0x8, 0x2c, 0xf8, + 0x9f, 0x9d, 0x4b, 0x36, 0xf, 0x8a, 0x58, 0xbb, 0xc3, 0xa5, 0xd8, + 0x87, 0x2a, 0xba, 0xdc, 0xe8, 0xb, 0x51, 0x83, 0x21, 0x2}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 687200189577855, 1082536651125675, 644224940871546, - 340923196057951, 343581346747396 -#else - 53508735, 10240080, 9171883, 16131053, 46239610, 9599699, - 33499487, 5080151, 2085892, 5119761 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2082717129583892, 27829425539422, 145655066671970, - 1690527209845512, 1865260509673478 -#else - 44903700, 31034903, 50727262, 414690, 42089314, 2170429, - 30634760, 25190818, 35108870, 27794547 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1059729620568824, 2163709103470266, 1440302280256872, - 1769143160546397, 869830310425069 -#else - 60263160, 15791201, 8550074, 32241778, 29928808, 21462176, - 27534429, 26362287, 44757485, 12961481 -#endif - }}, + {0x7f, 0x7a, 0x30, 0x43, 0x1, 0x71, 0x5a, 0x9d, 0x5f, 0xa4, 0x7d, + 0xc4, 0x9e, 0xde, 0x63, 0xb0, 0xd3, 0x7a, 0x92, 0xbe, 0x52, 0xfe, + 0xbb, 0x22, 0x6c, 0x42, 0x40, 0xfd, 0x41, 0xc4, 0x87, 0x13}, + {0x14, 0x2d, 0xad, 0x5e, 0x38, 0x66, 0xf7, 0x4a, 0x30, 0x58, 0x7c, + 0xca, 0x80, 0xd8, 0x8e, 0xa0, 0x3d, 0x1e, 0x21, 0x10, 0xe6, 0xa6, + 0x13, 0xd, 0x3, 0x6c, 0x80, 0x7b, 0xe1, 0x1c, 0x7, 0x6a}, + {0xf8, 0x8a, 0x97, 0x87, 0xd1, 0xc3, 0xd3, 0xb5, 0x13, 0x44, 0xe, + 0x7f, 0x3d, 0x5a, 0x2b, 0x72, 0xa0, 0x7c, 0x47, 0xbb, 0x48, 0x48, + 0x7b, 0xd, 0x92, 0xdc, 0x1e, 0xaf, 0x6a, 0xb2, 0x71, 0x31}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1609516219779025, 777277757338817, 2101121130363987, - 550762194946473, 1905542338659364 -#else - 42616785, 23983660, 10368193, 11582341, 43711571, 31309144, - 16533929, 8206996, 36914212, 28394793 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2024821921041576, 426948675450149, 595133284085473, - 471860860885970, 600321679413000 -#else - 55987368, 30172197, 2307365, 6362031, 66973409, 8868176, - 50273234, 7031274, 7589640, 8945490 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 598474602406721, 1468128276358244, 1191923149557635, - 1501376424093216, 1281662691293476 -#else - 34956097, 8917966, 6661220, 21876816, 65916803, 17761038, - 7251488, 22372252, 24099108, 19098262 -#endif - }}, + {0xd1, 0x47, 0x8a, 0xb2, 0xd8, 0xb7, 0xd, 0xa6, 0xf1, 0xa4, 0x70, + 0x17, 0xd6, 0x14, 0xbf, 0xa6, 0x58, 0xbd, 0xdd, 0x53, 0x93, 0xf8, + 0xa1, 0xd4, 0xe9, 0x43, 0x42, 0x34, 0x63, 0x4a, 0x51, 0x6c}, + {0xa8, 0x4c, 0x56, 0x97, 0x90, 0x31, 0x2f, 0xa9, 0x19, 0xe1, 0x75, + 0x22, 0x4c, 0xb8, 0x7b, 0xff, 0x50, 0x51, 0x87, 0xa4, 0x37, 0xfe, + 0x55, 0x4f, 0x5a, 0x83, 0xf0, 0x3c, 0x87, 0xd4, 0x1f, 0x22}, + {0x41, 0x63, 0x15, 0x3a, 0x4f, 0x20, 0x22, 0x23, 0x2d, 0x3, 0xa, + 0xba, 0xe9, 0xe0, 0x73, 0xfb, 0xe, 0x3, 0xf, 0x41, 0x4c, 0xdd, + 0xe0, 0xfc, 0xaa, 0x4a, 0x92, 0xfb, 0x96, 0xa5, 0xda, 0x48}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1721138489890707, 1264336102277790, 433064545421287, - 1359988423149466, 1561871293409447 -#else - 5019539, 25646962, 4244126, 18840076, 40175591, 6453164, - 47990682, 20265406, 60876967, 23273695 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 719520245587143, 393380711632345, 132350400863381, - 1543271270810729, 1819543295798660 -#else - 10853575, 10721687, 26480089, 5861829, 44113045, 1972174, - 65242217, 22996533, 63745412, 27113307 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 396397949784152, 1811354474471839, 1362679985304303, - 2117033964846756, 498041172552279 -#else - 50106456, 5906789, 221599, 26991285, 7828207, 20305514, - 24362660, 31546264, 53242455, 7421391 -#endif - }}, + {0x93, 0x97, 0x4c, 0xc8, 0x5d, 0x1d, 0xf6, 0x14, 0x6, 0x82, 0x41, + 0xef, 0xe3, 0xf9, 0x41, 0x99, 0xac, 0x77, 0x62, 0x34, 0x8f, 0xb8, + 0xf5, 0xcd, 0xa9, 0x79, 0x8a, 0xe, 0xfa, 0x37, 0xc8, 0x58}, + {0xc7, 0x9c, 0xa5, 0x5c, 0x66, 0x8e, 0xca, 0x6e, 0xa0, 0xac, 0x38, + 0x2e, 0x4b, 0x25, 0x47, 0xa8, 0xce, 0x17, 0x1e, 0xd2, 0x8, 0xc7, + 0xaf, 0x31, 0xf7, 0x4a, 0xd8, 0xca, 0xfc, 0xd6, 0x6d, 0x67}, + {0x58, 0x90, 0xfc, 0x96, 0x85, 0x68, 0xf9, 0xc, 0x1b, 0xa0, 0x56, + 0x7b, 0xf3, 0xbb, 0xdc, 0x1d, 0x6a, 0xd6, 0x35, 0x49, 0x7d, 0xe7, + 0xc2, 0xdc, 0xa, 0x7f, 0xa5, 0xc6, 0xf2, 0x73, 0x4f, 0x1c}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1812471844975748, 1856491995543149, 126579494584102, - 1036244859282620, 1975108050082550 -#else - 8139908, 27007935, 32257645, 27663886, 30375718, 1886181, - 45933756, 15441251, 28826358, 29431403 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 650623932407995, 1137551288410575, 2125223403615539, - 1725658013221271, 2134892965117796 -#else - 6267067, 9695052, 7709135, 16950835, 34239795, 31668296, - 14795159, 25714308, 13746020, 31812384 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 522584000310195, 1241762481390450, 1743702789495384, - 2227404127826575, 1686746002148897 -#else - 28584883, 7787108, 60375922, 18503702, 22846040, 25983196, - 63926927, 33190907, 4771361, 25134474 -#endif - }}, + {0x84, 0x34, 0x7c, 0xfc, 0x6e, 0x70, 0x6e, 0xb3, 0x61, 0xcf, 0xc1, + 0xc3, 0xb4, 0xc9, 0xdf, 0x73, 0xe5, 0xc7, 0x1c, 0x78, 0xc9, 0x79, + 0x1d, 0xeb, 0x5c, 0x67, 0xaf, 0x7d, 0xdb, 0x9a, 0x45, 0x70}, + {0xbb, 0xa0, 0x5f, 0x30, 0xbd, 0x4f, 0x7a, 0xe, 0xad, 0x63, 0xc6, + 0x54, 0xe0, 0x4c, 0x9d, 0x82, 0x48, 0x38, 0xe3, 0x2f, 0x83, 0xc3, + 0x21, 0xf4, 0x42, 0x4c, 0xf6, 0x1b, 0xd, 0xc8, 0x5a, 0x79}, + {0xb3, 0x2b, 0xb4, 0x91, 0x49, 0xdb, 0x91, 0x1b, 0xca, 0xdc, 0x2, + 0x4b, 0x23, 0x96, 0x26, 0x57, 0xdc, 0x78, 0x8c, 0x1f, 0xe5, 0x9e, + 0xdf, 0x9f, 0xd3, 0x1f, 0xe2, 0x8c, 0x84, 0x62, 0xe1, 0x5f}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 427904865186312, 1703211129693455, 1585368107547509, - 1436984488744336, 761188534613978 -#else - 24949256, 6376279, 39642383, 25379823, 48462709, 23623825, - 33543568, 21412737, 3569626, 11342593 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 318101947455002, 248138407995851, 1481904195303927, - 309278454311197, 1258516760217879 -#else - 26514970, 4740088, 27912651, 3697550, 19331575, 22082093, - 6809885, 4608608, 7325975, 18753361 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1275068538599310, 513726919533379, 349926553492294, - 688428871968420, 1702400196000666 -#else - 55490446, 19000001, 42787651, 7655127, 65739590, 5214311, - 39708324, 10258389, 49462170, 25367739 -#endif - }}, + {0x8, 0xb2, 0x7c, 0x5d, 0x2d, 0x85, 0x79, 0x28, 0xe7, 0xf2, 0x7d, + 0x68, 0x70, 0xdd, 0xde, 0xb8, 0x91, 0x78, 0x68, 0x21, 0xab, 0xff, + 0xb, 0xdc, 0x35, 0xaa, 0x7d, 0x67, 0x43, 0xc0, 0x44, 0x2b}, + {0x1a, 0x96, 0x94, 0xe1, 0x4f, 0x21, 0x59, 0x4e, 0x4f, 0xcd, 0x71, + 0xd, 0xc7, 0x7d, 0xbe, 0x49, 0x2d, 0xf2, 0x50, 0x3b, 0xd2, 0xcf, + 0x0, 0x93, 0x32, 0x72, 0x91, 0xfc, 0x46, 0xd4, 0x89, 0x47}, + {0x8e, 0xb7, 0x4e, 0x7, 0xab, 0x87, 0x1c, 0x1a, 0x67, 0xf4, 0xda, + 0x99, 0x8e, 0xd1, 0xc6, 0xfa, 0x67, 0x90, 0x4f, 0x48, 0xcd, 0xbb, + 0xac, 0x3e, 0xe4, 0xa4, 0xb9, 0x2b, 0xef, 0x2e, 0xc5, 0x60}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1061864036265233, 961611260325381, 321859632700838, - 1045600629959517, 1985130202504038 -#else - 11431185, 15823007, 26570245, 14329124, 18029990, 4796082, - 35662685, 15580663, 9280358, 29580745 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1558816436882417, 1962896332636523, 1337709822062152, - 1501413830776938, 294436165831932 -#else - 66948081, 23228174, 44253547, 29249434, 46247496, 19933429, - 34297962, 22372809, 51563772, 4387440 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 818359826554971, 1862173000996177, 626821592884859, - 573655738872376, 1749691246745455 -#else - 46309467, 12194511, 3937617, 27748540, 39954043, 9340369, - 42594872, 8548136, 20617071, 26072431 -#endif - }}, + {0x11, 0x6d, 0xae, 0x7c, 0xc2, 0xc5, 0x2b, 0x70, 0xab, 0x8c, 0xa4, + 0x54, 0x9b, 0x69, 0xc7, 0x44, 0xb2, 0x2e, 0x49, 0xba, 0x56, 0x40, + 0xbc, 0xef, 0x6d, 0x67, 0xb6, 0xd9, 0x48, 0x72, 0xd7, 0x70}, + {0xf1, 0x8b, 0xfd, 0x3b, 0xbc, 0x89, 0x5d, 0xb, 0x1a, 0x55, 0xf3, + 0xc9, 0x37, 0x92, 0x6b, 0xb0, 0xf5, 0x28, 0x30, 0xd5, 0xb0, 0x16, + 0x4c, 0xe, 0xab, 0xca, 0xcf, 0x2c, 0x31, 0x9c, 0xbc, 0x10}, + {0x5b, 0xa0, 0xc2, 0x3e, 0x4b, 0xe8, 0x8a, 0xaa, 0xe0, 0x81, 0x17, + 0xed, 0xf4, 0x9e, 0x69, 0x98, 0xd1, 0x85, 0x8e, 0x70, 0xe4, 0x13, + 0x45, 0x79, 0x13, 0xf4, 0x76, 0xa9, 0xd3, 0x5b, 0x75, 0x63}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1988022651432119, 1082111498586040, 1834020786104821, - 1454826876423687, 692929915223122 -#else - 66170039, 29623845, 58394552, 16124717, 24603125, 27329039, - 53333511, 21678609, 24345682, 10325460 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2146513703733331, 584788900394667, 464965657279958, - 2183973639356127, 238371159456790 -#else - 47253587, 31985546, 44906155, 8714033, 14007766, 6928528, - 16318175, 32543743, 4766742, 3552007 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1129007025494441, 2197883144413266, 265142755578169, - 971864464758890, 1983715884903702 -#else - 45357481, 16823515, 1351762, 32751011, 63099193, 3950934, - 3217514, 14481909, 10988822, 29559670 -#endif - }}, + {0xb7, 0xac, 0xf1, 0x97, 0x18, 0x10, 0xc7, 0x3d, 0xd8, 0xbb, 0x65, + 0xc1, 0x5e, 0x7d, 0xda, 0x5d, 0xf, 0x2, 0xa1, 0xf, 0x9c, 0x5b, + 0x8e, 0x50, 0x56, 0x2a, 0xc5, 0x37, 0x17, 0x75, 0x63, 0x27}, + {0x53, 0x8, 0xd1, 0x2a, 0x3e, 0xa0, 0x5f, 0xb5, 0x69, 0x35, 0xe6, + 0x9e, 0x90, 0x75, 0x6f, 0x35, 0x90, 0xb8, 0x69, 0xbe, 0xfd, 0xf1, + 0xf9, 0x9f, 0x84, 0x6f, 0xc1, 0x8b, 0xc4, 0xc1, 0x8c, 0xd}, + {0xa9, 0x19, 0xb4, 0x6e, 0xd3, 0x2, 0x94, 0x2, 0xa5, 0x60, 0xb4, + 0x77, 0x7e, 0x4e, 0xb4, 0xf0, 0x56, 0x49, 0x3c, 0xd4, 0x30, 0x62, + 0xa8, 0xcf, 0xe7, 0x66, 0xd1, 0x7a, 0x8a, 0xdd, 0xc2, 0x70}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1291366624493075, 381456718189114, 1711482489312444, - 1815233647702022, 892279782992467 -#else - 15564307, 19242862, 3101242, 5684148, 30446780, 25503076, - 12677126, 27049089, 58813011, 13296004 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 444548969917454, 1452286453853356, 2113731441506810, - 645188273895859, 810317625309512 -#else - 57666574, 6624295, 36809900, 21640754, 62437882, 31497052, - 31521203, 9614054, 37108040, 12074673 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2242724082797924, 1373354730327868, 1006520110883049, - 2147330369940688, 1151816104883620 -#else - 4771172, 33419193, 14290748, 20464580, 27992297, 14998318, - 65694928, 31997715, 29832612, 17163397 -#endif - }}, + {0x13, 0x7e, 0xed, 0xb8, 0x7d, 0x96, 0xd4, 0x91, 0x7a, 0x81, 0x76, + 0xd7, 0xa, 0x2f, 0x25, 0x74, 0x64, 0x25, 0x85, 0xd, 0xe0, 0x82, + 0x9, 0xe4, 0xe5, 0x3c, 0xa5, 0x16, 0x38, 0x61, 0xb8, 0x32}, + {0xe, 0xec, 0x6f, 0x9f, 0x50, 0x94, 0x61, 0x65, 0x8d, 0x51, 0xc6, + 0x46, 0xa9, 0x7e, 0x2e, 0xee, 0x5c, 0x9b, 0xe0, 0x67, 0xf3, 0xc1, + 0x33, 0x97, 0x95, 0x84, 0x94, 0x63, 0x63, 0xac, 0xf, 0x2e}, + {0x64, 0xcd, 0x48, 0xe4, 0xbe, 0xf7, 0xe7, 0x79, 0xd0, 0x86, 0x78, + 0x8, 0x67, 0x3a, 0xc8, 0x6a, 0x2e, 0xdb, 0xe4, 0xa0, 0xd9, 0xd4, + 0x9f, 0xf8, 0x41, 0x4f, 0x5a, 0x73, 0x5c, 0x21, 0x79, 0x41}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1745720200383796, 1911723143175317, 2056329390702074, - 355227174309849, 879232794371100 -#else - 7064884, 26013258, 47946901, 28486894, 48217594, 30641695, - 25825241, 5293297, 39986204, 13101589 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 163723479936298, 115424889803150, 1156016391581227, - 1894942220753364, 1970549419986329 -#else - 64810282, 2439669, 59642254, 1719964, 39841323, 17225986, - 32512468, 28236839, 36752793, 29363474 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 681981452362484, 267208874112496, 1374683991933094, - 638600984916117, 646178654558546 -#else - 37102324, 10162315, 33928688, 3981722, 50626726, 20484387, - 14413973, 9515896, 19568978, 9628812 -#endif - }}, + {0x34, 0xcd, 0x6b, 0x28, 0xb9, 0x33, 0xae, 0xe4, 0xdc, 0xd6, 0x9d, + 0x55, 0xb6, 0x7e, 0xef, 0xb7, 0x1f, 0x8e, 0xd3, 0xb3, 0x1f, 0x14, + 0x8b, 0x27, 0x86, 0xc2, 0x41, 0x22, 0x66, 0x85, 0xfa, 0x31}, + {0x2a, 0xed, 0xdc, 0xd7, 0xe7, 0x94, 0x70, 0x8c, 0x70, 0x9c, 0xd3, + 0x47, 0xc3, 0x8a, 0xfb, 0x97, 0x2, 0xd9, 0x6, 0xa9, 0x33, 0xe0, + 0x3b, 0xe1, 0x76, 0x9d, 0xd9, 0xc, 0xa3, 0x44, 0x3, 0x70}, + {0xf4, 0x22, 0x36, 0x2e, 0x42, 0x6c, 0x82, 0xaf, 0x2d, 0x50, 0x33, + 0x98, 0x87, 0x29, 0x20, 0xc1, 0x23, 0x91, 0x38, 0x2b, 0xe1, 0xb7, + 0xc1, 0x9b, 0x89, 0x24, 0x95, 0xa9, 0x12, 0x23, 0xbb, 0x24}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 13378654854251, 106237307029567, 1944412051589651, - 1841976767925457, 230702819835573 -#else - 33053803, 199357, 15894591, 1583059, 27380243, 28973997, - 49269969, 27447592, 60817077, 3437739 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 260683893467075, 854060306077237, 913639551980112, - 4704576840123, 280254810808712 -#else - 48129987, 3884492, 19469877, 12726490, 15913552, 13614290, - 44147131, 70103, 7463304, 4176122 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 715374893080287, 1173334812210491, 1806524662079626, - 1894596008000979, 398905715033393 -#else - 39984863, 10659916, 11482427, 17484051, 12771466, 26919315, - 34389459, 28231680, 24216881, 5944158 -#endif - }}, + {0x6b, 0x5c, 0xf8, 0xf5, 0x2a, 0xc, 0xf8, 0x41, 0x94, 0x67, 0xfa, + 0x4, 0xc3, 0x84, 0x72, 0x68, 0xad, 0x1b, 0xba, 0xa3, 0x99, 0xdf, + 0x45, 0x89, 0x16, 0x5d, 0xeb, 0xff, 0xf9, 0x2a, 0x1d, 0xd}, + {0xc3, 0x67, 0xde, 0x32, 0x17, 0xed, 0xa8, 0xb1, 0x48, 0x49, 0x1b, + 0x46, 0x18, 0x94, 0xb4, 0x3c, 0xd2, 0xbc, 0xcf, 0x76, 0x43, 0x43, + 0xbd, 0x8e, 0x8, 0x80, 0x18, 0x1e, 0x87, 0x3e, 0xee, 0xf}, + {0xdf, 0x1e, 0x62, 0x32, 0xa1, 0x8a, 0xda, 0xa9, 0x79, 0x65, 0x22, + 0x59, 0xa1, 0x22, 0xb8, 0x30, 0x93, 0xc1, 0x9a, 0xa7, 0x7b, 0x19, + 0x4, 0x40, 0x76, 0x1d, 0x53, 0x18, 0x97, 0xd7, 0xac, 0x16}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 500026409727661, 1596431288195371, 1420380351989370, - 985211561521489, 392444930785633 -#else - 8894125, 7450974, 64444715, 23788679, 39028346, 21165316, - 19345745, 14680796, 11632993, 5847885 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2096421546958141, 1922523000950363, 789831022876840, - 427295144688779, 320923973161730 -#else - 26942781, 31239115, 9129563, 28647825, 26024104, 11769399, - 55590027, 6367193, 57381634, 4782139 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1927770723575450, 1485792977512719, 1850996108474547, - 551696031508956, 2126047405475647 -#else - 19916442, 28726022, 44198159, 22140040, 25606323, 27581991, - 33253852, 8220911, 6358847, 31680575 -#endif - }}, + {0xad, 0xb6, 0x87, 0x78, 0xc5, 0xc6, 0x59, 0xc9, 0xba, 0xfe, 0x90, + 0x5f, 0xad, 0x9e, 0xe1, 0x94, 0x4, 0xf5, 0x42, 0xa3, 0x62, 0x4e, + 0xe2, 0x16, 0x0, 0x17, 0x16, 0x18, 0x4b, 0xd3, 0x4e, 0x16}, + {0x3d, 0x1d, 0x9b, 0x2d, 0xaf, 0x72, 0xdf, 0x72, 0x5a, 0x24, 0x32, + 0xa4, 0x36, 0x2a, 0x46, 0x63, 0x37, 0x96, 0xb3, 0x16, 0x79, 0xa0, + 0xce, 0x3e, 0x9, 0x23, 0x30, 0xb9, 0xf6, 0xe, 0x3e, 0x12}, + {0x9a, 0xe6, 0x2f, 0x19, 0x4c, 0xd9, 0x7e, 0x48, 0x13, 0x15, 0x91, + 0x3a, 0xea, 0x2c, 0xae, 0x61, 0x27, 0xde, 0xa4, 0xb9, 0xd3, 0xf6, + 0x7b, 0x87, 0xeb, 0xf3, 0x73, 0x10, 0xc6, 0xf, 0xda, 0x78}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2112099158080148, 742570803909715, 6484558077432, - 1951119898618916, 93090382703416 -#else - 801428, 31472730, 16569427, 11065167, 29875704, 96627, 7908388, - 29073952, 53570360, 1387154 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 383905201636970, 859946997631870, 855623867637644, - 1017125780577795, 794250831877809 -#else - 19646058, 5720633, 55692158, 12814208, 11607948, 12749789, - 14147075, 15156355, 45242033, 11835259 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 77571826285752, 999304298101753, 487841111777762, - 1038031143212339, 339066367948762 -#else - 19299512, 1155910, 28703737, 14890794, 2925026, 7269399, - 26121523, 15467869, 40548314, 5052482 -#endif - }}, + {0x94, 0x3a, 0xc, 0x68, 0xf1, 0x80, 0x9f, 0xa2, 0xe6, 0xe7, 0xe9, + 0x1a, 0x15, 0x7e, 0xf7, 0x71, 0x73, 0x79, 0x1, 0x48, 0x58, 0xf1, + 0x0, 0x11, 0xdd, 0x8d, 0xb3, 0x16, 0xb3, 0xa4, 0x4a, 0x5}, + {0x6a, 0xc6, 0x2b, 0xe5, 0x28, 0x5d, 0xf1, 0x5b, 0x8e, 0x1a, 0xf0, + 0x70, 0x18, 0xe3, 0x47, 0x2c, 0xdd, 0x8b, 0xc2, 0x6, 0xbc, 0xaf, + 0x19, 0x24, 0x3a, 0x17, 0x6b, 0x25, 0xeb, 0xde, 0x25, 0x2d}, + {0xb8, 0x7c, 0x26, 0x19, 0x8d, 0x46, 0xc8, 0xdf, 0xaf, 0x4d, 0xe5, + 0x66, 0x9c, 0x78, 0x28, 0xb, 0x17, 0xec, 0x6e, 0x66, 0x2a, 0x1d, + 0xeb, 0x2a, 0x60, 0xa7, 0x7d, 0xab, 0xa6, 0x10, 0x46, 0x13}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 674994775520533, 266035846330789, 826951213393478, - 1405007746162285, 1781791018620876 -#else - 64091413, 10058205, 1980837, 3964243, 22160966, 12322533, - 60677741, 20936246, 12228556, 26550755 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1001412661522686, 348196197067298, 1666614366723946, - 888424995032760, 580747687801357 -#else - 32944382, 14922211, 44263970, 5188527, 21913450, 24834489, - 4001464, 13238564, 60994061, 8653814 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1939560076207777, 1409892634407635, 552574736069277, - 383854338280405, 190706709864139 -#else - 22865569, 28901697, 27603667, 21009037, 14348957, 8234005, - 24808405, 5719875, 28483275, 2841751 -#endif - }}, + {0x15, 0xf5, 0xd1, 0x77, 0xe7, 0x65, 0x2a, 0xcd, 0xf1, 0x60, 0xaa, + 0x8f, 0x87, 0x91, 0x89, 0x54, 0xe5, 0x6, 0xbc, 0xda, 0xbc, 0x3b, + 0xb7, 0xb1, 0xfb, 0xc9, 0x7c, 0xa9, 0xcb, 0x78, 0x48, 0x65}, + {0xfe, 0xb0, 0xf6, 0x8d, 0xc7, 0x8e, 0x13, 0x51, 0x1b, 0xf5, 0x75, + 0xe5, 0x89, 0xda, 0x97, 0x53, 0xb9, 0xf1, 0x7a, 0x71, 0x1d, 0x7a, + 0x20, 0x9, 0x50, 0xd6, 0x20, 0x2b, 0xba, 0xfd, 0x2, 0x21}, + {0xa1, 0xe6, 0x5c, 0x5, 0x5, 0xe4, 0x9e, 0x96, 0x29, 0xad, 0x51, + 0x12, 0x68, 0xa7, 0xbc, 0x36, 0x15, 0xa4, 0x7d, 0xaa, 0x17, 0xf5, + 0x1a, 0x3a, 0xba, 0xb2, 0xec, 0x29, 0xdb, 0x25, 0xd7, 0xa}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2177087163428741, 1439255351721944, 1208070840382793, - 2230616362004769, 1396886392021913 -#else - 50687877, 32441126, 66781144, 21446575, 21886281, 18001658, - 65220897, 33238773, 19932057, 20815229 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 676962063230039, 1880275537148808, 2046721011602706, - 888463247083003, 1318301552024067 -#else - 55452759, 10087520, 58243976, 28018288, 47830290, 30498519, - 3999227, 13239134, 62331395, 19644223 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1466980508178206, 617045217998949, 652303580573628, - 757303753529064, 207583137376902 -#else - 1382174, 21859713, 17266789, 9194690, 53784508, 9720080, - 20403944, 11284705, 53095046, 3093229 -#endif - }}, + {0x85, 0x6f, 0x5, 0x9b, 0xc, 0xbc, 0xc7, 0xfe, 0xd7, 0xff, 0xf5, + 0xe7, 0x68, 0x52, 0x7d, 0x53, 0xfa, 0xae, 0x12, 0x43, 0x62, 0xc6, + 0xaf, 0x77, 0xd9, 0x9f, 0x39, 0x2, 0x53, 0x5f, 0x67, 0x4f}, + {0x57, 0x24, 0x4e, 0x83, 0xb1, 0x67, 0x42, 0xdc, 0xc5, 0x1b, 0xce, + 0x70, 0xb5, 0x44, 0x75, 0xb6, 0xd7, 0x5e, 0xd1, 0xf7, 0xb, 0x7a, + 0xf0, 0x1a, 0x50, 0x36, 0xa0, 0x71, 0xfb, 0xcf, 0xef, 0x4a}, + {0x1e, 0x17, 0x15, 0x4, 0x36, 0x36, 0x2d, 0xc3, 0x3b, 0x48, 0x98, + 0x89, 0x11, 0xef, 0x2b, 0xcd, 0x10, 0x51, 0x94, 0xd0, 0xad, 0x6e, + 0xa, 0x87, 0x61, 0x65, 0xa8, 0xa2, 0x72, 0xbb, 0xcc, 0xb}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1511056752906902, 105403126891277, 493434892772846, - 1091943425335976, 1802717338077427 -#else - 16650902, 22516500, 66044685, 1570628, 58779118, 7352752, - 66806440, 16271224, 43059443, 26862581 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1853982405405128, 1878664056251147, 1528011020803992, - 1019626468153565, 1128438412189035 -#else - 45197768, 27626490, 62497547, 27994275, 35364760, 22769138, - 24123613, 15193618, 45456747, 16815042 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1963939888391106, 293456433791664, 697897559513649, - 985882796904380, 796244541237972 -#else - 57172930, 29264984, 41829040, 4372841, 2087473, 10399484, - 31870908, 14690798, 17361620, 11864968 -#endif - }}, + {0x96, 0x12, 0xfe, 0x50, 0x4c, 0x5e, 0x6d, 0x18, 0x7e, 0x9f, 0xe8, + 0xfe, 0x82, 0x7b, 0x39, 0xe0, 0xb0, 0x31, 0x70, 0x50, 0xc5, 0xf6, + 0xc7, 0x3b, 0xc2, 0x37, 0x8f, 0x10, 0x69, 0xfd, 0x78, 0x66}, + {0xc8, 0xa9, 0xb1, 0xea, 0x2f, 0x96, 0x5e, 0x18, 0xcd, 0x7d, 0x14, + 0x65, 0x35, 0xe6, 0xe7, 0x86, 0xf2, 0x6d, 0x5b, 0xbb, 0x31, 0xe0, + 0x92, 0xb0, 0x3e, 0xb7, 0xd6, 0x59, 0xab, 0xf0, 0x24, 0x40}, + {0xc2, 0x63, 0x68, 0x63, 0x31, 0xfa, 0x86, 0x15, 0xf2, 0x33, 0x2d, + 0x57, 0x48, 0x8c, 0xf6, 0x7, 0xfc, 0xae, 0x9e, 0x78, 0x9f, 0xcc, + 0x73, 0x4f, 0x1, 0x47, 0xad, 0x8e, 0x10, 0xe2, 0x42, 0x2d}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 416770998629779, 389655552427054, 1314476859406756, - 1749382513022778, 1161905598739491 -#else - 55801235, 6210371, 13206574, 5806320, 38091172, 19587231, - 54777658, 26067830, 41530403, 17313742 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1428358296490651, 1027115282420478, 304840698058337, - 441410174026628, 1819358356278573 -#else - 14668443, 21284197, 26039038, 15305210, 25515617, 4542480, - 10453892, 6577524, 9145645, 27110552 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 204943430200135, 1554861433819175, 216426658514651, - 264149070665950, 2047097371738319 -#else - 5974855, 3053895, 57675815, 23169240, 35243739, 3225008, - 59136222, 3936127, 61456591, 30504127 -#endif - }}, + {0x93, 0x75, 0x53, 0xf, 0xd, 0x7b, 0x71, 0x21, 0x4c, 0x6, 0x1e, + 0x13, 0xb, 0x69, 0x4e, 0x91, 0x9f, 0xe0, 0x2a, 0x75, 0xae, 0x87, + 0xb6, 0x1b, 0x6e, 0x3c, 0x42, 0x9b, 0xa7, 0xf3, 0xb, 0x42}, + {0x9b, 0xd2, 0xdf, 0x94, 0x15, 0x13, 0xf5, 0x97, 0x6a, 0x4c, 0x3f, + 0x31, 0x5d, 0x98, 0x55, 0x61, 0x10, 0x50, 0x45, 0x8, 0x7, 0x3f, + 0xa1, 0xeb, 0x22, 0xd3, 0xd2, 0xb8, 0x8, 0x26, 0x6b, 0x67}, + {0x47, 0x2b, 0x5b, 0x1c, 0x65, 0xba, 0x38, 0x81, 0x80, 0x1b, 0x1b, + 0x31, 0xec, 0xb6, 0x71, 0x86, 0xb0, 0x35, 0x31, 0xbc, 0xb1, 0xc, + 0xff, 0x7b, 0xe0, 0xf1, 0xc, 0x9c, 0xfa, 0x2f, 0x5d, 0x74}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1934415182909034, 1393285083565062, 516409331772960, - 1157690734993892, 121039666594268 -#else - 30625386, 28825032, 41552902, 20761565, 46624288, 7695098, - 17097188, 17250936, 39109084, 1803631 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 662035583584445, 286736105093098, 1131773000510616, - 818494214211439, 472943792054479 -#else - 63555773, 9865098, 61880298, 4272700, 61435032, 16864731, - 14911343, 12196514, 45703375, 7047411 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 665784778135882, 1893179629898606, 808313193813106, - 276797254706413, 1563426179676396 -#else - 20093258, 9920966, 55970670, 28210574, 13161586, 12044805, - 34252013, 4124600, 34765036, 23296865 -#endif - }}, + {0x6a, 0x4e, 0xd3, 0x21, 0x57, 0xdf, 0x36, 0x60, 0xd0, 0xb3, 0x7b, + 0x99, 0x27, 0x88, 0xdb, 0xb1, 0xfa, 0x6a, 0x75, 0xc8, 0xc3, 0x9, + 0xc2, 0xd3, 0x39, 0xc8, 0x1d, 0x4c, 0xe5, 0x5b, 0xe1, 0x6}, + {0xbd, 0xc8, 0xc9, 0x2b, 0x1e, 0x5a, 0x52, 0xbf, 0x81, 0x9d, 0x47, + 0x26, 0x8, 0x26, 0x5b, 0xea, 0xdb, 0x55, 0x1, 0xdf, 0xe, 0xc7, + 0x11, 0xd5, 0xd0, 0xf5, 0xc, 0x96, 0xeb, 0x3c, 0xe2, 0x1a}, + {0x4a, 0x99, 0x32, 0x19, 0x87, 0x5d, 0x72, 0x5b, 0xb0, 0xda, 0xb1, + 0xce, 0xb5, 0x1c, 0x35, 0x32, 0x5, 0xca, 0xb7, 0xda, 0x49, 0x15, + 0xc4, 0x7d, 0xf7, 0xc1, 0x8e, 0x27, 0x61, 0xd8, 0xde, 0x58}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 945205108984232, 526277562959295, 1324180513733566, - 1666970227868664, 153547609289173 -#else - 46320040, 14084653, 53577151, 7842146, 19119038, 19731827, - 4752376, 24839792, 45429205, 2288037 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2031433403516252, 203996615228162, 170487168837083, - 981513604791390, 843573964916831 -#else - 40289628, 30270716, 29965058, 3039786, 52635099, 2540456, - 29457502, 14625692, 42289247, 12570231 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1476570093962618, 838514669399805, 1857930577281364, - 2017007352225784, 317085545220047 -#else - 66045306, 22002608, 16920317, 12494842, 1278292, 27685323, - 45948920, 30055751, 55134159, 4724942 -#endif - }}, + {0xa8, 0xc9, 0xc2, 0xb6, 0xa8, 0x5b, 0xfb, 0x2d, 0x8c, 0x59, 0x2c, + 0xf5, 0x8e, 0xef, 0xee, 0x48, 0x73, 0x15, 0x2d, 0xf1, 0x7, 0x91, + 0x80, 0x33, 0xd8, 0x5b, 0x1d, 0x53, 0x6b, 0x69, 0xba, 0x8}, + {0x5c, 0xc5, 0x66, 0xf2, 0x93, 0x37, 0x17, 0xd8, 0x49, 0x4e, 0x45, + 0xcc, 0xc5, 0x76, 0xc9, 0xc8, 0xa8, 0xc3, 0x26, 0xbc, 0xf8, 0x82, + 0xe3, 0x5c, 0xf9, 0xf6, 0x85, 0x54, 0xe8, 0x9d, 0xf3, 0x2f}, + {0x7a, 0xc5, 0xef, 0xc3, 0xee, 0x3e, 0xed, 0x77, 0x11, 0x48, 0xff, + 0xd4, 0x17, 0x55, 0xe0, 0x4, 0xcb, 0x71, 0xa6, 0xf1, 0x3f, 0x7a, + 0x3d, 0xea, 0x54, 0xfe, 0x7c, 0x94, 0xb4, 0x33, 0x6, 0x12}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1461557121912842, 1600674043318359, 2157134900399597, - 1670641601940616, 127765583803283 -#else - 17960970, 21778898, 62967895, 23851901, 58232301, 32143814, - 54201480, 24894499, 37532563, 1903855 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1293543509393474, 2143624609202546, 1058361566797508, - 214097127393994, 946888515472729 -#else - 23134274, 19275300, 56426866, 31942495, 20684484, 15770816, - 54119114, 3190295, 26955097, 14109738 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 357067959932916, 1290876214345711, 521245575443703, - 1494975468601005, 800942377643885 -#else - 15308788, 5320727, 36995055, 19235554, 22902007, 7767164, - 29425325, 22276870, 31960941, 11934971 -#endif - }}, + {0xa, 0x10, 0x12, 0x49, 0x47, 0x31, 0xbd, 0x82, 0x6, 0xbe, 0x6f, + 0x7e, 0x6d, 0x7b, 0x23, 0xde, 0xc6, 0x79, 0xea, 0x11, 0x19, 0x76, + 0x1e, 0xe1, 0xde, 0x3b, 0x39, 0xcb, 0xe3, 0x3b, 0x43, 0x7}, + {0x42, 0x0, 0x61, 0x91, 0x78, 0x98, 0x94, 0xb, 0xe8, 0xfa, 0xeb, + 0xec, 0x3c, 0xb1, 0xe7, 0x4e, 0xc0, 0xa4, 0xf0, 0x94, 0x95, 0x73, + 0xbe, 0x70, 0x85, 0x91, 0xd5, 0xb4, 0x99, 0xa, 0xd3, 0x35}, + {0xf4, 0x97, 0xe9, 0x5c, 0xc0, 0x44, 0x79, 0xff, 0xa3, 0x51, 0x5c, + 0xb0, 0xe4, 0x3d, 0x5d, 0x57, 0x7c, 0x84, 0x76, 0x5a, 0xfd, 0x81, + 0x33, 0x58, 0x9f, 0xda, 0xf6, 0x7a, 0xde, 0x3e, 0x87, 0x2d}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 566116659100033, 820247422481740, 994464017954148, - 327157611686365, 92591318111744 -#else - 39713153, 8435795, 4109644, 12222639, 42480996, 14818668, - 20638173, 4875028, 10491392, 1379718 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 617256647603209, 1652107761099439, 1857213046645471, - 1085597175214970, 817432759830522 -#else - 53949449, 9197840, 3875503, 24618324, 65725151, 27674630, - 33518458, 16176658, 21432314, 12180697 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 771808161440705, 1323510426395069, 680497615846440, - 851580615547985, 1320806384849017 -#else - 55321537, 11500837, 13787581, 19721842, 44678184, 10140204, - 1465425, 12689540, 56807545, 19681548 -#endif - }}, + {0x81, 0xf9, 0x5d, 0x4e, 0xe1, 0x2, 0x62, 0xaa, 0xf5, 0xe1, 0x15, + 0x50, 0x17, 0x59, 0xd, 0xa2, 0x6c, 0x1d, 0xe2, 0xba, 0xd3, 0x75, + 0xa2, 0x18, 0x53, 0x2, 0x60, 0x1, 0x8a, 0x61, 0x43, 0x5}, + {0x9, 0x34, 0x37, 0x43, 0x64, 0x31, 0x7a, 0x15, 0xd9, 0x81, 0xaa, + 0xf4, 0xee, 0xb7, 0xb8, 0xfa, 0x6, 0x48, 0xa6, 0xf5, 0xe6, 0xfe, + 0x93, 0xb0, 0xb6, 0xa7, 0x7f, 0x70, 0x54, 0x36, 0x77, 0x2e}, + {0xc1, 0x23, 0x4c, 0x97, 0xf4, 0xbd, 0xea, 0xd, 0x93, 0x46, 0xce, + 0x9d, 0x25, 0xa, 0x6f, 0xaa, 0x2c, 0xba, 0x9a, 0xa2, 0xb8, 0x2c, + 0x20, 0x4, 0xd, 0x96, 0x7, 0x2d, 0x36, 0x43, 0x14, 0x4b}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1219260086131915, 647169006596815, 79601124759706, - 2161724213426748, 404861897060198 -#else - 5414091, 18168391, 46101199, 9643569, 12834970, 1186149, - 64485948, 32212200, 26128230, 6032912 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1327968293887866, 1335500852943256, 1401587164534264, - 558137311952440, 1551360549268902 -#else - 40771450, 19788269, 32496024, 19900513, 17847800, 20885276, - 3604024, 8316894, 41233830, 23117073 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 417621685193956, 1429953819744454, 396157358457099, - 1940470778873255, 214000046234152 -#else - 3296484, 6223048, 24680646, 21307972, 44056843, 5903204, - 58246567, 28915267, 12376616, 3188849 -#endif - }}, + {0xcb, 0x9c, 0x52, 0x1c, 0xe9, 0x54, 0x7c, 0x96, 0xfb, 0x35, 0xc6, + 0x64, 0x92, 0x26, 0xf6, 0x30, 0x65, 0x19, 0x12, 0x78, 0xf4, 0xaf, + 0x47, 0x27, 0x5c, 0x6f, 0xf6, 0xea, 0x18, 0x84, 0x3, 0x17}, + {0x7a, 0x1f, 0x6e, 0xb6, 0xc7, 0xb7, 0xc4, 0xcc, 0x7e, 0x2f, 0xc, + 0xf5, 0x25, 0x7e, 0x15, 0x44, 0x1c, 0xaf, 0x3e, 0x71, 0xfc, 0x6d, + 0xf0, 0x3e, 0xf7, 0x63, 0xda, 0x52, 0x67, 0x44, 0x2f, 0x58}, + {0xe4, 0x4c, 0x32, 0x20, 0xd3, 0x7b, 0x31, 0xc6, 0xc4, 0x8b, 0x48, + 0xa4, 0xe8, 0x42, 0x10, 0xa8, 0x64, 0x13, 0x5a, 0x4e, 0x8b, 0xf1, + 0x1e, 0xb2, 0xc9, 0x8d, 0xa2, 0xcd, 0x4b, 0x1c, 0x2a, 0xc}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1268047918491973, 2172375426948536, 1533916099229249, - 1761293575457130, 1590622667026765 -#else - 29190469, 18895386, 27549112, 32370916, 3520065, 22857131, - 32049514, 26245319, 50999629, 23702124 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1627072914981959, 2211603081280073, 1912369601616504, - 1191770436221309, 2187309757525860 -#else - 52364359, 24245275, 735817, 32955454, 46701176, 28496527, - 25246077, 17758763, 18640740, 32593455 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1149147819689533, 378692712667677, 828475842424202, - 2218619146419342, 70688125792186 -#else - 60180029, 17123636, 10361373, 5642961, 4910474, 12345252, - 35470478, 33060001, 10530746, 1053335 -#endif - }}, + {0x45, 0x69, 0xbd, 0x69, 0x48, 0x81, 0xc4, 0xed, 0x22, 0x8d, 0x1c, + 0xbe, 0x7d, 0x90, 0x6d, 0xd, 0xab, 0xc5, 0x5c, 0xd5, 0x12, 0xd2, + 0x3b, 0xc6, 0x83, 0xdc, 0x14, 0xa3, 0x30, 0x9b, 0x6a, 0x5a}, + {0x47, 0x4, 0x1f, 0x6f, 0xd0, 0xc7, 0x4d, 0xd2, 0x59, 0xc0, 0x87, + 0xdb, 0x3e, 0x9e, 0x26, 0xb2, 0x8f, 0xd2, 0xb2, 0xfb, 0x72, 0x2, + 0x5b, 0xd1, 0x77, 0x48, 0xf6, 0xc6, 0xd1, 0x8b, 0x55, 0x7c}, + {0x3d, 0x46, 0x96, 0xd3, 0x24, 0x15, 0xec, 0xd0, 0xf0, 0x24, 0x5a, + 0xc3, 0x8a, 0x62, 0xbb, 0x12, 0xa4, 0x5f, 0xbc, 0x1c, 0x79, 0x3a, + 0xc, 0xa5, 0xc3, 0xaf, 0xfb, 0xa, 0xca, 0xa5, 0x4, 0x4}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1299739417079761, 1438616663452759, 1536729078504412, - 2053896748919838, 1008421032591246 -#else - 37842897, 19367626, 53570647, 21437058, 47651804, 22899047, - 35646494, 30605446, 24018830, 15026644 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2040723824657366, 399555637875075, 632543375452995, - 872649937008051, 1235394727030233 -#else - 44516310, 30409154, 64819587, 5953842, 53668675, 9425630, - 25310643, 13003497, 64794073, 18408815 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2211311599327900, 2139787259888175, 938706616835350, - 12609661139114, 2081897930719789 -#else - 39688860, 32951110, 59064879, 31885314, 41016598, 13987818, - 39811242, 187898, 43942445, 31022696 -#endif - }}, + {0xd1, 0x6f, 0x41, 0x2a, 0x1b, 0x9e, 0xbc, 0x62, 0x8b, 0x59, 0x50, + 0xe3, 0x28, 0xf7, 0xc6, 0xb5, 0x67, 0x69, 0x5d, 0x3d, 0xd8, 0x3f, + 0x34, 0x4, 0x98, 0xee, 0xf8, 0xe7, 0x16, 0x75, 0x52, 0x39}, + {0xd6, 0x43, 0xa7, 0xa, 0x7, 0x40, 0x1f, 0x8c, 0xe8, 0x5e, 0x26, + 0x5b, 0xcb, 0xd0, 0xba, 0xcc, 0xde, 0xd2, 0x8f, 0x66, 0x6b, 0x4, + 0x4b, 0x57, 0x33, 0x96, 0xdd, 0xca, 0xfd, 0x5b, 0x39, 0x46}, + {0x9c, 0x9a, 0x5d, 0x1a, 0x2d, 0xdb, 0x7f, 0x11, 0x2a, 0x5c, 0x0, + 0xd1, 0xbc, 0x45, 0x77, 0x9c, 0xea, 0x6f, 0xd5, 0x54, 0xf1, 0xbe, + 0xd4, 0xef, 0x16, 0xd0, 0x22, 0xe8, 0x29, 0x9a, 0x57, 0x76}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1324994503390450, 336982330582631, 1183998925654177, - 1091654665913274, 48727673971319 -#else - 45364466, 19743956, 1844839, 5021428, 56674465, 17642958, - 9716666, 16266922, 62038647, 726098 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1845522914617879, 1222198248335542, 150841072760134, - 1927029069940982, 1189913404498011 -#else - 29370903, 27500434, 7334070, 18212173, 9385286, 2247707, - 53446902, 28714970, 30007387, 17731091 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1079559557592645, 2215338383666441, 1903569501302605, - 49033973033940, 305703433934152 -#else - 66172485, 16086690, 23751945, 33011114, 65941325, 28365395, - 9137108, 730663, 9835848, 4555336 -#endif - }}, + {0xf2, 0x34, 0xb4, 0x52, 0x13, 0xb5, 0x3c, 0x33, 0xe1, 0x80, 0xde, + 0x93, 0x49, 0x28, 0x32, 0xd8, 0xce, 0x35, 0xd, 0x75, 0x87, 0x28, + 0x51, 0xb5, 0xc1, 0x77, 0x27, 0x2a, 0xbb, 0x14, 0xc5, 0x2}, + {0x17, 0x2a, 0xc0, 0x49, 0x7e, 0x8e, 0xb6, 0x45, 0x7f, 0xa3, 0xa9, + 0xbc, 0xa2, 0x51, 0xcd, 0x23, 0x1b, 0x4c, 0x22, 0xec, 0x11, 0x5f, + 0xd6, 0x3e, 0xb1, 0xbd, 0x5, 0x9e, 0xdc, 0x84, 0xa3, 0x43}, + {0x45, 0xb6, 0xf1, 0x8b, 0xda, 0xd5, 0x4b, 0x68, 0x53, 0x4b, 0xb5, + 0xf6, 0x7e, 0xd3, 0x8b, 0xfb, 0x53, 0xd2, 0xb0, 0xa9, 0xd7, 0x16, + 0x39, 0x31, 0x59, 0x80, 0x54, 0x61, 0x9, 0x92, 0x60, 0x11}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 94653405416909, 1386121349852999, 1062130477891762, - 36553947479274, 833669648948846 -#else - 43732429, 1410445, 44855111, 20654817, 30867634, 15826977, - 17693930, 544696, 55123566, 12422645 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1432015813136298, 440364795295369, 1395647062821501, - 1976874522764578, 934452372723352 -#else - 31117226, 21338698, 53606025, 6561946, 57231997, 20796761, - 61990178, 29457725, 29120152, 13924425 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1296625309219774, 2068273464883862, 1858621048097805, - 1492281814208508, 2235868981918946 -#else - 49707966, 19321222, 19675798, 30819676, 56101901, 27695611, - 57724924, 22236731, 7240930, 33317044 -#endif - }}, + {0xcd, 0x4d, 0x9b, 0x36, 0x16, 0x56, 0x38, 0x7a, 0x63, 0x35, 0x5c, + 0x65, 0xa7, 0x2c, 0xc0, 0x75, 0x21, 0x80, 0xf1, 0xd4, 0xf9, 0x1b, + 0xc2, 0x7d, 0x42, 0xe0, 0xe6, 0x91, 0x74, 0x7d, 0x63, 0x2f}, + {0xaa, 0xcf, 0xda, 0x29, 0x69, 0x16, 0x4d, 0xb4, 0x8f, 0x59, 0x13, + 0x84, 0x4c, 0x9f, 0x52, 0xda, 0x59, 0x55, 0x3d, 0x45, 0xca, 0x63, + 0xef, 0xe9, 0xb, 0x8e, 0x69, 0xc5, 0x5b, 0x12, 0x1e, 0x35}, + {0xbe, 0x7b, 0xf6, 0x1a, 0x46, 0x9b, 0xb4, 0xd4, 0x61, 0x89, 0xab, + 0xc8, 0x7a, 0x3, 0x3, 0xd6, 0xfb, 0x99, 0xa6, 0xf9, 0x9f, 0xe1, + 0xde, 0x71, 0x9a, 0x2a, 0xce, 0xe7, 0x6, 0x2d, 0x18, 0x7f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1490330266465570, 1858795661361448, 1436241134969763, - 294573218899647, 1208140011028933 -#else - 35747106, 22207651, 52101416, 27698213, 44655523, 21401660, - 1222335, 4389483, 3293637, 18002689 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1282462923712748, 741885683986255, 2027754642827561, - 518989529541027, 1826610009555945 -#else - 50424044, 19110186, 11038543, 11054958, 53307689, 30215898, - 42789283, 7733546, 12796905, 27218610 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1525827120027511, 723686461809551, 1597702369236987, - 244802101764964, 1502833890372311 -#else - 58349431, 22736595, 41689999, 10783768, 36493307, 23807620, - 38855524, 3647835, 3222231, 22393970 -#endif - }}, + {0x22, 0x75, 0x21, 0x8e, 0x72, 0x4b, 0x45, 0x9, 0xd8, 0xb8, 0x84, + 0xd4, 0xf4, 0xe8, 0x58, 0xaa, 0x3c, 0x90, 0x46, 0x7f, 0x4d, 0x25, + 0x58, 0xd3, 0x17, 0x52, 0x1c, 0x24, 0x43, 0xc0, 0xac, 0x44}, + {0xec, 0x68, 0x1, 0xab, 0x64, 0x8e, 0x7c, 0x7a, 0x43, 0xc5, 0xed, + 0x15, 0x55, 0x4a, 0x5a, 0xcb, 0xda, 0xe, 0xcd, 0x47, 0xd3, 0x19, + 0x55, 0x9, 0xb0, 0x93, 0x3e, 0x34, 0x8c, 0xac, 0xd4, 0x67}, + {0x77, 0x57, 0x7a, 0x4f, 0xbb, 0x6b, 0x7d, 0x1c, 0xe1, 0x13, 0x83, + 0x91, 0xd4, 0xfe, 0x35, 0x8b, 0x84, 0x46, 0x6b, 0xc9, 0xc6, 0xa1, + 0xdc, 0x4a, 0xbd, 0x71, 0xad, 0x12, 0x83, 0x1c, 0x6d, 0x55}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 113622036244513, 1233740067745854, 674109952278496, - 2114345180342965, 166764512856263 -#else - 18606113, 1693100, 41660478, 18384159, 4112352, 10045021, - 23603893, 31506198, 59558087, 2484984 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2041668749310338, 2184405322203901, 1633400637611036, - 2110682505536899, 2048144390084644 -#else - 9255298, 30423235, 54952701, 32550175, 13098012, 24339566, - 16377219, 31451620, 47306788, 30519729 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 503058759232932, 760293024620937, 2027152777219493, - 666858468148475, 1539184379870952 -#else - 44379556, 7496159, 61366665, 11329248, 19991973, 30206930, - 35390715, 9936965, 37011176, 22935634 -#endif - }}, + {0x21, 0xe8, 0x1b, 0xb1, 0x56, 0x67, 0xf0, 0x81, 0xdd, 0xf3, 0xa3, + 0x10, 0x23, 0xf8, 0xaf, 0xf, 0x5d, 0x46, 0x99, 0x6a, 0x55, 0xd0, + 0xb2, 0xf8, 0x5, 0x7f, 0x8c, 0xcc, 0x38, 0xbe, 0x7a, 0x9}, + {0x82, 0x39, 0x8d, 0xc, 0xe3, 0x40, 0xef, 0x17, 0x34, 0xfa, 0xa3, + 0x15, 0x3e, 0x7, 0xf7, 0x31, 0x6e, 0x64, 0x73, 0x7, 0xcb, 0xf3, + 0x21, 0x4f, 0xff, 0x4e, 0x82, 0x1d, 0x6d, 0x6c, 0x6c, 0x74}, + {0xa4, 0x2d, 0xa5, 0x7e, 0x87, 0xc9, 0x49, 0xc, 0x43, 0x1d, 0xdc, + 0x9b, 0x55, 0x69, 0x43, 0x4c, 0xd2, 0xeb, 0xcc, 0xf7, 0x9, 0x38, + 0x2c, 0x2, 0xbd, 0x84, 0xee, 0x4b, 0xa3, 0x14, 0x7e, 0x57}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1916168475367211, 915626432541343, 883217071712575, - 363427871374304, 1976029821251593 -#else - 21878571, 28553135, 4338335, 13643897, 64071999, 13160959, - 19708896, 5415497, 59748361, 29445138 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 678039535434506, 570587290189340, 1605302676614120, - 2147762562875701, 1706063797091704 -#else - 27736842, 10103576, 12500508, 8502413, 63695848, 23920873, - 10436917, 32004156, 43449720, 25422331 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1439489648586438, 2194580753290951, 832380563557396, - 561521973970522, 584497280718389 -#else - 19492550, 21450067, 37426887, 32701801, 63900692, 12403436, - 30066266, 8367329, 13243957, 8709688 -#endif - }}, + {0x2b, 0xd7, 0x4d, 0xbd, 0xbe, 0xce, 0xfe, 0x94, 0x11, 0x22, 0xf, + 0x6, 0xda, 0x4f, 0x6a, 0xf4, 0xff, 0xd1, 0xc8, 0xc0, 0x77, 0x59, + 0x4a, 0x12, 0x95, 0x92, 0x0, 0xfb, 0xb8, 0x4, 0x53, 0x70}, + {0xa, 0x3b, 0xa7, 0x61, 0xac, 0x68, 0xe2, 0xf0, 0xf5, 0xa5, 0x91, + 0x37, 0x10, 0xfa, 0xfa, 0xf2, 0xe9, 0x0, 0x6d, 0x6b, 0x82, 0x3e, + 0xe1, 0xc1, 0x42, 0x8f, 0xd7, 0x6f, 0xe9, 0x7e, 0xfa, 0x60}, + {0xc6, 0x6e, 0x29, 0x4d, 0x35, 0x1d, 0x3d, 0xb6, 0xd8, 0x31, 0xad, + 0x5f, 0x3e, 0x5, 0xc3, 0xf3, 0xec, 0x42, 0xbd, 0xb4, 0x8c, 0x95, + 0xb, 0x67, 0xfd, 0x53, 0x63, 0xa1, 0xc, 0x8e, 0x39, 0x21}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 187989455492609, 681223515948275, 1933493571072456, - 1872921007304880, 488162364135671 -#else - 12015105, 2801261, 28198131, 10151021, 24818120, 28811299, - 55914672, 27908697, 5150967, 7274186 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1413466089534451, 410844090765630, 1397263346404072, - 408227143123410, 1594561803147811 -#else - 2831347, 21062286, 1478974, 6122054, 23825128, 20820846, - 31097298, 6083058, 31021603, 23760822 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2102170800973153, 719462588665004, 1479649438510153, - 1097529543970028, 1302363283777685 -#else - 64578913, 31324785, 445612, 10720828, 53259337, 22048494, - 43601132, 16354464, 15067285, 19406725 -#endif - }}, + {0x1, 0x56, 0xb7, 0xb4, 0xf9, 0xaa, 0x98, 0x27, 0x72, 0xad, 0x8d, + 0x5c, 0x13, 0x72, 0xac, 0x5e, 0x23, 0xa0, 0xb7, 0x61, 0x61, 0xaa, + 0xce, 0xd2, 0x4e, 0x7d, 0x8f, 0xe9, 0x84, 0xb2, 0xbf, 0x1b}, + {0xf3, 0x33, 0x2b, 0x38, 0x8a, 0x5, 0xf5, 0x89, 0xb4, 0xc0, 0x48, + 0xad, 0xb, 0xba, 0xe2, 0x5a, 0x6e, 0xb3, 0x3d, 0xa5, 0x3, 0xb5, + 0x93, 0x8f, 0xe6, 0x32, 0xa2, 0x95, 0x9d, 0xed, 0xa3, 0x5a}, + {0x61, 0x65, 0xd9, 0xc7, 0xe9, 0x77, 0x67, 0x65, 0x36, 0x80, 0xc7, + 0x72, 0x54, 0x12, 0x2b, 0xcb, 0xee, 0x6e, 0x50, 0xd9, 0x99, 0x32, + 0x5, 0x65, 0xcc, 0x57, 0x89, 0x5e, 0x4e, 0xe1, 0x7, 0x4a}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 942065717847195, 1069313679352961, 2007341951411051, - 70973416446291, 1419433790163706 -#else - 7840923, 14037873, 33744001, 15934015, 66380651, 29911725, - 21403987, 1057586, 47729402, 21151211 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1146565545556377, 1661971299445212, 406681704748893, - 564452436406089, 1109109865829139 -#else - 915865, 17085158, 15608284, 24765302, 42751837, 6060029, - 49737545, 8410996, 59888403, 16527024 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2214421081775077, 1165671861210569, 1890453018796184, - 3556249878661, 442116172656317 -#else - 32922597, 32997445, 20336073, 17369864, 10903704, 28169945, - 16957573, 52992, 23834301, 6588044 -#endif - }}, + {0x9b, 0xa4, 0x77, 0xc4, 0xcd, 0x58, 0xb, 0x24, 0x17, 0xf0, 0x47, + 0x64, 0xde, 0xda, 0x38, 0xfd, 0xad, 0x6a, 0xc8, 0xa7, 0x32, 0x8d, + 0x92, 0x19, 0x81, 0xa0, 0xaf, 0x84, 0xed, 0x7a, 0xaf, 0x50}, + {0x99, 0xf9, 0xd, 0x98, 0xcb, 0x12, 0xe4, 0x4e, 0x71, 0xc7, 0x6e, + 0x3c, 0x6f, 0xd7, 0x15, 0xa3, 0xfd, 0x77, 0x5c, 0x92, 0xde, 0xed, + 0xa5, 0xbb, 0x2, 0x34, 0x31, 0x1d, 0x39, 0xac, 0xb, 0x3f}, + {0xe5, 0x5b, 0xf6, 0x15, 0x1, 0xde, 0x4f, 0x6e, 0xb2, 0x9, 0x61, + 0x21, 0x21, 0x26, 0x98, 0x29, 0xd9, 0xd6, 0xad, 0xb, 0x81, 0x5, + 0x2, 0x78, 0x6, 0xd0, 0xeb, 0xba, 0x16, 0xa3, 0x21, 0x19}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 753830546620811, 1666955059895019, 1530775289309243, - 1119987029104146, 2164156153857580 -#else - 32752011, 11232950, 3381995, 24839566, 22652987, 22810329, - 17159698, 16689107, 46794284, 32248439 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 615171919212796, 1523849404854568, 854560460547503, - 2067097370290715, 1765325848586042 -#else - 62419196, 9166775, 41398568, 22707125, 11576751, 12733943, - 7924251, 30802151, 1976122, 26305405 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1094538949313667, 1796592198908825, 870221004284388, - 2025558921863561, 1699010892802384 -#else - 21251203, 16309901, 64125849, 26771309, 30810596, 12967303, - 156041, 30183180, 12331344, 25317235 -#endif - }}, + {0x8b, 0xc1, 0xf3, 0xd9, 0x9a, 0xad, 0x5a, 0xd7, 0x9c, 0xc1, 0xb1, + 0x60, 0xef, 0xe, 0x6a, 0x56, 0xd9, 0xe, 0x5c, 0x25, 0xac, 0xb, + 0x9a, 0x3e, 0xf5, 0xc7, 0x62, 0xa0, 0xec, 0x9d, 0x4, 0x7b}, + {0xfc, 0x70, 0xb8, 0xdf, 0x7e, 0x2f, 0x42, 0x89, 0xbd, 0xb3, 0x76, + 0x4f, 0xeb, 0x6b, 0x29, 0x2c, 0xf7, 0x4d, 0xc2, 0x36, 0xd4, 0xf1, + 0x38, 0x7, 0xb0, 0xae, 0x73, 0xe2, 0x41, 0xdf, 0x58, 0x64}, + {0x83, 0x44, 0x44, 0x35, 0x7a, 0xe3, 0xcb, 0xdc, 0x93, 0xbe, 0xed, + 0xf, 0x33, 0x79, 0x88, 0x75, 0x87, 0xdd, 0xc5, 0x12, 0xc3, 0x4, + 0x60, 0x78, 0x64, 0xe, 0x95, 0xc2, 0xcb, 0xdc, 0x93, 0x60}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1951351290725195, 1916457206844795, 198025184438026, - 1909076887557595, 1938542290318919 -#else - 8651595, 29077400, 51023227, 28557437, 13002506, 2950805, - 29054427, 28447462, 10008135, 28886531 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1014323197538413, 869150639940606, 1756009942696599, - 1334952557375672, 1544945379082874 -#else - 31486061, 15114593, 52847614, 12951353, 14369431, 26166587, - 16347320, 19892343, 8684154, 23021480 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 764055910920305, 1603590757375439, 146805246592357, - 1843313433854297, 954279890114939 -#else - 19443825, 11385320, 24468943, 23895364, 43189605, 2187568, - 40845657, 27467510, 31316347, 14219878 -#endif - }}, + {0x4b, 0x3, 0x84, 0x60, 0xbe, 0xee, 0xde, 0x6b, 0x54, 0xb8, 0xf, + 0x78, 0xb6, 0xc2, 0x99, 0x31, 0x95, 0x6, 0x2d, 0xb6, 0xab, 0x76, + 0x33, 0x97, 0x90, 0x7d, 0x64, 0x8b, 0xc9, 0x80, 0x31, 0x6e}, + {0x6d, 0x70, 0xe0, 0x85, 0x85, 0x9a, 0xf3, 0x1f, 0x33, 0x39, 0xe7, + 0xb3, 0xd8, 0xa5, 0xd0, 0x36, 0x3b, 0x45, 0x8f, 0x71, 0xe1, 0xf2, + 0xb9, 0x43, 0x7c, 0xa9, 0x27, 0x48, 0x8, 0xea, 0xd1, 0x57}, + {0x71, 0xb0, 0x28, 0xa1, 0xe7, 0xb6, 0x7a, 0xee, 0xaa, 0x8b, 0xa8, + 0x93, 0x6d, 0x59, 0xc1, 0xa4, 0x30, 0x61, 0x21, 0xb2, 0x82, 0xde, + 0xb4, 0xf7, 0x18, 0xbd, 0x97, 0xdd, 0x9d, 0x99, 0x3e, 0x36}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 80113526615750, 764536758732259, 1055139345100233, - 469252651759390, 617897512431515 -#else - 38514374, 1193784, 32245219, 11392485, 31092169, 15722801, - 27146014, 6992409, 29126555, 9207390 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 74497112547268, 740094153192149, 1745254631717581, - 727713886503130, 1283034364416928 -#else - 32382916, 1110093, 18477781, 11028262, 39697101, 26006320, - 62128346, 10843781, 59151264, 19118701 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 525892105991110, 1723776830270342, 1476444848991936, - 573789489857760, 133864092632978 -#else - 2814918, 7836403, 27519878, 25686276, 46214848, 22000742, - 45614304, 8550129, 28346258, 1994730 -#endif - }}, + {0xc6, 0xae, 0x4b, 0xe2, 0xdc, 0x48, 0x18, 0x2f, 0x60, 0xaf, 0xbc, + 0xba, 0x55, 0x72, 0x9b, 0x76, 0x31, 0xe9, 0xef, 0x3c, 0x6e, 0x3c, + 0xcb, 0x90, 0x55, 0xb3, 0xf9, 0xc6, 0x9b, 0x97, 0x1f, 0x23}, + {0xc4, 0x1f, 0xee, 0x35, 0xc1, 0x43, 0xa8, 0x96, 0xcf, 0xc8, 0xe4, + 0x8, 0x55, 0xb3, 0x6e, 0x97, 0x30, 0xd3, 0x8c, 0xb5, 0x1, 0x68, + 0x2f, 0xb4, 0x2b, 0x5, 0x3a, 0x69, 0x78, 0x9b, 0xee, 0x48}, + {0xc6, 0xf3, 0x2a, 0xcc, 0x4b, 0xde, 0x31, 0x5c, 0x1f, 0x8d, 0x20, + 0xfe, 0x30, 0xb0, 0x4b, 0xb0, 0x66, 0xb4, 0x4f, 0xc1, 0x9, 0x70, + 0x8d, 0xb7, 0x13, 0x24, 0x79, 0x8, 0x9b, 0xfa, 0x9b, 0x7}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 542611720192581, 1986812262899321, 1162535242465837, - 481498966143464, 544600533583622 -#else - 47530565, 8085544, 53108345, 29605809, 2785837, 17323125, - 47591912, 7174893, 22628102, 8115180 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 64123227344372, 1239927720647794, 1360722983445904, - 222610813654661, 62429487187991 -#else - 36703732, 955510, 55975026, 18476362, 34661776, 20276352, - 41457285, 3317159, 57165847, 930271 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1793193323953132, 91096687857833, 70945970938921, - 2158587638946380, 1537042406482111 -#else - 51805164, 26720662, 28856489, 1357446, 23421993, 1057177, - 24091212, 32165462, 44343487, 22903716 -#endif - }}, + {0x45, 0x42, 0xd5, 0xa2, 0x80, 0xed, 0xc9, 0xf3, 0x52, 0x39, 0xf6, + 0x77, 0x78, 0x8b, 0xa0, 0xa, 0x75, 0x54, 0x8, 0xd1, 0x63, 0xac, + 0x6d, 0xd7, 0x6b, 0x63, 0x70, 0x94, 0x15, 0xfb, 0xf4, 0x1e}, + {0xf4, 0xd, 0x30, 0xda, 0x51, 0x3a, 0x90, 0xe3, 0xb0, 0x5a, 0xa9, + 0x3d, 0x23, 0x64, 0x39, 0x84, 0x80, 0x64, 0x35, 0xb, 0x2d, 0xf1, + 0x3c, 0xed, 0x94, 0x71, 0x81, 0x84, 0xf6, 0x77, 0x8c, 0x3}, + {0xec, 0x7b, 0x16, 0x5b, 0xe6, 0x5e, 0x4e, 0x85, 0xc2, 0xcd, 0xd0, + 0x96, 0x42, 0xa, 0x59, 0x59, 0x99, 0x21, 0x10, 0x98, 0x34, 0xdf, + 0xb2, 0x72, 0x56, 0xff, 0xb, 0x4a, 0x2a, 0xe9, 0x5e, 0x57}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1895854577604609, 1394895708949416, 1728548428495944, - 1140864900240149, 563645333603061 -#else - 44357633, 28250434, 54201256, 20785565, 51297352, 25757378, - 52269845, 17000211, 65241845, 8398969 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 141358280486863, 91435889572504, 1087208572552643, - 1829599652522921, 1193307020643647 -#else - 35139535, 2106402, 62372504, 1362500, 12813763, 16200670, - 22981545, 27263159, 18009407, 17781660 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1611230858525381, 950720175540785, 499589887488610, - 2001656988495019, 88977313255908 -#else - 49887941, 24009210, 39324209, 14166834, 29815394, 7444469, - 29551787, 29827013, 19288548, 1325865 -#endif - }}, + {0x1, 0xd8, 0xa4, 0xa, 0x45, 0xbc, 0x46, 0x5d, 0xd8, 0xb9, 0x33, + 0xa5, 0x27, 0x12, 0xaf, 0xc3, 0xc2, 0x6, 0x89, 0x2b, 0x26, 0x3b, + 0x9e, 0x38, 0x1b, 0x58, 0x2f, 0x38, 0x7e, 0x1e, 0xa, 0x20}, + {0xcf, 0x2f, 0x18, 0x8a, 0x90, 0x80, 0xc0, 0xd4, 0xbd, 0x9d, 0x48, + 0x99, 0xc2, 0x70, 0xe1, 0x30, 0xde, 0x33, 0xf7, 0x52, 0x57, 0xbd, + 0xba, 0x5, 0x0, 0xfd, 0xd3, 0x2c, 0x11, 0xe7, 0xd4, 0x43}, + {0xc5, 0x3a, 0xf9, 0xea, 0x67, 0xb9, 0x8d, 0x51, 0xc0, 0x52, 0x66, + 0x5, 0x9b, 0x98, 0xbc, 0x71, 0xf5, 0x97, 0x71, 0x56, 0xd9, 0x85, + 0x2b, 0xfe, 0x38, 0x4e, 0x1e, 0x65, 0x52, 0xca, 0xe, 0x5}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1189080501479658, 2184348804772597, 1040818725742319, - 2018318290311834, 1712060030915354 -#else - 15100138, 17718680, 43184885, 32549333, 40658671, 15509407, - 12376730, 30075286, 33166106, 25511682 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 873966876953756, 1090638350350440, 1708559325189137, - 672344594801910, 1320437969700239 -#else - 20909212, 13023121, 57899112, 16251777, 61330449, 25459517, - 12412150, 10018715, 2213263, 19676059 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1508590048271766, 1131769479776094, 101550868699323, - 428297785557897, 561791648661744 -#else - 32529814, 22479743, 30361438, 16864679, 57972923, 1513225, - 22922121, 6382134, 61341936, 8371347 -#endif - }}, + {0xea, 0x68, 0xe6, 0x60, 0x76, 0x39, 0xac, 0x97, 0x97, 0xb4, 0x3a, + 0x15, 0xfe, 0xbb, 0x19, 0x9b, 0x9f, 0xa7, 0xec, 0x34, 0xb5, 0x79, + 0xb1, 0x4c, 0x57, 0xae, 0x31, 0xa1, 0x9f, 0xc0, 0x51, 0x61}, + {0x9c, 0xc, 0x3f, 0x45, 0xde, 0x1a, 0x43, 0xc3, 0x9b, 0x3b, 0x70, + 0xff, 0x5e, 0x4, 0xf5, 0xe9, 0x3d, 0x7b, 0x84, 0xed, 0xc9, 0x7a, + 0xd9, 0xfc, 0xc6, 0xf4, 0x58, 0x1c, 0xc2, 0xe6, 0xe, 0x4b}, + {0x96, 0x5d, 0xf0, 0xfd, 0xd, 0x5c, 0xf5, 0x3a, 0x7a, 0xee, 0xb4, + 0x2a, 0xe0, 0x2e, 0x26, 0xdd, 0x9, 0x17, 0x17, 0x12, 0x87, 0xbb, + 0xb2, 0x11, 0xb, 0x3, 0xf, 0x80, 0xfa, 0x24, 0xef, 0x1f}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 756417570499462, 237882279232602, 2136263418594016, - 1701968045454886, 703713185137472 -#else - 9923462, 11271500, 12616794, 3544722, 37110496, 31832805, - 12891686, 25361300, 40665920, 10486143 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1781187809325462, 1697624151492346, 1381393690939988, - 175194132284669, 1483054666415238 -#else - 44511638, 26541766, 8587002, 25296571, 4084308, 20584370, - 361725, 2610596, 43187334, 22099236 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2175517777364616, 708781536456029, 955668231122942, - 1967557500069555, 2021208005604118 -#else - 5408392, 32417741, 62139741, 10561667, 24145918, 14240566, - 31319731, 29318891, 19985174, 30118346 -#endif - }}, + {0x86, 0x6b, 0x97, 0x30, 0xf5, 0xaf, 0xd2, 0x22, 0x4, 0x46, 0xd2, + 0xc2, 0x6, 0xb8, 0x90, 0x8d, 0xe5, 0xba, 0xe5, 0x4d, 0x6c, 0x89, + 0xa1, 0xdc, 0x17, 0xc, 0x34, 0xc8, 0xe6, 0x5f, 0x0, 0x28}, + {0x96, 0x31, 0xa7, 0x1a, 0xfb, 0x53, 0xd6, 0x37, 0x18, 0x64, 0xd7, + 0x3f, 0x30, 0x95, 0x94, 0xf, 0xb2, 0x17, 0x3a, 0xfb, 0x9, 0xb, + 0x20, 0xad, 0x3e, 0x61, 0xc8, 0x2f, 0x29, 0x49, 0x4d, 0x54}, + {0x88, 0x86, 0x52, 0x34, 0x9f, 0xba, 0xef, 0x6a, 0xa1, 0x7d, 0x10, + 0x25, 0x94, 0xff, 0x1b, 0x5c, 0x36, 0x4b, 0xd9, 0x66, 0xcd, 0xbb, + 0x5b, 0xf7, 0xfa, 0x6d, 0x31, 0xf, 0x93, 0x72, 0xe4, 0x72}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1115135966606887, 224217372950782, 915967306279222, - 593866251291540, 561747094208006 -#else - 53114407, 16616820, 14549246, 3341099, 32155958, 13648976, - 49531796, 8849296, 65030, 8370684 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1443163092879439, 391875531646162, 2180847134654632, - 464538543018753, 1594098196837178 -#else - 58787919, 21504805, 31204562, 5839400, 46481576, 32497154, - 47665921, 6922163, 12743482, 23753914 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 850858855888869, 319436476624586, 327807784938441, - 740785849558761, 17128415486016 -#else - 64747493, 12678784, 28815050, 4759974, 43215817, 4884716, - 23783145, 11038569, 18800704, 255233 -#endif - }}, + {0x27, 0x76, 0x2a, 0xd3, 0x35, 0xf6, 0xf3, 0x7, 0xf0, 0x66, 0x65, + 0x5f, 0x86, 0x4d, 0xaa, 0x7a, 0x50, 0x44, 0xd0, 0x28, 0x97, 0xe7, + 0x85, 0x3c, 0x38, 0x64, 0xe0, 0xf, 0x0, 0x7f, 0xee, 0x1f}, + {0x4f, 0x8, 0x81, 0x97, 0x8c, 0x20, 0x95, 0x26, 0xe1, 0xe, 0x45, + 0x23, 0xb, 0x2a, 0x50, 0xb1, 0x2, 0xde, 0xef, 0x3, 0xa6, 0xae, + 0x9d, 0xfd, 0x4c, 0xa3, 0x33, 0x27, 0x8c, 0x2e, 0x9d, 0x5a}, + {0xe5, 0xf7, 0xdb, 0x3, 0xda, 0x5, 0x53, 0x76, 0xbd, 0xcd, 0x34, + 0x14, 0x49, 0xf2, 0xda, 0xa4, 0xec, 0x88, 0x4a, 0xd2, 0xcd, 0xd5, + 0x4a, 0x7b, 0x43, 0x5, 0x4, 0xee, 0x51, 0x40, 0xf9, 0x0}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2132756334090067, 536247820155645, 48907151276867, - 608473197600695, 1261689545022784 -#else - 61839187, 31780545, 13957885, 7990715, 23132995, 728773, - 13393847, 9066957, 19258688, 18800639 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1525176236978354, 974205476721062, 293436255662638, - 148269621098039, 137961998433963 -#else - 64172210, 22726896, 56676774, 14516792, 63468078, 4372540, - 35173943, 2209389, 65584811, 2055793 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1121075518299410, 2071745529082111, 1265567917414828, - 1648196578317805, 496232102750820 -#else - 580882, 16705327, 5468415, 30871414, 36182444, 18858431, - 59905517, 24560042, 37087844, 7394434 -#endif - }}, + {0x53, 0x97, 0xaf, 0x7, 0xbb, 0x93, 0xef, 0xd7, 0xa7, 0x66, 0xb7, + 0x3d, 0xcf, 0xd0, 0x3e, 0x58, 0xc5, 0x1e, 0xb, 0x6e, 0xbf, 0x98, + 0x69, 0xce, 0x52, 0x4, 0xd4, 0x5d, 0xd2, 0xff, 0xb7, 0x47}, + {0xb2, 0x30, 0xd3, 0xc3, 0x23, 0x6b, 0x35, 0x8d, 0x6, 0x1b, 0x47, + 0xb0, 0x9b, 0x8b, 0x1c, 0xf2, 0x3c, 0xb8, 0x42, 0x6e, 0x6c, 0x31, + 0x6c, 0xb3, 0xd, 0xb1, 0xea, 0x8b, 0x7e, 0x9c, 0xd7, 0x7}, + {0x12, 0xdd, 0x8, 0xbc, 0x9c, 0xfb, 0xfb, 0x87, 0x9b, 0xc2, 0xee, + 0xe1, 0x3a, 0x6b, 0x6, 0x8a, 0xbf, 0xc1, 0x1f, 0xdb, 0x2b, 0x24, + 0x57, 0xd, 0xb6, 0x4b, 0xa6, 0x5e, 0xa3, 0x20, 0x35, 0x1c}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 122321229299801, 1022922077493685, 2001275453369484, - 2017441881607947, 993205880778002 -#else - 23838809, 1822728, 51370421, 15242726, 8318092, 29821328, - 45436683, 30062226, 62287122, 14799920 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 654925550560074, 1168810995576858, 575655959430926, - 905758704861388, 496774564663534 -#else - 13345610, 9759151, 3371034, 17416641, 16353038, 8577942, - 31129804, 13496856, 58052846, 7402517 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1954109525779738, 2117022646152485, 338102630417180, - 1194140505732026, 107881734943492 -#else - 2286874, 29118501, 47066405, 31546095, 53412636, 5038121, - 11006906, 17794080, 8205060, 1607563 -#endif - }}, + {0x59, 0xc0, 0x6b, 0x21, 0x40, 0x6f, 0xa8, 0xcd, 0x7e, 0xd8, 0xbc, + 0x12, 0x1d, 0x23, 0xbb, 0x1f, 0x90, 0x9, 0xc7, 0x17, 0x9e, 0x6a, + 0x95, 0xb4, 0x55, 0x2e, 0xd1, 0x66, 0x3b, 0xc, 0x75, 0x38}, + {0x4a, 0xa3, 0xcb, 0xbc, 0xa6, 0x53, 0xd2, 0x80, 0x9b, 0x21, 0x38, + 0x38, 0xa1, 0xc3, 0x61, 0x3e, 0x96, 0xe3, 0x82, 0x98, 0x1, 0xb6, + 0xc3, 0x90, 0x6f, 0xe6, 0xe, 0x5d, 0x77, 0x5, 0x3d, 0x1c}, + {0x1a, 0xe5, 0x22, 0x94, 0x40, 0xf1, 0x2e, 0x69, 0x71, 0xf6, 0x5d, + 0x2b, 0x3c, 0xc7, 0xc0, 0xcb, 0x29, 0xe0, 0x4c, 0x74, 0xe7, 0x4f, + 0x1, 0x21, 0x7c, 0x48, 0x30, 0xd3, 0xc7, 0xe2, 0x21, 0x6}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1714785840001267, 2036500018681589, 1876380234251966, - 2056717182974196, 1645855254384642 -#else - 14414067, 25552300, 3331829, 30346215, 22249150, 27960244, - 18364660, 30647474, 30019586, 24525154 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 106431476499341, 62482972120563, 1513446655109411, - 807258751769522, 538491469114 -#else - 39420813, 1585952, 56333811, 931068, 37988643, 22552112, - 52698034, 12029092, 9944378, 8024 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2002850762893643, 1243624520538135, 1486040410574605, - 2184752338181213, 378495998083531 -#else - 4368715, 29844802, 29874199, 18531449, 46878477, 22143727, - 50994269, 32555346, 58966475, 5640029 -#endif - }}, + {0xf3, 0xf0, 0xdb, 0xb0, 0x96, 0x17, 0xae, 0xb7, 0x96, 0xe1, 0x7c, + 0xe1, 0xb9, 0xaf, 0xdf, 0x54, 0xb4, 0xa3, 0xaa, 0xe9, 0x71, 0x30, + 0x92, 0x25, 0x9d, 0x2e, 0x0, 0xa1, 0x9c, 0x58, 0x8e, 0x5d}, + {0x8d, 0x83, 0x59, 0x82, 0xcc, 0x60, 0x98, 0xaf, 0xdc, 0x9a, 0x9f, + 0xc6, 0xc1, 0x48, 0xea, 0x90, 0x30, 0x1e, 0x58, 0x65, 0x37, 0x48, + 0x26, 0x65, 0xbc, 0xa5, 0xd3, 0x7b, 0x9, 0xd6, 0x7, 0x0}, + {0x4b, 0xa9, 0x42, 0x8, 0x95, 0x1d, 0xbf, 0xc0, 0x3e, 0x2e, 0x8f, + 0x58, 0x63, 0xc3, 0xd3, 0xb2, 0xef, 0xe2, 0x51, 0xbb, 0x38, 0x14, + 0x96, 0xa, 0x86, 0xbf, 0x1c, 0x3c, 0x78, 0xd7, 0x83, 0x15}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 922510868424903, 1089502620807680, 402544072617374, - 1131446598479839, 1290278588136533 -#else - 10299591, 13746483, 11661824, 16234854, 7630238, 5998374, - 9809887, 16859868, 15219797, 19226649 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1867998812076769, 715425053580701, 39968586461416, - 2173068014586163, 653822651801304 -#else - 27425505, 27835351, 3055005, 10660664, 23458024, 595578, - 51710259, 32381236, 48766680, 9742716 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 162892278589453, 182585796682149, 75093073137630, - 497037941226502, 133871727117371 -#else - 6744077, 2427284, 26042789, 2720740, 66260958, 1118973, - 32324614, 7406442, 12420155, 1994844 -#endif - }}, + {0xc7, 0x28, 0x9d, 0xcc, 0x4, 0x47, 0x3, 0x90, 0x8f, 0xc5, 0x2c, + 0xf7, 0x9e, 0x67, 0x1b, 0x1d, 0x26, 0x87, 0x5b, 0xbe, 0x5f, 0x2b, + 0xe1, 0x16, 0xa, 0x58, 0xc5, 0x83, 0x4e, 0x6, 0x58, 0x49}, + {0xe1, 0x7a, 0xa2, 0x5d, 0xef, 0xa2, 0xee, 0xec, 0x74, 0x1, 0x67, + 0x55, 0x14, 0x3a, 0x7c, 0x59, 0x7a, 0x16, 0x9, 0x66, 0x12, 0x2a, + 0xa6, 0xc9, 0x70, 0x8f, 0xed, 0x81, 0x2e, 0x5f, 0x2a, 0x25}, + {0xd, 0xe8, 0x66, 0x50, 0x26, 0x94, 0x28, 0xd, 0x6b, 0x8c, 0x7c, + 0x30, 0x85, 0xf7, 0xc3, 0xfc, 0xfd, 0x12, 0x11, 0xc, 0x78, 0xda, + 0x53, 0x1b, 0x88, 0xb3, 0x43, 0xd8, 0xb, 0x17, 0x9c, 0x7}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1914596576579670, 1608999621851578, 1987629837704609, - 1519655314857977, 1819193753409464 -#else - 14012502, 28529712, 48724410, 23975962, 40623521, 29617992, - 54075385, 22644628, 24319928, 27108099 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1949315551096831, 1069003344994464, 1939165033499916, - 1548227205730856, 1933767655861407 -#else - 16412671, 29047065, 10772640, 15929391, 50040076, 28895810, - 10555944, 23070383, 37006495, 28815383 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1730519386931635, 1393284965610134, 1597143735726030, - 416032382447158, 1429665248828629 -#else - 22397363, 25786748, 57815702, 20761563, 17166286, 23799296, - 39775798, 6199365, 21880021, 21303672 -#endif - }}, + {0x56, 0xd0, 0xd5, 0xc0, 0x50, 0xcd, 0xd6, 0xcd, 0x3b, 0x57, 0x3, + 0xbb, 0x6d, 0x68, 0xf7, 0x9a, 0x48, 0xef, 0xc3, 0xf3, 0x3f, 0x72, + 0xa6, 0x3c, 0xcc, 0x8a, 0x7b, 0x31, 0xd7, 0xc0, 0x68, 0x67}, + {0xff, 0x6f, 0xfa, 0x64, 0xe4, 0xec, 0x6, 0x5, 0x23, 0xe5, 0x5, + 0x62, 0x1e, 0x43, 0xe3, 0xbe, 0x42, 0xea, 0xb8, 0x51, 0x24, 0x42, + 0x79, 0x35, 0x0, 0xfb, 0xc9, 0x4a, 0xe3, 0x5, 0xec, 0x6d}, + {0xb3, 0xc1, 0x55, 0xf1, 0xe5, 0x25, 0xb6, 0x94, 0x91, 0x7b, 0x7b, + 0x99, 0xa7, 0xf3, 0x7b, 0x41, 0x0, 0x26, 0x6b, 0x6d, 0xdc, 0xbd, + 0x2c, 0xc2, 0xf4, 0x52, 0xcd, 0xdd, 0x14, 0x5e, 0x44, 0x51}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 360275475604565, 547835731063078, 215360904187529, - 596646739879007, 332709650425085 -#else - 62825557, 5368522, 35991846, 8163388, 36785801, 3209127, - 16557151, 8890729, 8840445, 4957760 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 47602113726801, 1522314509708010, 437706261372925, - 814035330438027, 335930650933545 -#else - 51661137, 709326, 60189418, 22684253, 37330941, 6522331, - 45388683, 12130071, 52312361, 5005756 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1291597595523886, 1058020588994081, 402837842324045, - 1363323695882781, 2105763393033193 -#else - 64994094, 19246303, 23019041, 15765735, 41839181, 6002751, - 10183197, 20315106, 50713577, 31378319 -#endif - }}, + {0x55, 0xa4, 0xbe, 0x2b, 0xab, 0x47, 0x31, 0x89, 0x29, 0x91, 0x7, + 0x92, 0x4f, 0xa2, 0x53, 0x8c, 0xa7, 0xf7, 0x30, 0xbe, 0x48, 0xf9, + 0x49, 0x4b, 0x3d, 0xd4, 0x4f, 0x6e, 0x8, 0x90, 0xe9, 0x12}, + {0x51, 0x49, 0x14, 0x3b, 0x4b, 0x2b, 0x50, 0x57, 0xb3, 0xbc, 0x4b, + 0x44, 0x6b, 0xff, 0x67, 0x8e, 0xdb, 0x85, 0x63, 0x16, 0x27, 0x69, + 0xbd, 0xb8, 0xc8, 0x95, 0x92, 0xe3, 0x31, 0x6f, 0x18, 0x13}, + {0x2e, 0xbb, 0xdf, 0x7f, 0xb3, 0x96, 0xc, 0xf1, 0xf9, 0xea, 0x1c, + 0x12, 0x5e, 0x93, 0x9a, 0x9f, 0x3f, 0x98, 0x5b, 0x3a, 0xc4, 0x36, + 0x11, 0xdf, 0xaf, 0x99, 0x3e, 0x5d, 0xf0, 0xe3, 0xb2, 0x77}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 109521982566564, 1715257748585139, 1112231216891516, - 2046641005101484, 134249157157013 -#else - 48083108, 1632004, 13466291, 25559332, 43468412, 16573536, - 35094956, 30497327, 22208661, 2000468 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2156991030936798, 2227544497153325, 1869050094431622, - 754875860479115, 1754242344267058 -#else - 3065054, 32141671, 41510189, 33192999, 49425798, 27851016, - 58944651, 11248526, 63417650, 26140247 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1846089562873800, 98894784984326, 1412430299204844, - 171351226625762, 1100604760929008 -#else - 10379208, 27508878, 8877318, 1473647, 37817580, 21046851, - 16690914, 2553332, 63976176, 16400288 -#endif - }}, + {0xa4, 0xb0, 0xdd, 0x12, 0x9c, 0x63, 0x98, 0xd5, 0x6b, 0x86, 0x24, + 0xc0, 0x30, 0x9f, 0xd1, 0xa5, 0x60, 0xe4, 0xfc, 0x58, 0x3, 0x2f, + 0x7c, 0xd1, 0x8a, 0x5e, 0x9, 0x2e, 0x15, 0x95, 0xa1, 0x7}, + {0xde, 0xc4, 0x2e, 0x9c, 0xc5, 0xa9, 0x6f, 0x29, 0xcb, 0xf3, 0x84, + 0x4f, 0xbf, 0x61, 0x8b, 0xbc, 0x8, 0xf9, 0xa8, 0x17, 0xd9, 0x6, + 0x77, 0x1c, 0x5d, 0x25, 0xd3, 0x7a, 0xfc, 0x95, 0xb7, 0x63}, + {0xc8, 0x5f, 0x9e, 0x38, 0x2, 0x8f, 0x36, 0xa8, 0x3b, 0xe4, 0x8d, + 0xcf, 0x2, 0x3b, 0x43, 0x90, 0x43, 0x26, 0x41, 0xc5, 0x5d, 0xfd, + 0xa1, 0xaf, 0x37, 0x1, 0x2f, 0x3, 0x3d, 0xe8, 0x8f, 0x3e}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 84172382130492, 499710970700046, 425749630620778, - 1762872794206857, 612842602127960 -#else - 15716668, 1254266, 48636174, 7446273, 58659946, 6344163, - 45011593, 26268851, 26894936, 9132066 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 868309334532756, 1703010512741873, 1952690008738057, - 4325269926064, 2071083554962116 -#else - 24158868, 12938817, 11085297, 25376834, 39045385, 29097348, - 36532400, 64451, 60291780, 30861549 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 523094549451158, 401938899487815, 1407690589076010, - 2022387426254453, 158660516411257 -#else - 13488534, 7794716, 22236231, 5989356, 25426474, 20976224, - 2350709, 30135921, 62420857, 2364225 -#endif - }}, + {0x3c, 0xd1, 0xef, 0xe8, 0x8d, 0x4c, 0x70, 0x8, 0x31, 0x37, 0xe0, + 0x33, 0x8e, 0x1a, 0xc5, 0xdf, 0xe3, 0xcd, 0x60, 0x12, 0xa5, 0x5d, + 0x9d, 0xa5, 0x86, 0x8c, 0x25, 0xa6, 0x99, 0x8, 0xd6, 0x22}, + {0x94, 0xa2, 0x70, 0x5, 0xb9, 0x15, 0x8b, 0x2f, 0x49, 0x45, 0x8, + 0x67, 0x70, 0x42, 0xf2, 0x94, 0x84, 0xfd, 0xbb, 0x61, 0xe1, 0x5a, + 0x1c, 0xde, 0x7, 0x40, 0xac, 0x7f, 0x79, 0x3b, 0xba, 0x75}, + {0x96, 0xd1, 0xcd, 0x70, 0xc0, 0xdb, 0x39, 0x62, 0x9a, 0x8a, 0x7d, + 0x6c, 0x8b, 0x8a, 0xfe, 0x60, 0x60, 0x12, 0x40, 0xeb, 0xbc, 0x47, + 0x88, 0xb3, 0x5e, 0x9e, 0x77, 0x87, 0x7b, 0xd0, 0x4, 0x9}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 612867287630009, 448212612103814, 571629077419196, - 1466796750919376, 1728478129663858 -#else - 16335033, 9132434, 25640582, 6678888, 1725628, 8517937, - 55301840, 21856974, 15445874, 25756331 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1723848973783452, 2208822520534681, 1718748322776940, - 1974268454121942, 1194212502258141 -#else - 29004188, 25687351, 28661401, 32914020, 54314860, 25611345, - 31863254, 29418892, 66830813, 17795152 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1254114807944608, 977770684047110, 2010756238954993, - 1783628927194099, 1525962994408256 -#else - 60986784, 18687766, 38493958, 14569918, 56250865, 29962602, - 10343411, 26578142, 37280576, 22738620 -#endif - }}, + {0xb9, 0x40, 0xf9, 0x48, 0x66, 0x2d, 0x32, 0xf4, 0x39, 0xc, 0x2d, + 0xbd, 0xc, 0x2f, 0x95, 0x6, 0x31, 0xf9, 0x81, 0xa0, 0xad, 0x97, + 0x76, 0x16, 0x6c, 0x2a, 0xf7, 0xba, 0xce, 0xaa, 0x40, 0x62}, + {0x9c, 0x91, 0xba, 0xdd, 0xd4, 0x1f, 0xce, 0xb4, 0xaa, 0x8d, 0x4c, + 0xc7, 0x3e, 0xdb, 0x31, 0xcf, 0x51, 0xcc, 0x86, 0xad, 0x63, 0xcc, + 0x63, 0x2c, 0x7, 0xde, 0x1d, 0xbc, 0x3f, 0x14, 0xe2, 0x43}, + {0xa0, 0x95, 0xa2, 0x5b, 0x9c, 0x74, 0x34, 0xf8, 0x5a, 0xd2, 0x37, + 0xca, 0x5b, 0x7c, 0x94, 0xd6, 0x6a, 0x31, 0xc9, 0xe7, 0xa7, 0x3b, + 0xf1, 0x66, 0xac, 0xc, 0xb4, 0x8d, 0x23, 0xaf, 0xbd, 0x56}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 232464058235826, 1948628555342434, 1835348780427694, - 1031609499437291, 64472106918373 -#else - 27081650, 3463984, 14099042, 29036828, 1616302, 27348828, - 29542635, 15372179, 17293797, 960709 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 767338676040683, 754089548318405, 1523192045639075, - 435746025122062, 512692508440385 -#else - 20263915, 11434237, 61343429, 11236809, 13505955, 22697330, - 50997518, 6493121, 47724353, 7639713 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1255955808701983, 1700487367990941, 1166401238800299, - 1175121994891534, 1190934801395380 -#else - 64278047, 18715199, 25403037, 25339236, 58791851, 17380732, - 18006286, 17510682, 29994676, 17746311 -#endif - }}, + {0xb2, 0x3b, 0x9d, 0xc1, 0x6c, 0xd3, 0x10, 0x13, 0xb9, 0x86, 0x23, + 0x62, 0xb7, 0x6b, 0x2a, 0x6, 0x5c, 0x4f, 0xa1, 0xd7, 0x91, 0x85, + 0x9b, 0x7c, 0x54, 0x57, 0x1e, 0x7e, 0x50, 0x31, 0xaa, 0x3}, + {0xeb, 0x33, 0x35, 0xf5, 0xe3, 0xb9, 0x2a, 0x36, 0x40, 0x3d, 0xb9, + 0x6e, 0xd5, 0x68, 0x85, 0x33, 0x72, 0x55, 0x5a, 0x1d, 0x52, 0x14, + 0xe, 0x9e, 0x18, 0x13, 0x74, 0x83, 0x6d, 0xa8, 0x24, 0x1d}, + {0x1f, 0xce, 0xd4, 0xff, 0x48, 0x76, 0xec, 0xf4, 0x1c, 0x8c, 0xac, + 0x54, 0xf0, 0xea, 0x45, 0xe0, 0x7c, 0x35, 0x9, 0x1d, 0x82, 0x25, + 0xd2, 0x88, 0x59, 0x48, 0xeb, 0x9a, 0xdc, 0x61, 0xb2, 0x43}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 349144008168292, 1337012557669162, 1475912332999108, - 1321618454900458, 47611291904320 -#else - 9769828, 5202651, 42951466, 19923039, 39057860, 21992807, - 42495722, 19693649, 35924288, 709463 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 877519947135419, 2172838026132651, 272304391224129, - 1655143327559984, 886229406429814 -#else - 12286395, 13076066, 45333675, 32377809, 42105665, 4057651, - 35090736, 24663557, 16102006, 13205847 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 375806028254706, 214463229793940, 572906353144089, - 572168269875638, 697556386112979 -#else - 13733362, 5599946, 10557076, 3195751, 61550873, 8536969, - 41568694, 8525971, 10151379, 10394400 -#endif - }}, + {0x64, 0x13, 0x95, 0x6c, 0x8b, 0x3d, 0x51, 0x19, 0x7b, 0xf4, 0xb, + 0x0, 0x26, 0x71, 0xfe, 0x94, 0x67, 0x95, 0x4f, 0xd5, 0xdd, 0x10, + 0x8d, 0x2, 0x64, 0x9, 0x94, 0x42, 0xe2, 0xd5, 0xb4, 0x2}, + {0xbb, 0x79, 0xbb, 0x88, 0x19, 0x1e, 0x5b, 0xe5, 0x9d, 0x35, 0x7a, + 0xc1, 0x7d, 0xd0, 0x9e, 0xa0, 0x33, 0xea, 0x3d, 0x60, 0xe2, 0x2e, + 0x2c, 0xb0, 0xc2, 0x6b, 0x27, 0x5b, 0xcf, 0x55, 0x60, 0x32}, + {0xf2, 0x8d, 0xd1, 0x28, 0xcb, 0x55, 0xa1, 0xb4, 0x8, 0xe5, 0x6c, + 0x18, 0x46, 0x46, 0xcc, 0xea, 0x89, 0x43, 0x82, 0x6c, 0x93, 0xf4, + 0x9c, 0xc4, 0x10, 0x34, 0x5d, 0xae, 0x9, 0xc8, 0xa6, 0x27}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1168827102357844, 823864273033637, 2071538752104697, - 788062026895924, 599578340743362 -#else - 4024660, 17416881, 22436261, 12276534, 58009849, 30868332, - 19698228, 11743039, 33806530, 8934413 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1948116082078088, 2054898304487796, 2204939184983900, - 210526805152138, 786593586607626 -#else - 51229064, 29029191, 58528116, 30620370, 14634844, 32856154, - 57659786, 3137093, 55571978, 11721157 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1915320147894736, 156481169009469, 655050471180417, - 592917090415421, 2165897438660879 -#else - 17555920, 28540494, 8268605, 2331751, 44370049, 9761012, - 9319229, 8835153, 57903375, 32274386 -#endif - }}, + {0x54, 0x69, 0x3d, 0xc4, 0xa, 0x27, 0x2c, 0xcd, 0xb2, 0xca, 0x66, + 0x6a, 0x57, 0x3e, 0x4a, 0xdd, 0x6c, 0x3, 0xd7, 0x69, 0x24, 0x59, + 0xfa, 0x79, 0x99, 0x25, 0x8c, 0x3d, 0x60, 0x3, 0x15, 0x22}, + {0x88, 0xb1, 0xd, 0x1f, 0xcd, 0xeb, 0xa6, 0x8b, 0xe8, 0x5b, 0x5a, + 0x67, 0x3a, 0xd7, 0xd3, 0x37, 0x5a, 0x58, 0xf5, 0x15, 0xa3, 0xdf, + 0x2e, 0xf2, 0x7e, 0xa1, 0x60, 0xff, 0x74, 0x71, 0xb6, 0x2c}, + {0xd0, 0xe1, 0xb, 0x39, 0xf9, 0xcd, 0xee, 0x59, 0xf1, 0xe3, 0x8c, + 0x72, 0x44, 0x20, 0x42, 0xa9, 0xf4, 0xf0, 0x94, 0x7a, 0x66, 0x1c, + 0x89, 0x82, 0x36, 0xf4, 0x90, 0x38, 0xb7, 0xf4, 0x1d, 0x7b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1726336468579724, 1119932070398949, 1929199510967666, - 33918788322959, 1836837863503150 -#else - 66647436, 25724417, 20614117, 16688288, 59594098, 28747312, - 22300303, 505429, 6108462, 27371017 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 829996854845988, 217061778005138, 1686565909803640, - 1346948817219846, 1723823550730181 -#else - 62038564, 12367916, 36445330, 3234472, 32617080, 25131790, - 29880582, 20071101, 40210373, 25686972 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 384301494966394, 687038900403062, 2211195391021739, - 254684538421383, 1245698430589680 -#else - 35133562, 5726538, 26934134, 10237677, 63935147, 32949378, - 24199303, 3795095, 7592688, 18562353 -#endif - }}, + {0x8c, 0xf5, 0xf8, 0x7, 0x18, 0x22, 0x2e, 0x5f, 0xd4, 0x9, 0x94, + 0xd4, 0x9f, 0x5c, 0x55, 0xe3, 0x30, 0xa6, 0xb6, 0x1f, 0x8d, 0xa8, + 0xaa, 0xb2, 0x3d, 0xe0, 0x52, 0xd3, 0x45, 0x82, 0x69, 0x68}, + {0x24, 0xa2, 0xb2, 0xb3, 0xe0, 0xf2, 0x92, 0xe4, 0x60, 0x11, 0x55, + 0x2b, 0x6, 0x9e, 0x6c, 0x7c, 0xe, 0x7b, 0x7f, 0xd, 0xe2, 0x8f, + 0xeb, 0x15, 0x92, 0x59, 0xfc, 0x58, 0x26, 0xef, 0xfc, 0x61}, + {0x7a, 0x18, 0x18, 0x2a, 0x85, 0x5d, 0xb1, 0xdb, 0xd7, 0xac, 0xdd, + 0x86, 0xd3, 0xaa, 0xe4, 0xf3, 0x82, 0xc4, 0xf6, 0xf, 0x81, 0xe2, + 0xba, 0x44, 0xcf, 0x1, 0xaf, 0x3d, 0x47, 0x4c, 0xcf, 0x46}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1247567493562688, 1978182094455847, 183871474792955, - 806570235643435, 288461518067916 -#else - 21594432, 18590204, 17466407, 29477210, 32537083, 2739898, - 6407723, 12018833, 38852812, 4298411 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1449077384734201, 38285445457996, 2136537659177832, - 2146493000841573, 725161151123125 -#else - 46458361, 21592935, 39872588, 570497, 3767144, 31836892, - 13891941, 31985238, 13717173, 10805743 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1201928866368855, 800415690605445, 1703146756828343, - 997278587541744, 1858284414104014 -#else - 52432215, 17910135, 15287173, 11927123, 24177847, 25378864, - 66312432, 14860608, 40169934, 27690595 -#endif - }}, + {0x40, 0x81, 0x49, 0xf1, 0xa7, 0x6e, 0x3c, 0x21, 0x54, 0x48, 0x2b, + 0x39, 0xf8, 0x7e, 0x1e, 0x7c, 0xba, 0xce, 0x29, 0x56, 0x8c, 0xc3, + 0x88, 0x24, 0xbb, 0xc5, 0x8c, 0xd, 0xe5, 0xaa, 0x65, 0x10}, + {0xf9, 0xe5, 0xc4, 0x9e, 0xed, 0x25, 0x65, 0x42, 0x3, 0x33, 0x90, + 0x16, 0x1, 0xda, 0x5e, 0xe, 0xdc, 0xca, 0xe5, 0xcb, 0xf2, 0xa7, + 0xb1, 0x72, 0x40, 0x5f, 0xeb, 0x14, 0xcd, 0x7b, 0x38, 0x29}, + {0x57, 0xd, 0x20, 0xdf, 0x25, 0x45, 0x2c, 0x1c, 0x4a, 0x67, 0xca, + 0xbf, 0xd6, 0x2d, 0x3b, 0x5c, 0x30, 0x40, 0x83, 0xe1, 0xb1, 0xe7, + 0x7, 0xa, 0x16, 0xe7, 0x1c, 0x4f, 0xe6, 0x98, 0xa1, 0x69}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 356468809648877, 782373916933152, 1718002439402870, - 1392222252219254, 663171266061951 -#else - 12962541, 5311799, 57048096, 11658279, 18855286, 25600231, - 13286262, 20745728, 62727807, 9882021 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 759628738230460, 1012693474275852, 353780233086498, - 246080061387552, 2030378857679162 -#else - 18512060, 11319350, 46985740, 15090308, 18818594, 5271736, - 44380960, 3666878, 43141434, 30255002 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2040672435071076, 888593182036908, 1298443657189359, - 1804780278521327, 354070726137060 -#else - 60319844, 30408388, 16192428, 13241070, 15898607, 19348318, - 57023983, 26893321, 64705764, 5276064 -#endif - }}, + {0xed, 0xca, 0xc5, 0xdc, 0x34, 0x44, 0x1, 0xe1, 0x33, 0xfb, 0x84, + 0x3c, 0x96, 0x5d, 0xed, 0x47, 0xe7, 0xa0, 0x86, 0xed, 0x76, 0x95, + 0x1, 0x70, 0xe4, 0xf9, 0x67, 0xd2, 0x7b, 0x69, 0xb2, 0x25}, + {0xbc, 0x78, 0x1a, 0xd9, 0xe0, 0xb2, 0x62, 0x90, 0x67, 0x96, 0x50, + 0xc8, 0x9c, 0x88, 0xc9, 0x47, 0xb8, 0x70, 0x50, 0x40, 0x66, 0x4a, + 0xf5, 0x9d, 0xbf, 0xa1, 0x93, 0x24, 0xa9, 0xe6, 0x69, 0x73}, + {0x64, 0x68, 0x98, 0x13, 0xfb, 0x3f, 0x67, 0x9d, 0xb8, 0xc7, 0x5d, + 0x41, 0xd9, 0xfb, 0xa5, 0x3c, 0x5e, 0x3b, 0x27, 0xdf, 0x3b, 0xcc, + 0x4e, 0xe0, 0xd2, 0x4c, 0x4e, 0xb5, 0x3d, 0x68, 0x20, 0x14}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1894938527423184, 1463213041477277, 474410505497651, - 247294963033299, 877975941029128 -#else - 30169808, 28236784, 26306205, 21803573, 27814963, 7069267, - 7152851, 3684982, 1449224, 13082861 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 207937160991127, 12966911039119, 820997788283092, - 1010440472205286, 1701372890140810 -#else - 10342807, 3098505, 2119311, 193222, 25702612, 12233820, - 23697382, 15056736, 46092426, 25352431 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 218882774543183, 533427444716285, 1233243976733245, - 435054256891319, 1509568989549904 -#else - 33958735, 3261607, 22745853, 7948688, 19370557, 18376767, - 40936887, 6482813, 56808784, 22494330 -#endif - }}, + {0xd0, 0x5a, 0xcc, 0xc1, 0x6f, 0xbb, 0xee, 0x34, 0x8b, 0xac, 0x46, + 0x96, 0xe9, 0xc, 0x1b, 0x6a, 0x53, 0xde, 0x6b, 0xa6, 0x49, 0xda, + 0xb0, 0xd3, 0xc1, 0x81, 0xd0, 0x61, 0x41, 0x3b, 0xe8, 0x31}, + {0x97, 0xd1, 0x9d, 0x24, 0x1e, 0xbd, 0x78, 0xb4, 0x2, 0xc1, 0x58, + 0x5e, 0x0, 0x35, 0xc, 0x62, 0x5c, 0xac, 0xba, 0xcc, 0x2f, 0xd3, + 0x2, 0xfb, 0x2d, 0xa7, 0x8, 0xf5, 0xeb, 0x3b, 0xb6, 0x60}, + {0x4f, 0x2b, 0x6, 0x9e, 0x12, 0xc7, 0xe8, 0x97, 0xd8, 0xa, 0x32, + 0x29, 0x4f, 0x8f, 0xe4, 0x49, 0x3f, 0x68, 0x18, 0x6f, 0x4b, 0xe1, + 0xec, 0x5b, 0x17, 0x3, 0x55, 0x2d, 0xb6, 0x1e, 0xcf, 0x55}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1888838535711826, 1052177758340622, 1213553803324135, - 169182009127332, 463374268115872 -#else - 32869458, 28145887, 25609742, 15678670, 56421095, 18083360, - 26112420, 2521008, 44444576, 6904814 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 299137589460312, 1594371588983567, 868058494039073, - 257771590636681, 1805012993142921 -#else - 29506904, 4457497, 3377935, 23757988, 36598817, 12935079, - 1561737, 3841096, 38105225, 26896789 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1806842755664364, 2098896946025095, 1356630998422878, - 1458279806348064, 347755825962072 -#else - 10340844, 26924055, 48452231, 31276001, 12621150, 20215377, - 30878496, 21730062, 41524312, 5181965 -#endif - }}, + {0x52, 0x8c, 0xf5, 0x7d, 0xe3, 0xb5, 0x76, 0x30, 0x36, 0xcc, 0x99, + 0xe7, 0xdd, 0xb9, 0x3a, 0xd7, 0x20, 0xee, 0x13, 0x49, 0xe3, 0x1c, + 0x83, 0xbd, 0x33, 0x1, 0xba, 0x62, 0xaa, 0xfb, 0x56, 0x1a}, + {0x58, 0x3d, 0xc2, 0x65, 0x10, 0x10, 0x79, 0x58, 0x9c, 0x81, 0x94, + 0x50, 0x6d, 0x8, 0x9d, 0x8b, 0xa7, 0x5f, 0xc5, 0x12, 0xa9, 0x2f, + 0x40, 0xe2, 0xd4, 0x91, 0x8, 0x57, 0x64, 0x65, 0x9a, 0x66}, + {0xec, 0xc9, 0x9d, 0x5c, 0x50, 0x6b, 0x3e, 0x94, 0x1a, 0x37, 0x7c, + 0xa7, 0xbb, 0x57, 0x25, 0x30, 0x51, 0x76, 0x34, 0x41, 0x56, 0xae, + 0x73, 0x98, 0x5c, 0x8a, 0xc5, 0x99, 0x67, 0x83, 0xc4, 0x13}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1402334161391744, 1560083671046299, 1008585416617747, - 1147797150908892, 1420416683642459 -#else - 25940096, 20896407, 17324187, 23247058, 58437395, 15029093, - 24396252, 17103510, 64786011, 21165857 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 665506704253369, 273770475169863, 799236974202630, - 848328990077558, 1811448782807931 -#else - 45343161, 9916822, 65808455, 4079497, 66080518, 11909558, - 1782390, 12641087, 20603771, 26992690 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1468412523962641, 771866649897997, 1931766110147832, - 799561180078482, 524837559150077 -#else - 48226577, 21881051, 24849421, 11501709, 13161720, 28785558, - 1925522, 11914390, 4662781, 7820689 -#endif - }}, + {0x80, 0xd0, 0x8b, 0x5d, 0x6a, 0xfb, 0xdc, 0xc4, 0x42, 0x48, 0x1a, + 0x57, 0xec, 0xc4, 0xeb, 0xde, 0x65, 0x53, 0xe5, 0xb8, 0x83, 0xe8, + 0xb2, 0xd4, 0x27, 0xb8, 0xe5, 0xc8, 0x7d, 0xc8, 0xbd, 0x50}, + {0xb9, 0xe1, 0xb3, 0x5a, 0x46, 0x5d, 0x3a, 0x42, 0x61, 0x3f, 0xf1, + 0xc7, 0x87, 0xc1, 0x13, 0xfc, 0xb6, 0xb9, 0xb5, 0xec, 0x64, 0x36, + 0xf8, 0x19, 0x7, 0xb6, 0x37, 0xa6, 0x93, 0xc, 0xf8, 0x66}, + {0x11, 0xe1, 0xdf, 0x6e, 0x83, 0x37, 0x6d, 0x60, 0xd9, 0xab, 0x11, + 0xf0, 0x15, 0x3e, 0x35, 0x32, 0x96, 0x3b, 0xb7, 0x25, 0xc3, 0x3a, + 0xb0, 0x64, 0xae, 0xd5, 0x5f, 0x72, 0x44, 0x64, 0xd5, 0x1d}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2223212657821850, 630416247363666, 2144451165500328, - 816911130947791, 1024351058410032 -#else - 12241050, 33128450, 8132690, 9393934, 32846760, 31954812, - 29749455, 12172924, 16136752, 15264020 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1266603897524861, 156378408858100, 1275649024228779, - 447738405888420, 253186462063095 -#else - 56758909, 18873868, 58896884, 2330219, 49446315, 19008651, - 10658212, 6671822, 19012087, 3772772 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2022215964509735, 136144366993649, 1800716593296582, - 1193970603800203, 871675847064218 -#else - 3753511, 30133366, 10617073, 2028709, 14841030, 26832768, - 28718731, 17791548, 20527770, 12988982 -#endif - }}, + {0x9a, 0xc8, 0xba, 0x8, 0x0, 0xe6, 0x97, 0xc2, 0xe0, 0xc3, 0xe1, + 0xea, 0x11, 0xea, 0x4c, 0x7d, 0x7c, 0x97, 0xe7, 0x9f, 0xe1, 0x8b, + 0xe3, 0xf3, 0xcd, 0x5, 0xa3, 0x63, 0xf, 0x45, 0x3a, 0x3a}, + {0x7d, 0x12, 0x62, 0x33, 0xf8, 0x7f, 0xa4, 0x8f, 0x15, 0x7c, 0xcd, + 0x71, 0xc4, 0x6a, 0x9f, 0xbc, 0x8b, 0xc, 0x22, 0x49, 0x43, 0x45, + 0x71, 0x6e, 0x2e, 0x73, 0x9f, 0x21, 0x12, 0x59, 0x64, 0xe}, + {0x27, 0x46, 0x39, 0xd8, 0x31, 0x2f, 0x8f, 0x7, 0x10, 0xa5, 0x94, + 0xde, 0x83, 0x31, 0x9d, 0x38, 0x80, 0x6f, 0x99, 0x17, 0x6d, 0x6c, + 0xe3, 0xd1, 0x7b, 0xa8, 0xa9, 0x93, 0x93, 0x8d, 0x8c, 0x31}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1862751661970328, 851596246739884, 1519315554814041, - 1542798466547449, 1417975335901520 -#else - 52286360, 27757162, 63400876, 12689772, 66209881, 22639565, - 42925817, 22989488, 3299664, 21129479 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1228168094547481, 334133883362894, 587567568420081, - 433612590281181, 603390400373205 -#else - 50331161, 18301130, 57466446, 4978982, 3308785, 8755439, - 6943197, 6461331, 41525717, 8991217 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 121893973206505, 1843345804916664, 1703118377384911, - 497810164760654, 101150811654673 -#else - 49882601, 1816361, 65435576, 27467992, 31783887, 25378441, - 34160718, 7417949, 36866577, 1507264 -#endif - }}, + {0x98, 0xd3, 0x1d, 0xab, 0x29, 0x9e, 0x66, 0x5d, 0x3b, 0x9e, 0x2d, + 0x34, 0x58, 0x16, 0x92, 0xfc, 0xcd, 0x73, 0x59, 0xf3, 0xfd, 0x1d, + 0x85, 0x55, 0xf6, 0xa, 0x95, 0x25, 0xc3, 0x41, 0x9a, 0x50}, + {0x19, 0xfe, 0xff, 0x2a, 0x3, 0x5d, 0x74, 0xf2, 0x66, 0xdb, 0x24, + 0x7f, 0x49, 0x3c, 0x9f, 0xc, 0xef, 0x98, 0x85, 0xba, 0xe3, 0xd3, + 0x98, 0xbc, 0x14, 0x53, 0x1d, 0x9a, 0x67, 0x7c, 0x4c, 0x22}, + {0xe9, 0x25, 0xf9, 0xa6, 0xdc, 0x6e, 0xc0, 0xbd, 0x33, 0x1f, 0x1b, + 0x64, 0xf4, 0xf3, 0x3e, 0x79, 0x89, 0x3e, 0x83, 0x9d, 0x80, 0x12, + 0xec, 0x82, 0x89, 0x13, 0xa1, 0x28, 0x23, 0xf0, 0xbf, 0x5}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 458346255946468, 290909935619344, 1452768413850679, - 550922875254215, 1537286854336538 -#else - 29692644, 6829891, 56610064, 4334895, 20945975, 21647936, - 38221255, 8209390, 14606362, 22907359 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 584322311184395, 380661238802118, 114839394528060, - 655082270500073, 2111856026034852 -#else - 63627275, 8707080, 32188102, 5672294, 22096700, 1711240, - 34088169, 9761486, 4170404, 31469107 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 996965581008991, 2148998626477022, 1012273164934654, - 1073876063914522, 1688031788934939 -#else - 55521375, 14855944, 62981086, 32022574, 40459774, 15084045, - 22186522, 16002000, 52832027, 25153633 -#endif - }}, + {0xe4, 0x12, 0xc5, 0xd, 0xdd, 0xa0, 0x81, 0x68, 0xfe, 0xfa, 0xa5, + 0x44, 0xc8, 0xd, 0xe7, 0x4f, 0x40, 0x52, 0x4a, 0x8f, 0x6b, 0x8e, + 0x74, 0x1f, 0xea, 0xa3, 0x1, 0xee, 0xcd, 0x77, 0x62, 0x57}, + {0xb, 0xe0, 0xca, 0x23, 0x70, 0x13, 0x32, 0x36, 0x59, 0xcf, 0xac, + 0xd1, 0xa, 0xcf, 0x4a, 0x54, 0x88, 0x1c, 0x1a, 0xd2, 0x49, 0x10, + 0x74, 0x96, 0xa7, 0x44, 0x2a, 0xfa, 0xc3, 0x8c, 0xb, 0x78}, + {0x5f, 0x30, 0x4f, 0x23, 0xbc, 0x8a, 0xf3, 0x1e, 0x8, 0xde, 0x5, + 0x14, 0xbd, 0x7f, 0x57, 0x9a, 0xd, 0x2a, 0xe6, 0x34, 0x14, 0xa5, + 0x82, 0x5e, 0xa1, 0xb7, 0x71, 0x62, 0x72, 0x18, 0xf4, 0x5f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 923487018849600, 2085106799623355, 528082801620136, - 1606206360876188, 735907091712524 -#else - 62297408, 13761028, 35404987, 31070512, 63796392, 7869046, - 59995292, 23934339, 13240844, 10965870 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1697697887804317, 1335343703828273, 831288615207040, - 949416685250051, 288760277392022 -#else - 59366301, 25297669, 52340529, 19898171, 43876480, 12387165, - 4498947, 14147411, 29514390, 4302863 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1419122478109648, 1325574567803701, 602393874111094, - 2107893372601700, 1314159682671307 -#else - 53695440, 21146572, 20757301, 19752600, 14785142, 8976368, - 62047588, 31410058, 17846987, 19582505 -#endif - }}, + {0x40, 0x95, 0xb6, 0x13, 0xe8, 0x47, 0xdb, 0xe5, 0xe1, 0x10, 0x26, + 0x43, 0x3b, 0x2a, 0x5d, 0xf3, 0x76, 0x12, 0x78, 0x38, 0xe9, 0x26, + 0x1f, 0xac, 0x69, 0xcb, 0xa0, 0xa0, 0x8c, 0xdb, 0xd4, 0x29}, + {0x9d, 0xdb, 0x89, 0x17, 0xc, 0x8, 0x8e, 0x39, 0xf5, 0x78, 0xe7, + 0xf3, 0x25, 0x20, 0x60, 0xa7, 0x5d, 0x3, 0xbd, 0x6, 0x4c, 0x89, + 0x98, 0xfa, 0xbe, 0x66, 0xa9, 0x25, 0xdc, 0x3, 0x6a, 0x10}, + {0xd0, 0x53, 0x33, 0x33, 0xaf, 0xa, 0xad, 0xd9, 0xe5, 0x9, 0xd3, + 0xac, 0xa5, 0x9d, 0x66, 0x38, 0xf0, 0xf7, 0x88, 0xc8, 0x8a, 0x65, + 0x57, 0x3c, 0xfa, 0xbe, 0x2c, 0x5, 0x51, 0x8a, 0xb3, 0x4a}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2201150872731804, 2180241023425241, 97663456423163, - 1633405770247824, 848945042443986 -#else - 64864412, 32799703, 62511833, 32488122, 60861691, 1455298, - 45461136, 24339642, 61886162, 12650266 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1173339555550611, 818605084277583, 47521504364289, - 924108720564965, 735423405754506 -#else - 57202067, 17484121, 21134159, 12198166, 40044289, 708125, - 387813, 13770293, 47974538, 10958662 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 830104860549448, 1886653193241086, 1600929509383773, - 1475051275443631, 286679780900937 -#else - 22470984, 12369526, 23446014, 28113323, 45588061, 23855708, - 55336367, 21979976, 42025033, 4271861 -#endif - }}, + {0x9c, 0xc0, 0xdd, 0x5f, 0xef, 0xd1, 0xcf, 0xd6, 0xce, 0x5d, 0x57, + 0xf7, 0xfd, 0x3e, 0x2b, 0xe8, 0xc2, 0x34, 0x16, 0x20, 0x5d, 0x6b, + 0xd5, 0x25, 0x9b, 0x2b, 0xed, 0x4, 0xbb, 0xc6, 0x41, 0x30}, + {0x93, 0xd5, 0x68, 0x67, 0x25, 0x2b, 0x7c, 0xda, 0x13, 0xca, 0x22, + 0x44, 0x57, 0xc0, 0xc1, 0x98, 0x1d, 0xce, 0xa, 0xca, 0xd5, 0xb, + 0xa8, 0xf1, 0x90, 0xa6, 0x88, 0xc0, 0xad, 0xd1, 0xcd, 0x29}, + {0x48, 0xe1, 0x56, 0xd9, 0xf9, 0xf2, 0xf2, 0xf, 0x2e, 0x6b, 0x35, + 0x9f, 0x75, 0x97, 0xe7, 0xad, 0x5c, 0x2, 0x6c, 0x5f, 0xbb, 0x98, + 0x46, 0x1a, 0x7b, 0x9a, 0x4, 0x14, 0x68, 0xbd, 0x4b, 0x10}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1577111294832995, 1030899169768747, 144900916293530, - 1964672592979567, 568390100955250 -#else - 41939299, 23500789, 47199531, 15361594, 61124506, 2159191, - 75375, 29275903, 34582642, 8469672 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 278388655910247, 487143369099838, 927762205508727, - 181017540174210, 1616886700741287 -#else - 15854951, 4148314, 58214974, 7259001, 11666551, 13824734, - 36577666, 2697371, 24154791, 24093489 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1191033906638969, 940823957346562, 1606870843663445, - 861684761499847, 658674867251089 -#else - 15446137, 17747788, 29759746, 14019369, 30811221, 23944241, - 35526855, 12840103, 24913809, 9815020 -#endif - }}, + {0x63, 0xf1, 0x7f, 0xd6, 0x5f, 0x9a, 0x5d, 0xa9, 0x81, 0x56, 0xc7, + 0x4c, 0x9d, 0xe6, 0x2b, 0xe9, 0x57, 0xf2, 0x20, 0xde, 0x4c, 0x2, + 0xf8, 0xb7, 0xf5, 0x2d, 0x7, 0xfb, 0x20, 0x2a, 0x4f, 0x20}, + {0x67, 0xed, 0xf1, 0x68, 0x31, 0xfd, 0xf0, 0x51, 0xc2, 0x3b, 0x6f, + 0xd8, 0xcd, 0x1d, 0x81, 0x2c, 0xde, 0xf2, 0xd2, 0x4, 0x43, 0x5c, + 0xdc, 0x44, 0x49, 0x71, 0x2a, 0x9, 0x57, 0xcc, 0xe8, 0x5b}, + {0x79, 0xb0, 0xeb, 0x30, 0x3d, 0x3b, 0x14, 0xc8, 0x30, 0x2e, 0x65, + 0xbd, 0x5a, 0x15, 0x89, 0x75, 0x31, 0x5c, 0x6d, 0x8f, 0x31, 0x3c, + 0x3c, 0x65, 0x1f, 0x16, 0x79, 0xc2, 0x17, 0xfb, 0x70, 0x25}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1875032594195546, 1427106132796197, 724736390962158, - 901860512044740, 635268497268760 -#else - 62399578, 27940162, 35267365, 21265538, 52665326, 10799413, - 58005188, 13438768, 18735128, 9466238 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 622869792298357, 1903919278950367, 1922588621661629, - 1520574711600434, 1087100760174640 -#else - 11933045, 9281483, 5081055, 28370608, 64480701, 28648802, - 59381042, 22658328, 44380208, 16199063 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 25465949416618, 1693639527318811, 1526153382657203, - 125943137857169, 145276964043999 -#else - 14576810, 379472, 40322331, 25237195, 37682355, 22741457, - 67006097, 1876698, 30801119, 2164795 -#endif - }}, + {0x5a, 0x24, 0xb8, 0xb, 0x55, 0xa9, 0x2e, 0x19, 0xd1, 0x50, 0x90, + 0x8f, 0xa8, 0xfb, 0xe6, 0xc8, 0x35, 0xc9, 0xa4, 0x88, 0x2d, 0xea, + 0x86, 0x79, 0x68, 0x86, 0x1, 0xde, 0x91, 0x5f, 0x1c, 0x24}, + {0x75, 0x15, 0xb6, 0x2c, 0x7f, 0x36, 0xfa, 0x3e, 0x6c, 0x2, 0xd6, + 0x1c, 0x76, 0x6f, 0xf9, 0xf5, 0x62, 0x25, 0xb5, 0x65, 0x2a, 0x14, + 0xc7, 0xe8, 0xcd, 0xa, 0x3, 0x53, 0xea, 0x65, 0xcb, 0x3d}, + {0xaa, 0x6c, 0xde, 0x40, 0x29, 0x17, 0xd8, 0x28, 0x3a, 0x73, 0xd9, + 0x22, 0xf0, 0x2c, 0xbf, 0x8f, 0xd1, 0x1, 0x5b, 0x23, 0xdd, 0xfc, + 0xd7, 0x16, 0xe5, 0xf0, 0xcd, 0x5f, 0xdd, 0xe, 0x42, 0x8}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 214739857969358, 920212862967915, 1939901550972269, - 1211862791775221, 85097515720120 -#else - 15995086, 3199873, 13672555, 13712240, 47730029, 28906785, - 54027253, 18058162, 53616056, 1268051 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2006245852772938, 734762734836159, 254642929763427, - 1406213292755966, 239303749517686 -#else - 56818250, 29895392, 63822271, 10948817, 23037027, 3794475, - 63638526, 20954210, 50053494, 3565903 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1619678837192149, 1919424032779215, 1357391272956794, - 1525634040073113, 1310226789796241 -#else - 29210069, 24135095, 61189071, 28601646, 10834810, 20226706, - 50596761, 22733718, 39946641, 19523900 -#endif - }}, + {0xce, 0x10, 0xf4, 0x4, 0x4e, 0xc3, 0x58, 0x3, 0x85, 0x6, 0x6e, + 0x27, 0x5a, 0x5b, 0x13, 0xb6, 0x21, 0x15, 0xb9, 0xeb, 0xc7, 0x70, + 0x96, 0x5d, 0x9c, 0x88, 0xdb, 0x21, 0xf3, 0x54, 0xd6, 0x4}, + {0x4a, 0xfa, 0x62, 0x83, 0xab, 0x20, 0xff, 0xcd, 0x6e, 0x3e, 0x1a, + 0xe2, 0xd4, 0x18, 0xe1, 0x57, 0x2b, 0xe6, 0x39, 0xfc, 0x17, 0x96, + 0x17, 0xe3, 0xfd, 0x69, 0x17, 0xbc, 0xef, 0x53, 0x9a, 0xd}, + {0xd5, 0xb5, 0xbd, 0xdd, 0x16, 0xc1, 0x7d, 0x5e, 0x2d, 0xdd, 0xa5, + 0x8d, 0xb6, 0xde, 0x54, 0x29, 0x92, 0xa2, 0x34, 0x33, 0x17, 0x8, + 0xb6, 0x1c, 0xd7, 0x1a, 0x99, 0x18, 0x26, 0x4f, 0x7a, 0x4a}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1040763709762123, 1704449869235352, 605263070456329, - 1998838089036355, 1312142911487502 -#else - 53946955, 15508587, 16663704, 25398282, 38758921, 9019122, - 37925443, 29785008, 2244110, 19552453 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1996723311435669, 1844342766567060, 985455700466044, - 1165924681400960, 311508689870129 -#else - 61955989, 29753495, 57802388, 27482848, 16243068, 14684434, - 41435776, 17373631, 13491505, 4641841 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 43173156290518, 2202883069785309, 1137787467085917, - 1733636061944606, 1394992037553852 -#else - 10813398, 643330, 47920349, 32825515, 30292061, 16954354, - 27548446, 25833190, 14476988, 20787001 -#endif - }}, + {0x4b, 0x2a, 0x37, 0xaf, 0x91, 0xb2, 0xc3, 0x24, 0xf2, 0x47, 0x81, + 0x71, 0x70, 0x82, 0xda, 0x93, 0xf2, 0x9e, 0x89, 0x86, 0x64, 0x85, + 0x84, 0xdd, 0x33, 0xee, 0xe0, 0x23, 0x42, 0x31, 0x96, 0x4a}, + {0x95, 0x5f, 0xb1, 0x5f, 0x2, 0x18, 0xa7, 0xf4, 0x8f, 0x1b, 0x5c, + 0x6b, 0x34, 0x5f, 0xf6, 0x3d, 0x12, 0x11, 0xe0, 0x0, 0x85, 0xf0, + 0xfc, 0xcd, 0x48, 0x18, 0xd3, 0xdd, 0x4c, 0xc, 0xb5, 0x11}, + {0xd6, 0xff, 0xa4, 0x8, 0x44, 0x27, 0xe8, 0xa6, 0xd9, 0x76, 0x15, + 0x9c, 0x7e, 0x17, 0x8e, 0x73, 0xf2, 0xb3, 0x2, 0x3d, 0xb6, 0x48, + 0x33, 0x77, 0x51, 0xcc, 0x6b, 0xce, 0x4d, 0xce, 0x4b, 0x4f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 670078326344559, 555655025059356, 471959386282438, - 2141455487356409, 849015953823125 -#else - 10292079, 9984945, 6481436, 8279905, 59857350, 7032742, - 27282937, 31910173, 39196053, 12651323 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2197214573372804, 794254097241315, 1030190060513737, - 267632515541902, 2040478049202624 -#else - 35923332, 32741048, 22271203, 11835308, 10201545, 15351028, - 17099662, 3988035, 21721536, 30405492 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1812516004670529, 1609256702920783, 1706897079364493, - 258549904773295, 996051247540686 -#else - 10202177, 27008593, 35735631, 23979793, 34958221, 25434748, - 54202543, 3852693, 13216206, 14842320 -#endif - }}, + {0x6f, 0xb, 0x9d, 0xc4, 0x6e, 0x61, 0xe2, 0x30, 0x17, 0x23, 0xec, + 0xca, 0x8f, 0x71, 0x56, 0xe4, 0xa6, 0x4f, 0x6b, 0xf2, 0x9b, 0x40, + 0xeb, 0x48, 0x37, 0x5f, 0x59, 0x61, 0xe5, 0xce, 0x42, 0x30}, + {0x84, 0x25, 0x24, 0xe2, 0x5a, 0xce, 0x1f, 0xa7, 0x9e, 0x8a, 0xf5, + 0x92, 0x56, 0x72, 0xea, 0x26, 0xf4, 0x3c, 0xea, 0x1c, 0xd7, 0x9, + 0x1a, 0xd2, 0xe6, 0x1, 0x1c, 0xb7, 0x14, 0xdd, 0xfc, 0x73}, + {0x41, 0xac, 0x9b, 0x44, 0x79, 0x70, 0x7e, 0x42, 0xa, 0x31, 0xe2, + 0xbc, 0x6d, 0xe3, 0x5a, 0x85, 0x7c, 0x1a, 0x84, 0x5f, 0x21, 0x76, + 0xae, 0x4c, 0xd6, 0xe1, 0x9c, 0x9a, 0xc, 0x74, 0x9e, 0x38}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1540374301420584, 1764656898914615, 1810104162020396, - 923808779163088, 664390074196579 -#else - 51293224, 22953365, 60569911, 26295436, 60124204, 26972653, - 35608016, 13765823, 39674467, 9900183 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1323460699404750, 1262690757880991, 871777133477900, - 1060078894988977, 1712236889662886 -#else - 14465486, 19721101, 34974879, 18815558, 39665676, 12990491, - 33046193, 15796406, 60056998, 25514317 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1696163952057966, 1391710137550823, 608793846867416, - 1034391509472039, 1780770894075012 -#else - 30924398, 25274812, 6359015, 20738097, 16508376, 9071735, - 41620263, 15413634, 9524356, 26535554 -#endif - }}, + {0x28, 0xac, 0xe, 0x57, 0xf6, 0x78, 0xbd, 0xc9, 0xe1, 0x9c, 0x91, + 0x27, 0x32, 0xb, 0x5b, 0xe5, 0xed, 0x91, 0x9b, 0xa1, 0xab, 0x3e, + 0xfc, 0x65, 0x90, 0x36, 0x26, 0xd6, 0xe5, 0x25, 0xc4, 0x25}, + {0xce, 0xb9, 0xdc, 0x34, 0xae, 0xb3, 0xfc, 0x64, 0xad, 0xd0, 0x48, + 0xe3, 0x23, 0x3, 0x50, 0x97, 0x1b, 0x38, 0xc6, 0x62, 0x7d, 0xf0, + 0xb3, 0x45, 0x88, 0x67, 0x5a, 0x46, 0x79, 0x53, 0x54, 0x61}, + {0x6e, 0xde, 0xd7, 0xf1, 0xa6, 0x6, 0x3e, 0x3f, 0x8, 0x23, 0x6, + 0x8e, 0x27, 0x76, 0xf9, 0x3e, 0x77, 0x6c, 0x8a, 0x4e, 0x26, 0xf6, + 0x14, 0x8c, 0x59, 0x47, 0x48, 0x15, 0x89, 0xa0, 0x39, 0x65}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1367603834210841, 2131988646583224, 890353773628144, - 1908908219165595, 270836895252891 -#else - 12274201, 20378885, 32627640, 31769106, 6736624, 13267305, - 5237659, 28444949, 15663515, 4035784 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 597536315471731, 40375058742586, 1942256403956049, - 1185484645495932, 312666282024145 -#else - 64157555, 8903984, 17349946, 601635, 50676049, 28941875, - 53376124, 17665097, 44850385, 4659090 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1919411405316294, 1234508526402192, 1066863051997083, - 1008444703737597, 1348810787701552 -#else - 50192582, 28601458, 36715152, 18395610, 20774811, 15897498, - 5736189, 15026997, 64930608, 20098846 -#endif - }}, + {0x19, 0x4a, 0xbb, 0x14, 0xd4, 0xdb, 0xc4, 0xdd, 0x8e, 0x4f, 0x42, + 0x98, 0x3c, 0xbc, 0xb2, 0x19, 0x69, 0x71, 0xca, 0x36, 0xd7, 0x9f, + 0xa8, 0x48, 0x90, 0xbd, 0x19, 0xf0, 0xe, 0x32, 0x65, 0xf}, + {0x73, 0xf7, 0xd2, 0xc3, 0x74, 0x1f, 0xd2, 0xe9, 0x45, 0x68, 0xc4, + 0x25, 0x41, 0x54, 0x50, 0xc1, 0x33, 0x9e, 0xb9, 0xf9, 0xe8, 0x5c, + 0x4e, 0x62, 0x6c, 0x18, 0xcd, 0xc5, 0xaa, 0xe4, 0xc5, 0x11}, + {0xc6, 0xe0, 0xfd, 0xca, 0xb1, 0xd1, 0x86, 0xd4, 0x81, 0x51, 0x3b, + 0x16, 0xe3, 0xe6, 0x3f, 0x4f, 0x9a, 0x93, 0xf2, 0xfa, 0xd, 0xaf, + 0xa8, 0x59, 0x2a, 0x7, 0x33, 0xec, 0xbd, 0xc7, 0xab, 0x4c}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2102881477513865, 1570274565945361, 1573617900503708, - 18662635732583, 2232324307922098 -#else - 58249865, 31335375, 28571665, 23398914, 66634396, 23448733, - 63307367, 278094, 23440562, 33264224 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1853931367696942, 8107973870707, 350214504129299, - 775206934582587, 1752317649166792 -#else - 10226222, 27625730, 15139955, 120818, 52241171, 5218602, - 32937275, 11551483, 50536904, 26111567 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1417148368003523, 721357181628282, 505725498207811, - 373232277872983, 261634707184480 -#else - 17932739, 21117156, 43069306, 10749059, 11316803, 7535897, - 22503767, 5561594, 63462240, 3898660 -#endif - }}, + {0x89, 0xd2, 0x78, 0x3f, 0x8f, 0x78, 0x8f, 0xc0, 0x9f, 0x4d, 0x40, + 0xa1, 0x2c, 0xa7, 0x30, 0xfe, 0x9d, 0xcc, 0x65, 0xcf, 0xfc, 0x8b, + 0x77, 0xf2, 0x21, 0x20, 0xcb, 0x5a, 0x16, 0x98, 0xe4, 0x7e}, + {0x2e, 0xa, 0x9c, 0x8, 0x24, 0x96, 0x9e, 0x23, 0x38, 0x47, 0xfe, + 0x3a, 0xc0, 0xc4, 0x48, 0xc7, 0x2a, 0xa1, 0x4f, 0x76, 0x2a, 0xed, + 0xdb, 0x17, 0x82, 0x85, 0x1c, 0x32, 0xf0, 0x93, 0x9b, 0x63}, + {0xc3, 0xa1, 0x11, 0x91, 0xe3, 0x8, 0xd5, 0x7b, 0x89, 0x74, 0x90, + 0x80, 0xd4, 0x90, 0x2b, 0x2b, 0x19, 0xfd, 0x72, 0xae, 0xc2, 0xae, + 0xd2, 0xe7, 0xa6, 0x2, 0xb6, 0x85, 0x3c, 0x49, 0xdf, 0xe}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2186733281493267, 2250694917008620, 1014829812957440, - 479998161452389, 83566193876474 -#else - 7749907, 32584865, 50769132, 33537967, 42090752, 15122142, - 65535333, 7152529, 21831162, 1245233 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1268116367301224, 560157088142809, 802626839600444, - 2210189936605713, 1129993785579988 -#else - 26958440, 18896406, 4314585, 8346991, 61431100, 11960071, - 34519569, 32934396, 36706772, 16838219 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 615183387352312, 917611676109240, 878893615973325, - 978940963313282, 938686890583575 -#else - 54942968, 9166946, 33491384, 13673479, 29787085, 13096535, - 6280834, 14587357, 44770839, 13987524 -#endif - }}, + {0x13, 0x41, 0x76, 0x84, 0xd2, 0xc4, 0x67, 0x67, 0x35, 0xf8, 0xf5, + 0xf7, 0x3f, 0x40, 0x90, 0xa0, 0xde, 0xbe, 0xe6, 0xca, 0xfa, 0xcf, + 0x8f, 0x1c, 0x69, 0xa3, 0xdf, 0xd1, 0x54, 0xc, 0xc0, 0x4}, + {0x68, 0x5a, 0x9b, 0x59, 0x58, 0x81, 0xcc, 0xae, 0xe, 0xe2, 0xad, + 0xeb, 0xf, 0x4f, 0x57, 0xea, 0x7, 0x7f, 0xb6, 0x22, 0x74, 0x1d, + 0xe4, 0x4f, 0xb4, 0x4f, 0x9d, 0x1, 0xe3, 0x92, 0x3b, 0x40}, + {0xf8, 0x5c, 0x46, 0x8b, 0x81, 0x2f, 0xc2, 0x4d, 0xf8, 0xef, 0x80, + 0x14, 0x5a, 0xf3, 0xa0, 0x71, 0x57, 0xd6, 0xc7, 0x4, 0xad, 0xbf, + 0xe8, 0xae, 0xf4, 0x76, 0x61, 0xb2, 0x2a, 0xb1, 0x5b, 0x35}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 522024729211672, 1045059315315808, 1892245413707790, - 1907891107684253, 2059998109500714 -#else - 42758936, 7778774, 21116000, 15572597, 62275598, 28196653, - 62807965, 28429792, 59639082, 30696363 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1799679152208884, 912132775900387, 25967768040979, - 432130448590461, 274568990261996 -#else - 9681908, 26817309, 35157219, 13591837, 60225043, 386949, - 31622781, 6439245, 52527852, 4091396 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 98698809797682, 2144627600856209, 1907959298569602, - 811491302610148, 1262481774981493 -#else - 58682418, 1470726, 38999185, 31957441, 3978626, 28430809, - 47486180, 12092162, 29077877, 18812444 -#endif - }}, + {0x18, 0x73, 0x8c, 0x5a, 0xc7, 0xda, 0x1, 0xa3, 0x11, 0xaa, 0xce, + 0xb3, 0x9d, 0x3, 0x90, 0xed, 0x2d, 0x3f, 0xae, 0x3b, 0xbf, 0x7c, + 0x7, 0x6f, 0x8e, 0xad, 0x52, 0xe0, 0xf8, 0xea, 0x18, 0x75}, + {0xf4, 0xbb, 0x93, 0x74, 0xcc, 0x64, 0x1e, 0xa7, 0xc3, 0xb0, 0xa3, + 0xec, 0xd9, 0x84, 0xbd, 0xe5, 0x85, 0xe7, 0x5, 0xfa, 0xc, 0xc5, + 0x6b, 0xa, 0x12, 0xc3, 0x2e, 0x18, 0x32, 0x81, 0x9b, 0xf}, + {0x32, 0x6c, 0x7f, 0x1b, 0xc4, 0x59, 0x88, 0xa4, 0x98, 0x32, 0x38, + 0xf4, 0xbc, 0x60, 0x2d, 0xf, 0xd9, 0xd1, 0xb1, 0xc9, 0x29, 0xa9, + 0x15, 0x18, 0xc4, 0x55, 0x17, 0xbb, 0x1b, 0x87, 0xc3, 0x47}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1791451399743152, 1713538728337276, 118349997257490, - 1882306388849954, 158235232210248 -#else - 5269168, 26694706, 53878652, 25533716, 25932562, 1763552, - 61502754, 28048550, 47091016, 2357888 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1217809823321928, 2173947284933160, 1986927836272325, - 1388114931125539, 12686131160169 -#else - 32264008, 18146780, 61721128, 32394338, 65017541, 29607531, - 23104803, 20684524, 5727337, 189038 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1650875518872272, 1136263858253897, 1732115601395988, - 734312880662190, 1252904681142109 -#else - 14609104, 24599962, 61108297, 16931650, 52531476, 25810533, - 40363694, 10942114, 41219933, 18669734 -#endif - }}, + {0xb0, 0x66, 0x50, 0xc8, 0x50, 0x5d, 0xe6, 0xfb, 0xb0, 0x99, 0xa2, + 0xb3, 0xb0, 0xc4, 0xec, 0x62, 0xe0, 0xe8, 0x1a, 0x44, 0xea, 0x54, + 0x37, 0xe5, 0x5f, 0x8d, 0xd4, 0xe8, 0x2c, 0xa0, 0xfe, 0x8}, + {0x48, 0x4f, 0xec, 0x71, 0x97, 0x53, 0x44, 0x51, 0x6e, 0x5d, 0x8c, + 0xc9, 0x7d, 0xb1, 0x5, 0xf8, 0x6b, 0xc6, 0xc3, 0x47, 0x1a, 0xc1, + 0x62, 0xf7, 0xdc, 0x99, 0x46, 0x76, 0x85, 0x9b, 0xb8, 0x0}, + {0xd0, 0xea, 0xde, 0x68, 0x76, 0xdd, 0x4d, 0x82, 0x23, 0x5d, 0x68, + 0x4b, 0x20, 0x45, 0x64, 0xc8, 0x65, 0xd6, 0x89, 0x5d, 0xcd, 0xcf, + 0x14, 0xb5, 0x37, 0xd5, 0x75, 0x4f, 0xa7, 0x29, 0x38, 0x47}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 372986456113865, 525430915458171, 2116279931702135, - 501422713587815, 1907002872974925 -#else - 20513481, 5557931, 51504251, 7829530, 26413943, 31535028, - 45729895, 7471780, 13913677, 28416557 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 803147181835288, 868941437997146, 316299302989663, - 943495589630550, 571224287904572 -#else - 41534488, 11967825, 29233242, 12948236, 60354399, 4713226, - 58167894, 14059179, 12878652, 8511905 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 227742695588364, 1776969298667369, 628602552821802, - 457210915378118, 2041906378111140 -#else - 41452044, 3393630, 64153449, 26478905, 64858154, 9366907, - 36885446, 6812973, 5568676, 30426776 -#endif - }}, + {0xc9, 0x2, 0x39, 0xad, 0x3a, 0x53, 0xd9, 0x23, 0x8f, 0x58, 0x3, + 0xef, 0xce, 0xdd, 0xc2, 0x64, 0xb4, 0x2f, 0xe1, 0xcf, 0x90, 0x73, + 0x25, 0x15, 0x90, 0xd3, 0xe4, 0x44, 0x4d, 0x8b, 0x66, 0x6c}, + {0x18, 0xc4, 0x79, 0x46, 0x75, 0xda, 0xd2, 0x82, 0xf0, 0x8d, 0x61, + 0xb2, 0xd8, 0xd7, 0x3b, 0xe6, 0xa, 0xeb, 0x47, 0xac, 0x24, 0xef, + 0x5e, 0x35, 0xb4, 0xc6, 0x33, 0x48, 0x4c, 0x68, 0x78, 0x20}, + {0xc, 0x82, 0x78, 0x7a, 0x21, 0xcf, 0x48, 0x3b, 0x97, 0x3e, 0x27, + 0x81, 0xb2, 0xa, 0x6a, 0xf7, 0x7b, 0xed, 0x8e, 0x8c, 0xa7, 0x65, + 0x6c, 0xa9, 0x3f, 0x43, 0x8a, 0x4f, 0x5, 0xa6, 0x11, 0x74}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 815000523470260, 913085688728307, 1052060118271173, - 1345536665214223, 541623413135555 -#else - 11630004, 12144454, 2116339, 13606037, 27378885, 15676917, - 49700111, 20050058, 52713667, 8070817 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1580216071604333, 1877997504342444, 857147161260913, - 703522726778478, 2182763974211603 -#else - 27117677, 23547054, 35826092, 27984343, 1127281, 12772488, - 37262958, 10483305, 55556115, 32525717 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1870080310923419, 71988220958492, 1783225432016732, - 615915287105016, 1035570475990230 -#else - 10637467, 27866368, 5674780, 1072708, 40765276, 26572129, - 65424888, 9177852, 39615702, 15431202 -#endif - }}, + {0xb4, 0x75, 0xb1, 0x18, 0x3d, 0xe5, 0x9a, 0x57, 0x2, 0xa1, 0x92, + 0xf3, 0x59, 0x31, 0x71, 0x68, 0xf5, 0x35, 0xef, 0x1e, 0xba, 0xec, + 0x55, 0x84, 0x8f, 0x39, 0x8c, 0x45, 0x72, 0xa8, 0xc9, 0x1e}, + {0x6d, 0xc8, 0x9d, 0xb9, 0x32, 0x9d, 0x65, 0x4d, 0x15, 0xf1, 0x3a, + 0x60, 0x75, 0xdc, 0x4c, 0x4, 0x88, 0xe4, 0xc2, 0xdc, 0x2c, 0x71, + 0x4c, 0xb3, 0xff, 0x34, 0x81, 0xfb, 0x74, 0x65, 0x13, 0x7c}, + {0x9b, 0x50, 0xa2, 0x0, 0xd4, 0xa4, 0xe6, 0xb8, 0xb4, 0x82, 0xc8, + 0xb, 0x2, 0xd7, 0x81, 0x9b, 0x61, 0x75, 0x95, 0xf1, 0x9b, 0xcc, + 0xe7, 0x57, 0x60, 0x64, 0xcd, 0xc7, 0xa5, 0x88, 0xdd, 0x3a}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 730987750830150, 857613889540280, 1083813157271766, - 1002817255970169, 1719228484436074 -#else - 20525126, 10892566, 54366392, 12779442, 37615830, 16150074, - 38868345, 14943141, 52052074, 25618500 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 377616581647602, 1581980403078513, 804044118130621, - 2034382823044191, 643844048472185 -#else - 37084402, 5626925, 66557297, 23573344, 753597, 11981191, - 25244767, 30314666, 63752313, 9594023 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 176957326463017, 1573744060478586, 528642225008045, - 1816109618372371, 1515140189765006 -#else - 43356201, 2636869, 61944954, 23450613, 585133, 7877383, - 11345683, 27062142, 13352334, 22577348 -#endif - }}, + {0x46, 0x30, 0x39, 0x59, 0xd4, 0x98, 0xc2, 0x85, 0xec, 0x59, 0xf6, + 0x5f, 0x98, 0x35, 0x7e, 0x8f, 0x3a, 0x6e, 0xf6, 0xf2, 0x2a, 0xa2, + 0x2c, 0x1d, 0x20, 0xa7, 0x6, 0xa4, 0x31, 0x11, 0xba, 0x61}, + {0xf2, 0xdc, 0x35, 0xb6, 0x70, 0x57, 0x89, 0xab, 0xbc, 0x1f, 0x6c, + 0xf6, 0x6c, 0xef, 0xdf, 0x2, 0x87, 0xd1, 0xb6, 0xbe, 0x68, 0x2, + 0x53, 0x85, 0x74, 0x9e, 0x87, 0xcc, 0xfc, 0x29, 0x99, 0x24}, + {0x29, 0x90, 0x95, 0x16, 0xf1, 0xa0, 0xd0, 0xa3, 0x89, 0xbd, 0x7e, + 0xba, 0x6c, 0x6b, 0x3b, 0x2, 0x7, 0x33, 0x78, 0x26, 0x3e, 0x5a, + 0xf1, 0x7b, 0xe7, 0xec, 0xd8, 0xbb, 0xc, 0x31, 0x20, 0x56}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1888911448245718, 1387110895611080, 1924503794066429, - 1731539523700949, 2230378382645454 -#else - 65177046, 28146973, 3304648, 20669563, 17015805, 28677341, - 37325013, 25801949, 53893326, 33235227 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 443392177002051, 233793396845137, 2199506622312416, - 1011858706515937, 974676837063129 -#else - 20239939, 6607058, 6203985, 3483793, 48721888, 32775202, - 46385121, 15077869, 44358105, 14523816 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1846351103143623, 1949984838808427, 671247021915253, - 1946756846184401, 1929296930380217 -#else - 27406023, 27512775, 27423595, 29057038, 4996213, 10002360, - 38266833, 29008937, 36936121, 28748764 -#endif - }}, + {0xd6, 0x85, 0xe2, 0x77, 0xf4, 0xb5, 0x46, 0x66, 0x93, 0x61, 0x8f, + 0x6c, 0x67, 0xff, 0xe8, 0x40, 0xdd, 0x94, 0xb5, 0xab, 0x11, 0x73, + 0xec, 0xa6, 0x4d, 0xec, 0x8c, 0x65, 0xf3, 0x46, 0xc8, 0x7e}, + {0x43, 0xd6, 0x34, 0x49, 0x43, 0x93, 0x89, 0x52, 0xf5, 0x22, 0x12, + 0xa5, 0x6, 0xf8, 0xdb, 0xb9, 0x22, 0x1c, 0xf4, 0xc3, 0x8f, 0x87, + 0x6d, 0x8f, 0x30, 0x97, 0x9d, 0x4d, 0x2a, 0x6a, 0x67, 0x37}, + {0xc7, 0x2e, 0xa2, 0x1d, 0x3f, 0x8f, 0x5e, 0x9b, 0x13, 0xcd, 0x1, + 0x6c, 0x77, 0x1d, 0xf, 0x13, 0xb8, 0x9f, 0x98, 0xa2, 0xcf, 0x8f, + 0x4c, 0x21, 0xd5, 0x9d, 0x9b, 0x39, 0x23, 0xf7, 0xaa, 0x6d}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 849646212452002, 1410198775302919, 73767886183695, - 1641663456615812, 762256272452411 -#else - 11374242, 12660715, 17861383, 21013599, 10935567, 1099227, - 53222788, 24462691, 39381819, 11358503 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 692017667358279, 723305578826727, 1638042139863265, - 748219305990306, 334589200523901 -#else - 54378055, 10311866, 1510375, 10778093, 64989409, 24408729, - 32676002, 11149336, 40985213, 4985767 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 22893968530686, 2235758574399251, 1661465835630252, - 925707319443452, 1203475116966621 -#else - 48012542, 341146, 60911379, 33315398, 15756972, 24757770, - 66125820, 13794113, 47694557, 17933176 -#endif - }}, + {0xa2, 0x8e, 0xad, 0xac, 0xbf, 0x4, 0x3b, 0x58, 0x84, 0xe8, 0x8b, + 0x14, 0xe8, 0x43, 0xb7, 0x29, 0xdb, 0xc5, 0x10, 0x8, 0x3b, 0x58, + 0x1e, 0x2b, 0xaa, 0xbb, 0xb3, 0x8e, 0xe5, 0x49, 0x54, 0x2b}, + {0x47, 0xbe, 0x3d, 0xeb, 0x62, 0x75, 0x3a, 0x5f, 0xb8, 0xa0, 0xbd, + 0x8e, 0x54, 0x38, 0xea, 0xf7, 0x99, 0x72, 0x74, 0x45, 0x31, 0xe5, + 0xc3, 0x0, 0x51, 0xd5, 0x27, 0x16, 0xe7, 0xe9, 0x4, 0x13}, + {0xfe, 0x9c, 0xdc, 0x6a, 0xd2, 0x14, 0x98, 0x78, 0xb, 0xdd, 0x48, + 0x8b, 0x3f, 0xab, 0x1b, 0x3c, 0xa, 0xc6, 0x79, 0xf9, 0xff, 0xe1, + 0xf, 0xda, 0x93, 0xd6, 0x2d, 0x7c, 0x2d, 0xde, 0x68, 0x44}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 801299035785166, 1733292596726131, 1664508947088596, - 467749120991922, 1647498584535623 -#else - 6490062, 11940286, 25495923, 25828072, 8668372, 24803116, - 3367602, 6970005, 65417799, 24549641 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 903105258014366, 427141894933047, 561187017169777, - 1884330244401954, 1914145708422219 -#else - 1656478, 13457317, 15370807, 6364910, 13605745, 8362338, - 47934242, 28078708, 50312267, 28522993 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1344191060517578, 1960935031767890, 1518838929955259, - 1781502350597190, 1564784025565682 -#else - 44835530, 20030007, 67044178, 29220208, 48503227, 22632463, - 46537798, 26546453, 67009010, 23317098 -#endif - }}, + {0xce, 0x7, 0x63, 0xf8, 0xc6, 0xd8, 0x9a, 0x4b, 0x28, 0xc, 0x5d, + 0x43, 0x31, 0x35, 0x11, 0x21, 0x2c, 0x77, 0x7a, 0x65, 0xc5, 0x66, + 0xa8, 0xd4, 0x52, 0x73, 0x24, 0x63, 0x7e, 0x42, 0xa6, 0x5d}, + {0x9e, 0x46, 0x19, 0x94, 0x5e, 0x35, 0xbb, 0x51, 0x54, 0xc7, 0xdd, + 0x23, 0x4c, 0xdc, 0xe6, 0x33, 0x62, 0x99, 0x7f, 0x44, 0xd6, 0xb6, + 0xa5, 0x93, 0x63, 0xbd, 0x44, 0xfb, 0x6f, 0x7c, 0xce, 0x6c}, + {0xca, 0x22, 0xac, 0xde, 0x88, 0xc6, 0x94, 0x1a, 0xf8, 0x1f, 0xae, + 0xbb, 0xf7, 0x6e, 0x6, 0xb9, 0xf, 0x58, 0x59, 0x8d, 0x38, 0x8c, + 0xad, 0x88, 0xa8, 0x2c, 0x9f, 0xe7, 0xbf, 0x9a, 0xf2, 0x58}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 673723351748086, 1979969272514923, 1175287312495508, - 1187589090978666, 1881897672213940 -#else - 17747446, 10039260, 19368299, 29503841, 46478228, 17513145, - 31992682, 17696456, 37848500, 28042460 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1917185587363432, 1098342571752737, 5935801044414, - 2000527662351839, 1538640296181569 -#else - 31932008, 28568291, 47496481, 16366579, 22023614, 88450, - 11371999, 29810185, 4882241, 22927527 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2495540013192, 678856913479236, 224998292422872, - 219635787698590, 1972465269000940 -#else - 29796488, 37186, 19818052, 10115756, 55279832, 3352735, - 18551198, 3272828, 61917932, 29392022 -#endif - }}, + {0xf6, 0xcd, 0xe, 0x71, 0xbf, 0x64, 0x5a, 0x4b, 0x3c, 0x29, 0x2c, + 0x46, 0x38, 0xe5, 0x4c, 0xb1, 0xb9, 0x3a, 0xb, 0xd5, 0x56, 0xd0, + 0x43, 0x36, 0x70, 0x48, 0x5b, 0x18, 0x24, 0x37, 0xf9, 0x6a}, + {0x68, 0x3e, 0xe7, 0x8d, 0xab, 0xcf, 0xe, 0xe9, 0xa5, 0x76, 0x7e, + 0x37, 0x9f, 0x6f, 0x3, 0x54, 0x82, 0x59, 0x1, 0xbe, 0xb, 0x5b, + 0x49, 0xf0, 0x36, 0x1e, 0xf4, 0xa7, 0xc4, 0x29, 0x76, 0x57}, + {0x88, 0xa8, 0xc6, 0x9, 0x45, 0x2, 0x20, 0x32, 0x73, 0x89, 0x55, + 0x4b, 0x13, 0x36, 0xe0, 0xd2, 0x9f, 0x28, 0x33, 0x3c, 0x23, 0x36, + 0xe2, 0x83, 0x8f, 0xc1, 0xae, 0xc, 0xbb, 0x25, 0x1f, 0x70}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 271413961212179, 1353052061471651, 344711291283483, - 2014925838520662, 2006221033113941 -#else - 12501267, 4044383, 58495907, 20162046, 34678811, 5136598, - 47878486, 30024734, 330069, 29895023 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 194583029968109, 514316781467765, 829677956235672, - 1676415686873082, 810104584395840 -#else - 6384877, 2899513, 17807477, 7663917, 64749976, 12363164, - 25366522, 24980540, 66837568, 12071498 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1980510813313589, 1948645276483975, 152063780665900, - 129968026417582, 256984195613935 -#else - 58743349, 29511910, 25133447, 29037077, 60897836, 2265926, - 34339246, 1936674, 61949167, 3829362 -#endif - }}, + {0x13, 0xc1, 0xbe, 0x7c, 0xd9, 0xf6, 0x18, 0x9d, 0xe4, 0xdb, 0xbf, + 0x74, 0xe6, 0x6, 0x4a, 0x84, 0xd6, 0x60, 0x4e, 0xac, 0x22, 0xb5, + 0xf5, 0x20, 0x51, 0x5e, 0x95, 0x50, 0xc0, 0x5b, 0xa, 0x72}, + {0xed, 0x6c, 0x61, 0xe4, 0xf8, 0xb0, 0xa8, 0xc3, 0x7d, 0xa8, 0x25, + 0x9e, 0xe, 0x66, 0x0, 0xf7, 0x9c, 0xa5, 0xbc, 0xf4, 0x1f, 0x6, + 0xe3, 0x61, 0xe9, 0xb, 0xc4, 0xbd, 0xbf, 0x92, 0xc, 0x2e}, + {0x35, 0x5a, 0x80, 0x9b, 0x43, 0x9, 0x3f, 0xc, 0xfc, 0xab, 0x42, + 0x62, 0x37, 0x8b, 0x4e, 0xe8, 0x46, 0x93, 0x22, 0x5c, 0xf3, 0x17, + 0x14, 0x69, 0xec, 0xf0, 0x4e, 0x14, 0xbb, 0x9c, 0x9b, 0xe}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1860190562533102, 1936576191345085, 461100292705964, - 1811043097042830, 957486749306835 -#else - 28425966, 27718999, 66531773, 28857233, 52891308, 6870929, - 7921550, 26986645, 26333139, 14267664 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 796664815624365, 1543160838872951, 1500897791837765, - 1667315977988401, 599303877030711 -#else - 56041645, 11871230, 27385719, 22994888, 62522949, 22365119, - 10004785, 24844944, 45347639, 8930323 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1151480509533204, 2136010406720455, 738796060240027, - 319298003765044, 1150614464349587 -#else - 45911060, 17158396, 25654215, 31829035, 12282011, 11008919, - 1541940, 4757911, 40617363, 17145491 -#endif - }}, + {0xee, 0xbe, 0xb1, 0x5d, 0xd5, 0x9b, 0xee, 0x8d, 0xb9, 0x3f, 0x72, + 0xa, 0x37, 0xab, 0xc3, 0xc9, 0x91, 0xd7, 0x68, 0x1c, 0xbf, 0xf1, + 0xa8, 0x44, 0xde, 0x3c, 0xfd, 0x1c, 0x19, 0x44, 0x6d, 0x36}, + {0xad, 0x20, 0x57, 0xfb, 0x8f, 0xd4, 0xba, 0xfb, 0xe, 0xd, 0xf9, + 0xdb, 0x6b, 0x91, 0x81, 0xee, 0xbf, 0x43, 0x55, 0x63, 0x52, 0x31, + 0x81, 0xd4, 0xd8, 0x7b, 0x33, 0x3f, 0xeb, 0x4, 0x11, 0x22}, + {0x14, 0x8c, 0xbc, 0xf2, 0x43, 0x17, 0x3c, 0x9e, 0x3b, 0x6c, 0x85, + 0xb5, 0xfc, 0x26, 0xda, 0x2e, 0x97, 0xfb, 0xa7, 0x68, 0xe, 0x2f, + 0xb8, 0xcc, 0x44, 0x32, 0x59, 0xbc, 0xe6, 0xa4, 0x67, 0x41}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1731069268103150, 735642447616087, 1364750481334268, - 417232839982871, 927108269127661 -#else - 13537262, 25794942, 46504023, 10961926, 61186044, 20336366, - 53952279, 6217253, 51165165, 13814989 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1017222050227968, 1987716148359, 2234319589635701, - 621282683093392, 2132553131763026 -#else - 49686272, 15157789, 18705543, 29619, 24409717, 33293956, - 27361680, 9257833, 65152338, 31777517 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1567828528453324, 1017807205202360, 565295260895298, - 829541698429100, 307243822276582 -#else - 42063564, 23362465, 15366584, 15166509, 54003778, 8423555, - 37937324, 12361134, 48422886, 4578289 -#endif - }}, + {0xee, 0x8f, 0xce, 0xf8, 0x65, 0x26, 0xbe, 0xc2, 0x2c, 0xd6, 0x80, + 0xe8, 0x14, 0xff, 0x67, 0xe9, 0xee, 0x4e, 0x36, 0x2f, 0x7e, 0x6e, + 0x2e, 0xf1, 0xf6, 0xd2, 0x7e, 0xcb, 0x70, 0x33, 0xb3, 0x34}, + {0x0, 0x27, 0xf6, 0x76, 0x28, 0x9d, 0x3b, 0x64, 0xeb, 0x68, 0x76, + 0xe, 0x40, 0x9d, 0x1d, 0x5d, 0x84, 0x6, 0xfc, 0x21, 0x3, 0x43, + 0x4b, 0x1b, 0x6a, 0x24, 0x55, 0x22, 0x7e, 0xbb, 0x38, 0x79}, + {0xcc, 0xd6, 0x81, 0x86, 0xee, 0x91, 0xc5, 0xcd, 0x53, 0xa7, 0x85, + 0xed, 0x9c, 0x10, 0x2, 0xce, 0x83, 0x88, 0x80, 0x58, 0xc1, 0x85, + 0x74, 0xed, 0xe4, 0x65, 0xfe, 0x2d, 0x6e, 0xfc, 0x76, 0x11}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 249079270936248, 1501514259790706, 947909724204848, - 944551802437487, 552658763982480 -#else - 24579768, 3711570, 1342322, 22374306, 40103728, 14124955, - 44564335, 14074918, 21964432, 8235257 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2089966982947227, 1854140343916181, 2151980759220007, - 2139781292261749, 158070445864917 -#else - 60580251, 31142934, 9442965, 27628844, 12025639, 32067012, - 64127349, 31885225, 13006805, 2355433 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1338766321464554, 1906702607371284, 1519569445519894, - 115384726262267, 1393058953390992 -#else - 50803946, 19949172, 60476436, 28412082, 16974358, 22643349, - 27202043, 1719366, 1141648, 20758196 -#endif - }}, + {0xb8, 0xe, 0x77, 0x49, 0x89, 0xe2, 0x90, 0xdb, 0xa3, 0x40, 0xf4, + 0xac, 0x2a, 0xcc, 0xfb, 0x98, 0x9b, 0x87, 0xd7, 0xde, 0xfe, 0x4f, + 0x35, 0x21, 0xb6, 0x6, 0x69, 0xf2, 0x54, 0x3e, 0x6a, 0x1f}, + {0x9b, 0x61, 0x9c, 0x5b, 0xd0, 0x6c, 0xaf, 0xb4, 0x80, 0x84, 0xa5, + 0xb2, 0xf4, 0xc9, 0xdf, 0x2d, 0xc4, 0x4d, 0xe9, 0xeb, 0x2, 0xa5, + 0x4f, 0x3d, 0x34, 0x5f, 0x7d, 0x67, 0x4c, 0x3a, 0xfc, 0x8}, + {0xea, 0x34, 0x7, 0xd3, 0x99, 0xc1, 0xa4, 0x60, 0xd6, 0x5c, 0x16, + 0x31, 0xb6, 0x85, 0xc0, 0x40, 0x95, 0x82, 0x59, 0xf7, 0x23, 0x3e, + 0x33, 0xe2, 0xd1, 0x0, 0xb9, 0x16, 0x1, 0xad, 0x2f, 0x4f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1364621558265400, 1512388234908357, 1926731583198686, - 2041482526432505, 920401122333774 -#else - 54244920, 20334445, 58790597, 22536340, 60298718, 28710537, - 13475065, 30420460, 32674894, 13715045 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1884844597333588, 601480070269079, 620203503079537, - 1079527400117915, 1202076693132015 -#else - 11423316, 28086373, 32344215, 8962751, 24989809, 9241752, - 53843611, 16086211, 38367983, 17912338 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 840922919763324, 727955812569642, 1303406629750194, - 522898432152867, 294161410441865 -#else - 65699196, 12530727, 60740138, 10847386, 19531186, 19422272, - 55399715, 7791793, 39862921, 4383346 -#endif - }}, + {0x38, 0xb6, 0x3b, 0xb7, 0x1d, 0xd9, 0x2c, 0x96, 0x8, 0x9c, 0x12, + 0xfc, 0xaa, 0x77, 0x5, 0xe6, 0x89, 0x16, 0xb6, 0xf3, 0x39, 0x9b, + 0x61, 0x6f, 0x81, 0xee, 0x44, 0x29, 0x5f, 0x99, 0x51, 0x34}, + {0x54, 0x4e, 0xae, 0x94, 0x41, 0xb2, 0xbe, 0x44, 0x6c, 0xef, 0x57, + 0x18, 0x51, 0x1c, 0x54, 0x5f, 0x98, 0x4, 0x8d, 0x36, 0x2d, 0x6b, + 0x1e, 0xa6, 0xab, 0xf7, 0x2e, 0x97, 0xa4, 0x84, 0x54, 0x44}, + {0x7c, 0x7d, 0xea, 0x9f, 0xd0, 0xfc, 0x52, 0x91, 0xf6, 0x5c, 0x93, + 0xb0, 0x94, 0x6c, 0x81, 0x4a, 0x40, 0x5c, 0x28, 0x47, 0xaa, 0x9a, + 0x8e, 0x25, 0xb7, 0x93, 0x28, 0x4, 0xa6, 0x9c, 0xb8, 0x10}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 353760790835310, 1598361541848743, 1122905698202299, - 1922533590158905, 419107700666580 -#else - 38137966, 5271446, 65842855, 23817442, 54653627, 16732598, - 62246457, 28647982, 27193556, 6245191 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 359856369838236, 180914355488683, 861726472646627, - 218807937262986, 575626773232501 -#else - 51914908, 5362277, 65324971, 2695833, 4960227, 12840725, - 23061898, 3260492, 22510453, 8577507 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 755467689082474, 909202735047934, 730078068932500, - 936309075711518, 2007798262842972 -#else - 54476394, 11257345, 34415870, 13548176, 66387860, 10879010, - 31168030, 13952092, 37537372, 29918525 -#endif - }}, + {0x6e, 0xf0, 0x45, 0x5a, 0xbe, 0x41, 0x39, 0x75, 0x65, 0x5f, 0x9c, + 0x6d, 0xed, 0xae, 0x7c, 0xd0, 0xb6, 0x51, 0xff, 0x72, 0x9c, 0x6b, + 0x77, 0x11, 0xa9, 0x4d, 0xd, 0xef, 0xd9, 0xd1, 0xd2, 0x17}, + {0x9c, 0x28, 0x18, 0x97, 0x49, 0x47, 0x59, 0x3d, 0x26, 0x3f, 0x53, + 0x24, 0xc5, 0xf8, 0xeb, 0x12, 0x15, 0xef, 0xc3, 0x14, 0xcb, 0xbf, + 0x62, 0x2, 0x8e, 0x51, 0xb7, 0x77, 0xd5, 0x78, 0xb8, 0x20}, + {0x6a, 0x3e, 0x3f, 0x7, 0x18, 0xaf, 0xf2, 0x27, 0x69, 0x10, 0x52, + 0xd7, 0x19, 0xe5, 0x3f, 0xfd, 0x22, 0x0, 0xa6, 0x3c, 0x2c, 0xb7, + 0xe3, 0x22, 0xa7, 0xc6, 0x65, 0xcc, 0x63, 0x4f, 0x21, 0x72}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1609384177904073, 362745185608627, 1335318541768201, - 800965770436248, 547877979267412 -#else - 3877321, 23981693, 32416691, 5405324, 56104457, 19897796, - 3759768, 11935320, 5611860, 8164018 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 984339177776787, 815727786505884, 1645154585713747, - 1659074964378553, 1686601651984156 -#else - 50833043, 14667796, 15906460, 12155291, 44997715, 24514713, - 32003001, 24722143, 5773084, 25132323 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1697863093781930, 599794399429786, 1104556219769607, - 830560774794755, 12812858601017 -#else - 43320746, 25300131, 1950874, 8937633, 18686727, 16459170, - 66203139, 12376319, 31632953, 190926 -#endif - }}, + {0xc9, 0x29, 0x3b, 0xf4, 0xb9, 0xb7, 0x9d, 0x1d, 0x75, 0x8f, 0x51, + 0x4f, 0x4a, 0x82, 0x5, 0xd6, 0xc4, 0x9d, 0x2f, 0x31, 0xbd, 0x72, + 0xc0, 0xf2, 0xb0, 0x45, 0x15, 0x5a, 0x85, 0xac, 0x24, 0x1f}, + {0x93, 0xa6, 0x7, 0x53, 0x40, 0x7f, 0xe3, 0xb4, 0x95, 0x67, 0x33, + 0x2f, 0xd7, 0x14, 0xa7, 0xab, 0x99, 0x10, 0x76, 0x73, 0xa7, 0xd0, + 0xfb, 0xd6, 0xc9, 0xcb, 0x71, 0x81, 0xc5, 0x48, 0xdf, 0x5f}, + {0xaa, 0x5, 0x95, 0x8e, 0x32, 0x8, 0xd6, 0x24, 0xee, 0x20, 0x14, + 0xc, 0xd1, 0xc1, 0x48, 0x47, 0xa2, 0x25, 0xfb, 0x6, 0x5c, 0xe4, + 0xff, 0xc7, 0xe6, 0x95, 0xe3, 0x2a, 0x9e, 0x73, 0xba, 0x0}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1168737550514982, 897832437380552, 463140296333799, - 302564600022547, 2008360505135501 -#else - 42515238, 17415546, 58684872, 13378745, 14162407, 6901328, - 58820115, 4508563, 41767309, 29926903 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1856930662813910, 678090852002597, 1920179140755167, - 1259527833759868, 55540971895511 -#else - 8884438, 27670423, 6023973, 10104341, 60227295, 28612898, - 18722940, 18768427, 65436375, 827624 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1158643631044921, 476554103621892, 178447851439725, - 1305025542653569, 103433927680625 -#else - 34388281, 17265135, 34605316, 7101209, 13354605, 2659080, - 65308289, 19446395, 42230385, 1541285 -#endif - }}, + {0x26, 0xbb, 0x88, 0xea, 0xf5, 0x26, 0x44, 0xae, 0xfb, 0x3b, 0x97, + 0x84, 0xd9, 0x79, 0x6, 0x36, 0x50, 0x4e, 0x69, 0x26, 0xc, 0x3, + 0x9f, 0x5c, 0x26, 0xd2, 0x18, 0xd5, 0xe7, 0x7d, 0x29, 0x72}, + {0xd6, 0x90, 0x87, 0x5c, 0xde, 0x98, 0x2e, 0x59, 0xdf, 0xa2, 0xc2, + 0x45, 0xd3, 0xb7, 0xbf, 0xe5, 0x22, 0x99, 0xb4, 0xf9, 0x60, 0x3b, + 0x5a, 0x11, 0xf3, 0x78, 0xad, 0x67, 0x3e, 0x3a, 0x28, 0x3}, + {0x39, 0xb9, 0xc, 0xbe, 0xc7, 0x1d, 0x24, 0x48, 0x80, 0x30, 0x63, + 0x8b, 0x4d, 0x9b, 0xf1, 0x32, 0x8, 0x93, 0x28, 0x2, 0xd, 0xc9, + 0xdf, 0xd3, 0x45, 0x19, 0x27, 0x46, 0x68, 0x29, 0xe1, 0x5}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2176793111709008, 1576725716350391, 2009350167273523, - 2012390194631546, 2125297410909580 -#else - 2901328, 32436745, 3880375, 23495044, 49487923, 29941650, - 45306746, 29986950, 20456844, 31669399 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 825403285195098, 2144208587560784, 1925552004644643, - 1915177840006985, 1015952128947864 -#else - 27019610, 12299467, 53450576, 31951197, 54247203, 28692960, - 47568713, 28538373, 29439640, 15138866 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1807108316634472, 1534392066433717, 347342975407218, - 1153820745616376, 7375003497471 -#else - 21536104, 26928012, 34661045, 22864223, 44700786, 5175813, - 61688824, 17193268, 7779327, 109896 -#endif - }}, + {0x50, 0x45, 0x2c, 0x24, 0xc8, 0xbb, 0xbf, 0xad, 0xd9, 0x81, 0x30, + 0xd0, 0xec, 0xc, 0xc8, 0xbc, 0x92, 0xdf, 0xc8, 0xf5, 0xa6, 0x66, + 0x35, 0x84, 0x4c, 0xce, 0x58, 0x82, 0xd3, 0x25, 0xcf, 0x78}, + {0x5a, 0x49, 0x9c, 0x2d, 0xb3, 0xee, 0x82, 0xba, 0x7c, 0xb9, 0x2b, + 0xf1, 0xfc, 0xc8, 0xef, 0xce, 0xe0, 0xd1, 0xb5, 0x93, 0xae, 0xab, + 0x2d, 0xb0, 0x9b, 0x8d, 0x69, 0x13, 0x9c, 0xc, 0xc0, 0x39}, + {0x68, 0x9d, 0x48, 0x31, 0x8e, 0x6b, 0xae, 0x15, 0x87, 0xf0, 0x2b, + 0x9c, 0xab, 0x1c, 0x85, 0xaa, 0x5, 0xfa, 0x4e, 0xf0, 0x97, 0x5a, + 0xa7, 0xc9, 0x32, 0xf8, 0x3f, 0x6b, 0x7, 0x52, 0x6b, 0x0}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 983061001799725, 431211889901241, 2201903782961093, - 817393911064341, 2214616493042167 -#else - 30279725, 14648750, 59063993, 6425557, 13639621, 32810923, - 28698389, 12180118, 23177719, 33000357 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 228567918409756, 865093958780220, 358083886450556, - 159617889659320, 1360637926292598 -#else - 26572828, 3405927, 35407164, 12890904, 47843196, 5335865, - 60615096, 2378491, 4439158, 20275085 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 234147501399755, 2229469128637390, 2175289352258889, - 1397401514549353, 1885288963089922 -#else - 44392139, 3489069, 57883598, 33221678, 18875721, 32414337, - 14819433, 20822905, 49391106, 28092994 -#endif - }}, + {0x2d, 0x8, 0xce, 0xb9, 0x16, 0x7e, 0xcb, 0xf5, 0x29, 0xbc, 0x7a, + 0x41, 0x4c, 0xf1, 0x7, 0x34, 0xab, 0xa7, 0xf4, 0x2b, 0xce, 0x6b, + 0xb3, 0xd4, 0xce, 0x75, 0x9f, 0x1a, 0x56, 0xe9, 0xe2, 0x7d}, + {0x1c, 0x78, 0x95, 0x9d, 0xe1, 0xcf, 0xe0, 0x29, 0xe2, 0x10, 0x63, + 0x96, 0x18, 0xdf, 0x81, 0xb6, 0x39, 0x6b, 0x51, 0x70, 0xd3, 0x39, + 0xdf, 0x57, 0x22, 0x61, 0xc7, 0x3b, 0x44, 0xe3, 0x57, 0x4d}, + {0xcb, 0x5e, 0xa5, 0xb6, 0xf4, 0xd4, 0x70, 0xde, 0x99, 0xdb, 0x85, + 0x5d, 0x7f, 0x52, 0x1, 0x48, 0x81, 0x9a, 0xee, 0xd3, 0x40, 0xc4, + 0xc9, 0xdb, 0xed, 0x29, 0x60, 0x1a, 0xaf, 0x90, 0x2a, 0x6b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1111762412951562, 252849572507389, 1048714233823341, - 146111095601446, 1237505378776770 -#else - 62052362, 16566550, 15953661, 3767752, 56672365, 15627059, - 66287910, 2177224, 8550082, 18440267 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1113790697840279, 1051167139966244, 1045930658550944, - 2011366241542643, 1686166824620755 -#else - 48635543, 16596774, 66727204, 15663610, 22860960, 15585581, - 39264755, 29971692, 43848403, 25125843 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1054097349305049, 1872495070333352, 182121071220717, - 1064378906787311, 100273572924182 -#else - 34628313, 15707274, 58902952, 27902350, 29464557, 2713815, - 44383727, 15860481, 45206294, 1494192 -#endif - }}, + {0xa, 0xd8, 0xb2, 0x5b, 0x24, 0xf3, 0xeb, 0x77, 0x9b, 0x7, 0xb9, + 0x2f, 0x47, 0x1b, 0x30, 0xd8, 0x33, 0x73, 0xee, 0x4c, 0xf2, 0xe6, + 0x47, 0xc6, 0x9, 0x21, 0x6c, 0x27, 0xc8, 0x12, 0x58, 0x46}, + {0x97, 0x1e, 0xe6, 0x9a, 0xfc, 0xf4, 0x23, 0x69, 0xd1, 0x5f, 0x3f, + 0xe0, 0x1d, 0x28, 0x35, 0x57, 0x2d, 0xd1, 0xed, 0xe6, 0x43, 0xae, + 0x64, 0xa7, 0x4a, 0x3e, 0x2d, 0xd1, 0xe9, 0xf4, 0xd8, 0x5f}, + {0xd9, 0x62, 0x10, 0x2a, 0xb2, 0xbe, 0x43, 0x4d, 0x16, 0xdc, 0x31, + 0x38, 0x75, 0xfb, 0x65, 0x70, 0xd7, 0x68, 0x29, 0xde, 0x7b, 0x4a, + 0xd, 0x18, 0x90, 0x67, 0xb1, 0x1c, 0x2b, 0x2c, 0xb3, 0x5}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1306410853171605, 1627717417672447, 50983221088417, - 1109249951172250, 870201789081392 -#else - 47546773, 19467038, 41524991, 24254879, 13127841, 759709, - 21923482, 16529112, 8742704, 12967017 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 104233794644221, 1548919791188248, 2224541913267306, - 2054909377116478, 1043803389015153 -#else - 38643965, 1553204, 32536856, 23080703, 42417258, 33148257, - 58194238, 30620535, 37205105, 15553882 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 216762189468802, 707284285441622, 190678557969733, - 973969342604308, 1403009538434867 -#else - 21877890, 3230008, 9881174, 10539357, 62311749, 2841331, - 11543572, 14513274, 19375923, 20906471 -#endif - }}, + {0x95, 0x81, 0xd5, 0x7a, 0x2c, 0xa4, 0xfc, 0xf7, 0xcc, 0xf3, 0x33, + 0x43, 0x6e, 0x28, 0x14, 0x32, 0x9d, 0x97, 0xb, 0x34, 0xd, 0x9d, + 0xc2, 0xb6, 0xe1, 0x7, 0x73, 0x56, 0x48, 0x1a, 0x77, 0x31}, + {0xfd, 0xa8, 0x4d, 0xd2, 0xcc, 0x5e, 0xc0, 0xc8, 0x83, 0xef, 0xdf, + 0x5, 0xac, 0x1a, 0xcf, 0xa1, 0x61, 0xcd, 0xf9, 0x7d, 0xf2, 0xef, + 0xbe, 0xdb, 0x99, 0x1e, 0x47, 0x7b, 0xa3, 0x56, 0x55, 0x3b}, + {0x82, 0xd4, 0x4d, 0xe1, 0x24, 0xc5, 0xb0, 0x32, 0xb6, 0xa4, 0x2b, + 0x1a, 0x54, 0x51, 0xb3, 0xed, 0xf3, 0x5a, 0x2b, 0x28, 0x48, 0x60, + 0xd1, 0xa3, 0xeb, 0x36, 0x73, 0x7a, 0xd2, 0x79, 0xc0, 0x4f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1279024291038477, 344776835218310, 273722096017199, - 1834200436811442, 634517197663804 -#else - 8832269, 19058947, 13253510, 5137575, 5037871, 4078777, - 24880818, 27331716, 2862652, 9455043 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 343805853118335, 1302216857414201, 566872543223541, - 2051138939539004, 321428858384280 -#else - 29306751, 5123106, 20245049, 19404543, 9592565, 8447059, - 65031740, 30564351, 15511448, 4789663 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 470067171324852, 1618629234173951, 2000092177515639, - 7307679772789, 1117521120249968 -#else - 46429108, 7004546, 8824831, 24119455, 63063159, 29803695, - 61354101, 108892, 23513200, 16652362 -#endif - }}, + {0xd, 0xc5, 0x86, 0xc, 0x44, 0x8b, 0x34, 0xdc, 0x51, 0xe6, 0x94, + 0xcc, 0xc9, 0xcb, 0x37, 0x13, 0xb9, 0x3c, 0x3e, 0x64, 0x4d, 0xf7, + 0x22, 0x64, 0x8, 0xcd, 0xe3, 0xba, 0xc2, 0x70, 0x11, 0x24}, + {0x7f, 0x2f, 0xbf, 0x89, 0xb0, 0x38, 0xc9, 0x51, 0xa7, 0xe9, 0xdf, + 0x2, 0x65, 0xbd, 0x97, 0x24, 0x53, 0xe4, 0x80, 0x78, 0x9c, 0xc0, + 0xff, 0xff, 0x92, 0x8e, 0xf9, 0xca, 0xce, 0x67, 0x45, 0x12}, + {0xb4, 0x73, 0xc4, 0xa, 0x86, 0xab, 0xf9, 0x3f, 0x35, 0xe4, 0x13, + 0x1, 0xee, 0x1d, 0x91, 0xf0, 0xaf, 0xc4, 0xc6, 0xeb, 0x60, 0x50, + 0xe7, 0x4a, 0xd, 0x0, 0x87, 0x6c, 0x96, 0x12, 0x86, 0x3f}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 278151578291475, 1810282338562947, 1771599529530998, - 1383659409671631, 685373414471841 -#else - 33852691, 4144781, 62632835, 26975308, 10770038, 26398890, - 60458447, 20618131, 48789665, 10212859 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 577009397403102, 1791440261786291, 2177643735971638, - 174546149911960, 1412505077782326 -#else - 2756062, 8598110, 7383731, 26694540, 22312758, 32449420, - 21179800, 2600940, 57120566, 21047965 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 893719721537457, 1201282458018197, 1522349501711173, - 58011597740583, 1130406465887139 -#else - 42463153, 13317461, 36659605, 17900503, 21365573, 22684775, - 11344423, 864440, 64609187, 16844368 -#endif - }}, + {0x13, 0x8d, 0x4, 0x36, 0xfa, 0xfc, 0x18, 0x9c, 0xdd, 0x9d, 0x89, + 0x73, 0xb3, 0x9d, 0x15, 0x29, 0xaa, 0xd0, 0x92, 0x9f, 0xb, 0x35, + 0x9f, 0xdc, 0xd4, 0x19, 0x8a, 0x87, 0xee, 0x7e, 0xf5, 0x26}, + {0xde, 0xd, 0x2a, 0x78, 0xc9, 0xc, 0x9a, 0x55, 0x85, 0x83, 0x71, + 0xea, 0xb2, 0xcd, 0x1d, 0x55, 0x8c, 0x23, 0xef, 0x31, 0x5b, 0x86, + 0x62, 0x7f, 0x3d, 0x61, 0x73, 0x79, 0x76, 0xa7, 0x4a, 0x50}, + {0xb1, 0xef, 0x87, 0x56, 0xd5, 0x2c, 0xab, 0xc, 0x7b, 0xf1, 0x7a, + 0x24, 0x62, 0xd1, 0x80, 0x51, 0x67, 0x24, 0x5a, 0x4f, 0x34, 0x5a, + 0xc1, 0x85, 0x69, 0x30, 0xba, 0x9d, 0x3d, 0x94, 0x41, 0x40}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 412607348255453, 1280455764199780, 2233277987330768, - 14180080401665, 331584698417165 -#else - 40676061, 6148328, 49924452, 19080277, 18782928, 33278435, - 44547329, 211299, 2719757, 4940997 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 262483770854550, 990511055108216, 526885552771698, - 571664396646158, 354086190278723 -#else - 65784982, 3911312, 60160120, 14759764, 37081714, 7851206, - 21690126, 8518463, 26699843, 5276295 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1820352417585487, 24495617171480, 1547899057533253, - 10041836186225, 480457105094042 -#else - 53958991, 27125364, 9396248, 365013, 24703301, 23065493, - 1321585, 149635, 51656090, 7159368 -#endif - }}, + {0xdd, 0xaa, 0x6c, 0xa2, 0x43, 0x77, 0x21, 0x4b, 0xce, 0xb7, 0x8a, + 0x64, 0x24, 0xb4, 0xa6, 0x47, 0xe3, 0xc9, 0xfb, 0x3, 0x7a, 0x4f, + 0x1d, 0xcb, 0x19, 0xd0, 0x0, 0x98, 0x42, 0x31, 0xd9, 0x12}, + {0x96, 0xcc, 0xeb, 0x43, 0xba, 0xee, 0xc0, 0xc3, 0xaf, 0x9c, 0xea, + 0x26, 0x9c, 0x9c, 0x74, 0x8d, 0xc6, 0xcc, 0x77, 0x1c, 0xee, 0x95, + 0xfa, 0xd9, 0xf, 0x34, 0x84, 0x76, 0xd9, 0xa1, 0x20, 0x14}, + {0x4f, 0x59, 0x37, 0xd3, 0x99, 0x77, 0xc6, 0x0, 0x7b, 0xa4, 0x3a, + 0xb2, 0x40, 0x51, 0x3c, 0x5e, 0x95, 0xf3, 0x5f, 0xe3, 0x54, 0x28, + 0x18, 0x44, 0x12, 0xa0, 0x59, 0x43, 0x31, 0x92, 0x4f, 0x1b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2023310314989233, 637905337525881, 2106474638900687, - 557820711084072, 1687858215057826 -#else - 9987761, 30149673, 17507961, 9505530, 9731535, 31388918, - 22356008, 8312176, 22477218, 25151047 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1144168702609745, 604444390410187, 1544541121756138, - 1925315550126027, 626401428894002 -#else - 18155857, 17049442, 19744715, 9006923, 15154154, 23015456, - 24256459, 28689437, 44560690, 9334108 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1922168257351784, 2018674099908659, 1776454117494445, - 956539191509034, 36031129147635 -#else - 2986088, 28642539, 10776627, 30080588, 10620589, 26471229, - 45695018, 14253544, 44521715, 536905 -#endif - }}, + {0xb1, 0x66, 0x98, 0xa4, 0x30, 0x30, 0xcf, 0x33, 0x59, 0x48, 0x5f, + 0x21, 0xd2, 0x73, 0x1f, 0x25, 0xf6, 0xf4, 0xde, 0x51, 0x40, 0xaa, + 0x82, 0xab, 0xf6, 0x23, 0x9a, 0x6f, 0xd5, 0x91, 0xf1, 0x5f}, + {0x51, 0x9, 0x15, 0x89, 0x9d, 0x10, 0x5c, 0x3e, 0x6a, 0x69, 0xe9, + 0x2d, 0x91, 0xfa, 0xce, 0x39, 0x20, 0x30, 0x5f, 0x97, 0x3f, 0xe4, + 0xea, 0x20, 0xae, 0x2d, 0x13, 0x7f, 0x2a, 0x57, 0x9b, 0x23}, + {0x68, 0x90, 0x2d, 0xac, 0x33, 0xd4, 0x9e, 0x81, 0x23, 0x85, 0xc9, + 0x5f, 0x79, 0xab, 0x83, 0x28, 0x3d, 0xeb, 0x93, 0x55, 0x80, 0x72, + 0x45, 0xef, 0xcb, 0x36, 0x8f, 0x75, 0x6a, 0x52, 0xc, 0x2}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 544644538748041, 1039872944430374, 876750409130610, - 710657711326551, 1216952687484972 -#else - 4377737, 8115836, 24567078, 15495314, 11625074, 13064599, - 7390551, 10589625, 10838060, 18134008 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 58242421545916, 2035812695641843, 2118491866122923, - 1191684463816273, 46921517454099 -#else - 47766460, 867879, 9277171, 30335973, 52677291, 31567988, - 19295825, 17757482, 6378259, 699185 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 272268252444639, 1374166457774292, 2230115177009552, - 1053149803909880, 1354288411641016 -#else - 7895007, 4057113, 60027092, 20476675, 49222032, 33231305, - 66392824, 15693154, 62063800, 20180469 -#endif - }}, + {0x89, 0xcc, 0x42, 0xf0, 0x59, 0xef, 0x31, 0xe9, 0xb6, 0x4b, 0x12, + 0x8e, 0x9d, 0x9c, 0x58, 0x2c, 0x97, 0x59, 0xc7, 0xae, 0x8a, 0xe1, + 0xc8, 0xad, 0xc, 0xc5, 0x2, 0x56, 0xa, 0xfe, 0x2c, 0x45}, + {0xbc, 0xdb, 0xd8, 0x9e, 0xf8, 0x34, 0x98, 0x77, 0x6c, 0xa4, 0x7c, + 0xdc, 0xf9, 0xaa, 0xf2, 0xc8, 0x74, 0xb0, 0xe1, 0xa3, 0xdc, 0x4c, + 0x52, 0xa9, 0x77, 0x38, 0x31, 0x15, 0x46, 0xcc, 0xaa, 0x2}, + {0xdf, 0x77, 0x78, 0x64, 0xa0, 0xf7, 0xa0, 0x86, 0x9f, 0x7c, 0x60, + 0xe, 0x27, 0x64, 0xc4, 0xbb, 0xc9, 0x11, 0xfb, 0xf1, 0x25, 0xea, + 0x17, 0xab, 0x7b, 0x87, 0x4b, 0x30, 0x7b, 0x7d, 0xfb, 0x4c}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1857910905368338, 1754729879288912, 885945464109877, - 1516096106802166, 1602902393369811 -#else - 59371282, 27685029, 52542544, 26147512, 11385653, 13201616, - 31730678, 22591592, 63190227, 23885106 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1193437069800958, 901107149704790, 999672920611411, - 477584824802207, 364239578697845 -#else - 10188286, 17783598, 59772502, 13427542, 22223443, 14896287, - 30743455, 7116568, 45322357, 5427592 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 886299989548838, 1538292895758047, 1590564179491896, - 1944527126709657, 837344427345298 -#else - 696102, 13206899, 27047647, 22922350, 15285304, 23701253, - 10798489, 28975712, 19236242, 12477404 -#endif - }}, + {0x12, 0xef, 0x89, 0x97, 0xc2, 0x99, 0x86, 0xe2, 0xd, 0x19, 0x57, + 0xdf, 0x71, 0xcd, 0x6e, 0x2b, 0xd0, 0x70, 0xc9, 0xec, 0x57, 0xc8, + 0x43, 0xc3, 0xc5, 0x3a, 0x4d, 0x43, 0xbc, 0x4c, 0x1d, 0x5b}, + {0xfe, 0x75, 0x9b, 0xb8, 0x6c, 0x3d, 0xb4, 0x72, 0x80, 0xdc, 0x6a, + 0x9c, 0xd9, 0x94, 0xc6, 0x54, 0x9f, 0x4c, 0xe3, 0x3e, 0x37, 0xaa, + 0xc3, 0xb8, 0x64, 0x53, 0x7, 0x39, 0x2b, 0x62, 0xb4, 0x14}, + {0x26, 0x9f, 0xa, 0xcc, 0x15, 0x26, 0xfb, 0xb6, 0xe5, 0xcc, 0x8d, + 0xb8, 0x2b, 0xe, 0x4f, 0x3a, 0x5, 0xa7, 0x69, 0x33, 0x8b, 0x49, + 0x1, 0x13, 0xd1, 0x2d, 0x59, 0x58, 0x12, 0xf7, 0x98, 0x2f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 754558365378305, 1712186480903618, 1703656826337531, - 750310918489786, 518996040250900 -#else - 55879425, 11243795, 50054594, 25513566, 66320635, 25386464, - 63211194, 11180503, 43939348, 7733643 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1309847803895382, 1462151862813074, 211370866671570, - 1544595152703681, 1027691798954090 -#else - 17800790, 19518253, 40108434, 21787760, 23887826, 3149671, - 23466177, 23016261, 10322026, 15313801 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 803217563745370, 1884799722343599, 1357706345069218, - 2244955901722095, 730869460037413 -#else - 26246234, 11968874, 32263343, 28085704, 6830754, 20231401, - 51314159, 33452449, 42659621, 10890803 -#endif - }}, + {0x1, 0xa7, 0x54, 0x4f, 0x44, 0xae, 0x12, 0x2e, 0xde, 0xd7, 0xcb, + 0xa9, 0xf0, 0x3e, 0xfe, 0xfc, 0xe0, 0x5d, 0x83, 0x75, 0xd, 0x89, + 0xbf, 0xce, 0x54, 0x45, 0x61, 0xe7, 0xe9, 0x62, 0x80, 0x1d}, + {0x56, 0x9e, 0xf, 0xb5, 0x4c, 0xa7, 0x94, 0xc, 0x20, 0x13, 0x8e, + 0x8e, 0xa9, 0xf4, 0x1f, 0x5b, 0x67, 0xf, 0x30, 0x82, 0x21, 0xcc, + 0x2a, 0x9a, 0xf9, 0xaa, 0x6, 0xd8, 0x49, 0xe2, 0x6a, 0x3a}, + {0x5a, 0x7c, 0x90, 0xa9, 0x85, 0xda, 0x7a, 0x65, 0x62, 0xf, 0xb9, + 0x91, 0xb5, 0xa8, 0xe, 0x1a, 0xe9, 0xb4, 0x34, 0xdf, 0xfb, 0x1d, + 0xe, 0x8d, 0xf3, 0x5f, 0xf2, 0xae, 0xe8, 0x8c, 0x8b, 0x29}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 689299471295966, 1831210565161071, 1375187341585438, - 1106284977546171, 1893781834054269 -#else - 35743198, 10271362, 54448239, 27287163, 16690206, 20491888, - 52126651, 16484930, 25180797, 28219548 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 696351368613042, 1494385251239250, 738037133616932, - 636385507851544, 927483222611406 -#else - 66522290, 10376443, 34522450, 22268075, 19801892, 10997610, - 2276632, 9482883, 316878, 13820577 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1949114198209333, 1104419699537997, 783495707664463, - 1747473107602770, 2002634765788641 -#else - 57226037, 29044064, 64993357, 16457135, 56008783, 11674995, - 30756178, 26039378, 30696929, 29841583 -#endif - }}, + {0xde, 0x65, 0x21, 0xa, 0xea, 0x72, 0x7a, 0x83, 0xf6, 0x79, 0xcf, + 0xb, 0xb4, 0x7, 0xab, 0x3f, 0x70, 0xae, 0x38, 0x77, 0xc7, 0x36, + 0x16, 0x52, 0xdc, 0xd7, 0xa7, 0x3, 0x18, 0x27, 0xa6, 0x6b}, + {0xb2, 0xc, 0xf7, 0xef, 0x53, 0x79, 0x92, 0x2a, 0x76, 0x70, 0x15, + 0x79, 0x2a, 0xc9, 0x89, 0x4b, 0x6a, 0xcf, 0xa7, 0x30, 0x7a, 0x45, + 0x18, 0x94, 0x85, 0xe4, 0x5c, 0x4d, 0x40, 0xa8, 0xb8, 0x34}, + {0x35, 0x33, 0x69, 0x83, 0xb5, 0xec, 0x6e, 0xc2, 0xfd, 0xfe, 0xb5, + 0x63, 0xdf, 0x13, 0xa8, 0xd5, 0x73, 0x25, 0xb2, 0xa4, 0x9a, 0xaa, + 0x93, 0xa2, 0x6a, 0x1c, 0x5e, 0x46, 0xdd, 0x2b, 0xd6, 0x71}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1607325776830197, 530883941415333, 1451089452727895, - 1581691157083423, 496100432831154 -#else - 32988917, 23951020, 12499365, 7910787, 56491607, 21622917, - 59766047, 23569034, 34759346, 7392472 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1068900648804224, 2006891997072550, 1134049269345549, - 1638760646180091, 2055396084625778 -#else - 58253184, 15927860, 9866406, 29905021, 64711949, 16898650, - 36699387, 24419436, 25112946, 30627788 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2222475519314561, 1870703901472013, 1884051508440561, - 1344072275216753, 1318025677799069 -#else - 64604801, 33117465, 25621773, 27875660, 15085041, 28074555, - 42223985, 20028237, 5537437, 19640113 -#endif - }}, + {0xf5, 0x5e, 0xf7, 0xb1, 0xda, 0xb5, 0x2d, 0xcd, 0xf5, 0x65, 0xb0, + 0x16, 0xcf, 0x95, 0x7f, 0xd7, 0x85, 0xf0, 0x49, 0x3f, 0xea, 0x1f, + 0x57, 0x14, 0x3d, 0x2b, 0x2b, 0x26, 0x21, 0x36, 0x33, 0x1c}, + {0x80, 0xdf, 0x78, 0xd3, 0x28, 0xcc, 0x33, 0x65, 0xb4, 0xa4, 0xf, + 0xa, 0x79, 0x43, 0xdb, 0xf6, 0x5a, 0xda, 0x1, 0xf7, 0xf9, 0x5f, + 0x64, 0xe3, 0xa4, 0x2b, 0x17, 0xf3, 0x17, 0xf3, 0xd5, 0x74}, + {0x81, 0xca, 0xd9, 0x67, 0x54, 0xe5, 0x6f, 0xa8, 0x37, 0x8c, 0x29, + 0x2b, 0x75, 0x7c, 0x8b, 0x39, 0x3b, 0x62, 0xac, 0xe3, 0x92, 0x8, + 0x6d, 0xda, 0x8c, 0xd9, 0xe9, 0x47, 0x45, 0xcc, 0xeb, 0x4a}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 155711679280656, 681100400509288, 389811735211209, - 2135723811340709, 408733211204125 -#else - 55883280, 2320284, 57524584, 10149186, 33664201, 5808647, - 52232613, 31824764, 31234589, 6090599 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 7813206966729, 194444201427550, 2071405409526507, - 1065605076176312, 1645486789731291 -#else - 57475529, 116425, 26083934, 2897444, 60744427, 30866345, 609720, - 15878753, 60138459, 24519663 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 16625790644959, 1647648827778410, 1579910185572704, - 436452271048548, 121070048451050 -#else - 39351007, 247743, 51914090, 24551880, 23288160, 23542496, - 43239268, 6503645, 20650474, 1804084 -#endif - }}, + {0x10, 0xb6, 0x54, 0x73, 0x9e, 0x8d, 0x40, 0xb, 0x6e, 0x5b, 0xa8, + 0x5b, 0x53, 0x32, 0x6b, 0x80, 0x7, 0xa2, 0x58, 0x4a, 0x3, 0x3a, + 0xe6, 0xdb, 0x2c, 0xdf, 0xa1, 0xc9, 0xdd, 0xd9, 0x3b, 0x17}, + {0xc9, 0x1, 0x6d, 0x27, 0x1b, 0x7, 0xf0, 0x12, 0x70, 0x8c, 0xc4, + 0x86, 0xc5, 0xba, 0xb8, 0xe7, 0xa9, 0xfb, 0xd6, 0x71, 0x9b, 0x12, + 0x8, 0x53, 0x92, 0xb7, 0x3d, 0x5a, 0xf9, 0xfb, 0x88, 0x5d}, + {0xdf, 0x72, 0x58, 0xfe, 0x1e, 0xf, 0x50, 0x2b, 0xc1, 0x18, 0x39, + 0xd4, 0x2e, 0x58, 0xd6, 0x58, 0xe0, 0x3a, 0x67, 0xc9, 0x8e, 0x27, + 0xed, 0xe6, 0x19, 0xa3, 0x9e, 0xb1, 0x13, 0xcd, 0xe1, 0x6}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1037263028552531, 568385780377829, 297953104144430, - 1558584511931211, 2238221839292471 -#else - 39519059, 15456423, 8972517, 8469608, 15640622, 4439847, - 3121995, 23224719, 27842615, 33352104 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 190565267697443, 672855706028058, 338796554369226, - 337687268493904, 853246848691734 -#else - 51801891, 2839643, 22530074, 10026331, 4602058, 5048462, - 28248656, 5031932, 55733782, 12714368 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1763863028400139, 766498079432444, 1321118624818005, - 69494294452268, 858786744165651 -#else - 20807691, 26283607, 29286140, 11421711, 39232341, 19686201, - 45881388, 1035545, 47375635, 12796919 -#endif - }}, + {0x53, 0x3, 0x5b, 0x9e, 0x62, 0xaf, 0x2b, 0x47, 0x47, 0x4, 0x8d, + 0x27, 0x90, 0xb, 0xaa, 0x3b, 0x27, 0xbf, 0x43, 0x96, 0x46, 0x5f, + 0x78, 0xc, 0x13, 0x7b, 0x83, 0x8d, 0x1a, 0x6a, 0x3a, 0x7f}, + {0x23, 0x6f, 0x16, 0x6f, 0x51, 0xad, 0xd0, 0x40, 0xbe, 0x6a, 0xab, + 0x1f, 0x93, 0x32, 0x8e, 0x11, 0x8e, 0x8, 0x4d, 0xa0, 0x14, 0x5e, + 0xe3, 0x3f, 0x66, 0x62, 0xe1, 0x26, 0x35, 0x60, 0x80, 0x30}, + {0xb, 0x80, 0x3d, 0x5d, 0x39, 0x44, 0xe6, 0xf7, 0xf6, 0xed, 0x1, + 0xc9, 0x55, 0xd5, 0xa8, 0x95, 0x39, 0x63, 0x2c, 0x59, 0x30, 0x78, + 0xcd, 0x68, 0x7e, 0x30, 0x51, 0x2e, 0xed, 0xfd, 0xd0, 0x30}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1292056768563024, 1456632109855638, 1100631247050184, - 1386133165675321, 1232898350193752 -#else - 12076880, 19253146, 58323862, 21705509, 42096072, 16400683, - 49517369, 20654993, 3480664, 18371617 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 366253102478259, 525676242508811, 1449610995265438, - 1183300845322183, 185960306491545 -#else - 34747315, 5457596, 28548107, 7833186, 7303070, 21600887, - 42745799, 17632556, 33734809, 2771024 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 28315355815982, 460422265558930, 1799675876678724, - 1969256312504498, 1051823843138725 -#else - 45719598, 421931, 26597266, 6860826, 22486084, 26817260, - 49971378, 29344205, 42556581, 15673396 -#endif - }}, + {0x50, 0x47, 0xb8, 0x68, 0x1e, 0x97, 0xb4, 0x9c, 0xcf, 0xbb, 0x64, + 0x66, 0x29, 0x72, 0x95, 0xa0, 0x2b, 0x41, 0xfa, 0x72, 0x26, 0xe7, + 0x8d, 0x5c, 0xd9, 0x89, 0xc5, 0x51, 0x43, 0x8, 0x15, 0x46}, + {0xb3, 0x33, 0x12, 0xf2, 0x1a, 0x4d, 0x59, 0xe0, 0x9c, 0x4d, 0xcc, + 0xf0, 0x8e, 0xe7, 0xdb, 0x1b, 0x77, 0x9a, 0x49, 0x8f, 0x7f, 0x18, + 0x65, 0x69, 0x68, 0x98, 0x9, 0x2c, 0x20, 0x14, 0x92, 0xa}, + {0x2e, 0xa0, 0xb9, 0xae, 0xc0, 0x19, 0x90, 0xbc, 0xae, 0x4c, 0x3, + 0x16, 0xd, 0x11, 0xc7, 0x55, 0xec, 0x32, 0x99, 0x65, 0x1, 0xf5, + 0x6d, 0xe, 0xfe, 0x5d, 0xca, 0x95, 0x28, 0xd, 0xca, 0x3b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 156914999361983, 1606148405719949, 1665208410108430, - 317643278692271, 1383783705665320 -#else - 46924223, 2338215, 19788685, 23933476, 63107598, 24813538, - 46837679, 4733253, 3727144, 20619984 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 54684536365732, 2210010038536222, 1194984798155308, - 535239027773705, 1516355079301361 -#else - 6120100, 814863, 55314462, 32931715, 6812204, 17806661, 2019593, - 7975683, 31123697, 22595451 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1484387703771650, 198537510937949, 2186282186359116, - 617687444857508, 647477376402122 -#else - 30069250, 22119100, 30434653, 2958439, 18399564, 32578143, - 12296868, 9204260, 50676426, 9648164 -#endif - }}, + {0xbf, 0x1, 0xcc, 0x9e, 0xb6, 0x8e, 0x68, 0x9c, 0x6f, 0x89, 0x44, + 0xa6, 0xad, 0x83, 0xbc, 0xf0, 0xe2, 0x9f, 0x7a, 0x5f, 0x5f, 0x95, + 0x2d, 0xca, 0x41, 0x82, 0xf2, 0x8d, 0x3, 0xb4, 0xa8, 0x4e}, + {0xa4, 0x62, 0x5d, 0x3c, 0xbc, 0x31, 0xf0, 0x40, 0x60, 0x7a, 0xf0, + 0xcf, 0x3e, 0x8b, 0xfc, 0x19, 0x45, 0xb5, 0xf, 0x13, 0xa2, 0x3d, + 0x18, 0x98, 0xcd, 0x13, 0x8f, 0xae, 0xdd, 0xde, 0x31, 0x56}, + {0x2, 0xd2, 0xca, 0xf1, 0xa, 0x46, 0xed, 0x2a, 0x83, 0xee, 0x8c, + 0xa4, 0x5, 0x53, 0x30, 0x46, 0x5f, 0x1a, 0xf1, 0x49, 0x45, 0x77, + 0x21, 0x91, 0x63, 0xa4, 0x2c, 0x54, 0x30, 0x9, 0xce, 0x24}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2147715541830533, 500032538445817, 646380016884826, - 352227855331122, 1488268620408052 -#else - 32705413, 32003455, 30705657, 7451065, 55303258, 9631812, - 3305266, 5248604, 41100532, 22176930 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 159386186465542, 1877626593362941, 618737197060512, - 1026674284330807, 1158121760792685 -#else - 17219846, 2375039, 35537917, 27978816, 47649184, 9219902, - 294711, 15298639, 2662509, 17257359 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1744544377739822, 1964054180355661, 1685781755873170, - 2169740670377448, 1286112621104591 -#else - 65935918, 25995736, 62742093, 29266687, 45762450, 25120105, - 32087528, 32331655, 32247247, 19164571 -#endif - }}, + {0x85, 0xb, 0xf3, 0xfd, 0x55, 0xa1, 0xcf, 0x3f, 0xa4, 0x2e, 0x37, + 0x36, 0x8e, 0x16, 0xf7, 0xd2, 0x44, 0xf8, 0x92, 0x64, 0xde, 0x64, + 0xe0, 0xb2, 0x80, 0x42, 0x4f, 0x32, 0xa7, 0x28, 0x99, 0x54}, + {0x6, 0xc1, 0x6, 0xfd, 0xf5, 0x90, 0xe8, 0x1f, 0xf2, 0x10, 0x88, + 0x5d, 0x35, 0x68, 0xc4, 0xb5, 0x3e, 0xaf, 0x8c, 0x6e, 0xfe, 0x8, + 0x78, 0x82, 0x4b, 0xd7, 0x6, 0x8a, 0xc2, 0xe3, 0xd4, 0x41}, + {0x2e, 0x1a, 0xee, 0x63, 0xa7, 0x32, 0x6e, 0xf2, 0xea, 0xfd, 0x5f, + 0xd2, 0xb7, 0xe4, 0x91, 0xae, 0x69, 0x4d, 0x7f, 0xd1, 0x3b, 0xd3, + 0x3b, 0xbc, 0x6a, 0xff, 0xdc, 0xc0, 0xde, 0x66, 0x1b, 0x49}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 81977249784993, 1667943117713086, 1668983819634866, - 1605016835177615, 1353960708075544 -#else - 14312609, 1221556, 17395390, 24854289, 62163122, 24869796, - 38911119, 23916614, 51081240, 20175586 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1602253788689063, 439542044889886, 2220348297664483, - 657877410752869, 157451572512238 -#else - 65680039, 23875441, 57873182, 6549686, 59725795, 33085767, - 23046501, 9803137, 17597934, 2346211 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1029287186166717, 65860128430192, 525298368814832, - 1491902500801986, 1461064796385400 -#else - 18510781, 15337574, 26171504, 981392, 44867312, 7827555, - 43617730, 22231079, 3059832, 21771562 -#endif - }}, + {0xa1, 0x64, 0xda, 0xd0, 0x8e, 0x4a, 0xf0, 0x75, 0x4b, 0x28, 0xe2, + 0x67, 0xaf, 0x2c, 0x22, 0xed, 0xa4, 0x7b, 0x7b, 0x1f, 0x79, 0xa3, + 0x34, 0x82, 0x67, 0x8b, 0x1, 0xb7, 0xb0, 0xb8, 0xf6, 0x4c}, + {0xa7, 0x32, 0xea, 0xc7, 0x3d, 0xb1, 0xf5, 0x98, 0x98, 0xdb, 0x16, + 0x7e, 0xcc, 0xf8, 0xd5, 0xe3, 0x47, 0xd9, 0xf8, 0xcb, 0x52, 0xbf, + 0xa, 0xac, 0xac, 0xe4, 0x5e, 0xc8, 0xd0, 0x38, 0xf3, 0x8}, + {0xbd, 0x73, 0x1a, 0x99, 0x21, 0xa8, 0x83, 0xc3, 0x7a, 0xc, 0x32, + 0xdf, 0x1, 0xbc, 0x27, 0xab, 0x63, 0x70, 0x77, 0x84, 0x1b, 0x33, + 0x3d, 0xc1, 0x99, 0x8a, 0x7, 0xeb, 0x82, 0x4a, 0xd, 0x53}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 408216988729246, 2121095722306989, 913562102267595, - 1879708920318308, 241061448436731 -#else - 10141598, 6082907, 17829293, 31606789, 9830091, 13613136, - 41552228, 28009845, 33606651, 3592095 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1185483484383269, 1356339572588553, 584932367316448, - 102132779946470, 1792922621116791 -#else - 33114149, 17665080, 40583177, 20211034, 33076704, 8716171, - 1151462, 1521897, 66126199, 26716628 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1966196870701923, 2230044620318636, 1425982460745905, - 261167817826569, 46517743394330 -#else - 34169699, 29298616, 23947180, 33230254, 34035889, 21248794, - 50471177, 3891703, 26353178, 693168 -#endif - }}, + {0x9e, 0xbf, 0x9a, 0x6c, 0x45, 0x73, 0x69, 0x6d, 0x80, 0xa8, 0x0, + 0x49, 0xfc, 0xb2, 0x7f, 0x25, 0x50, 0xb8, 0xcf, 0xc8, 0x12, 0xf4, + 0xac, 0x2b, 0x5b, 0xbd, 0xbf, 0xc, 0xe0, 0xe7, 0xb3, 0xd}, + {0x25, 0x48, 0xf9, 0xe1, 0x30, 0x36, 0x4c, 0x0, 0x5a, 0x53, 0xab, + 0x8c, 0x26, 0x78, 0x2d, 0x7e, 0x8b, 0xff, 0x84, 0xcc, 0x23, 0x23, + 0x48, 0xc7, 0xb9, 0x70, 0x17, 0x10, 0x3f, 0x75, 0xea, 0x65}, + {0x63, 0x63, 0x9, 0xe2, 0x3e, 0xfc, 0x66, 0x3d, 0x6b, 0xcb, 0xb5, + 0x61, 0x7f, 0x2c, 0xd6, 0x81, 0x1a, 0x3b, 0x44, 0x13, 0x42, 0x4, + 0xbe, 0xf, 0xdb, 0xa1, 0xe1, 0x21, 0x19, 0xec, 0xa4, 0x2}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 107077591595359, 884959942172345, 27306869797400, - 2224911448949390, 964352058245223 -#else - 30374239, 1595580, 50224825, 13186930, 4600344, 406904, 9585294, - 33153764, 31375463, 14369965 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1730194207717538, 431790042319772, 1831515233279467, - 1372080552768581, 1074513929381760 -#else - 52738210, 25781902, 1510300, 6434173, 48324075, 27291703, - 32732229, 20445593, 17901440, 16011505 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1450880638731607, 1019861580989005, 1229729455116861, - 1174945729836143, 826083146840706 -#else - 18171223, 21619806, 54608461, 15197121, 56070717, 18324396, - 47936623, 17508055, 8764034, 12309598 -#endif - }}, + {0x5f, 0x79, 0xcf, 0xf1, 0x62, 0x61, 0xc8, 0xf5, 0xf2, 0x57, 0xee, + 0x26, 0x19, 0x86, 0x8c, 0x11, 0x78, 0x35, 0x6, 0x1c, 0x85, 0x24, + 0x21, 0x17, 0xcf, 0x7f, 0x6, 0xec, 0x5d, 0x2b, 0xd1, 0x36}, + {0xa2, 0xb8, 0x24, 0x3b, 0x9a, 0x25, 0xe6, 0x5c, 0xb8, 0xa0, 0xaf, + 0x45, 0xcc, 0x7a, 0x57, 0xb8, 0x37, 0x70, 0xa0, 0x8b, 0xe8, 0xe6, + 0xcb, 0xcc, 0xbf, 0x9, 0x78, 0x12, 0x51, 0x3c, 0x14, 0x3d}, + {0x57, 0x45, 0x15, 0x79, 0x91, 0x27, 0x6d, 0x12, 0xa, 0x3a, 0x78, + 0xfc, 0x5c, 0x8f, 0xe4, 0xd5, 0xac, 0x9b, 0x17, 0xdf, 0xe8, 0xb6, + 0xbd, 0x36, 0x59, 0x28, 0xa8, 0x5b, 0x88, 0x17, 0xf5, 0x2e}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1899935429242705, 1602068751520477, 940583196550370, - 82431069053859, 1540863155745696 -#else - 5975889, 28311244, 47649501, 23872684, 55567586, 14015781, - 43443107, 1228318, 17544096, 22960650 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2136688454840028, 2099509000964294, 1690800495246475, - 1217643678575476, 828720645084218 -#else - 5811932, 31839139, 3442886, 31285122, 48741515, 25194890, - 49064820, 18144304, 61543482, 12348899 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 765548025667841, 462473984016099, 998061409979798, - 546353034089527, 2212508972466858 -#else - 35709185, 11407554, 25755363, 6891399, 63851926, 14872273, - 42259511, 8141294, 56476330, 32968952 -#endif - }}, + {0x51, 0x2f, 0x5b, 0x30, 0xfb, 0xbf, 0xee, 0x96, 0xb8, 0x96, 0x95, + 0x88, 0xad, 0x38, 0xf9, 0xd3, 0x25, 0xdd, 0xd5, 0x46, 0xc7, 0x2d, + 0xf5, 0xf0, 0x95, 0x0, 0x3a, 0xbb, 0x90, 0x82, 0x96, 0x57}, + {0xdc, 0xae, 0x58, 0x8c, 0x4e, 0x97, 0x37, 0x46, 0xa4, 0x41, 0xf0, + 0xab, 0xfb, 0x22, 0xef, 0xb9, 0x8a, 0x71, 0x80, 0xe9, 0x56, 0xd9, + 0x85, 0xe1, 0xa6, 0xa8, 0x43, 0xb1, 0xfa, 0x78, 0x1b, 0x2f}, + {0x1, 0xe1, 0x20, 0xa, 0x43, 0xb8, 0x1a, 0xf7, 0x47, 0xec, 0xf0, + 0x24, 0x8d, 0x65, 0x93, 0xf3, 0xd1, 0xee, 0xe2, 0x6e, 0xa8, 0x9, + 0x75, 0xcf, 0xe1, 0xa3, 0x2a, 0xdc, 0x35, 0x3e, 0xc4, 0x7d}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 46575283771160, 892570971573071, 1281983193144090, - 1491520128287375, 75847005908304 -#else - 54433560, 694025, 62032719, 13300343, 14015258, 19103038, - 57410191, 22225381, 30944592, 1130208 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1801436127943107, 1734436817907890, 1268728090345068, - 167003097070711, 2233597765834956 -#else - 8247747, 26843490, 40546482, 25845122, 52706924, 18905521, - 4652151, 2488540, 23550156, 33283200 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1997562060465113, 1048700225534011, 7615603985628, - 1855310849546841, 2242557647635213 -#else - 17294297, 29765994, 7026747, 15626851, 22990044, 113481, - 2267737, 27646286, 66700045, 33416712 -#endif - }}, + {0x18, 0x97, 0x3e, 0x27, 0x5c, 0x2a, 0x78, 0x5a, 0x94, 0xfd, 0x4e, + 0x5e, 0x99, 0xc6, 0x76, 0x35, 0x3e, 0x7d, 0x23, 0x1f, 0x5, 0xd8, + 0x2e, 0xf, 0x99, 0xa, 0xd5, 0x82, 0x1d, 0xb8, 0x4f, 0x4}, + {0xc3, 0xd9, 0x7d, 0x88, 0x65, 0x66, 0x96, 0x85, 0x55, 0x53, 0xb0, + 0x4b, 0x31, 0x9b, 0xf, 0xc9, 0xb1, 0x79, 0x20, 0xef, 0xf8, 0x8d, + 0xe0, 0xc6, 0x2f, 0xc1, 0x8c, 0x75, 0x16, 0x20, 0xf7, 0x7e}, + {0xd9, 0xe3, 0x7, 0xa9, 0xc5, 0x18, 0xdf, 0xc1, 0x59, 0x63, 0x4c, + 0xce, 0x1d, 0x37, 0xb3, 0x57, 0x49, 0xbb, 0x1, 0xb2, 0x34, 0x45, + 0x70, 0xca, 0x2e, 0xdd, 0x30, 0x9c, 0x3f, 0x82, 0x79, 0x7f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1161017320376250, 492624580169043, 2169815802355237, - 976496781732542, 1770879511019629 -#else - 16091066, 17300506, 18599251, 7340678, 2137637, 32332775, - 63744702, 14550935, 3260525, 26388161 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1357044908364776, 729130645262438, 1762469072918979, - 1365633616878458, 181282906404941 -#else - 62198760, 20221544, 18550886, 10864893, 50649539, 26262835, - 44079994, 20349526, 54360141, 2701325 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1080413443139865, 1155205815510486, 1848782073549786, - 622566975152580, 124965574467971 -#else - 58534169, 16099414, 4629974, 17213908, 46322650, 27548999, - 57090500, 9276970, 11329923, 1862132 -#endif - }}, + {0xba, 0x87, 0xf5, 0x68, 0xf0, 0x1f, 0x9c, 0x6a, 0xde, 0xc8, 0x50, + 0x0, 0x4e, 0x89, 0x27, 0x8, 0xe7, 0x5b, 0xed, 0x7d, 0x55, 0x99, + 0xbf, 0x3c, 0xf0, 0xd6, 0x6, 0x1c, 0x43, 0xb0, 0xa9, 0x64}, + {0xe8, 0x13, 0xb5, 0xa3, 0x39, 0xd2, 0x34, 0x83, 0xd8, 0xa8, 0x1f, + 0xb9, 0xd4, 0x70, 0x36, 0xc1, 0x33, 0xbd, 0x90, 0xf5, 0x36, 0x41, + 0xb5, 0x12, 0xb4, 0xd9, 0x84, 0xd7, 0x73, 0x3, 0x4e, 0xa}, + {0x19, 0x29, 0x7d, 0x5b, 0xa1, 0xd6, 0xb3, 0x2e, 0x35, 0x82, 0x3a, + 0xd5, 0xa0, 0xf6, 0xb4, 0xb0, 0x47, 0x5d, 0xa4, 0x89, 0x43, 0xce, + 0x56, 0x71, 0x6c, 0x34, 0x18, 0xce, 0xa, 0x7d, 0x1a, 0x7}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1184526762066993, 247622751762817, 692129017206356, - 820018689412496, 2188697339828085 -#else - 14763057, 17650824, 36190593, 3689866, 3511892, 10313526, - 45157776, 12219230, 58070901, 32614131 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2020536369003019, 202261491735136, 1053169669150884, - 2056531979272544, 778165514694311 -#else - 8894987, 30108338, 6150752, 3013931, 301220, 15693451, 35127648, - 30644714, 51670695, 11595569 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 237404399610207, 1308324858405118, 1229680749538400, - 720131409105291, 1958958863624906 -#else - 15214943, 3537601, 40870142, 19495559, 4418656, 18323671, - 13947275, 10730794, 53619402, 29190761 -#endif - }}, + {0x31, 0x44, 0xe1, 0x20, 0x52, 0x35, 0xc, 0xcc, 0x41, 0x51, 0xb1, + 0x9, 0x7, 0x95, 0x65, 0xd, 0x36, 0x5f, 0x9d, 0x20, 0x1b, 0x62, + 0xf5, 0x9a, 0xd3, 0x55, 0x77, 0x61, 0xf7, 0xbc, 0x69, 0x7c}, + {0xb, 0xba, 0x87, 0xc8, 0xaa, 0x2d, 0x7, 0xd3, 0xee, 0x62, 0xa5, + 0xbf, 0x5, 0x29, 0x26, 0x1, 0x8b, 0x76, 0xef, 0xc0, 0x2, 0x30, + 0x54, 0xcf, 0x9c, 0x7e, 0xea, 0x46, 0x71, 0xcc, 0x3b, 0x2c}, + {0x5f, 0x29, 0xe8, 0x4, 0xeb, 0xd7, 0xf0, 0x7, 0x7d, 0xf3, 0x50, + 0x2f, 0x25, 0x18, 0xdb, 0x10, 0xd7, 0x98, 0x17, 0x17, 0xa3, 0xa9, + 0x51, 0xe9, 0x1d, 0xa5, 0xac, 0x22, 0x73, 0x9a, 0x5a, 0x6f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 515583508038846, 17656978857189, 1717918437373989, - 1568052070792483, 46975803123923 -#else - 64570558, 7682792, 32759013, 263109, 37124133, 25598979, - 44776739, 23365796, 977107, 699994 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 281527309158085, 36970532401524, 866906920877543, - 2222282602952734, 1289598729589882 -#else - 54642373, 4195083, 57897332, 550903, 51543527, 12917919, - 19118110, 33114591, 36574330, 19216518 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1278207464902042, 494742455008756, 1262082121427081, - 1577236621659884, 1888786707293291 -#else - 31788442, 19046775, 4799988, 7372237, 8808585, 18806489, - 9408236, 23502657, 12493931, 28145115 -#endif - }}, + {0xbe, 0x44, 0xd9, 0xa3, 0xeb, 0xd4, 0x29, 0xe7, 0x9e, 0xaf, 0x78, + 0x80, 0x40, 0x9, 0x9e, 0x8d, 0x3, 0x9c, 0x86, 0x47, 0x7a, 0x56, + 0x25, 0x45, 0x24, 0x3b, 0x8d, 0xee, 0x80, 0x96, 0xab, 0x2}, + {0xc5, 0xc6, 0x41, 0x2f, 0xc, 0x0, 0xa1, 0x8b, 0x9b, 0xfb, 0xfe, + 0xc, 0xc1, 0x79, 0x9f, 0xc4, 0x9f, 0x1c, 0xc5, 0x3c, 0x70, 0x47, + 0xfa, 0x4e, 0xca, 0xaf, 0x47, 0xe1, 0xa2, 0x21, 0x4e, 0x49}, + {0x9a, 0xd, 0xe5, 0xdd, 0x85, 0x8a, 0xa4, 0xef, 0x49, 0xa2, 0xb9, + 0xf, 0x4e, 0x22, 0x9a, 0x21, 0xd9, 0xf6, 0x1e, 0xd9, 0x1d, 0x1f, + 0x9, 0xfa, 0x34, 0xbb, 0x46, 0xea, 0xcb, 0x76, 0x5d, 0x6b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 353042527954210, 1830056151907359, 1111731275799225, - 174960955838824, 404312815582675 -#else - 41428258, 5260743, 47873055, 27269961, 63412921, 16566086, - 27218280, 2607121, 29375955, 6024730 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2064251142068628, 1666421603389706, 1419271365315441, - 468767774902855, 191535130366583 -#else - 842132, 30759739, 62345482, 24831616, 26332017, 21148791, - 11831879, 6985184, 57168503, 2854095 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1716987058588002, 1859366439773457, 1767194234188234, - 64476199777924, 1117233614485261 -#else - 62261602, 25585100, 2516241, 27706719, 9695690, 26333246, - 16512644, 960770, 12121869, 16648078 -#endif - }}, + {0x22, 0x25, 0x78, 0x1e, 0x17, 0x41, 0xf9, 0xe0, 0xd3, 0x36, 0x69, + 0x3, 0x74, 0xae, 0xe6, 0xf1, 0x46, 0xc7, 0xfc, 0xd0, 0xa2, 0x3e, + 0x8b, 0x40, 0x3e, 0x31, 0xdd, 0x3, 0x9c, 0x86, 0xfb, 0x16}, + {0x94, 0xd9, 0xc, 0xec, 0x6c, 0x55, 0x57, 0x88, 0xba, 0x1d, 0xd0, + 0x5c, 0x6f, 0xdc, 0x72, 0x64, 0x77, 0xb4, 0x42, 0x8f, 0x14, 0x69, + 0x1, 0xaf, 0x54, 0x73, 0x27, 0x85, 0xf6, 0x33, 0xe3, 0xa}, + {0x62, 0x9, 0xb6, 0x33, 0x97, 0x19, 0x8e, 0x28, 0x33, 0xe1, 0xab, + 0xd8, 0xb4, 0x72, 0xfc, 0x24, 0x3e, 0xd0, 0x91, 0x9, 0xed, 0xf7, + 0x11, 0x48, 0x75, 0xd0, 0x70, 0x8f, 0x8b, 0xe3, 0x81, 0x3f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 984292135520292, 135138246951259, 2220652137473167, - 1722843421165029, 190482558012909 -#else - 51890212, 14667095, 53772635, 2013716, 30598287, 33090295, - 35603941, 25672367, 20237805, 2838411 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 298845952651262, 1166086588952562, 1179896526238434, - 1347812759398693, 1412945390096208 -#else - 47820798, 4453151, 15298546, 17376044, 22115042, 17581828, - 12544293, 20083975, 1068880, 21054527 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1143239552672925, 906436640714209, 2177000572812152, - 2075299936108548, 325186347798433 -#else - 57549981, 17035596, 33238497, 13506958, 30505848, 32439836, - 58621956, 30924378, 12521377, 4845654 -#endif - }}, + {0x24, 0xc8, 0x17, 0x5f, 0x35, 0x7f, 0xdb, 0xa, 0xa4, 0x99, 0x42, + 0xd7, 0xc3, 0x23, 0xb9, 0x74, 0xf7, 0xea, 0xf8, 0xcb, 0x8b, 0x3e, + 0x7c, 0xd5, 0x3d, 0xdc, 0xde, 0x4c, 0xd3, 0xe2, 0xd3, 0xa}, + {0xfe, 0xaf, 0xd9, 0x7e, 0xcc, 0xf, 0x91, 0x7f, 0x4b, 0x87, 0x65, + 0x24, 0xa1, 0xb8, 0x5c, 0x54, 0x4, 0x47, 0xc, 0x4b, 0xd2, 0x7e, + 0x39, 0xa8, 0x93, 0x9, 0xf5, 0x4, 0xc1, 0xf, 0x51, 0x50}, + {0x9d, 0x24, 0x6e, 0x33, 0xc5, 0xf, 0xc, 0x6f, 0xd9, 0xcf, 0x31, + 0xc3, 0x19, 0xde, 0x5e, 0x74, 0x1c, 0xfe, 0xee, 0x9, 0x0, 0xfd, + 0xd6, 0xf2, 0xbe, 0x1e, 0xfa, 0xf0, 0x8b, 0x15, 0x7c, 0x12}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 721024854374772, 684487861263316, 1373438744094159, - 2193186935276995, 1387043709851261 -#else - 38910324, 10744107, 64150484, 10199663, 7759311, 20465832, - 3409347, 32681032, 60626557, 20668561 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 418098668140962, 715065997721283, 1471916138376055, - 2168570337288357, 937812682637044 -#else - 43547042, 6230155, 46726851, 10655313, 43068279, 21933259, - 10477733, 32314216, 63995636, 13974497 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1043584187226485, 2143395746619356, 2209558562919611, - 482427979307092, 847556718384018 -#else - 12966261, 15550616, 35069916, 31939085, 21025979, 32924988, - 5642324, 7188737, 18895762, 12629579 -#endif - }}, + {0x74, 0xb9, 0x51, 0xae, 0xc4, 0x8f, 0xa2, 0xde, 0x96, 0xfe, 0x4d, + 0x74, 0xd3, 0x73, 0x99, 0x1d, 0xa8, 0x48, 0x38, 0x87, 0xb, 0x68, + 0x40, 0x62, 0x95, 0xdf, 0x67, 0xd1, 0x79, 0x24, 0xd8, 0x4e}, + {0xa2, 0x79, 0x98, 0x2e, 0x42, 0x7c, 0x19, 0xf6, 0x47, 0x36, 0xca, + 0x52, 0xd4, 0xdd, 0x4a, 0xa4, 0xcb, 0xac, 0x4e, 0x4b, 0xc1, 0x3f, + 0x41, 0x9b, 0x68, 0x4f, 0xef, 0x7, 0x7d, 0xf8, 0x4e, 0x35}, + {0x75, 0xd9, 0xc5, 0x60, 0x22, 0xb5, 0xe3, 0xfe, 0xb8, 0xb0, 0x41, + 0xeb, 0xfc, 0x2e, 0x35, 0x50, 0x3c, 0x65, 0xf6, 0xa9, 0x30, 0xac, + 0x8, 0x88, 0x6d, 0x23, 0x39, 0x5, 0xd2, 0x92, 0x2d, 0x30}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1248731221520759, 1465200936117687, 540803492710140, - 52978634680892, 261434490176109 -#else - 14741879, 18607545, 22177207, 21833195, 1279740, 8058600, - 11758140, 789443, 32195181, 3895677 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1057329623869501, 620334067429122, 461700859268034, - 2012481616501857, 297268569108938 -#else - 10758205, 15755439, 62598914, 9243697, 62229442, 6879878, - 64904289, 29988312, 58126794, 4429646 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1055352180870759, 1553151421852298, 1510903185371259, - 1470458349428097, 1226259419062731 -#else - 64654951, 15725972, 46672522, 23143759, 61304955, 22514211, - 59972993, 21911536, 18047435, 18272689 -#endif - }}, + {0x77, 0xf1, 0xe0, 0xe4, 0xb6, 0x6f, 0xbc, 0x2d, 0x93, 0x6a, 0xbd, + 0xa4, 0x29, 0xbf, 0xe1, 0x4, 0xe8, 0xf6, 0x7a, 0x78, 0xd4, 0x66, + 0x19, 0x5e, 0x60, 0xd0, 0x26, 0xb4, 0x5e, 0x5f, 0xdc, 0xe}, + {0x3d, 0x28, 0xa4, 0xbc, 0xa2, 0xc1, 0x13, 0x78, 0xd9, 0x3d, 0x86, + 0xa1, 0x91, 0xf0, 0x62, 0xed, 0x86, 0xfa, 0x68, 0xc2, 0xb8, 0xbc, + 0xc7, 0xae, 0x4c, 0xae, 0x1c, 0x6f, 0xb7, 0xd3, 0xe5, 0x10}, + {0x67, 0x8e, 0xda, 0x53, 0xd6, 0xbf, 0x53, 0x54, 0x41, 0xf6, 0xa9, + 0x24, 0xec, 0x1e, 0xdc, 0xe9, 0x23, 0x8a, 0x57, 0x3, 0x3b, 0x26, + 0x87, 0xbf, 0x72, 0xba, 0x1c, 0x36, 0x51, 0x6c, 0xb4, 0x45}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1492988790301668, 790326625573331, 1190107028409745, - 1389394752159193, 1620408196604194 -#else - 41935844, 22247266, 29759955, 11776784, 44846481, 17733976, - 10993113, 20703595, 49488162, 24145963 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 47000654413729, 1004754424173864, 1868044813557703, - 173236934059409, 588771199737015 -#else - 21987233, 700364, 42603816, 14972007, 59334599, 27836036, - 32155025, 2581431, 37149879, 8773374 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 30498470091663, 1082245510489825, 576771653181956, - 806509986132686, 1317634017056939 -#else - 41540495, 454462, 53896929, 16126714, 25240068, 8594567, - 20656846, 12017935, 59234475, 19634276 -#endif - }}, + {0xe4, 0xe3, 0x7f, 0x8a, 0xdd, 0x4d, 0x9d, 0xce, 0x30, 0xe, 0x62, + 0x76, 0x56, 0x64, 0x13, 0xab, 0x58, 0x99, 0xe, 0xb3, 0x7b, 0x4f, + 0x59, 0x4b, 0xdf, 0x29, 0x12, 0x32, 0xef, 0xa, 0x1c, 0x5c}, + {0xa1, 0x7f, 0x4f, 0x31, 0xbf, 0x2a, 0x40, 0xa9, 0x50, 0xf4, 0x8c, + 0x8e, 0xdc, 0xf1, 0x57, 0xe2, 0x84, 0xbe, 0xa8, 0x23, 0x4b, 0xd5, + 0xbb, 0x1d, 0x3b, 0x71, 0xcb, 0x6d, 0xa3, 0xbf, 0x77, 0x21}, + {0x8f, 0xdb, 0x79, 0xfa, 0xbc, 0x1b, 0x8, 0x37, 0xb3, 0x59, 0x5f, + 0xc2, 0x1e, 0x81, 0x48, 0x60, 0x87, 0x24, 0x83, 0x9c, 0x65, 0x76, + 0x7a, 0x8, 0xbb, 0xb5, 0x8a, 0x7d, 0x38, 0x19, 0xe6, 0x4a}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 420308055751555, 1493354863316002, 165206721528088, - 1884845694919786, 2065456951573059 -#else - 6028163, 6263078, 36097058, 22252721, 66289944, 2461771, - 35267690, 28086389, 65387075, 30777706 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1115636332012334, 1854340990964155, 83792697369514, - 1972177451994021, 457455116057587 -#else - 54829870, 16624276, 987579, 27631834, 32908202, 1248608, - 7719845, 29387734, 28408819, 6816612 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1698968457310898, 1435137169051090, 1083661677032510, - 938363267483709, 340103887207182 -#else - 56750770, 25316602, 19549650, 21385210, 22082622, 16147817, - 20613181, 13982702, 56769294, 5067942 -#endif - }}, + {0x83, 0xfb, 0x5b, 0x98, 0x44, 0x7e, 0x11, 0x61, 0x36, 0x31, 0x96, + 0x71, 0x2a, 0x46, 0xe0, 0xfc, 0x4b, 0x90, 0x25, 0xd4, 0x48, 0x34, + 0xac, 0x83, 0x64, 0x3d, 0xa4, 0x5b, 0xbe, 0x5a, 0x68, 0x75}, + {0x2e, 0xa3, 0x44, 0x53, 0xaa, 0xf6, 0xdb, 0x8d, 0x78, 0x40, 0x1b, + 0xb4, 0xb4, 0xea, 0x88, 0x7d, 0x60, 0xd, 0x13, 0x4a, 0x97, 0xeb, + 0xb0, 0x5e, 0x3, 0x3e, 0xbf, 0x17, 0x1b, 0xd9, 0x0, 0x1a}, + {0xb2, 0xf2, 0x61, 0xeb, 0x33, 0x9, 0x96, 0x6e, 0x52, 0x49, 0xff, + 0xc9, 0xa8, 0xf, 0x3d, 0x54, 0x69, 0x65, 0xf6, 0x7a, 0x10, 0x75, + 0x72, 0xdf, 0xaa, 0xe6, 0xb0, 0x23, 0xb6, 0x29, 0x55, 0x13}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1995325341336574, 911500251774648, 164010755403692, - 855378419194762, 1573601397528842 -#else - 36602878, 29732664, 12074680, 13582412, 47230892, 2443950, - 47389578, 12746131, 5331210, 23448488 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 241719380661528, 310028521317150, 1215881323380194, - 1408214976493624, 2141142156467363 -#else - 30528792, 3601899, 65151774, 4619784, 39747042, 18118043, - 24180792, 20984038, 27679907, 31905504 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1315157046163473, 727368447885818, 1363466668108618, - 1668921439990361, 1398483384337907 -#else - 9402385, 19597367, 32834042, 10838634, 40528714, 20317236, - 26653273, 24868867, 22611443, 20839026 -#endif - }}, + {0xfe, 0x83, 0x2e, 0xe2, 0xbc, 0x16, 0xc7, 0xf5, 0xc1, 0x85, 0x9, + 0xe8, 0x19, 0xeb, 0x2b, 0xb4, 0xae, 0x4a, 0x25, 0x14, 0x37, 0xa6, + 0x9d, 0xec, 0x13, 0xa6, 0x90, 0x15, 0x5, 0xea, 0x72, 0x59}, + {0x18, 0xd5, 0xd1, 0xad, 0xd7, 0xdb, 0xf0, 0x18, 0x11, 0x1f, 0xc1, + 0xcf, 0x88, 0x78, 0x9f, 0x97, 0x9b, 0x75, 0x14, 0x71, 0xf0, 0xe1, + 0x32, 0x87, 0x1, 0x3a, 0xca, 0x65, 0x1a, 0xb8, 0xb5, 0x79}, + {0x11, 0x78, 0x8f, 0xdc, 0x20, 0xac, 0xd4, 0xf, 0xa8, 0x4f, 0x4d, + 0xac, 0x94, 0xd2, 0x9a, 0x9a, 0x34, 0x4, 0x36, 0xb3, 0x64, 0x2d, + 0x1b, 0xc0, 0xdb, 0x3b, 0x5f, 0x90, 0x95, 0x9c, 0x7e, 0x4f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 75029678299646, 1015388206460473, 1849729037055212, - 1939814616452984, 444404230394954 -#else - 22190590, 1118029, 22736441, 15130463, 36648172, 27563110, - 19189624, 28905490, 4854858, 6622139 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2053597130993710, 2024431685856332, 2233550957004860, - 2012407275509545, 872546993104440 -#else - 58798126, 30600981, 58846284, 30166382, 56707132, 33282502, - 13424425, 29987205, 26404408, 13001963 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1217269667678610, 599909351968693, 1390077048548598, - 1471879360694802, 739586172317596 -#else - 35867026, 18138731, 64114613, 8939345, 11562230, 20713762, - 41044498, 21932711, 51703708, 11020692 -#endif - }}, + {0xfe, 0x99, 0x52, 0x35, 0x3d, 0x44, 0xc8, 0x71, 0xd7, 0xea, 0xeb, + 0xdb, 0x1c, 0x3b, 0xcd, 0x8b, 0x66, 0x94, 0xa4, 0xf1, 0x9e, 0x49, + 0x92, 0x80, 0xc8, 0xad, 0x44, 0xa1, 0xc4, 0xee, 0x42, 0x19}, + {0x2e, 0x30, 0x81, 0x57, 0xbc, 0x4b, 0x67, 0x62, 0xf, 0xdc, 0xad, + 0x89, 0x39, 0xf, 0x52, 0xd8, 0xc6, 0xd9, 0xfb, 0x53, 0xae, 0x99, + 0x29, 0x8c, 0x4c, 0x8e, 0x63, 0x2e, 0xd9, 0x3a, 0x99, 0x31}, + {0x92, 0x49, 0x23, 0xae, 0x19, 0x53, 0xac, 0x7d, 0x92, 0x3e, 0xea, + 0xc, 0x91, 0x3d, 0x1b, 0x2c, 0x22, 0x11, 0x3c, 0x25, 0x94, 0xe4, + 0x3c, 0x55, 0x75, 0xca, 0xf9, 0x4e, 0x31, 0x65, 0xa, 0x2a}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1718318639380794, 1560510726633958, 904462881159922, - 1418028351780052, 94404349451937 -#else - 1866042, 25604943, 59210214, 23253421, 12483314, 13477547, - 3175636, 21130269, 28761761, 1406734 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2132502667405250, 214379346175414, 1502748313768060, - 1960071701057800, 1353971822643138 -#else - 66660290, 31776765, 13018550, 3194501, 57528444, 22392694, - 24760584, 29207344, 25577410, 20175752 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 319394212043702, 2127459436033571, 717646691535162, - 663366796076914, 318459064945314 -#else - 42818486, 4759344, 66418211, 31701615, 2066746, 10693769, - 37513074, 9884935, 57739938, 4745409 -#endif - }}, + {0x3a, 0x79, 0x1c, 0x3c, 0xcd, 0x1a, 0x36, 0xcf, 0x3b, 0xbc, 0x35, + 0x5a, 0xac, 0xbc, 0x9e, 0x2f, 0xab, 0xa6, 0xcd, 0xa8, 0xe9, 0x60, + 0xe8, 0x60, 0x13, 0x1a, 0xea, 0x6d, 0x9b, 0xc3, 0x5d, 0x5}, + {0xc2, 0x27, 0xf9, 0xf7, 0x7f, 0x93, 0xb7, 0x2d, 0x35, 0xa6, 0xd0, + 0x17, 0x6, 0x1f, 0x74, 0xdb, 0x76, 0xaf, 0x55, 0x11, 0xa2, 0xf3, + 0x82, 0x59, 0xed, 0x2d, 0x7c, 0x64, 0x18, 0xe2, 0xf6, 0x4c}, + {0xb6, 0x5b, 0x8d, 0xc2, 0x7c, 0x22, 0x19, 0xb1, 0xab, 0xff, 0x4d, + 0x77, 0xbc, 0x4e, 0xe2, 0x7, 0x89, 0x2c, 0xa3, 0xe4, 0xce, 0x78, + 0x3c, 0xa8, 0xb6, 0x24, 0xaa, 0x10, 0x77, 0x30, 0x1a, 0x12}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 405989424923593, 1960452633787083, 667349034401665, - 1492674260767112, 1451061489880787 -#else - 57967561, 6049713, 47577803, 29213020, 35848065, 9944275, - 51646856, 22242579, 10931923, 21622501 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 947085906234007, 323284730494107, 1485778563977200, - 728576821512394, 901584347702286 -#else - 50547351, 14112679, 59096219, 4817317, 59068400, 22139825, - 44255434, 10856640, 46638094, 13434653 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1575783124125742, 2126210792434375, 1569430791264065, - 1402582372904727, 1891780248341114 -#else - 22759470, 23480998, 50342599, 31683009, 13637441, 23386341, - 1765143, 20900106, 28445306, 28189722 -#endif - }}, + {0xc9, 0x83, 0x74, 0xc7, 0x3e, 0x71, 0x59, 0xd6, 0xaf, 0x96, 0x2b, + 0xb8, 0x77, 0xe0, 0xbf, 0x88, 0xd3, 0xbc, 0x97, 0x10, 0x23, 0x28, + 0x9e, 0x28, 0x9b, 0x3a, 0xed, 0x6c, 0x4a, 0xb9, 0x7b, 0x52}, + {0x97, 0x4a, 0x3, 0x9f, 0x5e, 0x5d, 0xdb, 0xe4, 0x2d, 0xbc, 0x34, + 0x30, 0x9, 0xfc, 0x53, 0xe1, 0xb1, 0xd3, 0x51, 0x95, 0x91, 0x46, + 0x5, 0x46, 0x2d, 0xe5, 0x40, 0x7a, 0x6c, 0xc7, 0x3f, 0x33}, + {0x2e, 0x48, 0x5b, 0x99, 0x2a, 0x99, 0x3d, 0x56, 0x1, 0x38, 0x38, + 0x6e, 0x7c, 0xd0, 0x5, 0x34, 0xe5, 0xd8, 0x64, 0x2f, 0xde, 0x35, + 0x50, 0x48, 0xf7, 0xa9, 0xa7, 0x20, 0x9b, 0x6, 0x89, 0x6b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 838432205560695, 1997703511451664, 1018791879907867, - 1662001808174331, 78328132957753 -#else - 29875063, 12493613, 2795536, 29768102, 1710619, 15181182, - 56913147, 24765756, 9074233, 1167180 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 739152638255629, 2074935399403557, 505483666745895, - 1611883356514088, 628654635394878 -#else - 40903181, 11014232, 57266213, 30918946, 40200743, 7532293, - 48391976, 24018933, 3843902, 9367684 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1822054032121349, 643057948186973, 7306757352712, - 577249257962099, 284735863382083 -#else - 56139269, 27150720, 9591133, 9582310, 11349256, 108879, - 16235123, 8601684, 66969667, 4242894 -#endif - }}, + {0x77, 0xdb, 0xc7, 0xb5, 0x8c, 0xfa, 0x82, 0x40, 0x55, 0xc1, 0x34, + 0xc7, 0xf8, 0x86, 0x86, 0x6, 0x7e, 0xa5, 0xe7, 0xf6, 0xd9, 0xc8, + 0xe6, 0x29, 0xcf, 0x9b, 0x63, 0xa7, 0x8, 0xd3, 0x73, 0x4}, + {0xd, 0x22, 0x70, 0x62, 0x41, 0xa0, 0x2a, 0x81, 0x4e, 0x5b, 0x24, + 0xf9, 0xfa, 0x89, 0x5a, 0x99, 0x5, 0xef, 0x72, 0x50, 0xce, 0xc4, + 0xad, 0xff, 0x73, 0xeb, 0x73, 0xaa, 0x3, 0x21, 0xbc, 0x23}, + {0x5, 0x9e, 0x58, 0x3, 0x26, 0x79, 0xee, 0xca, 0x92, 0xc4, 0xdc, + 0x46, 0x12, 0x42, 0x4b, 0x2b, 0x4f, 0xa9, 0x1, 0xe6, 0x74, 0xef, + 0xa1, 0x2, 0x1a, 0x34, 0x4, 0xde, 0xbf, 0x73, 0x2f, 0x10}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1366558556363930, 1448606567552086, 1478881020944768, - 165803179355898, 1115718458123498 -#else - 22092954, 20363309, 65066070, 21585919, 32186752, 22037044, - 60534522, 2470659, 39691498, 16625500 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 204146226972102, 1630511199034723, 2215235214174763, - 174665910283542, 956127674017216 -#else - 56051142, 3042015, 13770083, 24296510, 584235, 33009577, - 59338006, 2602724, 39757248, 14247412 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1562934578796716, 1070893489712745, 11324610642270, - 958989751581897, 2172552325473805 -#else - 6314156, 23289540, 34336361, 15957556, 56951134, 168749, - 58490057, 14290060, 27108877, 32373552 -#endif - }}, + {0x9a, 0x1c, 0x51, 0xb5, 0xe0, 0xda, 0xb4, 0xa2, 0x6, 0xff, 0xff, + 0x2b, 0x29, 0x60, 0xc8, 0x7a, 0x34, 0x42, 0x50, 0xf5, 0x5d, 0x37, + 0x1f, 0x98, 0x2d, 0xa1, 0x4e, 0xda, 0x25, 0xd7, 0x6b, 0x3f}, + {0xc6, 0x45, 0x57, 0x7f, 0xab, 0xb9, 0x18, 0xeb, 0x90, 0xc6, 0x87, + 0x57, 0xee, 0x8a, 0x3a, 0x2, 0xa9, 0xaf, 0xf7, 0x2d, 0xda, 0x12, + 0x27, 0xb7, 0x3d, 0x1, 0x5c, 0xea, 0x25, 0x7d, 0x59, 0x36}, + {0xac, 0x58, 0x60, 0x10, 0x7b, 0x8d, 0x4d, 0x73, 0x5f, 0x90, 0xc6, + 0x6f, 0x9e, 0x57, 0x40, 0xd9, 0x2d, 0x93, 0x2, 0x92, 0xf9, 0xf8, + 0x66, 0x64, 0xd0, 0xd6, 0x60, 0xda, 0x19, 0xcc, 0x7e, 0x7b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1770564423056027, 735523631664565, 1326060113795289, - 1509650369341127, 65892421582684 -#else - 58522267, 26383465, 13241781, 10960156, 34117849, 19759835, - 33547975, 22495543, 39960412, 981873 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 623682558650637, 1337866509471512, 990313350206649, - 1314236615762469, 1164772974270275 -#else - 22833421, 9293594, 34459416, 19935764, 57971897, 14756818, - 44180005, 19583651, 56629059, 17356469 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 223256821462517, 723690150104139, 1000261663630601, - 933280913953265, 254872671543046 -#else - 59340277, 3326785, 38997067, 10783823, 19178761, 14905060, - 22680049, 13906969, 51175174, 3797898 -#endif - }}, + {0x9b, 0xfa, 0x7c, 0xa7, 0x51, 0x4a, 0xae, 0x6d, 0x50, 0x86, 0xa3, + 0xe7, 0x54, 0x36, 0x26, 0x82, 0xdb, 0x82, 0x2d, 0x8f, 0xcd, 0xff, + 0xbb, 0x9, 0xba, 0xca, 0xf5, 0x1b, 0x66, 0xdc, 0xbe, 0x3}, + {0xd, 0x69, 0x5c, 0x69, 0x3c, 0x37, 0xc2, 0x78, 0x6e, 0x90, 0x42, + 0x6, 0x66, 0x2e, 0x25, 0xdd, 0xd2, 0x2b, 0xe1, 0x4a, 0x44, 0x44, + 0x1d, 0x95, 0x56, 0x39, 0x74, 0x1, 0x76, 0xad, 0x35, 0x42}, + {0xf5, 0x75, 0x89, 0x7, 0xd, 0xcb, 0x58, 0x62, 0x98, 0xf2, 0x89, + 0x91, 0x54, 0x42, 0x29, 0x49, 0xe4, 0x6e, 0xe3, 0xe2, 0x23, 0xb4, + 0xca, 0xa0, 0xa1, 0x66, 0xf0, 0xcd, 0xb0, 0xe2, 0x7c, 0xe}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1969087237026041, 624795725447124, 1335555107635969, - 2069986355593023, 1712100149341902 -#else - 21721337, 29341686, 54902740, 9310181, 63226625, 19901321, - 23740223, 30845200, 20491982, 25512280 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1236103475266979, 1837885883267218, 1026072585230455, - 1025865513954973, 1801964901432134 -#else - 9209251, 18419377, 53852306, 27386633, 66377847, 15289672, - 25947805, 15286587, 30997318, 26851369 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1115241013365517, 1712251818829143, 2148864332502771, - 2096001471438138, 2235017246626125 -#else - 7392013, 16618386, 23946583, 25514540, 53843699, 32020573, - 52911418, 31232855, 17649997, 33304352 -#endif - }}, + {0xf9, 0x70, 0x4b, 0xd9, 0xdf, 0xfe, 0xa6, 0xfe, 0x2d, 0xba, 0xfc, + 0xc1, 0x51, 0xc0, 0x30, 0xf1, 0x89, 0xab, 0x2f, 0x7f, 0x7e, 0xd4, + 0x82, 0x48, 0xb5, 0xee, 0xec, 0x8a, 0x13, 0x56, 0x52, 0x61}, + {0xa3, 0x85, 0x8c, 0xc4, 0x3a, 0x64, 0x94, 0xc4, 0xad, 0x39, 0x61, + 0x3c, 0xf4, 0x1d, 0x36, 0xfd, 0x48, 0x4d, 0xe9, 0x3a, 0xdd, 0x17, + 0xdb, 0x9, 0x4a, 0x67, 0xb4, 0x8f, 0x5d, 0xa, 0x6e, 0x66}, + {0xd, 0xcb, 0x70, 0x48, 0x4e, 0xf6, 0xbb, 0x2a, 0x6b, 0x8b, 0x45, + 0xaa, 0xf0, 0xbc, 0x65, 0xcd, 0x5d, 0x98, 0xe8, 0x75, 0xba, 0x4e, + 0xbe, 0x9a, 0xe4, 0xde, 0x14, 0xd5, 0x10, 0xc8, 0xb, 0x7f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1299268198601632, 2047148477845621, 2165648650132450, - 1612539282026145, 514197911628890 -#else - 57807776, 19360604, 30609525, 30504889, 41933794, 32270679, - 51867297, 24028707, 64875610, 7662145 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 118352772338543, 1067608711804704, 1434796676193498, - 1683240170548391, 230866769907437 -#else - 49550191, 1763593, 33994528, 15908609, 37067994, 21380136, - 7335079, 25082233, 63934189, 3440182 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1850689576796636, 1601590730430274, 1139674615958142, - 1954384401440257, 76039205311 -#else - 47219164, 27577423, 42997570, 23865561, 10799742, 16982475, - 40449, 29122597, 4862399, 1133 -#endif - }}, + {0xa0, 0x13, 0x72, 0x73, 0xad, 0x9d, 0xac, 0x83, 0x98, 0x2e, 0xf7, + 0x2e, 0xba, 0xf8, 0xf6, 0x9f, 0x57, 0x69, 0xec, 0x43, 0xdd, 0x2e, + 0x1e, 0x31, 0x75, 0xab, 0xc5, 0xde, 0x7d, 0x90, 0x3a, 0x1d}, + {0x6f, 0x13, 0xf4, 0x26, 0xa4, 0x6b, 0x0, 0xb9, 0x35, 0x30, 0xe0, + 0x57, 0x9e, 0x36, 0x67, 0x8d, 0x28, 0x3c, 0x46, 0x4f, 0xd9, 0xdf, + 0xc8, 0xcb, 0xf5, 0xdb, 0xee, 0xf8, 0xbc, 0x8d, 0x1f, 0xd}, + {0xdc, 0x81, 0xd0, 0x3e, 0x31, 0x93, 0x16, 0xba, 0x80, 0x34, 0x1b, + 0x85, 0xad, 0x9f, 0x32, 0x29, 0xcb, 0x21, 0x3, 0x3, 0x3c, 0x1, + 0x28, 0x1, 0xe3, 0xfd, 0x1b, 0xa3, 0x44, 0x1b, 0x1, 0x0}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1723387471374172, 997301467038410, 533927635123657, - 20928644693965, 1756575222802513 -#else - 34252636, 25680474, 61686474, 14860949, 50789833, 7956141, - 7258061, 311861, 36513873, 26175010 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2146711623855116, 503278928021499, 625853062251406, - 1109121378393107, 1033853809911861 -#else - 63335436, 31988495, 28985339, 7499440, 24445838, 9325937, - 29727763, 16527196, 18278453, 15405622 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 571005965509422, 2005213373292546, 1016697270349626, - 56607856974274, 914438579435146 -#else - 62726958, 8508651, 47210498, 29880007, 61124410, 15149969, - 53795266, 843522, 45233802, 13626196 -#endif - }}, + {0x5c, 0xa7, 0xa, 0x6a, 0x69, 0x1f, 0x56, 0x16, 0x6a, 0xbd, 0x52, + 0x58, 0x5c, 0x72, 0xbf, 0xc1, 0xad, 0x66, 0x79, 0x9a, 0x7f, 0xdd, + 0xa8, 0x11, 0x26, 0x10, 0x85, 0xd2, 0xa2, 0x88, 0xd9, 0x63}, + {0xc, 0x6c, 0xc6, 0x3f, 0x6c, 0xa0, 0xdf, 0x3f, 0xd2, 0xd, 0xd6, + 0x4d, 0x8e, 0xe3, 0x40, 0x5d, 0x71, 0x4d, 0x8e, 0x26, 0x38, 0x8b, + 0xe3, 0x7a, 0xe1, 0x57, 0x83, 0x6e, 0x91, 0x8d, 0xc4, 0x3a}, + {0x2e, 0x23, 0xbd, 0xaf, 0x53, 0x7, 0x12, 0x0, 0x83, 0xf6, 0xd8, + 0xfd, 0xb8, 0xce, 0x2b, 0xe9, 0x91, 0x2b, 0xe7, 0x84, 0xb3, 0x69, + 0x16, 0xf8, 0x66, 0xa0, 0x68, 0x23, 0x2b, 0xd5, 0xfa, 0x33}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1346698876211176, 2076651707527589, 1084761571110205, - 265334478828406, 1068954492309671 -#else - 2281448, 20067377, 56193445, 30944521, 1879357, 16164207, - 56324982, 3953791, 13340839, 15928663 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1769967932677654, 1695893319756416, 1151863389675920, - 1781042784397689, 400287774418285 -#else - 31727126, 26374577, 48671360, 25270779, 2875792, 17164102, - 41838969, 26539605, 43656557, 5964752 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1851867764003121, 403841933237558, 820549523771987, - 761292590207581, 1743735048551143 -#else - 4100401, 27594980, 49929526, 6017713, 48403027, 12227140, - 40424029, 11344143, 2538215, 25983677 -#endif - }}, + {0xe8, 0xcf, 0x22, 0xc4, 0xd0, 0xc8, 0x2c, 0x8d, 0xcb, 0x3a, 0xa1, + 0x5, 0x7b, 0x4f, 0x2b, 0x7, 0x6f, 0xa5, 0xf6, 0xec, 0xe6, 0xb6, + 0xfe, 0xa3, 0xe2, 0x71, 0xa, 0xb9, 0xcc, 0x55, 0xc3, 0x3c}, + {0x16, 0x1e, 0xe4, 0xc5, 0xc6, 0x49, 0x6, 0x54, 0x35, 0x77, 0x3f, + 0x33, 0x30, 0x64, 0xf8, 0xa, 0x46, 0xe7, 0x5, 0xf3, 0xd2, 0xfc, + 0xac, 0xb2, 0xa7, 0xdc, 0x56, 0xa2, 0x29, 0xf4, 0xc0, 0x16}, + {0x31, 0x91, 0x3e, 0x90, 0x43, 0x94, 0xb6, 0xe9, 0xce, 0x37, 0x56, + 0x7a, 0xcb, 0x94, 0xa4, 0xb8, 0x44, 0x92, 0xba, 0xba, 0xa4, 0xd1, + 0x7c, 0xc8, 0x68, 0x75, 0xae, 0x6b, 0x42, 0xaf, 0x1e, 0x63}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 410915148140008, 2107072311871739, 1004367461876503, - 99684895396761, 1180818713503224 -#else - 57675240, 6123112, 11159803, 31397824, 30016279, 14966241, - 46633881, 1485420, 66479608, 17595569 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 285945406881439, 648174397347453, 1098403762631981, - 1366547441102991, 1505876883139217 -#else - 40304287, 4260918, 11851389, 9658551, 35091757, 16367491, - 46903439, 20363143, 11659921, 22439314 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 672095903120153, 1675918957959872, 636236529315028, - 1569297300327696, 2164144194785875 -#else - 26180377, 10015009, 36264640, 24973138, 5418196, 9480663, - 2231568, 23384352, 33100371, 32248261 -#endif - }}, + {0xe8, 0xd, 0x70, 0xa3, 0xb9, 0x75, 0xd9, 0x47, 0x52, 0x5, 0xf8, + 0xe2, 0xfb, 0xc5, 0x80, 0x72, 0xe1, 0x5d, 0xe4, 0x32, 0x27, 0x8f, + 0x65, 0x53, 0xb5, 0x80, 0x5f, 0x66, 0x7f, 0x2c, 0x1f, 0x43}, + {0x9f, 0xfe, 0x66, 0xda, 0x10, 0x4, 0xe9, 0xb3, 0xa6, 0xe5, 0x16, + 0x6c, 0x52, 0x4b, 0xdd, 0x85, 0x83, 0xbf, 0xf9, 0x1e, 0x61, 0x97, + 0x3d, 0xbc, 0xb5, 0x19, 0xa9, 0x1e, 0x8b, 0x64, 0x99, 0x55}, + {0x19, 0x7b, 0x8f, 0x85, 0x44, 0x63, 0x2, 0xd6, 0x4a, 0x51, 0xea, + 0xa1, 0x2f, 0x35, 0xab, 0x14, 0xd7, 0xa9, 0x90, 0x20, 0x1a, 0x44, + 0x0, 0x89, 0x26, 0x3b, 0x25, 0x91, 0x5f, 0x71, 0x4, 0x7b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1902708175321798, 1035343530915438, 1178560808893263, - 301095684058146, 1280977479761118 -#else - 15121094, 28352561, 56718958, 15427820, 39598927, 17561924, - 21670946, 4486675, 61177054, 19088051 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1615357281742403, 404257611616381, 2160201349780978, - 1160947379188955, 1578038619549541 -#else - 16166467, 24070699, 56004733, 6023907, 35182066, 32189508, - 2340059, 17299464, 56373093, 23514607 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2013087639791217, 822734930507457, 1785668418619014, - 1668650702946164, 389450875221715 -#else - 28042865, 29997343, 54982337, 12259705, 63391366, 26608532, - 6766452, 24864833, 18036435, 5803270 -#endif - }}, + {0xc6, 0xba, 0xe6, 0xc4, 0x80, 0xc2, 0x76, 0xb3, 0xb, 0x9b, 0x1d, + 0x6d, 0xdd, 0xd3, 0xe, 0x97, 0x44, 0xf9, 0xb, 0x45, 0x58, 0x95, + 0x9a, 0xb0, 0x23, 0xe2, 0xcd, 0x57, 0xfa, 0xac, 0xd0, 0x48}, + {0x43, 0xae, 0xf6, 0xac, 0x28, 0xbd, 0xed, 0x83, 0xb4, 0x7a, 0x5c, + 0x7d, 0x8b, 0x7c, 0x35, 0x86, 0x44, 0x2c, 0xeb, 0xb7, 0x69, 0x47, + 0x40, 0xc0, 0x3f, 0x58, 0xf6, 0xc2, 0xf5, 0x7b, 0xb3, 0x59}, + {0x71, 0xe6, 0xab, 0x7d, 0xe4, 0x26, 0xf, 0xb6, 0x37, 0x3a, 0x2f, + 0x62, 0x97, 0xa1, 0xd1, 0xf1, 0x94, 0x3, 0x96, 0xe9, 0x7e, 0xce, + 0x8, 0x42, 0xdb, 0x3b, 0x6d, 0x33, 0x91, 0x41, 0x23, 0x16}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 453918449698368, 106406819929001, 2072540975937135, - 308588860670238, 1304394580755385 -#else - 66291264, 6763911, 11803561, 1585585, 10958447, 30883267, - 23855390, 4598332, 60949433, 19436993 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1295082798350326, 2091844511495996, 1851348972587817, - 3375039684596, 789440738712837 -#else - 36077558, 19298237, 17332028, 31170912, 31312681, 27587249, - 696308, 50292, 47013125, 11763583 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2083069137186154, 848523102004566, 993982213589257, - 1405313299916317, 1532824818698468 -#else - 66514282, 31040148, 34874710, 12643979, 12650761, 14811489, - 665117, 20940800, 47335652, 22840869 -#endif - }}, + {0x40, 0x86, 0xf3, 0x1f, 0xd6, 0x9c, 0x49, 0xdd, 0xa0, 0x25, 0x36, + 0x6, 0xc3, 0x9b, 0xcd, 0x29, 0xc3, 0x3d, 0xd7, 0x3d, 0x2, 0xd8, + 0xe2, 0x51, 0x31, 0x92, 0x3b, 0x20, 0x7a, 0x70, 0x25, 0x4a}, + {0xf6, 0x7f, 0x26, 0xf6, 0xde, 0x99, 0xe4, 0xb9, 0x43, 0x8, 0x2c, + 0x74, 0x7b, 0xca, 0x72, 0x77, 0xb1, 0xf2, 0xa4, 0xe9, 0x3f, 0x15, + 0xa0, 0x23, 0x6, 0x50, 0xd0, 0xd5, 0xec, 0xdf, 0xdf, 0x2c}, + {0x6a, 0xed, 0xf6, 0x53, 0x8a, 0x66, 0xb7, 0x2a, 0xa1, 0x70, 0xd1, + 0x1d, 0x58, 0x42, 0x42, 0x30, 0x61, 0x1, 0xe2, 0x3a, 0x4c, 0x14, + 0x0, 0x40, 0xfc, 0x49, 0x8e, 0x24, 0x6d, 0x89, 0x21, 0x57}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1495961298852430, 1397203457344779, 1774950217066942, - 139302743555696, 66603584342787 -#else - 30464590, 22291560, 62981387, 20819953, 19835326, 26448819, - 42712688, 2075772, 50088707, 992470 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1782411379088302, 1096724939964781, 27593390721418, - 542241850291353, 1540337798439873 -#else - 18357166, 26559999, 7766381, 16342475, 37783946, 411173, - 14578841, 8080033, 55534529, 22952821 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 693543956581437, 171507720360750, 1557908942697227, - 1074697073443438, 1104093109037196 -#else - 19598397, 10334610, 12555054, 2555664, 18821899, 23214652, - 21873262, 16014234, 26224780, 16452269 -#endif - }}, + {0x4e, 0xda, 0xd0, 0xa1, 0x91, 0x50, 0x5d, 0x28, 0x8, 0x3e, 0xfe, + 0xb5, 0xa7, 0x6f, 0xaa, 0x4b, 0xb3, 0x93, 0x93, 0xe1, 0x7c, 0x17, + 0xe5, 0x63, 0xfd, 0x30, 0xb0, 0xc4, 0xaf, 0x35, 0xc9, 0x3}, + {0xae, 0x1b, 0x18, 0xfd, 0x17, 0x55, 0x6e, 0xb, 0xb4, 0x63, 0xb9, + 0x2b, 0x9f, 0x62, 0x22, 0x90, 0x25, 0x46, 0x6, 0x32, 0xe9, 0xbc, + 0x9, 0x55, 0xda, 0x13, 0x3c, 0xf6, 0x74, 0xdd, 0x8e, 0x57}, + {0x3d, 0xc, 0x2b, 0x49, 0xc6, 0x76, 0x72, 0x99, 0xfc, 0x5, 0xe2, + 0xdf, 0xc4, 0xc2, 0xcc, 0x47, 0x3c, 0x3a, 0x62, 0xdd, 0x84, 0x9b, + 0xd2, 0xdc, 0xa2, 0xc7, 0x88, 0x2, 0x59, 0xab, 0xc2, 0x3e}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 345288228393419, 1099643569747172, 134881908403743, - 1740551994106740, 248212179299770 -#else - 36884939, 5145195, 5944548, 16385966, 3976735, 2009897, - 55731060, 25936245, 46575034, 3698649 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 231429562203065, 1526290236421172, 2021375064026423, - 1520954495658041, 806337791525116 -#else - 14187449, 3448569, 56472628, 22743496, 44444983, 30120835, - 7268409, 22663988, 27394300, 12015369 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1079623667189886, 872403650198613, 766894200588288, - 2163700860774109, 2023464507911816 -#else - 19695742, 16087646, 28032085, 12999827, 6817792, 11427614, - 20244189, 32241655, 53849736, 30151970 -#endif - }}, + {0xcb, 0xd1, 0x32, 0xae, 0x9, 0x3a, 0x21, 0xa7, 0xd5, 0xc2, 0xf5, + 0x40, 0xdf, 0x87, 0x2b, 0xf, 0x29, 0xab, 0x1e, 0xe8, 0xc6, 0xa4, + 0xae, 0xb, 0x5e, 0xac, 0xdb, 0x6a, 0x6c, 0xf6, 0x1b, 0xe}, + {0xb9, 0x7b, 0xd8, 0xe4, 0x7b, 0xd2, 0xa0, 0xa1, 0xed, 0x1a, 0x39, + 0x61, 0xeb, 0x4d, 0x8b, 0xa9, 0x83, 0x9b, 0xcb, 0x73, 0xd0, 0xdd, + 0xa0, 0x99, 0xce, 0xca, 0xf, 0x20, 0x5a, 0xc2, 0xd5, 0x2d}, + {0x7e, 0x88, 0x2c, 0x79, 0xe9, 0xd5, 0xab, 0xe2, 0x5d, 0x6d, 0x92, + 0xcb, 0x18, 0x0, 0x2, 0x1a, 0x1e, 0x5f, 0xae, 0xba, 0xcd, 0x69, + 0xba, 0xbf, 0x5f, 0x8f, 0xe8, 0x5a, 0xb3, 0x48, 0x5, 0x73}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 854645372543796, 1936406001954827, 151460662541253, - 825325739271555, 1554306377287556 -#else - 30860084, 12735208, 65220619, 28854697, 50133957, 2256939, - 58942851, 12298311, 58558340, 23160969 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1497138821904622, 1044820250515590, 1742593886423484, - 1237204112746837, 849047450816987 -#else - 61389038, 22309106, 65198214, 15569034, 26642876, 25966672, - 61319509, 18435777, 62132699, 12651792 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 667962773375330, 1897271816877105, 1399712621683474, - 1143302161683099, 2081798441209593 -#else - 64260450, 9953420, 11531313, 28271553, 26895122, 20857343, - 53990043, 17036529, 9768697, 31021214 -#endif - }}, + {0x34, 0xe3, 0xd6, 0xa1, 0x4b, 0x9, 0x5b, 0x80, 0x19, 0x3f, 0x35, + 0x9, 0x77, 0xf1, 0x3e, 0xbf, 0x2b, 0x70, 0x22, 0x6, 0xcb, 0x6, + 0x3f, 0x42, 0xdd, 0x45, 0x78, 0xd8, 0x77, 0x22, 0x5a, 0x58}, + {0xee, 0xb8, 0xa8, 0xcb, 0xa3, 0x51, 0x35, 0xc4, 0x16, 0x5f, 0x11, + 0xb2, 0x1d, 0x6f, 0xa2, 0x65, 0x50, 0x38, 0x8c, 0xab, 0x52, 0x4f, + 0xf, 0x76, 0xca, 0xb8, 0x1d, 0x41, 0x3b, 0x44, 0x43, 0x30}, + {0x62, 0x89, 0xd4, 0x33, 0x82, 0x5f, 0x8a, 0xa1, 0x7f, 0x25, 0x78, + 0xec, 0xb5, 0xc4, 0x98, 0x66, 0xff, 0x41, 0x3e, 0x37, 0xa5, 0x6f, + 0x8e, 0xa7, 0x1f, 0x98, 0xef, 0x50, 0x89, 0x27, 0x56, 0x76}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 127147851567005, 1936114012888110, 1704424366552046, - 856674880716312, 716603621335359 -#else - 42389405, 1894650, 66821166, 28850346, 15348718, 25397902, - 32767512, 12765450, 4940095, 10678226 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1072409664800960, 2146937497077528, 1508780108920651, - 935767602384853, 1112800433544068 -#else - 18860224, 15980149, 48121624, 31991861, 40875851, 22482575, - 59264981, 13944023, 42736516, 16582018 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 333549023751292, 280219272863308, 2104176666454852, - 1036466864875785, 536135186520207 -#else - 51604604, 4970267, 37215820, 4175592, 46115652, 31354675, - 55404809, 15444559, 56105103, 7989036 -#endif - }}, + {0x9d, 0xcf, 0x86, 0xea, 0xa3, 0x73, 0x70, 0xe1, 0xdc, 0x5f, 0x15, + 0x7, 0xb7, 0xfb, 0x8c, 0x3a, 0x8e, 0x8a, 0x83, 0x31, 0xfc, 0xe7, + 0x53, 0x48, 0x16, 0xf6, 0x13, 0xb6, 0x84, 0xf4, 0xbb, 0x28}, + {0xc0, 0xc8, 0x1f, 0xd5, 0x59, 0xcf, 0xc3, 0x38, 0xf2, 0xb6, 0x6, + 0x5, 0xfd, 0xd2, 0xed, 0x9b, 0x8f, 0xe, 0x57, 0xab, 0x9f, 0x10, + 0xbf, 0x26, 0xa6, 0x46, 0xb8, 0xc1, 0xa8, 0x60, 0x41, 0x3f}, + {0x7c, 0x6c, 0x13, 0x6f, 0x5c, 0x2f, 0x61, 0xf2, 0xbe, 0x11, 0xdd, + 0xf6, 0x7, 0xd1, 0xea, 0xaf, 0x33, 0x6f, 0xde, 0x13, 0xd2, 0x9a, + 0x7e, 0x52, 0x5d, 0xf7, 0x88, 0x81, 0x35, 0xcb, 0x79, 0x1e}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 373666279883137, 146457241530109, 304116267127857, - 416088749147715, 1258577131183391 -#else - 31490433, 5568061, 64696061, 2182382, 34772017, 4531685, - 35030595, 6200205, 47422751, 18754260 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1186115062588401, 2251609796968486, 1098944457878953, - 1153112761201374, 1791625503417267 -#else - 49800177, 17674491, 35586086, 33551600, 34221481, 16375548, - 8680158, 17182719, 28550067, 26697300 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1870078460219737, 2129630962183380, 852283639691142, - 292865602592851, 401904317342226 -#else - 38981977, 27866340, 16837844, 31733974, 60258182, 12700015, - 37068883, 4364037, 1155602, 5988841 -#endif - }}, + {0x81, 0x81, 0xe0, 0xf5, 0xd8, 0x53, 0xe9, 0x77, 0xd9, 0xde, 0x9d, + 0x29, 0x44, 0xc, 0xa5, 0x84, 0xe5, 0x25, 0x45, 0x86, 0xc, 0x2d, + 0x6c, 0xdc, 0xf4, 0xf2, 0xd1, 0x39, 0x2d, 0xb5, 0x8a, 0x47}, + {0xf1, 0xe3, 0xf7, 0xee, 0xc3, 0x36, 0x34, 0x1, 0xf8, 0x10, 0x9e, + 0xfe, 0x7f, 0x6a, 0x8b, 0x82, 0xfc, 0xde, 0xf9, 0xbc, 0xe5, 0x8, + 0xf9, 0x7f, 0x31, 0x38, 0x3b, 0x3a, 0x1b, 0x95, 0xd7, 0x65}, + {0x59, 0xd1, 0x52, 0x92, 0xd3, 0xa4, 0xa6, 0x66, 0x7, 0xc8, 0x1a, + 0x87, 0xbc, 0xe1, 0xdd, 0xe5, 0x6f, 0xc9, 0xc1, 0xa6, 0x40, 0x6b, + 0x2c, 0xb8, 0x14, 0x22, 0x21, 0x1a, 0x41, 0x7a, 0xd8, 0x16}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1361070124828035, 815664541425524, 1026798897364671, - 1951790935390647, 555874891834790 -#else - 21890435, 20281525, 54484852, 12154348, 59276991, 15300495, - 23148983, 29083951, 24618406, 8283181 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1546301003424277, 459094500062839, 1097668518375311, - 1780297770129643, 720763293687608 -#else - 33972757, 23041680, 9975415, 6841041, 35549071, 16356535, - 3070187, 26528504, 1466168, 10740210 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1212405311403990, 1536693382542438, 61028431067459, - 1863929423417129, 1223219538638038 -#else - 65599446, 18066246, 53605478, 22898515, 32799043, 909394, - 53169961, 27774712, 34944214, 18227391 -#endif - }}, + {0x83, 0x5, 0x4e, 0xd5, 0xe2, 0xd5, 0xa4, 0xfb, 0xfa, 0x99, 0xbd, + 0x2e, 0xd7, 0xaf, 0x1f, 0xe2, 0x8f, 0x77, 0xe9, 0x6e, 0x73, 0xc2, + 0x7a, 0x49, 0xde, 0x6d, 0x5a, 0x7a, 0x57, 0xb, 0x99, 0x1f}, + {0x15, 0x62, 0x6, 0x42, 0x5a, 0x7e, 0xbd, 0xb3, 0xc1, 0x24, 0x5a, + 0xc, 0xcd, 0xe3, 0x9b, 0x87, 0xb7, 0x94, 0xf9, 0xd6, 0xb1, 0x5d, + 0xc0, 0x57, 0xa6, 0x8c, 0xf3, 0x65, 0x81, 0x7c, 0xf8, 0x28}, + {0xd6, 0xf7, 0xe8, 0x1b, 0xad, 0x4e, 0x34, 0xa3, 0x8f, 0x79, 0xea, + 0xac, 0xeb, 0x50, 0x1e, 0x7d, 0x52, 0xe0, 0xd, 0x52, 0x9e, 0x56, + 0xc6, 0x77, 0x3e, 0x6d, 0x4d, 0x53, 0xe1, 0x2f, 0x88, 0x45}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1294303766540260, 1183557465955093, 882271357233093, - 63854569425375, 2213283684565087 -#else - 3960804, 19286629, 39082773, 17636380, 47704005, 13146867, - 15567327, 951507, 63848543, 32980496 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 339050984211414, 601386726509773, 413735232134068, - 966191255137228, 1839475899458159 -#else - 24740822, 5052253, 37014733, 8961360, 25877428, 6165135, - 42740684, 14397371, 59728495, 27410326 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 235605972169408, 2174055643032978, 1538335001838863, - 1281866796917192, 1815940222628465 -#else - 38220480, 3510802, 39005586, 32395953, 55870735, 22922977, - 51667400, 19101303, 65483377, 27059617 -#endif - }}, + {0xe4, 0x6f, 0x3c, 0x94, 0x29, 0x99, 0xac, 0xd8, 0xa2, 0x92, 0x83, + 0xa3, 0x61, 0xf1, 0xf9, 0xb5, 0xf3, 0x9a, 0xc8, 0xbe, 0x13, 0xdb, + 0x99, 0x26, 0x74, 0xf0, 0x5, 0xe4, 0x3c, 0x84, 0xcf, 0x7d}, + {0xd6, 0x83, 0x79, 0x75, 0x5d, 0x34, 0x69, 0x66, 0xa6, 0x11, 0xaa, + 0x17, 0x11, 0xed, 0xb6, 0x62, 0x8f, 0x12, 0x5e, 0x98, 0x57, 0x18, + 0xdd, 0x7d, 0xdd, 0xf6, 0x26, 0xf6, 0xb8, 0xe5, 0x8f, 0x68}, + {0xc0, 0x32, 0x47, 0x4a, 0x48, 0xd6, 0x90, 0x6c, 0x99, 0x32, 0x56, + 0xca, 0xfd, 0x43, 0x21, 0xd5, 0xe1, 0xc6, 0x5d, 0x91, 0xc3, 0x28, + 0xbe, 0xb3, 0x1b, 0x19, 0x27, 0x73, 0x7e, 0x68, 0x39, 0x67}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1632352921721536, 1833328609514701, 2092779091951987, - 1923956201873226, 2210068022482919 -#else - 793280, 24323954, 8836301, 27318725, 39747955, 31184838, - 33152842, 28669181, 57202663, 32932579 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 35271216625062, 1712350667021807, 983664255668860, - 98571260373038, 1232645608559836 -#else - 5666214, 525582, 20782575, 25516013, 42570364, 14657739, - 16099374, 1468826, 60937436, 18367850 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1998172393429622, 1798947921427073, 784387737563581, - 1589352214827263, 1589861734168180 -#else - 62249590, 29775088, 64191105, 26806412, 7778749, 11688288, - 36704511, 23683193, 65549940, 23690785 -#endif - }}, + {0xc0, 0x1a, 0xc, 0xc8, 0x9d, 0xcc, 0x6d, 0xa6, 0x36, 0xa4, 0x38, + 0x1b, 0xf4, 0x5c, 0xa0, 0x97, 0xc6, 0xd7, 0xdb, 0x95, 0xbe, 0xf3, + 0xeb, 0xa7, 0xab, 0x7d, 0x7e, 0x8d, 0xf6, 0xb8, 0xa0, 0x7d}, + {0xa6, 0x75, 0x56, 0x38, 0x14, 0x20, 0x78, 0xef, 0xe8, 0xa9, 0xfd, + 0xaa, 0x30, 0x9f, 0x64, 0xa2, 0xcb, 0xa8, 0xdf, 0x5c, 0x50, 0xeb, + 0xd1, 0x4c, 0xb3, 0xc0, 0x4d, 0x1d, 0xba, 0x5a, 0x11, 0x46}, + {0x76, 0xda, 0xb5, 0xc3, 0x53, 0x19, 0xf, 0xd4, 0x9b, 0x9e, 0x11, + 0x21, 0x73, 0x6f, 0xac, 0x1d, 0x60, 0x59, 0xb2, 0xfe, 0x21, 0x60, + 0xcc, 0x3, 0x4b, 0x4b, 0x67, 0x83, 0x7e, 0x88, 0x5f, 0x5a}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1733739258725305, 31715717059538, 201969945218860, - 992093044556990, 1194308773174556 -#else - 10896313, 25834728, 824274, 472601, 47648556, 3009586, 25248958, - 14783338, 36527388, 17796587 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 846415389605137, 746163495539180, 829658752826080, - 592067705956946, 957242537821393 -#else - 10566929, 12612572, 35164652, 11118702, 54475488, 12362878, - 21752402, 8822496, 24003793, 14264025 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1758148849754419, 619249044817679, 168089007997045, - 1371497636330523, 1867101418880350 -#else - 27713843, 26198459, 56100623, 9227529, 27050101, 2504721, - 23886875, 20436907, 13958494, 27821979 -#endif - }}, + {0xb9, 0x43, 0xa6, 0xa0, 0xd3, 0x28, 0x96, 0x9e, 0x64, 0x20, 0xc3, + 0xe6, 0x0, 0xcb, 0xc3, 0xb5, 0x32, 0xec, 0x2d, 0x7c, 0x89, 0x2, + 0x53, 0x9b, 0xc, 0xc7, 0xd1, 0xd5, 0xe2, 0x7a, 0xe3, 0x43}, + {0x11, 0x3d, 0xa1, 0x70, 0xcf, 0x1, 0x63, 0x8f, 0xc4, 0xd0, 0xd, + 0x35, 0x15, 0xb8, 0xce, 0xcf, 0x7e, 0xa4, 0xbc, 0xa4, 0xd4, 0x97, + 0x2, 0xf7, 0x34, 0x14, 0x4d, 0xe4, 0x56, 0xb6, 0x69, 0x36}, + {0x33, 0xe1, 0xa6, 0xed, 0x6, 0x3f, 0x7e, 0x38, 0xc0, 0x3a, 0xa1, + 0x99, 0x51, 0x1d, 0x30, 0x67, 0x11, 0x38, 0x26, 0x36, 0xf8, 0xd8, + 0x5a, 0xbd, 0xbe, 0xe9, 0xd5, 0x4f, 0xcd, 0xe6, 0x21, 0x6a}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 326633984209635, 261759506071016, 1700682323676193, - 1577907266349064, 1217647663383016 -#else - 43627235, 4867225, 39861736, 3900520, 29838369, 25342141, - 35219464, 23512650, 7340520, 18144364 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1714182387328607, 1477856482074168, 574895689942184, - 2159118410227270, 1555532449716575 -#else - 4646495, 25543308, 44342840, 22021777, 23184552, 8566613, - 31366726, 32173371, 52042079, 23179239 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 853828206885131, 998498946036955, 1835887550391235, - 207627336608048, 258363815956050 -#else - 49838347, 12723031, 50115803, 14878793, 21619651, 27356856, - 27584816, 3093888, 58265170, 3849920 -#endif - }}, + {0xe3, 0xb2, 0x99, 0x66, 0x12, 0x29, 0x41, 0xef, 0x1, 0x13, 0x8d, + 0x70, 0x47, 0x8, 0xd3, 0x71, 0xbd, 0xb0, 0x82, 0x11, 0xd0, 0x32, + 0x54, 0x32, 0x36, 0x8b, 0x1e, 0x0, 0x7, 0x1b, 0x37, 0x45}, + {0x5f, 0xe6, 0x46, 0x30, 0xa, 0x17, 0xc6, 0xf1, 0x24, 0x35, 0xd2, + 0x0, 0x2a, 0x2a, 0x71, 0x58, 0x55, 0xb7, 0x82, 0x8c, 0x3c, 0xbd, + 0xdb, 0x69, 0x57, 0xff, 0x95, 0xa1, 0xf1, 0xf9, 0x6b, 0x58}, + {0xb, 0x79, 0xf8, 0x5e, 0x8d, 0x8, 0xdb, 0xa6, 0xe5, 0x37, 0x9, + 0x61, 0xdc, 0xf0, 0x78, 0x52, 0xb8, 0x6e, 0xa1, 0x61, 0xd2, 0x49, + 0x3, 0xac, 0x79, 0x21, 0xe5, 0x90, 0x37, 0xb0, 0xaf, 0xe}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 141141474651677, 1236728744905256, 643101419899887, - 1646615130509173, 1208239602291765 -#else - 58043933, 2103171, 25561640, 18428694, 61869039, 9582957, - 32477045, 24536477, 5002293, 18004173 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1501663228068911, 1354879465566912, 1444432675498247, - 897812463852601, 855062598754348 -#else - 55051311, 22376525, 21115584, 20189277, 8808711, 21523724, - 16489529, 13378448, 41263148, 12741425 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 714380763546606, 1032824444965790, 1774073483745338, - 1063840874947367, 1738680636537158 -#else - 61162478, 10645102, 36197278, 15390283, 63821882, 26435754, - 24306471, 15852464, 28834118, 25908360 -#endif - }}, + {0x1d, 0xae, 0x75, 0xf, 0x5e, 0x80, 0x40, 0x51, 0x30, 0xcc, 0x62, + 0x26, 0xe3, 0xfb, 0x2, 0xec, 0x6d, 0x39, 0x92, 0xea, 0x1e, 0xdf, + 0xeb, 0x2c, 0xb3, 0x5b, 0x43, 0xc5, 0x44, 0x33, 0xae, 0x44}, + {0x2f, 0x4, 0x48, 0x37, 0xc1, 0x55, 0x5, 0x96, 0x11, 0xaa, 0xb, + 0x82, 0xe6, 0x41, 0x9a, 0x21, 0xc, 0x6d, 0x48, 0x73, 0x38, 0xf7, + 0x81, 0x1c, 0x61, 0xc6, 0x2, 0x5a, 0x67, 0xcc, 0x9a, 0x30}, + {0xee, 0x43, 0xa5, 0xbb, 0xb9, 0x89, 0xf2, 0x9c, 0x42, 0x71, 0xc9, + 0x5a, 0x9d, 0xe, 0x76, 0xf3, 0xaa, 0x60, 0x93, 0x4f, 0xc6, 0xe5, + 0x82, 0x1d, 0x8f, 0x67, 0x94, 0x7f, 0x1b, 0x22, 0xd5, 0x62}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1640635546696252, 633168953192112, 2212651044092396, - 30590958583852, 368515260889378 -#else - 49773116, 24447374, 42577584, 9434952, 58636780, 32971069, - 54018092, 455840, 20461858, 5491305 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1171650314802029, 1567085444565577, 1453660792008405, - 757914533009261, 1619511342778196 -#else - 13669229, 17458950, 54626889, 23351392, 52539093, 21661233, - 42112877, 11293806, 38520660, 24132599 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 420958967093237, 971103481109486, 2169549185607107, - 1301191633558497, 1661514101014240 -#else - 28497909, 6272777, 34085870, 14470569, 8906179, 32328802, - 18504673, 19389266, 29867744, 24758489 -#endif - }}, + {0x3c, 0x7a, 0xf7, 0x3a, 0x26, 0xd4, 0x85, 0x75, 0x4d, 0x14, 0xe9, + 0xfe, 0x11, 0x7b, 0xae, 0xdf, 0x3d, 0x19, 0xf7, 0x59, 0x80, 0x70, + 0x6, 0xa5, 0x37, 0x20, 0x92, 0x83, 0x53, 0x9a, 0xf2, 0x14}, + {0x6d, 0x93, 0xd0, 0x18, 0x9c, 0x29, 0x4c, 0x52, 0xc, 0x1a, 0xc, + 0x8a, 0x6c, 0xb5, 0x6b, 0xc8, 0x31, 0x86, 0x4a, 0xdb, 0x2e, 0x5, + 0x75, 0xa3, 0x62, 0x45, 0x75, 0xbc, 0xe4, 0xfd, 0xe, 0x5c}, + {0xf5, 0xd7, 0xb2, 0x25, 0xdc, 0x7e, 0x71, 0xdf, 0x40, 0x30, 0xb5, + 0x99, 0xdb, 0x70, 0xf9, 0x21, 0x62, 0x4c, 0xed, 0xc3, 0xb7, 0x34, + 0x92, 0xda, 0x3e, 0x9, 0xee, 0x7b, 0x5c, 0x36, 0x72, 0x5e}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 907123651818302, 1332556122804146, 1824055253424487, - 1367614217442959, 1982558335973172 -#else - 50901822, 13517195, 39309234, 19856633, 24009063, 27180541, - 60741263, 20379039, 22853428, 29542421 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1121533090144639, 1021251337022187, 110469995947421, - 1511059774758394, 2110035908131662 -#else - 24191359, 16712145, 53177067, 15217830, 14542237, 1646131, - 18603514, 22516545, 12876622, 31441985 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 303213233384524, 2061932261128138, 352862124777736, - 40828818670255, 249879468482660 -#else - 17902668, 4518229, 66697162, 30725184, 26878216, 5258055, - 54248111, 608396, 16031844, 3723494 -#endif - }}, + {0x3e, 0xb3, 0x8, 0x2f, 0x6, 0x39, 0x93, 0x7d, 0xbe, 0x32, 0x9f, + 0xdf, 0xe5, 0x59, 0x96, 0x5b, 0xfd, 0xbd, 0x9e, 0x1f, 0xad, 0x3d, + 0xff, 0xac, 0xb7, 0x49, 0x73, 0xcb, 0x55, 0x5, 0xb2, 0x70}, + {0x7f, 0x21, 0x71, 0x45, 0x7, 0xfc, 0x5b, 0x57, 0x5b, 0xd9, 0x94, + 0x6, 0x5d, 0x67, 0x79, 0x37, 0x33, 0x1e, 0x19, 0xf4, 0xbb, 0x37, + 0xa, 0x9a, 0xbc, 0xea, 0xb4, 0x47, 0x4c, 0x10, 0xf1, 0x77}, + {0x4c, 0x2c, 0x11, 0x55, 0xc5, 0x13, 0x51, 0xbe, 0xcd, 0x1f, 0x88, + 0x9a, 0x3a, 0x42, 0x88, 0x66, 0x47, 0x3b, 0x50, 0x5e, 0x85, 0x77, + 0x66, 0x44, 0x4a, 0x40, 0x6, 0x4a, 0x8f, 0x39, 0x34, 0xe}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 856559257852200, 508517664949010, 1378193767894916, - 1723459126947129, 1962275756614521 -#else - 38476072, 12763727, 46662418, 7577503, 33001348, 20536687, - 17558841, 25681542, 23896953, 29240187 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1445691340537320, 40614383122127, 402104303144865, - 485134269878232, 1659439323587426 -#else - 47103464, 21542479, 31520463, 605201, 2543521, 5991821, - 64163800, 7229063, 57189218, 24727572 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 20057458979482, 1183363722525800, 2140003847237215, - 2053873950687614, 2112017736174909 -#else - 28816026, 298879, 38943848, 17633493, 19000927, 31888542, - 54428030, 30605106, 49057085, 31471516 -#endif - }}, + {0x28, 0x19, 0x4b, 0x3e, 0x9, 0xb, 0x93, 0x18, 0x40, 0xf6, 0xf3, + 0x73, 0xe, 0xe1, 0xe3, 0x7d, 0x6f, 0x5d, 0x39, 0x73, 0xda, 0x17, + 0x32, 0xf4, 0x3e, 0x9c, 0x37, 0xca, 0xd6, 0xde, 0x8a, 0x6f}, + {0xe8, 0xbd, 0xce, 0x3e, 0xd9, 0x22, 0x7d, 0xb6, 0x7, 0x2f, 0x82, + 0x27, 0x41, 0xe8, 0xb3, 0x9, 0x8d, 0x6d, 0x5b, 0xb0, 0x1f, 0xa6, + 0x3f, 0x74, 0x72, 0x23, 0x36, 0x8a, 0x36, 0x5, 0x54, 0x5e}, + {0x9a, 0xb2, 0xb7, 0xfd, 0x3d, 0x12, 0x40, 0xe3, 0x91, 0xb2, 0x1a, + 0xa2, 0xe1, 0x97, 0x7b, 0x48, 0x9e, 0x94, 0xe6, 0xfd, 0x2, 0x7d, + 0x96, 0xf9, 0x97, 0xde, 0xd3, 0xc8, 0x2e, 0xe7, 0xd, 0x78}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2228654250927986, 1483591363415267, 1368661293910956, - 1076511285177291, 526650682059608 -#else - 16000882, 33209536, 3493091, 22107234, 37604268, 20394642, - 12577739, 16041268, 47393624, 7847706 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 709481497028540, 531682216165724, 316963769431931, - 1814315888453765, 258560242424104 -#else - 10151868, 10572098, 27312476, 7922682, 14825339, 4723128, - 34252933, 27035413, 57088296, 3852847 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1053447823660455, 1955135194248683, 1010900954918985, - 1182614026976701, 1240051576966610 -#else - 55678375, 15697595, 45987307, 29133784, 5386313, 15063598, - 16514493, 17622322, 29330898, 18478208 -#endif - }}, + {0x72, 0x27, 0xf4, 0x0, 0xf3, 0xea, 0x1f, 0x67, 0xaa, 0x41, 0x8c, + 0x2a, 0x2a, 0xeb, 0x72, 0x8f, 0x92, 0x32, 0x37, 0x97, 0xd7, 0x7f, + 0xa1, 0x29, 0xa6, 0x87, 0xb5, 0x32, 0xad, 0xc6, 0xef, 0x1d}, + {0xbc, 0xe7, 0x9a, 0x8, 0x45, 0x85, 0xe2, 0xa, 0x6, 0x4d, 0x7f, + 0x1c, 0xcf, 0xde, 0x8d, 0x38, 0xb8, 0x11, 0x48, 0xa, 0x51, 0x15, + 0xac, 0x38, 0xe4, 0x8c, 0x92, 0x71, 0xf6, 0x8b, 0xb2, 0xe}, + {0xa7, 0x95, 0x51, 0xef, 0x1a, 0xbe, 0x5b, 0xaf, 0xed, 0x15, 0x7b, + 0x91, 0x77, 0x12, 0x8c, 0x14, 0x2e, 0xda, 0xe5, 0x7a, 0xfb, 0xf7, + 0x91, 0x29, 0x67, 0x28, 0xdd, 0xf8, 0x1b, 0x20, 0x7d, 0x46}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1957943897155497, 1788667368028035, 137692910029106, - 1039519607062, 826404763313028 -#else - 41609129, 29175637, 51885955, 26653220, 16615730, 2051784, - 3303702, 15490, 39560068, 12314390 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1848942433095597, 1582009882530495, 1849292741020143, - 1068498323302788, 2001402229799484 -#else - 15683501, 27551389, 18109119, 23573784, 15337967, 27556609, - 50391428, 15921865, 16103996, 29823217 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1528282417624269, 2142492439828191, 2179662545816034, - 362568973150328, 1591374675250271 -#else - 43939021, 22773182, 13588191, 31925625, 63310306, 32479502, - 47835256, 5402698, 37293151, 23713330 -#endif - }}, + {0xa9, 0xe7, 0x7a, 0x56, 0xbd, 0xf4, 0x1e, 0xbc, 0xbd, 0x98, 0x44, + 0xd6, 0xb2, 0x4c, 0x62, 0x3f, 0xc8, 0x4e, 0x1f, 0x2c, 0xd2, 0x64, + 0x10, 0xe4, 0x1, 0x40, 0x38, 0xba, 0xa5, 0xc5, 0xf9, 0x2e}, + {0xad, 0x4f, 0xef, 0x74, 0x9a, 0x91, 0xfe, 0x95, 0xa2, 0x8, 0xa3, + 0xf6, 0xec, 0x7b, 0x82, 0x3a, 0x1, 0x7b, 0xa4, 0x9, 0xd3, 0x1, + 0x4e, 0x96, 0x97, 0xc7, 0xa3, 0x5b, 0x4f, 0x3c, 0xc4, 0x71}, + {0xcd, 0x74, 0x9e, 0xfa, 0xf6, 0x6d, 0xfd, 0xb6, 0x7a, 0x26, 0xaf, + 0xe4, 0xbc, 0x78, 0x82, 0xf1, 0xe, 0x99, 0xef, 0xf1, 0xd0, 0xb3, + 0x55, 0x82, 0x93, 0xf2, 0xc5, 0x90, 0xa3, 0x8c, 0x75, 0x5a}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 160026679434388, 232341189218716, 2149181472355545, - 598041771119831, 183859001910173 -#else - 23190676, 2384583, 34394524, 3462153, 37205209, 32025299, - 55842007, 8911516, 41903005, 2739712 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2013278155187349, 662660471354454, 793981225706267, - 411706605985744, 804490933124791 -#else - 21374101, 30000182, 33584214, 9874410, 15377179, 11831242, - 33578960, 6134906, 4931255, 11987849 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2051892037280204, 488391251096321, 2230187337030708, - 930221970662692, 679002758255210 -#else - 67101132, 30575573, 50885377, 7277596, 105524, 33232381, - 35628324, 13861387, 37032554, 10117929 -#endif - }}, + {0x94, 0xdc, 0x61, 0x1d, 0x8b, 0x91, 0xe0, 0x8c, 0x66, 0x30, 0x81, + 0x9a, 0x46, 0x36, 0xed, 0x8d, 0xd3, 0xaa, 0xe8, 0xaf, 0x29, 0xa8, + 0xe6, 0xd4, 0x3f, 0xd4, 0x39, 0xf6, 0x27, 0x80, 0x73, 0xa}, + {0x95, 0x24, 0x46, 0xd9, 0x10, 0x27, 0xb7, 0xa2, 0x3, 0x50, 0x7d, + 0xd5, 0xd2, 0xc6, 0xa8, 0x3a, 0xca, 0x87, 0xb4, 0xa0, 0xbf, 0x0, + 0xd4, 0xe3, 0xec, 0x72, 0xeb, 0xb3, 0x44, 0xe2, 0xba, 0x2d}, + {0xcc, 0xe1, 0xff, 0x57, 0x2f, 0x4a, 0xf, 0x98, 0x43, 0x98, 0x83, + 0xe1, 0xd, 0xd, 0x67, 0x0, 0xfd, 0x15, 0xfb, 0x49, 0x4a, 0x3f, + 0x5c, 0x10, 0x9c, 0xa6, 0x26, 0x51, 0x63, 0xca, 0x98, 0x26}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1530723630438670, 875873929577927, 341560134269988, - 449903119530753, 1055551308214179 -#else - 37607694, 22809559, 40945095, 13051538, 41483300, 5089642, - 60783361, 6704078, 12890019, 15728940 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1461835919309432, 1955256480136428, 180866187813063, - 1551979252664528, 557743861963950 -#else - 45136504, 21783052, 66157804, 29135591, 14704839, 2695116, - 903376, 23126293, 12885166, 8311031 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 359179641731115, 1324915145732949, 902828372691474, - 294254275669987, 1887036027752957 -#else - 49592363, 5352193, 10384213, 19742774, 7506450, 13453191, - 26423267, 4384730, 1888765, 28119028 -#endif - }}, + {0xe, 0xd9, 0x3d, 0x5e, 0x2f, 0x70, 0x3d, 0x2e, 0x86, 0x53, 0xd2, + 0xe4, 0x18, 0x9, 0x3f, 0x9e, 0x6a, 0xa9, 0x4d, 0x2, 0xf6, 0x3e, + 0x77, 0x5e, 0x32, 0x33, 0xfa, 0x4a, 0xc, 0x4b, 0x0, 0x3c}, + {0x78, 0xba, 0xb0, 0x32, 0x88, 0x31, 0x65, 0xe7, 0x8b, 0xff, 0x5c, + 0x92, 0xf7, 0x31, 0x18, 0x38, 0xcc, 0x1f, 0x29, 0xa0, 0x91, 0x1b, + 0xa8, 0x8, 0x7, 0xeb, 0xca, 0x49, 0xcc, 0x3d, 0xb4, 0x1f}, + {0x2b, 0xb8, 0xf4, 0x6, 0xac, 0x46, 0xa9, 0x9a, 0xf3, 0xc4, 0x6, + 0xa8, 0xa5, 0x84, 0xa2, 0x1c, 0x87, 0x47, 0xcd, 0xc6, 0x5f, 0x26, + 0xd3, 0x3e, 0x17, 0xd2, 0x1f, 0xcd, 0x1, 0xfd, 0x43, 0x6b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2043271609454323, 2038225437857464, 1317528426475850, - 1398989128982787, 2027639881006861 -#else - 41291507, 30447119, 53614264, 30371925, 30896458, 19632703, - 34857219, 20846562, 47644429, 30214188 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2072902725256516, 312132452743412, 309930885642209, - 996244312618453, 1590501300352303 -#else - 43500868, 30888657, 66582772, 4651135, 5765089, 4618330, - 6092245, 14845197, 17151279, 23700316 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1397254305160710, 695734355138021, 2233992044438756, - 1776180593969996, 1085588199351115 -#else - 42278406, 20820711, 51942885, 10367249, 37577956, 33289075, - 22825804, 26467153, 50242379, 16176524 -#endif - }}, + {0xf3, 0xe, 0x76, 0x3e, 0x58, 0x42, 0xc7, 0xb5, 0x90, 0xb9, 0xa, + 0xee, 0xb9, 0x52, 0xdc, 0x75, 0x3f, 0x92, 0x2b, 0x7, 0xc2, 0x27, + 0x14, 0xbf, 0xf0, 0xd9, 0xf0, 0x6f, 0x2d, 0xb, 0x42, 0x73}, + {0x44, 0xc5, 0x97, 0x46, 0x4b, 0x5d, 0xa7, 0xc7, 0xbf, 0xff, 0xf, + 0xdf, 0x48, 0xf8, 0xfd, 0x15, 0x5a, 0x78, 0x46, 0xaa, 0xeb, 0xb9, + 0x68, 0x28, 0x14, 0xf7, 0x52, 0x5b, 0x10, 0xd7, 0x68, 0x5a}, + {0x6, 0x1e, 0x85, 0x9e, 0xcb, 0xf6, 0x2c, 0xaf, 0xc4, 0x38, 0x22, + 0xc6, 0x13, 0x39, 0x59, 0x8f, 0x73, 0xf3, 0xfb, 0x99, 0x96, 0xb8, + 0x8a, 0xda, 0x9e, 0xbc, 0x34, 0xea, 0x2f, 0x63, 0xb5, 0x3d}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 440567051331029, 254894786356681, 493869224930222, - 1556322069683366, 1567456540319218 -#else - 43525589, 6564960, 20063689, 3798228, 62368686, 7359224, - 2006182, 23191006, 38362610, 23356922 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1950722461391320, 1907845598854797, 1822757481635527, - 2121567704750244, 73811931471221 -#else - 56482264, 29068029, 53788301, 28429114, 3432135, 27161203, - 23632036, 31613822, 32808309, 1099883 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 387139307395758, 2058036430315676, 1220915649965325, - 1794832055328951, 1230009312169328 -#else - 15030958, 5768825, 39657628, 30667132, 60681485, 18193060, - 51830967, 26745081, 2051440, 18328567 -#endif - }}, + {0xd5, 0x25, 0x98, 0x82, 0xb1, 0x90, 0x49, 0x2e, 0x91, 0x89, 0x9a, + 0x3e, 0x87, 0xeb, 0xea, 0xed, 0xf8, 0x4a, 0x70, 0x4c, 0x39, 0x3d, + 0xf0, 0xee, 0xe, 0x2b, 0xdf, 0x95, 0xa4, 0x7e, 0x19, 0x59}, + {0xd8, 0xd9, 0x5d, 0xf7, 0x2b, 0xee, 0x6e, 0xf4, 0xa5, 0x59, 0x67, + 0x39, 0xf6, 0xb1, 0x17, 0xd, 0x73, 0x72, 0x9e, 0x49, 0x31, 0xd1, + 0xf2, 0x1b, 0x13, 0x5f, 0xd7, 0x49, 0xdf, 0x1a, 0x32, 0x4}, + {0xae, 0x5a, 0xe5, 0xe4, 0x19, 0x60, 0xe1, 0x4, 0xe9, 0x92, 0x2f, + 0x7e, 0x7a, 0x43, 0x7b, 0xe7, 0xa4, 0x9a, 0x15, 0x6f, 0xc1, 0x2d, + 0xce, 0xc7, 0xc0, 0xc, 0xd7, 0xf4, 0xc1, 0xfd, 0xea, 0x45}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1765973779329517, 659344059446977, 19821901606666, - 1301928341311214, 1116266004075885 -#else - 63746541, 26315059, 7517889, 9824992, 23555850, 295369, 5148398, - 19400244, 44422509, 16633659 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1127572801181483, 1224743760571696, 1276219889847274, - 1529738721702581, 1589819666871853 -#else - 4577067, 16802144, 13249840, 18250104, 19958762, 19017158, - 18559669, 22794883, 8402477, 23690159 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2181229378964934, 2190885205260020, 1511536077659137, - 1246504208580490, 668883326494241 -#else - 38702534, 32502850, 40318708, 32646733, 49896449, 22523642, - 9453450, 18574360, 17983009, 9967138 -#endif - }}, + {0xed, 0xb1, 0xcc, 0xcf, 0x24, 0x46, 0xe, 0xb6, 0x95, 0x3, 0x5c, + 0xbd, 0x92, 0xc2, 0xdb, 0x59, 0xc9, 0x81, 0x4, 0xdc, 0x1d, 0x9d, + 0xa0, 0x31, 0x40, 0xd9, 0x56, 0x5d, 0xea, 0xce, 0x73, 0x3f}, + {0x2b, 0xd7, 0x45, 0x80, 0x85, 0x1, 0x84, 0x69, 0x51, 0x6, 0x2f, + 0xcf, 0xa2, 0xfa, 0x22, 0x4c, 0xc6, 0x2d, 0x22, 0x6b, 0x65, 0x36, + 0x1a, 0x94, 0xde, 0xda, 0x62, 0x3, 0xc8, 0xeb, 0x5e, 0x5a}, + {0xc6, 0x8d, 0x4e, 0xa, 0xd1, 0xbf, 0xa7, 0xb7, 0x39, 0xb3, 0xc9, + 0x44, 0x7e, 0x0, 0x57, 0xbe, 0xfa, 0xae, 0x57, 0x15, 0x7f, 0x20, + 0xc1, 0x60, 0xdb, 0x18, 0x62, 0x26, 0x91, 0x88, 0x5, 0x26}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 437866655573314, 669026411194768, 81896997980338, - 523874406393178, 245052060935236 -#else - 41346370, 6524721, 26585488, 9969270, 24709298, 1220360, - 65430874, 7806336, 17507396, 3651560 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1975438052228868, 1071801519999806, 594652299224319, - 1877697652668809, 1489635366987285 -#else - 56688388, 29436320, 14584638, 15971087, 51340543, 8861009, - 26556809, 27979875, 48555541, 22197296 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 958592545673770, 233048016518599, 851568750216589, - 567703851596087, 1740300006094761 -#else - 2839082, 14284142, 4029895, 3472686, 14402957, 12689363, - 40466743, 8459446, 61503401, 25932490 -#endif - }}, + {0x42, 0xe5, 0x76, 0xc6, 0x3c, 0x8e, 0x81, 0x4c, 0xad, 0xcc, 0xce, + 0x3, 0x93, 0x2c, 0x42, 0x5e, 0x8, 0x9f, 0x12, 0xb4, 0xca, 0xcc, + 0x7, 0xec, 0xb8, 0x43, 0x44, 0xb2, 0x10, 0xfa, 0xed, 0xd}, + {0x4, 0xff, 0x60, 0x83, 0xa6, 0x4, 0xf7, 0x59, 0xf4, 0xe6, 0x61, + 0x76, 0xde, 0x3f, 0xd9, 0xc3, 0x51, 0x35, 0x87, 0x12, 0x73, 0x2a, + 0x1b, 0x83, 0x57, 0x5d, 0x61, 0x4e, 0x2e, 0xc, 0xad, 0x54}, + {0x2a, 0x52, 0x2b, 0xb8, 0xd5, 0x67, 0x3b, 0xee, 0xeb, 0xc1, 0xa5, + 0x9f, 0x46, 0x63, 0xf1, 0x36, 0xd3, 0x9f, 0xc1, 0x6e, 0xf2, 0xd2, + 0xb4, 0xa5, 0x8, 0x94, 0x7a, 0xa7, 0xba, 0xb2, 0xec, 0x62}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2014540178270324, 192672779514432, 213877182641530, - 2194819933853411, 1716422829364835 -#else - 62269556, 30018987, 9744960, 2871048, 25113978, 3187018, - 41998051, 32705365, 17258083, 25576693 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1540769606609725, 2148289943846077, 1597804156127445, - 1230603716683868, 815423458809453 -#else - 18164541, 22959256, 49953981, 32012014, 19237077, 23809137, - 23357532, 18337424, 26908269, 12150756 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1738560251245018, 1779576754536888, 1783765347671392, - 1880170990446751, 1088225159617541 -#else - 36843994, 25906566, 5112248, 26517760, 65609056, 26580174, - 43167, 28016731, 34806789, 16215818 -#endif - }}, + {0x74, 0x28, 0xb6, 0xaf, 0x36, 0x28, 0x7, 0x92, 0xa5, 0x4, 0xe1, + 0x79, 0x85, 0x5e, 0xcd, 0x5f, 0x4a, 0xa1, 0x30, 0xc6, 0xad, 0x1, + 0xad, 0x5a, 0x98, 0x3f, 0x66, 0x75, 0x50, 0x3d, 0x91, 0x61}, + {0x3d, 0x2b, 0x15, 0x61, 0x52, 0x79, 0xed, 0xe5, 0xd1, 0xd7, 0xdd, + 0xe, 0x7d, 0x35, 0x62, 0x49, 0x71, 0x4c, 0x6b, 0xb9, 0xd0, 0xc8, + 0x82, 0x74, 0xbe, 0xd8, 0x66, 0xa9, 0x19, 0xf9, 0x59, 0x2e}, + {0xda, 0x31, 0x32, 0x1a, 0x36, 0x2d, 0xc6, 0xd, 0x70, 0x2, 0x20, + 0x94, 0x32, 0x58, 0x47, 0xfa, 0xce, 0x94, 0x95, 0x3f, 0x51, 0x1, + 0xd8, 0x2, 0x5c, 0x5d, 0xc0, 0x31, 0xa1, 0xc2, 0xdb, 0x3d}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 659303913929492, 1956447718227573, 1830568515922666, - 841069049744408, 1669607124206368 -#else - 60209940, 9824393, 54804085, 29153342, 35711722, 27277596, - 32574488, 12532905, 59605792, 24879084 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1143465490433355, 1532194726196059, 1093276745494697, - 481041706116088, 2121405433561163 -#else - 39765323, 17038963, 39957339, 22831480, 946345, 16291093, - 254968, 7168080, 21676107, 31611404 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1686424298744462, 1451806974487153, 266296068846582, - 1834686947542675, 1720762336132256 -#else - 21260942, 25129680, 50276977, 21633609, 43430902, 3968120, - 63456915, 27338965, 63552672, 25641356 -#endif - }}, + {0x14, 0xbb, 0x96, 0x27, 0xa2, 0x57, 0xaa, 0xf3, 0x21, 0xda, 0x7, + 0x9b, 0xb7, 0xba, 0x3a, 0x88, 0x1c, 0x39, 0xa0, 0x31, 0x18, 0xe2, + 0x4b, 0xe5, 0xf9, 0x5, 0x32, 0xd8, 0x38, 0xfb, 0xe7, 0x5e}, + {0x4b, 0xc5, 0x5e, 0xce, 0xf9, 0xf, 0xdc, 0x9a, 0xd, 0x13, 0x2f, + 0x8c, 0x6b, 0x2a, 0x9c, 0x3, 0x15, 0x95, 0xf8, 0xf0, 0xc7, 0x7, + 0x80, 0x2, 0x6b, 0xb3, 0x4, 0xac, 0x14, 0x83, 0x96, 0x78}, + {0x8e, 0x6a, 0x44, 0x41, 0xcb, 0xfd, 0x8d, 0x53, 0xf9, 0x37, 0x49, + 0x43, 0xa9, 0xfd, 0xac, 0xa5, 0x78, 0x8c, 0x3c, 0x26, 0x8d, 0x90, + 0xaf, 0x46, 0x9, 0xd, 0xca, 0x9b, 0x3c, 0x63, 0xd0, 0x61}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 889217026388959, 1043290623284660, 856125087551909, - 1669272323124636, 1603340330827879 -#else - 16544735, 13250366, 50304436, 15546241, 62525861, 12757257, - 64646556, 24874095, 48201831, 23891632 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1206396181488998, 333158148435054, 1402633492821422, - 1120091191722026, 1945474114550509 -#else - 64693606, 17976703, 18312302, 4964443, 51836334, 20900867, - 26820650, 16690659, 25459437, 28989823 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 766720088232571, 1512222781191002, 1189719893490790, - 2091302129467914, 2141418006894941 -#else - 41964155, 11425019, 28423002, 22533875, 60963942, 17728207, - 9142794, 31162830, 60676445, 31909614 -#endif - }}, + {0xdf, 0x73, 0xfc, 0xf8, 0xbc, 0x28, 0xa3, 0xad, 0xfc, 0x37, 0xf0, + 0xa6, 0x5d, 0x69, 0x84, 0xee, 0x9, 0xa9, 0xc2, 0x38, 0xdb, 0xb4, + 0x7f, 0x63, 0xdc, 0x7b, 0x6, 0xf8, 0x2d, 0xac, 0x23, 0x5b}, + {0x66, 0x25, 0xdb, 0xff, 0x35, 0x49, 0x74, 0x63, 0xbb, 0x68, 0xb, + 0x78, 0x89, 0x6b, 0xbd, 0xc5, 0x3, 0xec, 0x3e, 0x55, 0x80, 0x32, + 0x1b, 0x6f, 0xf5, 0xd7, 0xae, 0x47, 0xd8, 0x5f, 0x96, 0x6e}, + {0x7b, 0x52, 0x80, 0xee, 0x53, 0xb9, 0xd2, 0x9a, 0x8d, 0x6d, 0xde, + 0xfa, 0xaa, 0x19, 0x8f, 0xe8, 0xcf, 0x82, 0xe, 0x15, 0x4, 0x17, + 0x71, 0xe, 0xdc, 0xde, 0x95, 0xdd, 0xb9, 0xbb, 0xb9, 0x79}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 419663647306612, 1998875112167987, 1426599870253707, - 1154928355379510, 486538532138187 -#else - 44004212, 6253475, 16964147, 29785560, 41994891, 21257994, - 39651638, 17209773, 6335691, 7249989 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 938160078005954, 1421776319053174, 1941643234741774, - 180002183320818, 1414380336750546 -#else - 36775618, 13979674, 7503222, 21186118, 55152142, 28932738, - 36836594, 2682241, 25993170, 21075909 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 398001940109652, 1577721237663248, 1012748649830402, - 1540516006905144, 1011684812884559 -#else - 4364628, 5930691, 32304656, 23509878, 59054082, 15091130, - 22857016, 22955477, 31820367, 15075278 -#endif - }}, + {0x74, 0x73, 0x9f, 0x8e, 0xae, 0x7d, 0x99, 0xd1, 0x16, 0x8, 0xbb, + 0xcf, 0xf8, 0xa2, 0x32, 0xa0, 0xa, 0x5f, 0x44, 0x6d, 0x12, 0xba, + 0x6c, 0xcd, 0x34, 0xb8, 0xcc, 0xa, 0x46, 0x11, 0xa8, 0x1b}, + {0xc2, 0x26, 0x31, 0x6a, 0x40, 0x55, 0xb3, 0xeb, 0x93, 0xc3, 0xc8, + 0x68, 0xa8, 0x83, 0x63, 0xd2, 0x82, 0x7a, 0xb9, 0xe5, 0x29, 0x64, + 0xc, 0x6c, 0x47, 0x21, 0xfd, 0xc9, 0x58, 0xf1, 0x65, 0x50}, + {0x54, 0x99, 0x42, 0xc, 0xfb, 0x69, 0x81, 0x70, 0x67, 0xcf, 0x6e, + 0xd7, 0xac, 0x0, 0x46, 0xe1, 0xba, 0x45, 0xe6, 0x70, 0x8a, 0xb9, + 0xaa, 0x2e, 0xf2, 0xfa, 0xa4, 0x58, 0x9e, 0xf3, 0x81, 0x39}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1653276489969630, 6081825167624, 1921777941170836, - 1604139841794531, 861211053640641 -#else - 31879134, 24635739, 17258760, 90626, 59067028, 28636722, - 24162787, 23903546, 49138625, 12833044 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 996661541407379, 1455877387952927, 744312806857277, - 139213896196746, 1000282908547789 -#else - 19073683, 14851414, 42705695, 21694263, 7625277, 11091125, - 47489674, 2074448, 57694925, 14905376 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1450817495603008, 1476865707053229, 1030490562252053, - 620966950353376, 1744760161539058 -#else - 24483648, 21618865, 64589997, 22007013, 65555733, 15355505, - 41826784, 9253128, 27628530, 25998952 -#endif - }}, + {0xde, 0x6f, 0xe6, 0x6d, 0xa5, 0xdf, 0x45, 0xc8, 0x3a, 0x48, 0x40, + 0x2c, 0x0, 0xa5, 0x52, 0xe1, 0x32, 0xf6, 0xb4, 0xc7, 0x63, 0xe1, + 0xd2, 0xe9, 0x65, 0x1b, 0xbc, 0xdc, 0x2e, 0x45, 0xf4, 0x30}, + {0x93, 0xa, 0x23, 0x59, 0x75, 0x8a, 0xfb, 0x18, 0x5d, 0xf4, 0xe6, + 0x60, 0x69, 0x8f, 0x16, 0x1d, 0xb5, 0x3c, 0xa9, 0x14, 0x45, 0xa9, + 0x85, 0x3a, 0xfd, 0xd0, 0xac, 0x5, 0x37, 0x8, 0xdc, 0x38}, + {0x40, 0x97, 0x75, 0xc5, 0x82, 0x27, 0x6d, 0x85, 0xcc, 0xbe, 0x9c, + 0xf9, 0x69, 0x45, 0x13, 0xfa, 0x71, 0x4e, 0xea, 0xc0, 0x73, 0xfc, + 0x44, 0x88, 0x69, 0x24, 0x3f, 0x59, 0x1a, 0x9a, 0x2d, 0x63}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 559728410002599, 37056661641185, 2038622963352006, - 1637244893271723, 1026565352238948 -#else - 17597607, 8340603, 19355617, 552187, 26198470, 30377849, - 4593323, 24396850, 52997988, 15297015 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 962165956135846, 1116599660248791, 182090178006815, - 1455605467021751, 196053588803284 -#else - 510886, 14337390, 35323607, 16638631, 6328095, 2713355, - 46891447, 21690211, 8683220, 2921426 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 796863823080135, 1897365583584155, 420466939481601, - 2165972651724672, 932177357788289 -#else - 18606791, 11874196, 27155355, 28272950, 43077121, 6265445, - 41930624, 32275507, 4674689, 13890525 -#endif - }}, + {0xa7, 0x84, 0xc, 0xed, 0x11, 0xfd, 0x9, 0xbf, 0x3a, 0x69, 0x9f, + 0xd, 0x81, 0x71, 0xf0, 0x63, 0x79, 0x87, 0xcf, 0x57, 0x2d, 0x8c, + 0x90, 0x21, 0xa2, 0x4b, 0xf6, 0x8a, 0xf2, 0x7d, 0x5a, 0x3a}, + {0xa6, 0xcb, 0x7, 0xb8, 0x15, 0x6b, 0xbb, 0xf6, 0xd7, 0xf0, 0x54, + 0xbc, 0xdf, 0xc7, 0x23, 0x18, 0xb, 0x67, 0x29, 0x6e, 0x3, 0x97, + 0x1d, 0xbb, 0x57, 0x4a, 0xed, 0x47, 0x88, 0xf4, 0x24, 0xb}, + {0xc7, 0xea, 0x1b, 0x51, 0xbe, 0xd4, 0xda, 0xdc, 0xf2, 0xcc, 0x26, + 0xed, 0x75, 0x80, 0x53, 0xa4, 0x65, 0x9a, 0x5f, 0x0, 0x9f, 0xff, + 0x9c, 0xe1, 0x63, 0x1f, 0x48, 0x75, 0x44, 0xf7, 0xfc, 0x34}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 877047233620632, 1375632631944375, 643773611882121, - 660022738847877, 19353932331831 -#else - 13609624, 13069022, 39736503, 20498523, 24360585, 9592974, - 14977157, 9835105, 4389687, 288396 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2216943882299338, 394841323190322, 2222656898319671, - 558186553950529, 1077236877025190 -#else - 9922506, 33035038, 13613106, 5883594, 48350519, 33120168, - 54804801, 8317627, 23388070, 16052080 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 801118384953213, 1914330175515892, 574541023311511, - 1471123787903705, 1526158900256288 -#else - 12719997, 11937594, 35138804, 28525742, 26900119, 8561328, - 46953177, 21921452, 52354592, 22741539 -#endif - }}, + {0x98, 0xaa, 0xcf, 0x78, 0xab, 0x1d, 0xbb, 0xa5, 0xf2, 0x72, 0xb, + 0x19, 0x67, 0xa2, 0xed, 0x5c, 0x8e, 0x60, 0x92, 0xa, 0x11, 0xc9, + 0x9, 0x93, 0xb0, 0x74, 0xb3, 0x2f, 0x4, 0xa3, 0x19, 0x1}, + {0xca, 0x67, 0x97, 0x78, 0x4c, 0xe0, 0x97, 0xc1, 0x7d, 0x46, 0xd9, + 0x38, 0xcb, 0x4d, 0x71, 0xb8, 0xa8, 0x5f, 0xf9, 0x83, 0x82, 0x88, + 0xde, 0x55, 0xf7, 0x63, 0xfa, 0x4d, 0x16, 0xdc, 0x3b, 0x3d}, + {0x7d, 0x17, 0xc2, 0xe8, 0x9c, 0xd8, 0xa2, 0x67, 0xc1, 0xd0, 0x95, + 0x68, 0xf6, 0xa5, 0x9d, 0x66, 0xb0, 0xa2, 0x82, 0xb2, 0xe5, 0x98, + 0x65, 0xf5, 0x73, 0xa, 0xe2, 0xed, 0xf1, 0x88, 0xc0, 0x56}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 949617889087234, 2207116611267331, 912920039141287, - 501158539198789, 62362560771472 -#else - 15961858, 14150409, 26716931, 32888600, 44314535, 13603568, - 11829573, 7467844, 38286736, 929274 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1474518386765335, 1760793622169197, 1157399790472736, - 1622864308058898, 165428294422792 -#else - 11038231, 21972036, 39798381, 26237869, 56610336, 17246600, - 43629330, 24182562, 45715720, 2465073 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1961673048027128, 102619413083113, 1051982726768458, - 1603657989805485, 1941613251499678 -#else - 20017144, 29231206, 27915241, 1529148, 12396362, 15675764, - 13817261, 23896366, 2463390, 28932292 -#endif - }}, + {0x2, 0x8f, 0xf3, 0x24, 0xac, 0x5f, 0x1b, 0x58, 0xbd, 0xc, 0xe3, + 0xba, 0xfe, 0xe9, 0xb, 0xa9, 0xf0, 0x92, 0xcf, 0x8a, 0x2, 0x69, + 0x21, 0x9a, 0x8f, 0x3, 0x59, 0x83, 0xa4, 0x7e, 0x8b, 0x3}, + {0x17, 0x6e, 0xa8, 0x10, 0x11, 0x3d, 0x6d, 0x33, 0xfa, 0xb2, 0x75, + 0xb, 0x32, 0x88, 0xf3, 0xd7, 0x88, 0x29, 0x7, 0x25, 0x76, 0x33, + 0x15, 0xf9, 0x87, 0x8b, 0x10, 0x99, 0x6b, 0x4c, 0x67, 0x9}, + {0xf8, 0x6f, 0x31, 0x99, 0x21, 0xf8, 0x4e, 0x9f, 0x4f, 0x8d, 0xa7, + 0xea, 0x82, 0xd2, 0x49, 0x2f, 0x74, 0x31, 0xef, 0x5a, 0xab, 0xa5, + 0x71, 0x9, 0x65, 0xeb, 0x69, 0x59, 0x2, 0x31, 0x5e, 0x6e}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1401939116319266, 335306339903072, 72046196085786, - 862423201496006, 850518754531384 -#else - 50749986, 20890520, 55043680, 4996453, 65852442, 1073571, - 9583558, 12851107, 4003896, 12673717 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1234706593321979, 1083343891215917, 898273974314935, - 1640859118399498, 157578398571149 -#else - 65377275, 18398561, 63845933, 16143081, 19294135, 13385325, - 14741514, 24450706, 7903885, 2348101 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1143483057726416, 1992614991758919, 674268662140796, - 1773370048077526, 674318359920189 -#else - 24536016, 17039225, 12715591, 29692277, 1511292, 10047386, - 63266518, 26425272, 38731325, 10048126 -#endif - }}, + {0x22, 0x62, 0x6, 0x63, 0xe, 0xfb, 0x4, 0x33, 0x3f, 0xba, 0xac, + 0x87, 0x89, 0x6, 0x35, 0xfb, 0xa3, 0x61, 0x10, 0x8c, 0x77, 0x24, + 0x19, 0xbd, 0x20, 0x86, 0x83, 0xd1, 0x43, 0xad, 0x58, 0x30}, + {0xfb, 0x93, 0xe5, 0x87, 0xf5, 0x62, 0x6c, 0xb1, 0x71, 0x3e, 0x5d, + 0xca, 0xde, 0xed, 0x99, 0x49, 0x6d, 0x3e, 0xcc, 0x14, 0xe0, 0xc1, + 0x91, 0xb4, 0xa8, 0xdb, 0xa8, 0x89, 0x47, 0x11, 0xf5, 0x8}, + {0xd0, 0x63, 0x76, 0xe5, 0xfd, 0xf, 0x3c, 0x32, 0x10, 0xa6, 0x2e, + 0xa2, 0x38, 0xdf, 0xc3, 0x5, 0x9a, 0x4f, 0x99, 0xac, 0xbd, 0x8a, + 0xc7, 0xbd, 0x99, 0xdc, 0xe3, 0xef, 0xa4, 0x9f, 0x54, 0x26}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1835401379538542, 173900035308392, 818247630716732, - 1762100412152786, 1021506399448291 -#else - 54486638, 27349611, 30718824, 2591312, 56491836, 12192839, - 18873298, 26257342, 34811107, 15221631 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1506632088156630, 2127481795522179, 513812919490255, - 140643715928370, 442476620300318 -#else - 40630742, 22450567, 11546243, 31701949, 9180879, 7656409, - 45764914, 2095754, 29769758, 6593415 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2056683376856736, 219094741662735, 2193541883188309, - 1841182310235800, 556477468664293 -#else - 35114656, 30646970, 4176911, 3264766, 12538965, 32686321, - 26312344, 27435754, 30958053, 8292160 -#endif - }}, + {0x6e, 0x66, 0x3f, 0xaf, 0x49, 0x85, 0x46, 0xdb, 0xa5, 0xe, 0x4a, + 0xf1, 0x4, 0xcf, 0x7f, 0xd7, 0x47, 0xc, 0xba, 0xa4, 0xf7, 0x3f, + 0xf2, 0x3d, 0x85, 0x3c, 0xce, 0x32, 0xe1, 0xdf, 0x10, 0x3a}, + {0xd6, 0xf9, 0x6b, 0x1e, 0x46, 0x5a, 0x1d, 0x74, 0x81, 0xa5, 0x77, + 0x77, 0xfc, 0xb3, 0x5, 0x23, 0xd9, 0xd3, 0x74, 0x64, 0xa2, 0x74, + 0x55, 0xd4, 0xff, 0xe0, 0x1, 0x64, 0xdc, 0xe1, 0x26, 0x19}, + {0xa0, 0xce, 0x17, 0xea, 0x8a, 0x4e, 0x7f, 0xe0, 0xfd, 0xc1, 0x1f, + 0x3a, 0x46, 0x15, 0xd5, 0x2f, 0xf1, 0xc0, 0xf2, 0x31, 0xfd, 0x22, + 0x53, 0x17, 0x15, 0x5d, 0x1e, 0x86, 0x1d, 0xd0, 0xa1, 0x1f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1315019427910827, 1049075855992603, 2066573052986543, - 266904467185534, 2040482348591520 -#else - 31429803, 19595316, 29173531, 15632448, 12174511, 30794338, - 32808830, 3977186, 26143136, 30405556 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 94096246544434, 922482381166992, 24517828745563, - 2139430508542503, 2097139044231004 -#else - 22648882, 1402143, 44308880, 13746058, 7936347, 365344, - 58440231, 31879998, 63350620, 31249806 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 537697207950515, 1399352016347350, 1563663552106345, - 2148749520888918, 549922092988516 -#else - 51616947, 8012312, 64594134, 20851969, 43143017, 23300402, - 65496150, 32018862, 50444388, 8194477 -#endif - }}, + {0xab, 0x94, 0xdf, 0xd1, 0x0, 0xac, 0xdc, 0x38, 0xe9, 0xd, 0x8, + 0xd1, 0xdd, 0x2b, 0x71, 0x2e, 0x62, 0xe2, 0xd5, 0xfd, 0x3e, 0xe9, + 0x13, 0x7f, 0xe5, 0x1, 0x9a, 0xee, 0x18, 0xed, 0xfc, 0x73}, + {0x32, 0x98, 0x59, 0x7d, 0x94, 0x55, 0x80, 0xcc, 0x20, 0x55, 0xf1, + 0x37, 0xda, 0x56, 0x46, 0x1e, 0x20, 0x93, 0x5, 0x4e, 0x74, 0xf7, + 0xf6, 0x99, 0x33, 0xcf, 0x75, 0x6a, 0xbc, 0x63, 0x35, 0x77}, + {0xb3, 0x9c, 0x13, 0x63, 0x8, 0xe9, 0xb1, 0x6, 0xcd, 0x3e, 0xa0, + 0xc5, 0x67, 0xda, 0x93, 0xa4, 0x32, 0x89, 0x63, 0xad, 0xc8, 0xce, + 0x77, 0x8d, 0x44, 0x4f, 0x86, 0x1b, 0x70, 0x6b, 0x42, 0x1f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1747985413252434, 680511052635695, 1809559829982725, - 594274250930054, 201673170745982 -#else - 27338066, 26047012, 59694639, 10140404, 48082437, 26964542, - 27277190, 8855376, 28572286, 3005164 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 323583936109569, 1973572998577657, 1192219029966558, - 79354804385273, 1374043025560347 -#else - 26287105, 4821776, 25476601, 29408529, 63344350, 17765447, - 49100281, 1182478, 41014043, 20474836 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 213277331329947, 416202017849623, 1950535221091783, - 1313441578103244, 2171386783823658 -#else - 59937691, 3178079, 23970071, 6201893, 49913287, 29065239, - 45232588, 19571804, 32208682, 32356184 -#endif - }}, + {0x52, 0x25, 0xa1, 0x91, 0xc8, 0x35, 0x7e, 0xf1, 0x76, 0x9c, 0x5e, + 0x57, 0x53, 0x81, 0x6b, 0xb7, 0x3e, 0x72, 0x9b, 0xd, 0x6f, 0x40, + 0x83, 0xfa, 0x38, 0xe4, 0xa7, 0x3f, 0x1b, 0xbb, 0x76, 0xb}, + {0x1, 0x1c, 0x91, 0x41, 0x4c, 0x26, 0xc9, 0xef, 0x25, 0x2c, 0xa2, + 0x17, 0xb8, 0xb7, 0xa3, 0xf1, 0x47, 0x14, 0xf, 0xf3, 0x6b, 0xda, + 0x75, 0x58, 0x90, 0xb0, 0x31, 0x1d, 0x27, 0xf5, 0x1a, 0x4e}, + {0x9b, 0x93, 0x92, 0x7f, 0xf9, 0xc1, 0xb8, 0x8, 0x6e, 0xab, 0x44, + 0xd4, 0xcb, 0x71, 0x67, 0xbe, 0x17, 0x80, 0xbb, 0x99, 0x63, 0x64, + 0xe5, 0x22, 0x55, 0xa9, 0x72, 0xb7, 0x1e, 0xd6, 0x6d, 0x7b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 189088804229831, 993969372859110, 895870121536987, - 1547301535298256, 1477373024911350 -#else - 50451143, 2817642, 56822502, 14811297, 6024667, 13349505, - 39793360, 23056589, 39436278, 22014573 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1620578418245010, 541035331188469, 2235785724453865, - 2154865809088198, 1974627268751826 -#else - 15941010, 24148500, 45741813, 8062054, 31876073, 33315803, - 51830470, 32110002, 15397330, 29424239 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1346805451740245, 1350981335690626, 942744349501813, - 2155094562545502, 1012483751693409 -#else - 8934485, 20068965, 43822466, 20131190, 34662773, 14047985, - 31170398, 32113411, 39603297, 15087183 -#endif - }}, + {0xc7, 0xd2, 0x1, 0xab, 0xf9, 0xab, 0x30, 0x57, 0x18, 0x3b, 0x14, + 0x40, 0xdc, 0x76, 0xfb, 0x16, 0x81, 0xb2, 0xcb, 0xa0, 0x65, 0xbe, + 0x6c, 0x86, 0xfe, 0x6a, 0xff, 0x9b, 0x65, 0x9b, 0xfa, 0x53}, + {0x92, 0x3d, 0xf3, 0x50, 0xe8, 0xc1, 0xad, 0xb7, 0xcf, 0xd5, 0x8c, + 0x60, 0x4f, 0xfa, 0x98, 0x79, 0xdb, 0x5b, 0xfc, 0x8d, 0xbd, 0x2d, + 0x96, 0xad, 0x4f, 0x2f, 0x1d, 0xaf, 0xce, 0x9b, 0x3e, 0x70}, + {0x55, 0x54, 0x88, 0x94, 0xe9, 0xc8, 0x14, 0x6c, 0xe5, 0xd4, 0xae, + 0x65, 0x66, 0x5d, 0x3a, 0x84, 0xf1, 0x5a, 0xd6, 0xbc, 0x3e, 0xb7, + 0x1b, 0x18, 0x50, 0x1f, 0xc6, 0xc4, 0xe5, 0x93, 0x8d, 0x39}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2107080134091762, 1132567062788208, 1824935377687210, - 769194804343737, 1857941799971888 -#else - 48751602, 31397940, 24524912, 16876564, 15520426, 27193656, - 51606457, 11461895, 16788528, 27685490 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1074666112436467, 249279386739593, 1174337926625354, - 1559013532006480, 1472287775519121 -#else - 65161459, 16013772, 21750665, 3714552, 49707082, 17498998, - 63338576, 23231111, 31322513, 21938797 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1872620123779532, 1892932666768992, 1921559078394978, - 1270573311796160, 1438913646755037 -#else - 21426636, 27904214, 53460576, 28206894, 38296674, 28633461, - 48833472, 18933017, 13040861, 21441484 -#endif - }}, + {0xf2, 0xe3, 0xe7, 0xd2, 0x60, 0x7c, 0x87, 0xc3, 0xb1, 0x8b, 0x82, + 0x30, 0xa0, 0xaa, 0x34, 0x3b, 0x38, 0xf1, 0x9e, 0x73, 0xe7, 0x26, + 0x3e, 0x28, 0x77, 0x5, 0xc3, 0x2, 0x90, 0x9c, 0x9c, 0x69}, + {0xf3, 0x48, 0xe2, 0x33, 0x67, 0xd1, 0x4b, 0x1c, 0x5f, 0xa, 0xbf, + 0x15, 0x87, 0x12, 0x9e, 0xbd, 0x76, 0x3, 0xb, 0xa1, 0xf0, 0x8c, + 0x3f, 0xd4, 0x13, 0x1b, 0x19, 0xdf, 0x5d, 0x9b, 0xb0, 0x53}, + {0xcc, 0xf1, 0x46, 0x59, 0x23, 0xa7, 0x6, 0xf3, 0x7d, 0xd9, 0xe5, + 0xcc, 0xb5, 0x18, 0x17, 0x92, 0x75, 0xe9, 0xb4, 0x81, 0x47, 0xd2, + 0xcd, 0x28, 0x7, 0xd9, 0xcd, 0x6f, 0xc, 0xf3, 0xca, 0x51}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 837390187648199, 1012253300223599, 989780015893987, - 1351393287739814, 328627746545550 -#else - 11293895, 12478086, 39972463, 15083749, 37801443, 14748871, - 14555558, 20137329, 1613710, 4896935 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1028328827183114, 1711043289969857, 1350832470374933, - 1923164689604327, 1495656368846911 -#else - 41213962, 15323293, 58619073, 25496531, 25967125, 20128972, - 2825959, 28657387, 43137087, 22287016 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1900828492104143, 430212361082163, 687437570852799, - 832514536673512, 1685641495940794 -#else - 51184079, 28324551, 49665331, 6410663, 3622847, 10243618, - 20615400, 12405433, 43355834, 25118015 -#endif - }}, + {0xc7, 0x54, 0xac, 0x18, 0x9a, 0xf9, 0x7a, 0x73, 0xf, 0xb3, 0x1c, + 0xc5, 0xdc, 0x78, 0x33, 0x90, 0xc7, 0xc, 0xe1, 0x4c, 0x33, 0xbc, + 0x89, 0x2b, 0x9a, 0xe9, 0xf8, 0x89, 0xc1, 0x29, 0xae, 0x12}, + {0xa, 0xe0, 0x74, 0x76, 0x42, 0xa7, 0xb, 0xa6, 0xf3, 0x7b, 0x7a, + 0xa1, 0x70, 0x85, 0xe, 0x63, 0xcc, 0x24, 0x33, 0xcf, 0x3d, 0x56, + 0x58, 0x37, 0xaa, 0xfd, 0x83, 0x23, 0x29, 0xaa, 0x4, 0x55}, + {0xcf, 0x1, 0xd, 0x1f, 0xcb, 0xc0, 0x9e, 0xa9, 0xae, 0xf7, 0x34, + 0x3a, 0xcc, 0xef, 0xd1, 0xd, 0x22, 0x4e, 0x9c, 0xd0, 0x21, 0x75, + 0xca, 0x55, 0xea, 0xa5, 0xeb, 0x58, 0xe9, 0x4f, 0xd1, 0x5f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 842632847936398, 605670026766216, 290836444839585, - 163210774892356, 2213815011799645 -#else - 60017550, 12556207, 46917512, 9025186, 50036385, 4333800, - 4378436, 2432030, 23097949, 32988414 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1176336383453996, 1725477294339771, 12700622672454, - 678015708818208, 162724078519879 -#else - 4565804, 17528778, 20084411, 25711615, 1724998, 189254, - 24767264, 10103221, 48596551, 2424777 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1448049969043497, 1789411762943521, 385587766217753, - 90201620913498, 832999441066823 -#else - 366633, 21577626, 8173089, 26664313, 30788633, 5745705, - 59940186, 1344108, 63466311, 12412658 -#endif - }}, + {0x8e, 0xcb, 0x93, 0xbf, 0x5e, 0xfe, 0x42, 0x3c, 0x5f, 0x56, 0xd4, + 0x36, 0x51, 0xa8, 0xdf, 0xbe, 0xe8, 0x20, 0x42, 0x88, 0x9e, 0x85, + 0xf0, 0xe0, 0x28, 0xd1, 0x25, 0x7, 0x96, 0x3f, 0xd7, 0x7d}, + {0x2c, 0xab, 0x45, 0x28, 0xdf, 0x2d, 0xdc, 0xb5, 0x93, 0xe9, 0x7f, + 0xa, 0xb1, 0x91, 0x94, 0x6, 0x46, 0xe3, 0x2, 0x40, 0xd6, 0xf3, + 0xaa, 0x4d, 0xd1, 0x74, 0x64, 0x58, 0x6e, 0xf2, 0x3f, 0x9}, + {0x29, 0x98, 0x5, 0x68, 0xfe, 0x24, 0xd, 0xb1, 0xe5, 0x23, 0xaf, + 0xdb, 0x72, 0x6, 0x73, 0x75, 0x29, 0xac, 0x57, 0xb4, 0x3a, 0x25, + 0x67, 0x13, 0xa4, 0x70, 0xb4, 0x86, 0xbc, 0xbc, 0x59, 0x2f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 516086333293313, 2240508292484616, 1351669528166508, - 1223255565316488, 750235824427138 -#else - 43107073, 7690285, 14929416, 33386175, 34898028, 20141445, - 24162696, 18227928, 63967362, 11179384 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1263624896582495, 1102602401673328, 526302183714372, - 2152015839128799, 1483839308490010 -#else - 18289503, 18829478, 8056944, 16430056, 45379140, 7842513, - 61107423, 32067534, 48424218, 22110928 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 442991718646863, 1599275157036458, 1925389027579192, - 899514691371390, 350263251085160 -#else - 476239, 6601091, 60956074, 23831056, 17503544, 28690532, - 27672958, 13403813, 11052904, 5219329 -#endif - }}, + {0x1, 0xc3, 0x91, 0xb6, 0x60, 0xd5, 0x41, 0x70, 0x1e, 0xe7, 0xd7, + 0xad, 0x3f, 0x1b, 0x20, 0x85, 0x85, 0x55, 0x33, 0x11, 0x63, 0xe1, + 0xc2, 0x16, 0xb1, 0x28, 0x8, 0x1, 0x3d, 0x5e, 0xa5, 0x2a}, + {0x5f, 0x13, 0x17, 0x99, 0x42, 0x7d, 0x84, 0x83, 0xd7, 0x3, 0x7d, + 0x56, 0x1f, 0x91, 0x1b, 0xad, 0xd1, 0xaa, 0x77, 0xbe, 0xd9, 0x48, + 0x77, 0x7e, 0x4a, 0xaf, 0x51, 0x2e, 0x2e, 0xb4, 0x58, 0x54}, + {0x4f, 0x44, 0x7, 0xc, 0xe6, 0x92, 0x51, 0xed, 0x10, 0x1d, 0x42, + 0x74, 0x2d, 0x4e, 0xc5, 0x42, 0x64, 0xc8, 0xb5, 0xfd, 0x82, 0x4c, + 0x2b, 0x35, 0x64, 0x86, 0x76, 0x8a, 0x4a, 0x0, 0xe9, 0x13}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1689713572022143, 593854559254373, 978095044791970, - 1985127338729499, 1676069120347625 -#else - 20678527, 25178694, 34436965, 8849122, 62099106, 14574751, - 31186971, 29580702, 9014761, 24975376 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1557207018622683, 340631692799603, 1477725909476187, - 614735951619419, 2033237123746766 -#else - 53464795, 23204192, 51146355, 5075807, 65594203, 22019831, - 34006363, 9160279, 8473550, 30297594 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 968764929340557, 1225534776710944, 662967304013036, - 1155521416178595, 791142883466590 -#else - 24900749, 14435722, 17209120, 18261891, 44516588, 9878982, - 59419555, 17218610, 42540382, 11788947 -#endif - }}, + {0x7f, 0x87, 0x3b, 0x19, 0xc9, 0x0, 0x2e, 0xbb, 0x6b, 0x50, 0xdc, + 0xe0, 0x90, 0xa8, 0xe3, 0xec, 0x9f, 0x64, 0xde, 0x36, 0xc0, 0xb7, + 0xf3, 0xec, 0x1a, 0x9e, 0xde, 0x98, 0x8, 0x4, 0x46, 0x5f}, + {0xdb, 0xce, 0x2f, 0x83, 0x45, 0x88, 0x9d, 0x73, 0x63, 0xf8, 0x6b, + 0xae, 0xc9, 0xd6, 0x38, 0xfa, 0xf7, 0xfe, 0x4f, 0xb7, 0xca, 0xd, + 0xbc, 0x32, 0x5e, 0xe4, 0xbc, 0x14, 0x88, 0x7e, 0x93, 0x73}, + {0x8d, 0xf4, 0x7b, 0x29, 0x16, 0x71, 0x3, 0xb9, 0x34, 0x68, 0xf0, + 0xd4, 0x22, 0x3b, 0xd1, 0xa9, 0xc6, 0xbd, 0x96, 0x46, 0x57, 0x15, + 0x97, 0xe1, 0x35, 0xe8, 0xd5, 0x91, 0xe8, 0xa4, 0xf8, 0x2c}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1487081286167458, 993039441814934, 1792378982844640, - 698652444999874, 2153908693179754 -#else - 63990690, 22159237, 53306774, 14797440, 9652448, 26708528, - 47071426, 10410732, 42540394, 32095740 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1123181311102823, 685575944875442, 507605465509927, - 1412590462117473, 568017325228626 -#else - 51449703, 16736705, 44641714, 10215877, 58011687, 7563910, - 11871841, 21049238, 48595538, 8464117 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 560258797465417, 2193971151466401, 1824086900849026, - 579056363542056, 1690063960036441 -#else - 43708233, 8348506, 52522913, 32692717, 63158658, 27181012, - 14325288, 8628612, 33313881, 25183915 -#endif - }}, + {0xa2, 0x6b, 0xd0, 0x17, 0x7e, 0x48, 0xb5, 0x2c, 0x6b, 0x19, 0x50, + 0x39, 0x1c, 0x38, 0xd2, 0x24, 0x30, 0x8a, 0x97, 0x85, 0x81, 0x9c, + 0x65, 0xd7, 0xf6, 0xa4, 0xd6, 0x91, 0x28, 0x7f, 0x6f, 0x7a}, + {0x67, 0xf, 0x11, 0x7, 0x87, 0xfd, 0x93, 0x6d, 0x49, 0xb5, 0x38, + 0x7c, 0xd3, 0x9, 0x4c, 0xdd, 0x86, 0x6a, 0x73, 0xc2, 0x4c, 0x6a, + 0xb1, 0x7c, 0x9, 0x2a, 0x25, 0x58, 0x6e, 0xbd, 0x49, 0x20}, + {0x49, 0xef, 0x9a, 0x6a, 0x8d, 0xfd, 0x9, 0x7d, 0xb, 0xb9, 0x3d, + 0x5b, 0xbe, 0x60, 0xee, 0xf0, 0xd4, 0xbf, 0x9e, 0x51, 0x2c, 0xb5, + 0x21, 0x4c, 0x1d, 0x94, 0x45, 0xc5, 0xdf, 0xaa, 0x11, 0x60}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1918407319222416, 353767553059963, 1930426334528099, - 1564816146005724, 1861342381708096 -#else - 46921872, 28586496, 22367355, 5271547, 66011747, 28765593, - 42303196, 23317577, 58168128, 27736162 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2131325168777276, 1176636658428908, 1756922641512981, - 1390243617176012, 1966325177038383 -#else - 60160060, 31759219, 34483180, 17533252, 32635413, 26180187, - 15989196, 20716244, 28358191, 29300528 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2063958120364491, 2140267332393533, 699896251574968, - 273268351312140, 375580724713232 -#else - 43547083, 30755372, 34757181, 31892468, 57961144, 10429266, - 50471180, 4072015, 61757200, 5596588 -#endif - }}, + {0x90, 0xf8, 0xcb, 0x2, 0xc8, 0xd0, 0xde, 0x63, 0xaa, 0x6a, 0xff, + 0xd, 0xca, 0x98, 0xd0, 0xfb, 0x99, 0xed, 0xb6, 0xb9, 0xfd, 0xa, + 0x4d, 0x62, 0x1e, 0xb, 0x34, 0x79, 0xb7, 0x18, 0xce, 0x69}, + {0x3c, 0xf8, 0x95, 0xcf, 0x6d, 0x92, 0x67, 0x5f, 0x71, 0x90, 0x28, + 0x71, 0x61, 0x85, 0x7e, 0x7c, 0x5b, 0x7a, 0x8f, 0x99, 0xf3, 0xe7, + 0xa1, 0xd6, 0xe0, 0xf9, 0x62, 0xb, 0x1b, 0xcc, 0xc5, 0x6f}, + {0xcb, 0x79, 0x98, 0xb2, 0x28, 0x55, 0xef, 0xd1, 0x92, 0x90, 0x7e, + 0xd4, 0x3c, 0xae, 0x1a, 0xdd, 0x52, 0x23, 0x9f, 0x18, 0x42, 0x4, + 0x7e, 0x12, 0xf1, 0x1, 0x71, 0xe5, 0x3a, 0x6b, 0x59, 0x15}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2024297515263178, 416959329722687, 1079014235017302, - 171612225573183, 1031677520051053 -#else - 38872266, 30164383, 12312895, 6213178, 3117142, 16078565, - 29266239, 2557221, 1768301, 15373193 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2033900009388450, 1744902869870788, 2190580087917640, - 1949474984254121, 231049754293748 -#else - 59865506, 30307471, 62515396, 26001078, 66980936, 32642186, - 66017961, 29049440, 42448372, 3442909 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 343868674606581, 550155864008088, 1450580864229630, - 481603765195050, 896972360018042 -#else - 36898293, 5124042, 14181784, 8197961, 18964734, 21615339, - 22597930, 7176455, 48523386, 13365929 -#endif - }}, + {0xca, 0x24, 0x51, 0x7e, 0x16, 0x31, 0xff, 0x9, 0xdf, 0x45, 0xc7, + 0xd9, 0x8b, 0x15, 0xe4, 0xb, 0xe5, 0x56, 0xf5, 0x7e, 0x22, 0x7d, + 0x2b, 0x29, 0x38, 0xd1, 0xb6, 0xaf, 0x41, 0xe2, 0xa4, 0x3a}, + {0xa2, 0x79, 0x91, 0x3f, 0xd2, 0x39, 0x27, 0x46, 0xcf, 0xdd, 0xd6, + 0x97, 0x31, 0x12, 0x83, 0xff, 0x8a, 0x14, 0xf2, 0x53, 0xb5, 0xde, + 0x7, 0x13, 0xda, 0x4d, 0x5f, 0x7b, 0x68, 0x37, 0x22, 0xd}, + {0xf5, 0x5, 0x33, 0x2a, 0xbf, 0x38, 0xc1, 0x2c, 0xc3, 0x26, 0xe9, + 0xa2, 0x8f, 0x3f, 0x58, 0x48, 0xeb, 0xd2, 0x49, 0x55, 0xa2, 0xb1, + 0x3a, 0x8, 0x6c, 0xa3, 0x87, 0x46, 0x6e, 0xaa, 0xfc, 0x32}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2151139328380127, 314745882084928, 59756825775204, - 1676664391494651, 2048348075599360 -#else - 59231455, 32054473, 8324672, 4690079, 6261860, 890446, 24538107, - 24984246, 57419264, 30522764 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1528930066340597, 1605003907059576, 1055061081337675, - 1458319101947665, 1234195845213142 -#else - 25008885, 22782833, 62803832, 23916421, 16265035, 15721635, - 683793, 21730648, 15723478, 18390951 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 830430507734812, 1780282976102377, 1425386760709037, - 362399353095425, 2168861579799910 -#else - 57448220, 12374378, 40101865, 26528283, 59384749, 21239917, - 11879681, 5400171, 519526, 32318556 -#endif - }}, + {0xdf, 0xcc, 0x87, 0x27, 0x73, 0xa4, 0x7, 0x32, 0xf8, 0xe3, 0x13, + 0xf2, 0x8, 0x19, 0xe3, 0x17, 0x4e, 0x96, 0xd, 0xf6, 0xd7, 0xec, + 0xb2, 0xd5, 0xe9, 0xb, 0x60, 0xc2, 0x36, 0x63, 0x6f, 0x74}, + {0xf5, 0x9a, 0x7d, 0xc5, 0x8d, 0x6e, 0xc5, 0x7b, 0xf2, 0xbd, 0xf0, + 0x9d, 0xed, 0xd2, 0xb, 0x3e, 0xa3, 0xe4, 0xef, 0x22, 0xde, 0x14, + 0xc0, 0xaa, 0x5c, 0x6a, 0xbd, 0xfe, 0xce, 0xe9, 0x27, 0x46}, + {0x1c, 0x97, 0x6c, 0xab, 0x45, 0xf3, 0x4a, 0x3f, 0x1f, 0x73, 0x43, + 0x99, 0x72, 0xeb, 0x88, 0xe2, 0x6d, 0x18, 0x44, 0x3, 0x8a, 0x6a, + 0x59, 0x33, 0x93, 0x62, 0xd6, 0x7e, 0x0, 0x17, 0x49, 0x7b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1155762232730333, 980662895504006, 2053766700883521, - 490966214077606, 510405877041357 -#else - 22258397, 17222199, 59239046, 14613015, 44588609, 30603508, - 46754982, 7315966, 16648397, 7605640 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1683750316716132, 652278688286128, 1221798761193539, - 1897360681476669, 319658166027343 -#else - 59027556, 25089834, 58885552, 9719709, 19259459, 18206220, - 23994941, 28272877, 57640015, 4763277 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 618808732869972, 72755186759744, 2060379135624181, - 1730731526741822, 48862757828238 -#else - 45409620, 9220968, 51378240, 1084136, 41632757, 30702041, - 31088446, 25789909, 55752334, 728111 -#endif - }}, + {0xdd, 0xa2, 0x53, 0xdd, 0x28, 0x1b, 0x34, 0x54, 0x3f, 0xfc, 0x42, + 0xdf, 0x5b, 0x90, 0x17, 0xaa, 0xf4, 0xf8, 0xd2, 0x4d, 0xd9, 0x92, + 0xf5, 0xf, 0x7d, 0xd3, 0x8c, 0xe0, 0xf, 0x62, 0x3, 0x1d}, + {0x64, 0xb0, 0x84, 0xab, 0x5c, 0xfb, 0x85, 0x2d, 0x14, 0xbc, 0xf3, + 0x89, 0xd2, 0x10, 0x78, 0x49, 0xc, 0xce, 0x15, 0x7b, 0x44, 0xdc, + 0x6a, 0x47, 0x7b, 0xfd, 0x44, 0xf8, 0x76, 0xa3, 0x2b, 0x12}, + {0x54, 0xe5, 0xb4, 0xa2, 0xcd, 0x32, 0x2, 0xc2, 0x7f, 0x18, 0x5d, + 0x11, 0x42, 0xfd, 0xd0, 0x9e, 0xd9, 0x79, 0xd4, 0x7d, 0xbe, 0xb4, + 0xab, 0x2e, 0x4c, 0xec, 0x68, 0x2b, 0xf5, 0xb, 0xc7, 0x2}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1463171970593505, 1143040711767452, 614590986558883, - 1409210575145591, 1882816996436803 -#else - 26047201, 21802961, 60208540, 17032633, 24092067, 9158119, - 62835319, 20998873, 37743427, 28056159 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2230133264691131, 563950955091024, 2042915975426398, - 827314356293472, 672028980152815 -#else - 17510331, 33231575, 5854288, 8403524, 17133918, 30441820, - 38997856, 12327944, 10750447, 10014012 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 264204366029760, 1654686424479449, 2185050199932931, - 2207056159091748, 506015669043634 -#else - 56796096, 3936951, 9156313, 24656749, 16498691, 32559785, - 39627812, 32887699, 3424690, 7540221 -#endif - }}, + {0xe1, 0x72, 0x8d, 0x45, 0xbf, 0x32, 0xe5, 0xac, 0xb5, 0x3c, 0xb7, + 0x7c, 0xe0, 0x68, 0xe7, 0x5b, 0xe7, 0xbd, 0x8b, 0xee, 0x94, 0x7d, + 0xcf, 0x56, 0x3, 0x3a, 0xb4, 0xfe, 0xe3, 0x97, 0x6, 0x6b}, + {0xbb, 0x2f, 0xb, 0x5d, 0x4b, 0xec, 0x87, 0xa2, 0xca, 0x82, 0x48, + 0x7, 0x90, 0x57, 0x5c, 0x41, 0x5c, 0x81, 0xd0, 0xc1, 0x1e, 0xa6, + 0x44, 0xe0, 0xe0, 0xf5, 0x9e, 0x40, 0xa, 0x4f, 0x33, 0x26}, + {0xc0, 0xa3, 0x62, 0xdf, 0x4a, 0xf0, 0xc8, 0xb6, 0x5d, 0xa4, 0x6d, + 0x7, 0xef, 0x0, 0xf0, 0x3e, 0xa9, 0xd2, 0xf0, 0x49, 0x58, 0xb9, + 0x9c, 0x9c, 0xae, 0x2f, 0x1b, 0x44, 0x43, 0x7f, 0xc3, 0x1c}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1784446333136569, 1973746527984364, 334856327359575, - 1156769775884610, 1023950124675478 -#else - 30322361, 26590322, 11361004, 29411115, 7433303, 4989748, - 60037442, 17237212, 57864598, 15258045 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2065270940578383, 31477096270353, 306421879113491, - 181958643936686, 1907105536686083 -#else - 13054543, 30774935, 19155473, 469045, 54626067, 4566041, - 5631406, 2711395, 1062915, 28418087 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1496516440779464, 1748485652986458, 872778352227340, - 818358834654919, 97932669284220 -#else - 47868616, 22299832, 37599834, 26054466, 61273100, 13005410, - 61042375, 12194496, 32960380, 1459310 -#endif - }}, + {0xb9, 0xae, 0xce, 0xc9, 0xf1, 0x56, 0x66, 0xd7, 0x6a, 0x65, 0xe5, + 0x18, 0xf8, 0x15, 0x5b, 0x1c, 0x34, 0x23, 0x4c, 0x84, 0x32, 0x28, + 0xe7, 0x26, 0x38, 0x68, 0x19, 0x2f, 0x77, 0x6f, 0x34, 0x3a}, + {0x4f, 0x32, 0xc7, 0x5c, 0x5a, 0x56, 0x8f, 0x50, 0x22, 0xa9, 0x6, + 0xe5, 0xc0, 0xc4, 0x61, 0xd0, 0x19, 0xac, 0x45, 0x5c, 0xdb, 0xab, + 0x18, 0xfb, 0x4a, 0x31, 0x80, 0x3, 0xc1, 0x9, 0x68, 0x6c}, + {0xc8, 0x6a, 0xda, 0xe2, 0x12, 0x51, 0xd5, 0xd2, 0xed, 0x51, 0xe8, + 0xb1, 0x31, 0x3, 0xbd, 0xe9, 0x62, 0x72, 0xc6, 0x8e, 0xdd, 0x46, + 0x7, 0x96, 0xd0, 0xc5, 0xf7, 0x6e, 0x9f, 0x1b, 0x91, 0x5}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 471636015770351, 672455402793577, 1804995246884103, - 1842309243470804, 1501862504981682 -#else - 19852015, 7027924, 23669353, 10020366, 8586503, 26896525, - 394196, 27452547, 18638002, 22379495 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1013216974933691, 538921919682598, 1915776722521558, - 1742822441583877, 1886550687916656 -#else - 31395515, 15098109, 26581030, 8030562, 50580950, 28547297, - 9012485, 25970078, 60465776, 28111795 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2094270000643336, 303971879192276, 40801275554748, - 649448917027930, 1818544418535447 -#else - 57916680, 31207054, 65111764, 4529533, 25766844, 607986, - 67095642, 9677542, 34813975, 27098423 -#endif - }}, + {0xef, 0xea, 0x2e, 0x51, 0xf3, 0xac, 0x49, 0x53, 0x49, 0xcb, 0xc1, + 0x1c, 0xd3, 0x41, 0xc1, 0x20, 0x8d, 0x68, 0x9a, 0xa9, 0x7, 0xc, + 0x18, 0x24, 0x17, 0x2d, 0x4b, 0xc6, 0xd1, 0xf9, 0x5e, 0x55}, + {0xbb, 0xe, 0xdf, 0xf5, 0x83, 0x99, 0x33, 0xc1, 0xac, 0x4c, 0x2c, + 0x51, 0x8f, 0x75, 0xf3, 0xc0, 0xe1, 0x98, 0xb3, 0xb, 0xa, 0x13, + 0xf1, 0x2c, 0x62, 0xc, 0x27, 0xaa, 0xf9, 0xec, 0x3c, 0x6b}, + {0x8, 0xbd, 0x73, 0x3b, 0xba, 0x70, 0xa7, 0x36, 0xc, 0xbf, 0xaf, + 0xa3, 0x8, 0xef, 0x4a, 0x62, 0xf2, 0x46, 0x9, 0xb4, 0x98, 0xff, + 0x37, 0x57, 0x9d, 0x74, 0x81, 0x33, 0xe1, 0x4d, 0x5f, 0x67}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2241737709499165, 549397817447461, 838180519319392, - 1725686958520781, 1705639080897747 -#else - 64664349, 33404494, 29348901, 8186665, 1873760, 12489863, - 36174285, 25714739, 59256019, 25416002 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1216074541925116, 50120933933509, 1565829004133810, - 721728156134580, 349206064666188 -#else - 51872508, 18120922, 7766469, 746860, 26346930, 23332670, - 39775412, 10754587, 57677388, 5203575 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 948617110470858, 346222547451945, 1126511960599975, - 1759386906004538, 493053284802266 -#else - 31834314, 14135496, 66338857, 5159117, 20917671, 16786336, - 59640890, 26216907, 31809242, 7347066 -#endif - }}, + {0x1d, 0xb3, 0xda, 0x3b, 0xd9, 0xf6, 0x2f, 0xa1, 0xfe, 0x2d, 0x65, + 0x9d, 0xf, 0xd8, 0x25, 0x7, 0x87, 0x94, 0xbe, 0x9a, 0xf3, 0x4f, + 0x9c, 0x1, 0x43, 0x3c, 0xcd, 0x82, 0xb8, 0x50, 0xf4, 0x60}, + {0xfc, 0x82, 0x17, 0x6b, 0x3, 0x52, 0x2c, 0xe, 0xb4, 0x83, 0xad, + 0x6c, 0x81, 0x6c, 0x81, 0x64, 0x3e, 0x7, 0x64, 0x69, 0xd9, 0xbd, + 0xdc, 0xd0, 0x20, 0xc5, 0x64, 0x1, 0xf7, 0x9d, 0xd9, 0x13}, + {0xca, 0xc0, 0xe5, 0x21, 0xc3, 0x5e, 0x4b, 0x1, 0xa2, 0xbf, 0x19, + 0xd7, 0xc9, 0x69, 0xcb, 0x4f, 0xa0, 0x23, 0x0, 0x75, 0x18, 0x1c, + 0x5f, 0x4e, 0x80, 0xac, 0xed, 0x55, 0x9e, 0xde, 0x6, 0x1c}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1454933046815146, 874696014266362, 1467170975468588, - 1432316382418897, 2111710746366763 -#else - 57502122, 21680191, 20414458, 13033986, 13716524, 21862551, - 19797969, 21343177, 15192875, 31466942 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2105387117364450, 1996463405126433, 1303008614294500, - 851908115948209, 1353742049788635 -#else - 54445282, 31372712, 1168161, 29749623, 26747876, 19416341, - 10609329, 12694420, 33473243, 20172328 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 750300956351719, 1487736556065813, 15158817002104, - 1511998221598392, 971739901354129 -#else - 33184999, 11180355, 15832085, 22169002, 65475192, 225883, - 15089336, 22530529, 60973201, 14480052 -#endif - }}, + {0xaa, 0x69, 0x6d, 0xff, 0x40, 0x2b, 0xd5, 0xff, 0xbb, 0x49, 0x40, + 0xdc, 0x18, 0xb, 0x53, 0x34, 0x97, 0x98, 0x4d, 0xa3, 0x2f, 0x5c, + 0x4a, 0x5e, 0x2d, 0xba, 0x32, 0x7d, 0x8e, 0x6f, 0x9, 0x78}, + {0xe2, 0xc4, 0x3e, 0xa3, 0xd6, 0x7a, 0xf, 0x99, 0x8e, 0xe0, 0x2e, + 0xbe, 0x38, 0xf9, 0x8, 0x66, 0x15, 0x45, 0x28, 0x63, 0xc5, 0x43, + 0xa1, 0x9c, 0xd, 0xb6, 0x2d, 0xec, 0x1f, 0x8a, 0xf3, 0x4c}, + {0xe7, 0x5c, 0xfa, 0xd, 0x65, 0xaa, 0xaa, 0xa0, 0x8c, 0x47, 0xb5, + 0x48, 0x2a, 0x9e, 0xc4, 0xf9, 0x5b, 0x72, 0x3, 0x70, 0x7d, 0xcc, + 0x9, 0x4f, 0xbe, 0x1a, 0x9, 0x26, 0x3a, 0xad, 0x3c, 0x37}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1874648163531693, 2124487685930551, 1810030029384882, - 918400043048335, 586348627300650 -#else - 31308717, 27934434, 31030839, 31657333, 15674546, 26971549, - 5496207, 13685227, 27595050, 8737275 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1235084464747900, 1166111146432082, 1745394857881591, - 1405516473883040, 4463504151617 -#else - 46790012, 18404192, 10933842, 17376410, 8335351, 26008410, - 36100512, 20943827, 26498113, 66511 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1663810156463827, 327797390285791, 1341846161759410, - 1964121122800605, 1747470312055380 -#else - 22644435, 24792703, 50437087, 4884561, 64003250, 19995065, - 30540765, 29267685, 53781076, 26039336 -#endif - }}, + {0xad, 0xbb, 0xdd, 0x89, 0xfb, 0xa8, 0xbe, 0xf1, 0xcb, 0xae, 0xae, + 0x61, 0xbc, 0x2c, 0xcb, 0x3b, 0x9d, 0x8d, 0x9b, 0x1f, 0xbb, 0xa7, + 0x58, 0x8f, 0x86, 0xa6, 0x12, 0x51, 0xda, 0x7e, 0x54, 0x21}, + {0x7c, 0xf5, 0xc9, 0x82, 0x4d, 0x63, 0x94, 0xb2, 0x36, 0x45, 0x93, + 0x24, 0xe1, 0xfd, 0xcb, 0x1f, 0x5a, 0xdb, 0x8c, 0x41, 0xb3, 0x4d, + 0x9c, 0x9e, 0xfc, 0x19, 0x44, 0x45, 0xd9, 0xf3, 0x40, 0x0}, + {0xd3, 0x86, 0x59, 0xfd, 0x39, 0xe9, 0xfd, 0xde, 0xc, 0x38, 0xa, + 0x51, 0x89, 0x2c, 0x27, 0xf4, 0xb9, 0x19, 0x31, 0xbb, 0x7, 0xa4, + 0x2b, 0xb7, 0xf4, 0x4d, 0x25, 0x4a, 0x33, 0xa, 0x55, 0x63}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 660005247548233, 2071860029952887, 1358748199950107, - 911703252219107, 1014379923023831 -#else - 39091017, 9834844, 18617207, 30873120, 63706907, 20246925, - 8205539, 13585437, 49981399, 15115438 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2206641276178231, 1690587809721504, 1600173622825126, - 2156096097634421, 1106822408548216 -#else - 23711543, 32881517, 31206560, 25191721, 6164646, 23844445, - 33572981, 32128335, 8236920, 16492939 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1344788193552206, 1949552134239140, 1735915881729557, - 675891104100469, 1834220014427292 -#else - 43198286, 20038905, 40809380, 29050590, 25005589, 25867162, - 19574901, 10071562, 6708380, 27332008 -#endif - }}, + {0x49, 0x7b, 0x54, 0x72, 0x45, 0x58, 0xba, 0x9b, 0xe0, 0x8, 0xc4, + 0xe2, 0xfa, 0xc6, 0x5, 0xf3, 0x8d, 0xf1, 0x34, 0xc7, 0x69, 0xfa, + 0xe8, 0x60, 0x7a, 0x76, 0x7d, 0xaa, 0xaf, 0x2b, 0xa9, 0x39}, + {0x37, 0xcf, 0x69, 0xb5, 0xed, 0xd6, 0x7, 0x65, 0xe1, 0x2e, 0xa5, + 0xc, 0xb0, 0x29, 0x84, 0x17, 0x5d, 0xd6, 0x6b, 0xeb, 0x90, 0x0, + 0x7c, 0xea, 0x51, 0x8f, 0xf7, 0xda, 0xc7, 0x62, 0xea, 0x3e}, + {0x4e, 0x27, 0x93, 0xe6, 0x13, 0xc7, 0x24, 0x9d, 0x75, 0xd3, 0xdb, + 0x68, 0x77, 0x85, 0x63, 0x5f, 0x9a, 0xb3, 0x8a, 0xeb, 0x60, 0x55, + 0x52, 0x70, 0xcd, 0xc4, 0xc9, 0x65, 0x6, 0x6a, 0x43, 0x68}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1920949492387964, 158885288387530, 70308263664033, - 626038464897817, 1468081726101009 -#else - 2101372, 28624378, 19702730, 2367575, 51681697, 1047674, - 5301017, 9328700, 29955601, 21876122 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 622221042073383, 1210146474039168, 1742246422343683, - 1403839361379025, 417189490895736 -#else - 3096359, 9271816, 45488000, 18032587, 52260867, 25961494, - 41216721, 20918836, 57191288, 6216607 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 22727256592983, 168471543384997, 1324340989803650, - 1839310709638189, 504999476432775 -#else - 34493015, 338662, 41913253, 2510421, 37895298, 19734218, - 24822829, 27407865, 40341383, 7525078 -#endif - }}, + {0x7c, 0x10, 0x20, 0xe8, 0x17, 0xd3, 0x56, 0x1e, 0x65, 0xe9, 0xa, + 0x84, 0x44, 0x68, 0x26, 0xc5, 0x7a, 0xfc, 0xf, 0x32, 0xc6, 0xa1, + 0xe0, 0xc1, 0x72, 0x14, 0x61, 0x91, 0x9c, 0x66, 0x73, 0x53}, + {0x27, 0x3f, 0x2f, 0x20, 0xe8, 0x35, 0x2, 0xbc, 0xb0, 0x75, 0xf9, + 0x64, 0xe2, 0x0, 0x5c, 0xc7, 0x16, 0x24, 0x8c, 0xa3, 0xd5, 0xe9, + 0xa4, 0x91, 0xf9, 0x89, 0xb7, 0x8a, 0xf6, 0xe7, 0xb6, 0x17}, + {0x57, 0x52, 0xe, 0x9a, 0xab, 0x14, 0x28, 0x5d, 0xfc, 0xb3, 0xca, + 0xc9, 0x84, 0x20, 0x8f, 0x90, 0xca, 0x1e, 0x2d, 0x5b, 0x88, 0xf5, + 0xca, 0xaf, 0x11, 0x7d, 0xf8, 0x78, 0xa6, 0xb5, 0xb4, 0x1c}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1313240518756327, 1721896294296942, 52263574587266, - 2065069734239232, 804910473424630 -#else - 44042215, 19568808, 16133486, 25658254, 63719298, 778787, - 66198528, 30771936, 47722230, 11994100 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1337466662091884, 1287645354669772, 2018019646776184, - 652181229374245, 898011753211715 -#else - 21691500, 19929806, 66467532, 19187410, 3285880, 30070836, - 42044197, 9718257, 59631427, 13381417 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1969792547910734, 779969968247557, 2011350094423418, - 1823964252907487, 1058949448296945 -#else - 18445390, 29352196, 14979845, 11622458, 65381754, 29971451, - 23111647, 27179185, 28535281, 15779576 -#endif - }}, + {0xe7, 0x7, 0xa0, 0xa2, 0x62, 0xaa, 0x74, 0x6b, 0xb1, 0xc7, 0x71, + 0xf0, 0xb0, 0xe0, 0x11, 0xf3, 0x23, 0xe2, 0xb, 0x0, 0x38, 0xe4, + 0x7, 0x57, 0xac, 0x6e, 0xef, 0x82, 0x2d, 0xfd, 0xc0, 0x2d}, + {0x6c, 0xfc, 0x4a, 0x39, 0x6b, 0xc0, 0x64, 0xb6, 0xb1, 0x5f, 0xda, + 0x98, 0x24, 0xde, 0x88, 0xc, 0x34, 0xd8, 0xca, 0x4b, 0x16, 0x3, + 0x8d, 0x4f, 0xa2, 0x34, 0x74, 0xde, 0x78, 0xca, 0xb, 0x33}, + {0x4e, 0x74, 0x19, 0x11, 0x84, 0xff, 0x2e, 0x98, 0x24, 0x47, 0x7, + 0x2b, 0x96, 0x5e, 0x69, 0xf9, 0xfb, 0x53, 0xc9, 0xbf, 0x4f, 0xc1, + 0x8a, 0xc5, 0xf5, 0x1c, 0x9f, 0x36, 0x1b, 0xbe, 0x31, 0x3c}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 207343737062002, 1118176942430253, 758894594548164, - 806764629546266, 1157700123092949 -#else - 30098034, 3089662, 57874477, 16662134, 45801924, 11308410, - 53040410, 12021729, 9955285, 17251076 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1273565321399022, 1638509681964574, 759235866488935, - 666015124346707, 897983460943405 -#else - 9734894, 18977602, 59635230, 24415696, 2060391, 11313496, - 48682835, 9924398, 20194861, 13380996 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1717263794012298, 1059601762860786, 1837819172257618, - 1054130665797229, 680893204263559 -#else - 40730762, 25589224, 44941042, 15789296, 49053522, 27385639, - 65123949, 15707770, 26342023, 10146099 -#endif - }}, + {0x72, 0x42, 0xcb, 0xf9, 0x93, 0xbc, 0x68, 0xc1, 0x98, 0xdb, 0xce, + 0xc7, 0x1f, 0x71, 0xb8, 0xae, 0x7a, 0x8d, 0xac, 0x34, 0xaa, 0x52, + 0xe, 0x7f, 0xbb, 0x55, 0x7d, 0x7e, 0x9, 0xc1, 0xce, 0x41}, + {0xee, 0x8a, 0x94, 0x8, 0x4d, 0x86, 0xf4, 0xb0, 0x6f, 0x1c, 0xba, + 0x91, 0xee, 0x19, 0xdc, 0x7, 0x58, 0xa1, 0xac, 0xa6, 0xae, 0xcd, + 0x75, 0x79, 0xbb, 0xd4, 0x62, 0x42, 0x13, 0x61, 0xb, 0x33}, + {0x8a, 0x80, 0x6d, 0xa2, 0xd7, 0x19, 0x96, 0xf7, 0x6d, 0x15, 0x9e, + 0x1d, 0x9e, 0xd4, 0x1f, 0xbb, 0x27, 0xdf, 0xa1, 0xdb, 0x6c, 0xc3, + 0xd7, 0x73, 0x7d, 0x77, 0x28, 0x1f, 0xd9, 0x4c, 0xb4, 0x26}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2237039662793603, 2249022333361206, 2058613546633703, - 149454094845279, 2215176649164582 -#else - 41091971, 33334488, 21339190, 33513044, 19745255, 30675732, - 37471583, 2227039, 21612326, 33008704 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 79472182719605, 1851130257050174, 1825744808933107, - 821667333481068, 781795293511946 -#else - 54031477, 1184227, 23562814, 27583990, 46757619, 27205717, - 25764460, 12243797, 46252298, 11649657 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 755822026485370, 152464789723500, 1178207602290608, - 410307889503239, 156581253571278 -#else - 57077370, 11262625, 27384172, 2271902, 26947504, 17556661, - 39943, 6114064, 33514190, 2333242 -#endif - }}, + {0x83, 0x3, 0x73, 0x62, 0x93, 0xf2, 0xb7, 0xe1, 0x2c, 0x8a, 0xca, + 0xeb, 0xff, 0x79, 0x52, 0x4b, 0x14, 0x13, 0xd4, 0xbf, 0x8a, 0x77, + 0xfc, 0xda, 0xf, 0x61, 0x72, 0x9c, 0x14, 0x10, 0xeb, 0x7d}, + {0x75, 0x74, 0x38, 0x8f, 0x47, 0x48, 0xf0, 0x51, 0x3c, 0xcb, 0xbe, + 0x9c, 0xf4, 0xbc, 0x5d, 0xb2, 0x55, 0x20, 0x9f, 0xd9, 0x44, 0x12, + 0xab, 0x9a, 0xd6, 0xa5, 0x10, 0x1c, 0x6c, 0x9e, 0x70, 0x2c}, + {0x7a, 0xee, 0x66, 0x87, 0x6a, 0xaf, 0x62, 0xcb, 0xe, 0xcd, 0x53, + 0x55, 0x4, 0xec, 0xcb, 0x66, 0xb5, 0xe4, 0xb, 0xf, 0x38, 0x1, + 0x80, 0x58, 0xea, 0xe2, 0x2c, 0xf6, 0x9f, 0x8e, 0xe6, 0x8}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1418185496130297, 484520167728613, 1646737281442950, - 1401487684670265, 1349185550126961 -#else - 45675257, 21132610, 8119781, 7219913, 45278342, 24538297, - 60429113, 20883793, 24350577, 20104431 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1495380034400429, 325049476417173, 46346894893933, - 1553408840354856, 828980101835683 -#else - 62992557, 22282898, 43222677, 4843614, 37020525, 690622, - 35572776, 23147595, 8317859, 12352766 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1280337889310282, 2070832742866672, 1640940617225222, - 2098284908289951, 450929509534434 -#else - 18200138, 19078521, 34021104, 30857812, 43406342, 24451920, - 43556767, 31266881, 20712162, 6719373 -#endif - }}, + {0xf9, 0xf2, 0xb8, 0xa, 0xd5, 0x9, 0x2d, 0x2f, 0xdf, 0x23, 0x59, + 0xc5, 0x8d, 0x21, 0xb9, 0xac, 0xb9, 0x6c, 0x76, 0x73, 0x26, 0x34, + 0x8f, 0x4a, 0xf5, 0x19, 0xf7, 0x38, 0xd7, 0x3b, 0xb1, 0x4c}, + {0xad, 0x30, 0xc1, 0x4b, 0xa, 0x50, 0xad, 0x34, 0x9c, 0xd4, 0xb, + 0x3d, 0x49, 0xdb, 0x38, 0x8d, 0xbe, 0x89, 0xa, 0x50, 0x98, 0x3d, + 0x5c, 0xa2, 0x9, 0x3b, 0xba, 0xee, 0x87, 0x3f, 0x1f, 0x2f}, + {0x4a, 0xb6, 0x15, 0xe5, 0x75, 0x8c, 0x84, 0xf7, 0x38, 0x90, 0x4a, + 0xdb, 0xba, 0x1, 0x95, 0xa5, 0x50, 0x1b, 0x75, 0x3f, 0x3f, 0x31, + 0xd, 0xc2, 0xe8, 0x2e, 0xae, 0xc0, 0x53, 0xe3, 0xa1, 0x19}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 407703353998781, 126572141483652, 286039827513621, - 1999255076709338, 2030511179441770 -#else - 26656189, 6075253, 59250308, 1886071, 38764821, 4262325, - 11117530, 29791222, 26224234, 30256974 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1254958221100483, 1153235960999843, 942907704968834, - 637105404087392, 1149293270147267 -#else - 49939907, 18700334, 63713187, 17184554, 47154818, 14050419, - 21728352, 9493610, 18620611, 17125804 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 894249020470196, 400291701616810, 406878712230981, - 1599128793487393, 1145868722604026 -#else - 53785524, 13325348, 11432106, 5964811, 18609221, 6062965, - 61839393, 23828875, 36407290, 17074774 -#endif - }}, + {0xbd, 0xbd, 0x96, 0xd5, 0xcd, 0x72, 0x21, 0xb4, 0x40, 0xfc, 0xee, + 0x98, 0x43, 0x45, 0xe0, 0x93, 0xb5, 0x9, 0x41, 0xb4, 0x47, 0x53, + 0xb1, 0x9f, 0x34, 0xae, 0x66, 0x2, 0x99, 0xd3, 0x6b, 0x73}, + {0xc3, 0x5, 0xfa, 0xba, 0x60, 0x75, 0x1c, 0x7d, 0x61, 0x5e, 0xe5, + 0xc6, 0xa0, 0xa0, 0xe1, 0xb3, 0x73, 0x64, 0xd6, 0xc0, 0x18, 0x97, + 0x52, 0xe3, 0x86, 0x34, 0xc, 0xc2, 0x11, 0x6b, 0x54, 0x41}, + {0xb4, 0xb3, 0x34, 0x93, 0x50, 0x2d, 0x53, 0x85, 0x73, 0x65, 0x81, + 0x60, 0x4b, 0x11, 0xfd, 0x46, 0x75, 0x83, 0x5c, 0x42, 0x30, 0x5f, + 0x5f, 0xcc, 0x5c, 0xab, 0x7f, 0xb8, 0xa2, 0x95, 0x22, 0x41}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1497955250203334, 110116344653260, 1128535642171976, - 1900106496009660, 129792717460909 -#else - 43248326, 22321272, 26961356, 1640861, 34695752, 16816491, - 12248508, 28313793, 13735341, 1934062 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 452487513298665, 1352120549024569, 1173495883910956, - 1999111705922009, 367328130454226 -#else - 25089769, 6742589, 17081145, 20148166, 21909292, 17486451, - 51972569, 29789085, 45830866, 5473615 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1717539401269642, 1475188995688487, 891921989653942, - 836824441505699, 1885988485608364 -#else - 31883658, 25593331, 1083431, 21982029, 22828470, 13290673, - 59983779, 12469655, 29111212, 28103418 -#endif - }}, + {0xc6, 0xea, 0x93, 0xe2, 0x61, 0x52, 0x65, 0x2e, 0xdb, 0xac, 0x33, + 0x21, 0x3, 0x92, 0x5a, 0x84, 0x6b, 0x99, 0x0, 0x79, 0xcb, 0x75, + 0x9, 0x46, 0x80, 0xdd, 0x5a, 0x19, 0x8d, 0xbb, 0x60, 0x7}, + {0xe9, 0xd6, 0x7e, 0xf5, 0x88, 0x9b, 0xc9, 0x19, 0x25, 0xc8, 0xf8, + 0x6d, 0x26, 0xcb, 0x93, 0x53, 0x73, 0xd2, 0xa, 0xb3, 0x13, 0x32, + 0xee, 0x5c, 0x34, 0x2e, 0x2d, 0xb5, 0xeb, 0x53, 0xe1, 0x14}, + {0x8a, 0x81, 0xe6, 0xcd, 0x17, 0x1a, 0x3e, 0x41, 0x84, 0xa0, 0x69, + 0xed, 0xa9, 0x6d, 0x15, 0x57, 0xb1, 0xcc, 0xca, 0x46, 0x8f, 0x26, + 0xbf, 0x2c, 0xf2, 0xc5, 0x3a, 0xc3, 0x9b, 0xbe, 0x34, 0x6b}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1241784121422547, 187337051947583, 1118481812236193, - 428747751936362, 30358898927325 -#else - 24244947, 18504025, 40845887, 2791539, 52111265, 16666677, - 24367466, 6388839, 56813277, 452382 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2022432361201842, 1088816090685051, 1977843398539868, - 1854834215890724, 564238862029357 -#else - 41468082, 30136590, 5217915, 16224624, 19987036, 29472163, - 42872612, 27639183, 15766061, 8407814 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 938868489100585, 1100285072929025, 1017806255688848, - 1957262154788833, 152787950560442 -#else - 46701865, 13990230, 15495425, 16395525, 5377168, 15166495, - 58191841, 29165478, 59040954, 2276717 -#endif - }}, + {0xd3, 0xf2, 0x71, 0x65, 0x65, 0x69, 0xfc, 0x11, 0x7a, 0x73, 0xe, + 0x53, 0x45, 0xe8, 0xc9, 0xc6, 0x35, 0x50, 0xfe, 0xd4, 0xa2, 0xe7, + 0x3a, 0xe3, 0xb, 0xd3, 0x6d, 0x2e, 0xb6, 0xc7, 0xb9, 0x1}, + {0xb2, 0xc0, 0x78, 0x3a, 0x64, 0x2f, 0xdf, 0xf3, 0x7c, 0x2, 0x2e, + 0xf2, 0x1e, 0x97, 0x3e, 0x4c, 0xa3, 0xb5, 0xc1, 0x49, 0x5e, 0x1c, + 0x7d, 0xec, 0x2d, 0xdd, 0x22, 0x9, 0x8f, 0xc1, 0x12, 0x20}, + {0x29, 0x9d, 0xc8, 0x5a, 0xe5, 0x55, 0xb, 0x88, 0x63, 0xa7, 0xa0, + 0x45, 0x1f, 0x24, 0x83, 0x14, 0x1f, 0x6c, 0xe7, 0xc2, 0xdf, 0xef, + 0x36, 0x3d, 0xe8, 0xad, 0x4b, 0x4e, 0x78, 0x5b, 0xaf, 0x8}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 867319417678923, 620471962942542, 226032203305716, - 342001443957629, 1761675818237336 -#else - 30157899, 12924066, 49396814, 9245752, 19895028, 3368142, - 43281277, 5096218, 22740376, 26251015 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1295072362439987, 931227904689414, 1355731432641687, - 922235735834035, 892227229410209 -#else - 2041139, 19298082, 7783686, 13876377, 41161879, 20201972, - 24051123, 13742383, 51471265, 13295221 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1680989767906154, 535362787031440, 2136691276706570, - 1942228485381244, 1267350086882274 -#else - 33338218, 25048699, 12532112, 7977527, 9106186, 31839181, - 49388668, 28941459, 62657506, 18884987 -#endif - }}, + {0x4b, 0x2c, 0xcc, 0x89, 0xd2, 0x14, 0x73, 0xe2, 0x8d, 0x17, 0x87, + 0xa2, 0x11, 0xbd, 0xe4, 0x4b, 0xce, 0x64, 0x33, 0xfa, 0xd6, 0x28, + 0xd5, 0x18, 0x6e, 0x82, 0xd9, 0xaf, 0xd5, 0xc1, 0x23, 0x64}, + {0x33, 0x25, 0x1f, 0x88, 0xdc, 0x99, 0x34, 0x28, 0xb6, 0x23, 0x93, + 0x77, 0xda, 0x25, 0x5, 0x9d, 0xf4, 0x41, 0x34, 0x67, 0xfb, 0xdd, + 0x7a, 0x89, 0x8d, 0x16, 0x3a, 0x16, 0x71, 0x9d, 0xb7, 0x32}, + {0x6a, 0xb3, 0xfc, 0xed, 0xd9, 0xf8, 0x85, 0xcc, 0xf9, 0xe5, 0x46, + 0x37, 0x8f, 0xc2, 0xbc, 0x22, 0xcd, 0xd3, 0xe5, 0xf9, 0x38, 0xe3, + 0x9d, 0xe4, 0xcc, 0x2d, 0x3e, 0xc1, 0xfb, 0x5e, 0xa, 0x48}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 366018233770527, 432660629755596, 126409707644535, - 1973842949591662, 645627343442376 -#else - 47063583, 5454096, 52762316, 6447145, 28862071, 1883651, - 64639598, 29412551, 7770568, 9620597 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 535509430575217, 546885533737322, 1524675609547799, - 2138095752851703, 1260738089896827 -#else - 23208049, 7979712, 33071466, 8149229, 1758231, 22719437, - 30945527, 31860109, 33606523, 18786461 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1159906385590467, 2198530004321610, 714559485023225, - 81880727882151, 1484020820037082 -#else - 1439939, 17283952, 66028874, 32760649, 4625401, 10647766, - 62065063, 1220117, 30494170, 22113633 -#endif - }}, + {0x1f, 0x22, 0xce, 0x42, 0xe4, 0x4c, 0x61, 0xb6, 0x28, 0x39, 0x5, + 0x4c, 0xcc, 0x9d, 0x19, 0x6e, 0x3, 0xbe, 0x1c, 0xdc, 0xa4, 0xb4, + 0x3f, 0x66, 0x6, 0x8e, 0x1c, 0x69, 0x47, 0x1d, 0xb3, 0x24}, + {0x71, 0x20, 0x62, 0x1, 0xb, 0xe7, 0x51, 0xb, 0xc5, 0xaf, 0x1d, + 0x8b, 0xcf, 0x5, 0xb5, 0x6, 0xcd, 0xab, 0x5a, 0xef, 0x61, 0xb0, + 0x6b, 0x2c, 0x31, 0xbf, 0xb7, 0xc, 0x60, 0x27, 0xaa, 0x47}, + {0xc3, 0xf8, 0x15, 0xc0, 0xed, 0x1e, 0x54, 0x2a, 0x7c, 0x3f, 0x69, + 0x7c, 0x7e, 0xfe, 0xa4, 0x11, 0xd6, 0x78, 0xa2, 0x4e, 0x13, 0x66, + 0xaf, 0xf0, 0x94, 0xa0, 0xdd, 0x14, 0x5d, 0x58, 0x5b, 0x54}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1377485731340769, 2046328105512000, 1802058637158797, - 62146136768173, 1356993908853901 -#else - 62071265, 20526136, 64138304, 30492664, 15640973, 26852766, - 40369837, 926049, 65424525, 20220784 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2013612215646735, 1830770575920375, 536135310219832, - 609272325580394, 270684344495013 -#else - 13908495, 30005160, 30919927, 27280607, 45587000, 7989038, - 9021034, 9078865, 3353509, 4033511 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1237542585982777, 2228682050256790, 1385281931622824, - 593183794882890, 493654978552689 -#else - 37445433, 18440821, 32259990, 33209950, 24295848, 20642309, - 23161162, 8839127, 27485041, 7356032 -#endif - }}, + {0xe1, 0x21, 0xb3, 0xe3, 0xd0, 0xe4, 0x4, 0x62, 0x95, 0x1e, 0xff, + 0x28, 0x7a, 0x63, 0xaa, 0x3b, 0x9e, 0xbd, 0x99, 0x5b, 0xfd, 0xcf, + 0xc, 0xb, 0x71, 0xd0, 0xc8, 0x64, 0x3e, 0xdc, 0x22, 0x4d}, + {0xf, 0x3a, 0xd4, 0xa0, 0x5e, 0x27, 0xbf, 0x67, 0xbe, 0xee, 0x9b, + 0x8, 0x34, 0x8e, 0xe6, 0xad, 0x2e, 0xe7, 0x79, 0xd4, 0x4c, 0x13, + 0x89, 0x42, 0x54, 0x54, 0xba, 0x32, 0xc3, 0xf9, 0x62, 0xf}, + {0x39, 0x5f, 0x3b, 0xd6, 0x89, 0x65, 0xb4, 0xfc, 0x61, 0xcf, 0xcb, + 0x57, 0x3f, 0x6a, 0xae, 0x5c, 0x5, 0xfa, 0x3a, 0x95, 0xd2, 0xc2, + 0xba, 0xfe, 0x36, 0x14, 0x37, 0x36, 0x1a, 0xa0, 0xf, 0x1c}, }, }, { { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 47341488007760, 1891414891220257, 983894663308928, - 176161768286818, 1126261115179708 -#else - 9661008, 705443, 11980065, 28184278, 65480320, 14661172, - 60762722, 2625014, 28431036, 16782598 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1694030170963455, 502038567066200, 1691160065225467, - 949628319562187, 275110186693066 -#else - 43269631, 25243016, 41163352, 7480957, 49427195, 25200248, - 44562891, 14150564, 15970762, 4099461 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1124515748676336, 1661673816593408, 1499640319059718, - 1584929449166988, 558148594103306 -#else - 29262576, 16756590, 26350592, 24760869, 8529670, 22346382, - 13617292, 23617289, 11465738, 8317062 -#endif - }}, + {0x50, 0x6a, 0x93, 0x8c, 0xe, 0x2b, 0x8, 0x69, 0xb6, 0xc5, 0xda, + 0xc1, 0x35, 0xa0, 0xc9, 0xf9, 0x34, 0xb6, 0xdf, 0xc4, 0x54, 0x3e, + 0xb7, 0x6f, 0x40, 0xc1, 0x2b, 0x1d, 0x9b, 0x41, 0x5, 0x40}, + {0xff, 0x3d, 0x94, 0x22, 0xb6, 0x4, 0xc6, 0xd2, 0xa0, 0xb3, 0xcf, + 0x44, 0xce, 0xbe, 0x8c, 0xbc, 0x78, 0x86, 0x80, 0x97, 0xf3, 0x4f, + 0x25, 0x5d, 0xbf, 0xa6, 0x1c, 0x3b, 0x4f, 0x61, 0xa3, 0xf}, + {0xf0, 0x82, 0xbe, 0xb9, 0xbd, 0xfe, 0x3, 0xa0, 0x90, 0xac, 0x44, + 0x3a, 0xaf, 0xc1, 0x89, 0x20, 0x8e, 0xfa, 0x54, 0x19, 0x91, 0x9f, + 0x49, 0xf8, 0x42, 0xab, 0x40, 0xef, 0x8a, 0x21, 0xba, 0x1f}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1784525599998356, 1619698033617383, 2097300287550715, - 258265458103756, 1905684794832758 -#else - 41615764, 26591503, 32500199, 24135381, 44070139, 31252209, - 14898636, 3848455, 20969334, 28396916 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1288941072872766, 931787902039402, 190731008859042, - 2006859954667190, 1005931482221702 -#else - 46724414, 19206718, 48772458, 13884721, 34069410, 2842113, - 45498038, 29904543, 11177094, 14989547 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1465551264822703, 152905080555927, 680334307368453, - 173227184634745, 666407097159852 -#else - 42612143, 21838415, 16959895, 2278463, 12066309, 10137771, - 13515641, 2581286, 38621356, 9930239 -#endif - }}, + {0x94, 0x1, 0x7b, 0x3e, 0x4, 0x57, 0x3e, 0x4f, 0x7f, 0xaf, 0xda, + 0x8, 0xee, 0x3e, 0x1d, 0xa8, 0xf1, 0xde, 0xdc, 0x99, 0xab, 0xc6, + 0x39, 0xc8, 0xd5, 0x61, 0x77, 0xff, 0x13, 0x5d, 0x53, 0x6c}, + {0x3e, 0xf5, 0xc8, 0xfa, 0x48, 0x94, 0x54, 0xab, 0x41, 0x37, 0xa6, + 0x7b, 0x9a, 0xe8, 0xf6, 0x81, 0x1, 0x5e, 0x2b, 0x6c, 0x7d, 0x6c, + 0xfd, 0x74, 0x42, 0x6e, 0xc8, 0xa8, 0xca, 0x3a, 0x2e, 0x39}, + {0xaf, 0x35, 0x8a, 0x3e, 0xe9, 0x34, 0xbd, 0x4c, 0x16, 0xe8, 0x87, + 0x58, 0x44, 0x81, 0x7, 0x2e, 0xab, 0xb0, 0x9a, 0xf2, 0x76, 0x9c, + 0x31, 0x19, 0x3b, 0xc1, 0xa, 0xd5, 0xe4, 0x7f, 0xe1, 0x25}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2111017076203943, 1378760485794347, 1248583954016456, - 1352289194864422, 1895180776543896 -#else - 49357223, 31456605, 16544299, 20545132, 51194056, 18605350, - 18345766, 20150679, 16291480, 28240394 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 171348223915638, 662766099800389, 462338943760497, - 466917763340314, 656911292869115 -#else - 33879670, 2553287, 32678213, 9875984, 8534129, 6889387, - 57432090, 6957616, 4368891, 9788741 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 488623681976577, 866497561541722, 1708105560937768, - 1673781214218839, 1506146329818807 -#else - 16660737, 7281060, 56278106, 12911819, 20108584, 25452756, - 45386327, 24941283, 16250551, 22443329 -#endif - }}, + {0xa7, 0x21, 0xf1, 0x76, 0xf5, 0x7f, 0x5f, 0x91, 0xe3, 0x87, 0xcd, + 0x2f, 0x27, 0x32, 0x4a, 0xc3, 0x26, 0xe5, 0x1b, 0x4d, 0xde, 0x2f, + 0xba, 0xcc, 0x9b, 0x89, 0x69, 0x89, 0x8f, 0x82, 0xba, 0x6b}, + {0x76, 0xf6, 0x4, 0x1e, 0xd7, 0x9b, 0x28, 0xa, 0x95, 0xf, 0x42, + 0xd6, 0x52, 0x1c, 0x8e, 0x20, 0xab, 0x1f, 0x69, 0x34, 0xb0, 0xd8, + 0x86, 0x51, 0x51, 0xb3, 0x9f, 0x2a, 0x44, 0x51, 0x57, 0x25}, + {0x1, 0x39, 0xfe, 0x90, 0x66, 0xbc, 0xd1, 0xe2, 0xd5, 0x7a, 0x99, + 0xa0, 0x18, 0x4a, 0xb5, 0x4c, 0xd4, 0x60, 0x84, 0xaf, 0x14, 0x69, + 0x1d, 0x97, 0xe4, 0x7b, 0x6b, 0x7f, 0x4f, 0x50, 0x9d, 0x55}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 160425464456957, 950394373239689, 430497123340934, - 711676555398832, 320964687779005 -#else - 47343357, 2390525, 50557833, 14161979, 1905286, 6414907, - 4689584, 10604807, 36918461, 4782746 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 988979367990485, 1359729327576302, 1301834257246029, - 294141160829308, 29348272277475 -#else - 65754325, 14736940, 59741422, 20261545, 7710541, 19398842, - 57127292, 4383044, 22546403, 437323 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1434382743317910, 100082049942065, 221102347892623, - 186982837860588, 1305765053501834 -#else - 31665558, 21373968, 50922033, 1491338, 48740239, 3294681, - 27343084, 2786261, 36475274, 19457415 -#endif - }}, + {0xfd, 0x66, 0xd2, 0xf6, 0xe7, 0x91, 0x48, 0x9c, 0x1b, 0x78, 0x7, + 0x3, 0x9b, 0xa1, 0x44, 0x7, 0x3b, 0xe2, 0x61, 0x60, 0x1d, 0x8f, + 0x38, 0x88, 0xe, 0xd5, 0x4b, 0x35, 0xa3, 0xa6, 0x3e, 0x12}, + {0xd5, 0x54, 0xeb, 0xb3, 0x78, 0x83, 0x73, 0xa7, 0x7c, 0x3c, 0x55, + 0xa5, 0x66, 0xd3, 0x69, 0x1d, 0xba, 0x0, 0x28, 0xf9, 0x62, 0xcf, + 0x26, 0xa, 0x17, 0x32, 0x7e, 0x80, 0xd5, 0x12, 0xab, 0x1}, + {0x96, 0x2d, 0xe3, 0x41, 0x90, 0x18, 0x8d, 0x11, 0x48, 0x58, 0x31, + 0xd8, 0xc2, 0xe3, 0xed, 0xb9, 0xd9, 0x45, 0x32, 0xd8, 0x71, 0x42, + 0xab, 0x1e, 0x54, 0xa1, 0x18, 0xc9, 0xe2, 0x61, 0x39, 0x4a}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 2205916462268190, 499863829790820, 961960554686616, - 158062762756985, 1841471168298305 -#else - 52641566, 32870716, 33734756, 7448551, 19294360, 14334329, - 47418233, 2355318, 47824193, 27440058 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1191737341426592, 1847042034978363, 1382213545049056, - 1039952395710448, 788812858896859 -#else - 15121312, 17758270, 6377019, 27523071, 56310752, 20596586, - 18952176, 15496498, 37728731, 11754227 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1346965964571152, 1291881610839830, 2142916164336056, - 786821641205979, 1571709146321039 -#else - 64471568, 20071356, 8488726, 19250536, 12728760, 31931939, - 7141595, 11724556, 22761615, 23420291 -#endif - }}, + {0x1e, 0x3f, 0x23, 0xf3, 0x44, 0xd6, 0x27, 0x3, 0x16, 0xf0, 0xfc, + 0x34, 0xe, 0x26, 0x9a, 0x49, 0x79, 0xb9, 0xda, 0xf2, 0x16, 0xa7, + 0xb5, 0x83, 0x1f, 0x11, 0xd4, 0x9b, 0xad, 0xee, 0xac, 0x68}, + {0xa0, 0xbb, 0xe6, 0xf8, 0xe0, 0x3b, 0xdc, 0x71, 0xa, 0xe3, 0xff, + 0x7e, 0x34, 0xf8, 0xce, 0xd6, 0x6a, 0x47, 0x3a, 0xe1, 0x5f, 0x42, + 0x92, 0xa9, 0x63, 0xb7, 0x1d, 0xfb, 0xe3, 0xbc, 0xd6, 0x2c}, + {0x10, 0xc2, 0xd7, 0xf3, 0xe, 0xc9, 0xb4, 0x38, 0xc, 0x4, 0xad, + 0xb7, 0x24, 0x6e, 0x8e, 0x30, 0x23, 0x3e, 0xe7, 0xb7, 0xf1, 0xd9, + 0x60, 0x38, 0x97, 0xf5, 0x8, 0xb5, 0xd5, 0x60, 0x57, 0x59}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 787164375951248, 202869205373189, 1356590421032140, - 1431233331032510, 786341368775957 -#else - 16918416, 11729663, 49025285, 3022986, 36093132, 20214772, - 38367678, 21327038, 32851221, 11717399 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 492448143532951, 304105152670757, 1761767168301056, - 233782684697790, 1981295323106089 -#else - 11166615, 7338049, 60386341, 4531519, 37640192, 26252376, - 31474878, 3483633, 65915689, 29523600 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 665807507761866, 1343384868355425, 895831046139653, - 439338948736892, 1986828765695105 -#else - 66923210, 9921304, 31456609, 20017994, 55095045, 13348922, - 33142652, 6546660, 47123585, 29606055 -#endif - }}, + {0x90, 0x27, 0x2, 0xfd, 0xeb, 0xcb, 0x2a, 0x88, 0x60, 0x57, 0x11, + 0xc4, 0x5, 0x33, 0xaf, 0x89, 0xf4, 0x73, 0x34, 0x7d, 0xe3, 0x92, + 0xf4, 0x65, 0x2b, 0x5a, 0x51, 0x54, 0xdf, 0xc5, 0xb2, 0x2c}, + {0x97, 0x63, 0xaa, 0x4, 0xe1, 0xbf, 0x29, 0x61, 0xcb, 0xfc, 0xa7, + 0xa4, 0x8, 0x0, 0x96, 0x8f, 0x58, 0x94, 0x90, 0x7d, 0x89, 0xc0, + 0x8b, 0x3f, 0xa9, 0x91, 0xb2, 0xdc, 0x3e, 0xa4, 0x9f, 0x70}, + {0xca, 0x2a, 0xfd, 0x63, 0x8c, 0x5d, 0xa, 0xeb, 0xff, 0x4e, 0x69, + 0x2e, 0x66, 0xc1, 0x2b, 0xd2, 0x3a, 0xb0, 0xcb, 0xf8, 0x6e, 0xf3, + 0x23, 0x27, 0x1f, 0x13, 0xc8, 0xf0, 0xec, 0x29, 0xf0, 0x70}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 756096210874553, 1721699973539149, 258765301727885, - 1390588532210645, 1212530909934781 -#else - 34648249, 11266711, 55911757, 25655328, 31703693, 3855903, - 58571733, 20721383, 36336829, 18068118 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 852891097972275, 1816988871354562, 1543772755726524, - 1174710635522444, 202129090724628 -#else - 49102387, 12709067, 3991746, 27075244, 45617340, 23004006, - 35973516, 17504552, 10928916, 3011958 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1205281565824323, 22430498399418, 992947814485516, - 1392458699738672, 688441466734558 -#else - 60151107, 17960094, 31696058, 334240, 29576716, 14796075, - 36277808, 20749251, 18008030, 10258577 -#endif - }}, + {0xb9, 0xb0, 0x10, 0x5e, 0xaa, 0xaf, 0x6a, 0x2a, 0xa9, 0x1a, 0x4, + 0xef, 0x70, 0xa3, 0xf0, 0x78, 0x1f, 0xd6, 0x3a, 0xaa, 0x77, 0xfb, + 0x3e, 0x77, 0xe1, 0xd9, 0x4b, 0xa7, 0xa2, 0xa5, 0xec, 0x44}, + {0x33, 0x3e, 0xed, 0x2e, 0xb3, 0x7, 0x13, 0x46, 0xe7, 0x81, 0x55, + 0xa4, 0x33, 0x2f, 0x4, 0xae, 0x66, 0x3, 0x5f, 0x19, 0xd3, 0x49, + 0x44, 0xc9, 0x58, 0x48, 0x31, 0x6c, 0x8a, 0x5d, 0x7d, 0xb}, + {0x43, 0xd5, 0x95, 0x7b, 0x32, 0x48, 0xd4, 0x25, 0x1d, 0xf, 0x34, + 0xa3, 0x0, 0x83, 0xd3, 0x70, 0x2b, 0xc5, 0xe1, 0x60, 0x1c, 0x53, + 0x1c, 0xde, 0xe4, 0xe9, 0x7d, 0x2c, 0x51, 0x24, 0x22, 0x27}, }, { - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1050627428414972, 1955849529137135, 2171162376368357, - 91745868298214, 447733118757826 -#else - 44660220, 15655568, 7018479, 29144429, 36794597, 32352840, - 65255398, 1367119, 25127874, 6671743 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1287181461435438, 622722465530711, 880952150571872, - 741035693459198, 311565274989772 -#else - 29701166, 19180498, 56230743, 9279287, 67091296, 13127209, - 21382910, 11042292, 25838796, 4642684 -#endif - }}, - {{ -#if defined(BORINGSSL_CURVE25519_64BIT) - 1003649078149734, 545233927396469, 1849786171789880, - 1318943684880434, 280345687170552 -#else - 46678630, 14955536, 42982517, 8124618, 61739576, 27563961, - 30468146, 19653792, 18423288, 4177476 -#endif - }}, + {0xfc, 0x75, 0xa9, 0x42, 0x8a, 0xbb, 0x7b, 0xbf, 0x58, 0xa3, 0xad, + 0x96, 0x77, 0x39, 0x5c, 0x8c, 0x48, 0xaa, 0xed, 0xcd, 0x6f, 0xc7, + 0x7f, 0xe2, 0xa6, 0x20, 0xbc, 0xf6, 0xd7, 0x5f, 0x73, 0x19}, + {0x2e, 0x34, 0xc5, 0x49, 0xaf, 0x92, 0xbc, 0x1a, 0xd0, 0xfa, 0xe6, + 0xb2, 0x11, 0xd8, 0xee, 0xff, 0x29, 0x4e, 0xc8, 0xfc, 0x8d, 0x8c, + 0xa2, 0xef, 0x43, 0xc5, 0x4c, 0xa4, 0x18, 0xdf, 0xb5, 0x11}, + {0x66, 0x42, 0xc8, 0x42, 0xd0, 0x90, 0xab, 0xe3, 0x7e, 0x54, 0x19, + 0x7f, 0xf, 0x8e, 0x84, 0xeb, 0xb9, 0x97, 0xa4, 0x65, 0xd0, 0xa1, + 0x3, 0x25, 0x5f, 0x89, 0xdf, 0x91, 0x11, 0x91, 0xef, 0xf}, }, }, }; @@ -7639,7 +3031,7 @@ static const ge_precomp k25519Precomp[32][8] = { static const ge_precomp Bi[8] = { { {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 1288382639258501, 245678601348599, 269427782077623, 1462984067271730, 137412439391563 #else @@ -7648,7 +3040,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 62697248952638, 204681361388450, 631292143396476, 338455783676468, 1213667448819585 #else @@ -7657,7 +3049,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 301289933810280, 1259582250014073, 1422107436869536, 796239922652654, 1953934009299142 #else @@ -7668,7 +3060,7 @@ static const ge_precomp Bi[8] = { }, { {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 1601611775252272, 1720807796594148, 1132070835939856, 1260455018889551, 2147779492816911 #else @@ -7677,7 +3069,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 316559037616741, 2177824224946892, 1459442586438991, 1461528397712656, 751590696113597 #else @@ -7686,7 +3078,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 1850748884277385, 1200145853858453, 1068094770532492, 672251375690438, 1586055907191707 #else @@ -7697,7 +3089,7 @@ static const ge_precomp Bi[8] = { }, { {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 769950342298419, 132954430919746, 844085933195555, 974092374476333, 726076285546016 #else @@ -7706,7 +3098,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 425251763115706, 608463272472562, 442562545713235, 837766094556764, 374555092627893 #else @@ -7715,7 +3107,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 1086255230780037, 274979815921559, 1960002765731872, 929474102396301, 1190409889297339 #else @@ -7726,7 +3118,7 @@ static const ge_precomp Bi[8] = { }, { {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 665000864555967, 2065379846933859, 370231110385876, 350988370788628, 1233371373142985 #else @@ -7735,7 +3127,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 2019367628972465, 676711900706637, 110710997811333, 1108646842542025, 517791959672113 #else @@ -7744,7 +3136,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 965130719900578, 247011430587952, 526356006571389, 91986625355052, 2157223321444601 #else @@ -7755,7 +3147,7 @@ static const ge_precomp Bi[8] = { }, { {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 1802695059465007, 1664899123557221, 593559490740857, 2160434469266659, 927570450755031 #else @@ -7764,7 +3156,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 1725674970513508, 1933645953859181, 1542344539275782, 1767788773573747, 1297447965928905 #else @@ -7773,7 +3165,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 1381809363726107, 1430341051343062, 2061843536018959, 1551778050872521, 2036394857967624 #else @@ -7784,7 +3176,7 @@ static const ge_precomp Bi[8] = { }, { {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 1970894096313054, 528066325833207, 1619374932191227, 2207306624415883, 1169170329061080 #else @@ -7793,7 +3185,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 2070390218572616, 1458919061857835, 624171843017421, 1055332792707765, 433987520732508 #else @@ -7802,7 +3194,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 893653801273833, 1168026499324677, 1242553501121234, 1306366254304474, 1086752658510815 #else @@ -7813,7 +3205,7 @@ static const ge_precomp Bi[8] = { }, { {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 213454002618221, 939771523987438, 1159882208056014, 317388369627517, 621213314200687 #else @@ -7822,7 +3214,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 1971678598905747, 338026507889165, 762398079972271, 655096486107477, 42299032696322 #else @@ -7831,7 +3223,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 177130678690680, 1754759263300204, 1864311296286618, 1180675631479880, 1292726903152791 #else @@ -7842,7 +3234,7 @@ static const ge_precomp Bi[8] = { }, { {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 1913163449625248, 460779200291993, 2193883288642314, 1008900146920800, 1721983679009502 #else @@ -7851,7 +3243,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 1070401523076875, 1272492007800961, 1910153608563310, 2075579521696771, 1191169788841221 #else @@ -7860,7 +3252,7 @@ static const ge_precomp Bi[8] = { #endif }}, {{ -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) 692896803108118, 500174642072499, 2068223309439677, 1162190621851337, 1426986007309901 #else diff --git a/Sources/CCryptoBoringSSL/crypto/curve25519/internal.h b/Sources/CCryptoBoringSSL/crypto/curve25519/internal.h index 5f246912..085894da 100644 --- a/Sources/CCryptoBoringSSL/crypto/curve25519/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/curve25519/internal.h @@ -15,14 +15,13 @@ #ifndef OPENSSL_HEADER_CURVE25519_INTERNAL_H #define OPENSSL_HEADER_CURVE25519_INTERNAL_H -#if defined(__cplusplus) -extern "C" { -#endif - -#include +#include #include "../internal.h" +#if defined(__cplusplus) +extern "C" { +#endif #if defined(OPENSSL_ARM) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_APPLE) #define BORINGSSL_X25519_NEON @@ -32,11 +31,28 @@ void x25519_NEON(uint8_t out[32], const uint8_t scalar[32], const uint8_t point[32]); #endif -#if defined(BORINGSSL_HAS_UINT128) -#define BORINGSSL_CURVE25519_64BIT +#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_SMALL) && \ + defined(__GNUC__) && defined(__x86_64__) +#define BORINGSSL_FE25519_ADX + +// fiat_curve25519_adx_mul is defined in +// third_party/fiat/asm/fiat_curve25519_adx_mul.S +void __attribute__((sysv_abi)) +fiat_curve25519_adx_mul(uint64_t out[4], const uint64_t in1[4], + const uint64_t in2[4]); + +// fiat_curve25519_adx_square is defined in +// third_party/fiat/asm/fiat_curve25519_adx_square.S +void __attribute__((sysv_abi)) +fiat_curve25519_adx_square(uint64_t out[4], const uint64_t in[4]); + +// x25519_scalar_mult_adx is defined in third_party/fiat/curve25519_64_adx.h +void x25519_scalar_mult_adx(uint8_t out[32], const uint8_t scalar[32], + const uint8_t point[32]); +void x25519_ge_scalarmult_base_adx(uint8_t h[4][32], const uint8_t a[32]); #endif -#if defined(BORINGSSL_CURVE25519_64BIT) +#if defined(OPENSSL_64_BIT) // fe means field element. Here the field is \Z/(2^255-19). An element t, // entries t[0]...t[4], represents the integer t[0]+2^51 t[1]+2^102 t[2]+2^153 // t[3]+2^204 t[4]. @@ -139,6 +155,8 @@ struct spake2_ctx_st { }; +extern const uint8_t k25519Precomp[32][8][3][32]; + #if defined(__cplusplus) } // extern C #endif diff --git a/Sources/CCryptoBoringSSL/crypto/dsa/dsa.c b/Sources/CCryptoBoringSSL/crypto/dsa/dsa.c index 75e5c4f4..e0906e68 100644 --- a/Sources/CCryptoBoringSSL/crypto/dsa/dsa.c +++ b/Sources/CCryptoBoringSSL/crypto/dsa/dsa.c @@ -202,6 +202,10 @@ int DSA_set0_pqg(DSA *dsa, BIGNUM *p, BIGNUM *q, BIGNUM *g) { dsa->g = g; } + BN_MONT_CTX_free(dsa->method_mont_p); + dsa->method_mont_p = NULL; + BN_MONT_CTX_free(dsa->method_mont_q); + dsa->method_mont_q = NULL; return 1; } diff --git a/Sources/CCryptoBoringSSL/crypto/dsa/internal.h b/Sources/CCryptoBoringSSL/crypto/dsa/internal.h index f38ce88e..eb537d6f 100644 --- a/Sources/CCryptoBoringSSL/crypto/dsa/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/dsa/internal.h @@ -17,11 +17,31 @@ #include +#include + +#include "../internal.h" + #if defined(__cplusplus) extern "C" { #endif +struct dsa_st { + BIGNUM *p; + BIGNUM *q; + BIGNUM *g; + + BIGNUM *pub_key; + BIGNUM *priv_key; + + // Normally used to cache montgomery values + CRYPTO_MUTEX method_mont_lock; + BN_MONT_CTX *method_mont_p; + BN_MONT_CTX *method_mont_q; + CRYPTO_refcount_t references; + CRYPTO_EX_DATA ex_data; +}; + // dsa_check_key performs cheap self-checks on |dsa|, and ensures it is within // DoS bounds. It returns one on success and zero on error. int dsa_check_key(const DSA *dsa); diff --git a/Sources/CCryptoBoringSSL/crypto/ec_extra/ec_asn1.c b/Sources/CCryptoBoringSSL/crypto/ec_extra/ec_asn1.c index 6e8e358d..7f3aa6c0 100644 --- a/Sources/CCryptoBoringSSL/crypto/ec_extra/ec_asn1.c +++ b/Sources/CCryptoBoringSSL/crypto/ec_extra/ec_asn1.c @@ -72,6 +72,16 @@ static const CBS_ASN1_TAG kParametersTag = static const CBS_ASN1_TAG kPublicKeyTag = CBS_ASN1_CONSTRUCTED | CBS_ASN1_CONTEXT_SPECIFIC | 1; +// TODO(https://crbug.com/boringssl/497): Allow parsers to specify a list of +// acceptable groups, so parsers don't have to pull in all four. +typedef const EC_GROUP *(*ec_group_func)(void); +static const ec_group_func kAllGroups[] = { + &EC_group_p224, + &EC_group_p256, + &EC_group_p384, + &EC_group_p521, +}; + EC_KEY *EC_KEY_parse_private_key(CBS *cbs, const EC_GROUP *group) { CBS ec_private_key, private_key; uint64_t version; @@ -84,7 +94,6 @@ EC_KEY *EC_KEY_parse_private_key(CBS *cbs, const EC_GROUP *group) { } // Parse the optional parameters field. - EC_GROUP *inner_group = NULL; EC_KEY *ret = NULL; BIGNUM *priv_key = NULL; if (CBS_peek_asn1_tag(&ec_private_key, kParametersTag)) { @@ -97,7 +106,7 @@ EC_KEY *EC_KEY_parse_private_key(CBS *cbs, const EC_GROUP *group) { OPENSSL_PUT_ERROR(EC, EC_R_DECODE_ERROR); goto err; } - inner_group = EC_KEY_parse_parameters(&child); + const EC_GROUP *inner_group = EC_KEY_parse_parameters(&child); if (inner_group == NULL) { goto err; } @@ -179,13 +188,11 @@ EC_KEY *EC_KEY_parse_private_key(CBS *cbs, const EC_GROUP *group) { } BN_free(priv_key); - EC_GROUP_free(inner_group); return ret; err: EC_KEY_free(ret); BN_free(priv_key); - EC_GROUP_free(inner_group); return NULL; } @@ -244,9 +251,12 @@ int EC_KEY_marshal_private_key(CBB *cbb, const EC_KEY *key, // kPrimeFieldOID is the encoding of 1.2.840.10045.1.1. static const uint8_t kPrimeField[] = {0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, 0x01}; -static int parse_explicit_prime_curve(CBS *in, CBS *out_prime, CBS *out_a, - CBS *out_b, CBS *out_base_x, - CBS *out_base_y, CBS *out_order) { +struct explicit_prime_curve { + CBS prime, a, b, base_x, base_y, order; +}; + +static int parse_explicit_prime_curve(CBS *in, + struct explicit_prime_curve *out) { // See RFC 3279, section 2.3.5. Note that RFC 3279 calls this structure an // ECParameters while RFC 5480 calls it a SpecifiedECDomain. CBS params, field_id, field_type, curve, base, cofactor; @@ -260,18 +270,18 @@ static int parse_explicit_prime_curve(CBS *in, CBS *out_prime, CBS *out_a, CBS_len(&field_type) != sizeof(kPrimeField) || OPENSSL_memcmp(CBS_data(&field_type), kPrimeField, sizeof(kPrimeField)) != 0 || - !CBS_get_asn1(&field_id, out_prime, CBS_ASN1_INTEGER) || - !CBS_is_unsigned_asn1_integer(out_prime) || + !CBS_get_asn1(&field_id, &out->prime, CBS_ASN1_INTEGER) || + !CBS_is_unsigned_asn1_integer(&out->prime) || CBS_len(&field_id) != 0 || !CBS_get_asn1(¶ms, &curve, CBS_ASN1_SEQUENCE) || - !CBS_get_asn1(&curve, out_a, CBS_ASN1_OCTETSTRING) || - !CBS_get_asn1(&curve, out_b, CBS_ASN1_OCTETSTRING) || + !CBS_get_asn1(&curve, &out->a, CBS_ASN1_OCTETSTRING) || + !CBS_get_asn1(&curve, &out->b, CBS_ASN1_OCTETSTRING) || // |curve| has an optional BIT STRING seed which we ignore. !CBS_get_optional_asn1(&curve, NULL, NULL, CBS_ASN1_BITSTRING) || CBS_len(&curve) != 0 || !CBS_get_asn1(¶ms, &base, CBS_ASN1_OCTETSTRING) || - !CBS_get_asn1(¶ms, out_order, CBS_ASN1_INTEGER) || - !CBS_is_unsigned_asn1_integer(out_order) || + !CBS_get_asn1(¶ms, &out->order, CBS_ASN1_INTEGER) || + !CBS_is_unsigned_asn1_integer(&out->order) || !CBS_get_optional_asn1(¶ms, &cofactor, &has_cofactor, CBS_ASN1_INTEGER) || CBS_len(¶ms) != 0) { @@ -300,25 +310,33 @@ static int parse_explicit_prime_curve(CBS *in, CBS *out_prime, CBS *out_a, return 0; } size_t field_len = CBS_len(&base) / 2; - CBS_init(out_base_x, CBS_data(&base), field_len); - CBS_init(out_base_y, CBS_data(&base) + field_len, field_len); + CBS_init(&out->base_x, CBS_data(&base), field_len); + CBS_init(&out->base_y, CBS_data(&base) + field_len, field_len); return 1; } -// integers_equal returns one if |a| and |b| are equal, up to leading zeros, and +// integers_equal returns one if |bytes| is a big-endian encoding of |bn|, and // zero otherwise. -static int integers_equal(const CBS *a, const uint8_t *b, size_t b_len) { - // Remove leading zeros from |a| and |b|. - CBS a_copy = *a; - while (CBS_len(&a_copy) > 0 && CBS_data(&a_copy)[0] == 0) { - CBS_skip(&a_copy, 1); +static int integers_equal(const CBS *bytes, const BIGNUM *bn) { + // Although, in SEC 1, Field-Element-to-Octet-String has a fixed width, + // OpenSSL mis-encodes the |a| and |b|, so we tolerate any number of leading + // zeros. (This matters for P-521 whose |b| has a leading 0.) + CBS copy = *bytes; + while (CBS_len(©) > 0 && CBS_data(©)[0] == 0) { + CBS_skip(©, 1); } - while (b_len > 0 && b[0] == 0) { - b++; - b_len--; + + if (CBS_len(©) > EC_MAX_BYTES) { + return 0; } - return CBS_mem_equal(&a_copy, b, b_len); + uint8_t buf[EC_MAX_BYTES]; + if (!BN_bn2bin_padded(buf, CBS_len(©), bn)) { + ERR_clear_error(); + return 0; + } + + return CBS_mem_equal(©, buf, CBS_len(©)); } EC_GROUP *EC_KEY_parse_curve_name(CBS *cbs) { @@ -329,13 +347,10 @@ EC_GROUP *EC_KEY_parse_curve_name(CBS *cbs) { } // Look for a matching curve. - const struct built_in_curves *const curves = OPENSSL_built_in_curves(); - for (size_t i = 0; i < OPENSSL_NUM_BUILT_IN_CURVES; i++) { - const struct built_in_curve *curve = &curves->curves[i]; - if (CBS_len(&named_curve) == curve->oid_len && - OPENSSL_memcmp(CBS_data(&named_curve), curve->oid, curve->oid_len) == - 0) { - return EC_GROUP_new_by_curve_name(curve->nid); + for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(kAllGroups); i++) { + const EC_GROUP *group = kAllGroups[i](); + if (CBS_mem_equal(&named_curve, group->oid, group->oid_len)) { + return (EC_GROUP *)group; } } @@ -344,25 +359,15 @@ EC_GROUP *EC_KEY_parse_curve_name(CBS *cbs) { } int EC_KEY_marshal_curve_name(CBB *cbb, const EC_GROUP *group) { - int nid = EC_GROUP_get_curve_name(group); - if (nid == NID_undef) { + if (group->oid_len == 0) { OPENSSL_PUT_ERROR(EC, EC_R_UNKNOWN_GROUP); return 0; } - const struct built_in_curves *const curves = OPENSSL_built_in_curves(); - for (size_t i = 0; i < OPENSSL_NUM_BUILT_IN_CURVES; i++) { - const struct built_in_curve *curve = &curves->curves[i]; - if (curve->nid == nid) { - CBB child; - return CBB_add_asn1(cbb, &child, CBS_ASN1_OBJECT) && - CBB_add_bytes(&child, curve->oid, curve->oid_len) && - CBB_flush(cbb); - } - } - - OPENSSL_PUT_ERROR(EC, EC_R_UNKNOWN_GROUP); - return 0; + CBB child; + return CBB_add_asn1(cbb, &child, CBS_ASN1_OBJECT) && + CBB_add_bytes(&child, group->oid, group->oid_len) && // + CBB_flush(cbb); } EC_GROUP *EC_KEY_parse_parameters(CBS *cbs) { @@ -374,34 +379,56 @@ EC_GROUP *EC_KEY_parse_parameters(CBS *cbs) { // of named curves. // // TODO(davidben): Remove support for this. - CBS prime, a, b, base_x, base_y, order; - if (!parse_explicit_prime_curve(cbs, &prime, &a, &b, &base_x, &base_y, - &order)) { + struct explicit_prime_curve curve; + if (!parse_explicit_prime_curve(cbs, &curve)) { return NULL; } - // Look for a matching prime curve. - const struct built_in_curves *const curves = OPENSSL_built_in_curves(); - for (size_t i = 0; i < OPENSSL_NUM_BUILT_IN_CURVES; i++) { - const struct built_in_curve *curve = &curves->curves[i]; - const unsigned param_len = curve->param_len; - // |curve->params| is ordered p, a, b, x, y, order, each component - // zero-padded up to the field length. Although SEC 1 states that the - // Field-Element-to-Octet-String conversion also pads, OpenSSL mis-encodes - // |a| and |b|, so this comparison must allow omitting leading zeros. (This - // is relevant for P-521 whose |b| has a leading 0.) - if (integers_equal(&prime, curve->params, param_len) && - integers_equal(&a, curve->params + param_len, param_len) && - integers_equal(&b, curve->params + param_len * 2, param_len) && - integers_equal(&base_x, curve->params + param_len * 3, param_len) && - integers_equal(&base_y, curve->params + param_len * 4, param_len) && - integers_equal(&order, curve->params + param_len * 5, param_len)) { - return EC_GROUP_new_by_curve_name(curve->nid); - } + const EC_GROUP *ret = NULL; + BIGNUM *p = BN_new(), *a = BN_new(), *b = BN_new(), *x = BN_new(), + *y = BN_new(); + if (p == NULL || a == NULL || b == NULL || x == NULL || y == NULL) { + goto err; } - OPENSSL_PUT_ERROR(EC, EC_R_UNKNOWN_GROUP); - return NULL; + for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(kAllGroups); i++) { + const EC_GROUP *group = kAllGroups[i](); + if (!integers_equal(&curve.order, EC_GROUP_get0_order(group))) { + continue; + } + + // The order alone uniquely identifies the group, but we check the other + // parameters to avoid misinterpreting the group. + if (!EC_GROUP_get_curve_GFp(group, p, a, b, NULL)) { + goto err; + } + if (!integers_equal(&curve.prime, p) || !integers_equal(&curve.a, a) || + !integers_equal(&curve.b, b)) { + break; + } + if (!EC_POINT_get_affine_coordinates_GFp( + group, EC_GROUP_get0_generator(group), x, y, NULL)) { + goto err; + } + if (!integers_equal(&curve.base_x, x) || + !integers_equal(&curve.base_y, y)) { + break; + } + ret = group; + break; + } + + if (ret == NULL) { + OPENSSL_PUT_ERROR(EC, EC_R_UNKNOWN_GROUP); + } + +err: + BN_free(p); + BN_free(a); + BN_free(b); + BN_free(x); + BN_free(y); + return (EC_GROUP *)ret; } int EC_POINT_point2cbb(CBB *out, const EC_GROUP *group, const EC_POINT *point, @@ -458,18 +485,16 @@ EC_KEY *d2i_ECParameters(EC_KEY **out_key, const uint8_t **inp, long len) { CBS cbs; CBS_init(&cbs, *inp, (size_t)len); - EC_GROUP *group = EC_KEY_parse_parameters(&cbs); + const EC_GROUP *group = EC_KEY_parse_parameters(&cbs); if (group == NULL) { return NULL; } EC_KEY *ret = EC_KEY_new(); if (ret == NULL || !EC_KEY_set_group(ret, group)) { - EC_GROUP_free(group); EC_KEY_free(ret); return NULL; } - EC_GROUP_free(group); if (out_key != NULL) { EC_KEY_free(*out_key); @@ -532,3 +557,16 @@ int i2o_ECPublicKey(const EC_KEY *key, uint8_t **outp) { // Historically, this function used the wrong return value on error. return ret > 0 ? ret : 0; } + +size_t EC_get_builtin_curves(EC_builtin_curve *out_curves, + size_t max_num_curves) { + if (max_num_curves > OPENSSL_ARRAY_SIZE(kAllGroups)) { + max_num_curves = OPENSSL_ARRAY_SIZE(kAllGroups); + } + for (size_t i = 0; i < max_num_curves; i++) { + const EC_GROUP *group = kAllGroups[i](); + out_curves[i].nid = group->curve_name; + out_curves[i].comment = group->comment; + } + return OPENSSL_ARRAY_SIZE(kAllGroups); +} diff --git a/Sources/CCryptoBoringSSL/crypto/ec_extra/ec_derive.c b/Sources/CCryptoBoringSSL/crypto/ec_extra/ec_derive.c index fe3693c1..fdbe521b 100644 --- a/Sources/CCryptoBoringSSL/crypto/ec_extra/ec_derive.c +++ b/Sources/CCryptoBoringSSL/crypto/ec_extra/ec_derive.c @@ -55,7 +55,8 @@ EC_KEY *EC_KEY_derive_from_secret(const EC_GROUP *group, const uint8_t *secret, } uint8_t derived[EC_KEY_DERIVE_EXTRA_BYTES + EC_MAX_BYTES]; - size_t derived_len = BN_num_bytes(&group->order) + EC_KEY_DERIVE_EXTRA_BYTES; + size_t derived_len = + BN_num_bytes(EC_GROUP_get0_order(group)) + EC_KEY_DERIVE_EXTRA_BYTES; assert(derived_len <= sizeof(derived)); if (!HKDF(derived, derived_len, EVP_sha256(), secret, secret_len, /*salt=*/NULL, /*salt_len=*/0, (const uint8_t *)info, @@ -74,10 +75,10 @@ EC_KEY *EC_KEY_derive_from_secret(const EC_GROUP *group, const uint8_t *secret, // enough. 2^(num_bytes(order)) < 2^8 * order, so: // // priv < 2^8 * order * 2^128 < order * order < order * R - !BN_from_montgomery(priv, priv, group->order_mont, ctx) || + !BN_from_montgomery(priv, priv, &group->order, ctx) || // Multiply by R^2 and do another Montgomery reduction to compute // priv * R^-1 * R^2 * R^-1 = priv mod order. - !BN_to_montgomery(priv, priv, group->order_mont, ctx) || + !BN_to_montgomery(priv, priv, &group->order, ctx) || !EC_POINT_mul(group, pub, priv, NULL, NULL, ctx) || !EC_KEY_set_group(key, group) || !EC_KEY_set_public_key(key, pub) || !EC_KEY_set_private_key(key, priv)) { diff --git a/Sources/CCryptoBoringSSL/crypto/ec_extra/hash_to_curve.c b/Sources/CCryptoBoringSSL/crypto/ec_extra/hash_to_curve.c index f013f6f6..2f7e19bb 100644 --- a/Sources/CCryptoBoringSSL/crypto/ec_extra/hash_to_curve.c +++ b/Sources/CCryptoBoringSSL/crypto/ec_extra/hash_to_curve.c @@ -179,12 +179,12 @@ static int hash_to_field2(const EC_GROUP *group, const EVP_MD *md, size_t msg_len) { size_t L; uint8_t buf[4 * EC_MAX_BYTES]; - if (!num_bytes_to_derive(&L, &group->field, k) || + if (!num_bytes_to_derive(&L, &group->field.N, k) || !expand_message_xmd(md, buf, 2 * L, msg, msg_len, dst, dst_len)) { return 0; } BN_ULONG words[2 * EC_MAX_WORDS]; - size_t num_words = 2 * group->field.width; + size_t num_words = 2 * group->field.N.width; big_endian_to_words(words, num_words, buf, L); group->meth->felem_reduce(group, out1, words, num_words); big_endian_to_words(words, num_words, buf + L, L); @@ -197,15 +197,16 @@ static int hash_to_field2(const EC_GROUP *group, const EVP_MD *md, static int hash_to_scalar(const EC_GROUP *group, const EVP_MD *md, EC_SCALAR *out, const uint8_t *dst, size_t dst_len, unsigned k, const uint8_t *msg, size_t msg_len) { + const BIGNUM *order = EC_GROUP_get0_order(group); size_t L; uint8_t buf[EC_MAX_BYTES * 2]; - if (!num_bytes_to_derive(&L, &group->order, k) || + if (!num_bytes_to_derive(&L, order, k) || !expand_message_xmd(md, buf, L, msg, msg_len, dst, dst_len)) { return 0; } BN_ULONG words[2 * EC_MAX_WORDS]; - size_t num_words = 2 * group->order.width; + size_t num_words = 2 * order->width; big_endian_to_words(words, num_words, buf, L); ec_scalar_reduce(group, out, words, num_words); return 1; @@ -230,7 +231,7 @@ static BN_ULONG sgn0(const EC_GROUP *group, const EC_FELEM *a) { } OPENSSL_UNUSED static int is_3mod4(const EC_GROUP *group) { - return group->field.width > 0 && (group->field.d[0] & 3) == 3; + return group->field.N.width > 0 && (group->field.N.d[0] & 3) == 3; } // sqrt_ratio_3mod4 implements the operation described in appendix F.2.1.2 @@ -273,7 +274,7 @@ static BN_ULONG sqrt_ratio_3mod4(const EC_GROUP *group, const EC_FELEM *Z, // in appendix F.2. static void map_to_curve_simple_swu(const EC_GROUP *group, const EC_FELEM *Z, const BN_ULONG *c1, size_t num_c1, - const EC_FELEM *c2, EC_RAW_POINT *out, + const EC_FELEM *c2, EC_JACOBIAN *out, const EC_FELEM *u) { // This function requires the prime be 3 mod 4, and that A = -3. assert(is_3mod4(group)); @@ -285,12 +286,12 @@ static void map_to_curve_simple_swu(const EC_GROUP *group, const EC_FELEM *Z, group->meth->felem_sqr; EC_FELEM tv1, tv2, tv3, tv4, tv5, tv6, x, y, y1; - felem_sqr(group, &tv1, u); // 1. tv1 = u^2 - felem_mul(group, &tv1, Z, &tv1); // 2. tv1 = Z * tv1 - felem_sqr(group, &tv2, &tv1); // 3. tv2 = tv1^2 - ec_felem_add(group, &tv2, &tv2, &tv1); // 4. tv2 = tv2 + tv1 - ec_felem_add(group, &tv3, &tv2, &group->one); // 5. tv3 = tv2 + 1 - felem_mul(group, &tv3, &group->b, &tv3); // 6. tv3 = B * tv3 + felem_sqr(group, &tv1, u); // 1. tv1 = u^2 + felem_mul(group, &tv1, Z, &tv1); // 2. tv1 = Z * tv1 + felem_sqr(group, &tv2, &tv1); // 3. tv2 = tv1^2 + ec_felem_add(group, &tv2, &tv2, &tv1); // 4. tv2 = tv2 + tv1 + ec_felem_add(group, &tv3, &tv2, ec_felem_one(group)); // 5. tv3 = tv2 + 1 + felem_mul(group, &tv3, &group->b, &tv3); // 6. tv3 = B * tv3 // 7. tv4 = CMOV(Z, -tv2, tv2 != 0) const BN_ULONG tv2_non_zero = ec_felem_non_zero_mask(group, &tv2); @@ -344,7 +345,7 @@ static void map_to_curve_simple_swu(const EC_GROUP *group, const EC_FELEM *Z, static int hash_to_curve(const EC_GROUP *group, const EVP_MD *md, const EC_FELEM *Z, const EC_FELEM *c2, unsigned k, - EC_RAW_POINT *out, const uint8_t *dst, size_t dst_len, + EC_JACOBIAN *out, const uint8_t *dst, size_t dst_len, const uint8_t *msg, size_t msg_len) { EC_FELEM u0, u1; if (!hash_to_field2(group, md, &u0, &u1, dst, dst_len, k, msg, msg_len)) { @@ -353,13 +354,13 @@ static int hash_to_curve(const EC_GROUP *group, const EVP_MD *md, // Compute |c1| = (p - 3) / 4. BN_ULONG c1[EC_MAX_WORDS]; - size_t num_c1 = group->field.width; - if (!bn_copy_words(c1, num_c1, &group->field)) { + size_t num_c1 = group->field.N.width; + if (!bn_copy_words(c1, num_c1, &group->field.N)) { return 0; } bn_rshift_words(c1, c1, /*shift=*/2, /*num=*/num_c1); - EC_RAW_POINT Q0, Q1; + EC_JACOBIAN Q0, Q1; map_to_curve_simple_swu(group, Z, c1, num_c1, c2, &Q0, &u0); map_to_curve_simple_swu(group, Z, c1, num_c1, c2, &Q1, &u1); @@ -370,7 +371,7 @@ static int hash_to_curve(const EC_GROUP *group, const EVP_MD *md, static int felem_from_u8(const EC_GROUP *group, EC_FELEM *out, uint8_t a) { uint8_t bytes[EC_MAX_BYTES] = {0}; - size_t len = BN_num_bytes(&group->field); + size_t len = BN_num_bytes(&group->field.N); bytes[len - 1] = a; return ec_felem_from_bytes(group, out, bytes, len); } @@ -401,7 +402,7 @@ static const uint8_t kP384Sqrt12[] = { 0xa8, 0x0f, 0x7e, 0x19, 0x14, 0xe2, 0xec, 0x69, 0xf5, 0xa6, 0x26, 0xb3}; int ec_hash_to_curve_p256_xmd_sha256_sswu(const EC_GROUP *group, - EC_RAW_POINT *out, const uint8_t *dst, + EC_JACOBIAN *out, const uint8_t *dst, size_t dst_len, const uint8_t *msg, size_t msg_len) { // See section 8.3 of draft-irtf-cfrg-hash-to-curve-16. @@ -434,7 +435,7 @@ int EC_hash_to_curve_p256_xmd_sha256_sswu(const EC_GROUP *group, EC_POINT *out, } int ec_hash_to_curve_p384_xmd_sha384_sswu(const EC_GROUP *group, - EC_RAW_POINT *out, const uint8_t *dst, + EC_JACOBIAN *out, const uint8_t *dst, size_t dst_len, const uint8_t *msg, size_t msg_len) { // See section 8.3 of draft-irtf-cfrg-hash-to-curve-16. @@ -479,7 +480,7 @@ int ec_hash_to_scalar_p384_xmd_sha384( } int ec_hash_to_curve_p384_xmd_sha512_sswu_draft07( - const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst, + const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t *dst, size_t dst_len, const uint8_t *msg, size_t msg_len) { // See section 8.3 of draft-irtf-cfrg-hash-to-curve-07. if (EC_GROUP_get_curve_name(group) != NID_secp384r1) { diff --git a/Sources/CCryptoBoringSSL/crypto/ec_extra/internal.h b/Sources/CCryptoBoringSSL/crypto/ec_extra/internal.h index 75d9db4e..29936794 100644 --- a/Sources/CCryptoBoringSSL/crypto/ec_extra/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/ec_extra/internal.h @@ -26,23 +26,23 @@ extern "C" { // Hash-to-curve. // -// Internal |EC_RAW_POINT| versions of the corresponding public APIs. +// Internal |EC_JACOBIAN| versions of the corresponding public APIs. // ec_hash_to_curve_p256_xmd_sha256_sswu hashes |msg| to a point on |group| and // writes the result to |out|, implementing the P256_XMD:SHA-256_SSWU_RO_ suite // from draft-irtf-cfrg-hash-to-curve-16. It returns one on success and zero on // error. OPENSSL_EXPORT int ec_hash_to_curve_p256_xmd_sha256_sswu( - const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst, - size_t dst_len, const uint8_t *msg, size_t msg_len); + const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t *dst, size_t dst_len, + const uint8_t *msg, size_t msg_len); // ec_hash_to_curve_p384_xmd_sha384_sswu hashes |msg| to a point on |group| and // writes the result to |out|, implementing the P384_XMD:SHA-384_SSWU_RO_ suite // from draft-irtf-cfrg-hash-to-curve-16. It returns one on success and zero on // error. OPENSSL_EXPORT int ec_hash_to_curve_p384_xmd_sha384_sswu( - const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst, - size_t dst_len, const uint8_t *msg, size_t msg_len); + const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t *dst, size_t dst_len, + const uint8_t *msg, size_t msg_len); // ec_hash_to_scalar_p384_xmd_sha384 hashes |msg| to a scalar on |group| // and writes the result to |out|, using the hash_to_field operation from the @@ -59,8 +59,8 @@ OPENSSL_EXPORT int ec_hash_to_scalar_p384_xmd_sha384( // // TODO(https://crbug.com/1414562): Migrate this to the final version. OPENSSL_EXPORT int ec_hash_to_curve_p384_xmd_sha512_sswu_draft07( - const EC_GROUP *group, EC_RAW_POINT *out, const uint8_t *dst, - size_t dst_len, const uint8_t *msg, size_t msg_len); + const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t *dst, size_t dst_len, + const uint8_t *msg, size_t msg_len); // ec_hash_to_scalar_p384_xmd_sha512_draft07 hashes |msg| to a scalar on |group| // and writes the result to |out|, using the hash_to_field operation from the diff --git a/Sources/CCryptoBoringSSL/crypto/ecdh_extra/ecdh_extra.c b/Sources/CCryptoBoringSSL/crypto/ecdh_extra/ecdh_extra.c index 2fd992a7..708b2c8e 100644 --- a/Sources/CCryptoBoringSSL/crypto/ecdh_extra/ecdh_extra.c +++ b/Sources/CCryptoBoringSSL/crypto/ecdh_extra/ecdh_extra.c @@ -92,7 +92,7 @@ int ECDH_compute_key(void *out, size_t out_len, const EC_POINT *pub_key, return -1; } - EC_RAW_POINT shared_point; + EC_JACOBIAN shared_point; uint8_t buf[EC_MAX_BYTES]; size_t buf_len; if (!ec_point_mul_scalar(group, &shared_point, &pub_key->raw, priv) || diff --git a/Sources/CCryptoBoringSSL/crypto/err/err.c b/Sources/CCryptoBoringSSL/crypto/err/err.c index 20278db7..747f336d 100644 --- a/Sources/CCryptoBoringSSL/crypto/err/err.c +++ b/Sources/CCryptoBoringSSL/crypto/err/err.c @@ -146,13 +146,13 @@ struct err_error_st { // ERR_STATE contains the per-thread, error queue. typedef struct err_state_st { - // errors contains the ERR_NUM_ERRORS most recent errors, organised as a ring - // buffer. + // errors contains up to ERR_NUM_ERRORS - 1 most recent errors, organised as a + // ring buffer. struct err_error_st errors[ERR_NUM_ERRORS]; - // top contains the index one past the most recent error. If |top| equals - // |bottom| then the queue is empty. + // top contains the index of the most recent error. If |top| equals |bottom| + // then the queue is empty. unsigned top; - // bottom contains the index of the last error in the queue. + // bottom contains the index before the least recent error in the queue. unsigned bottom; // to_free, if not NULL, contains a pointer owned by this structure that was @@ -192,8 +192,7 @@ static int global_next_library = ERR_NUM_LIBS; // global_next_library_mutex protects |global_next_library| from concurrent // updates. -static struct CRYPTO_STATIC_MUTEX global_next_library_mutex = - CRYPTO_STATIC_MUTEX_INIT; +static CRYPTO_MUTEX global_next_library_mutex = CRYPTO_MUTEX_INIT; static void err_state_free(void *statep) { ERR_STATE *state = statep; @@ -367,9 +366,9 @@ void ERR_remove_thread_state(const CRYPTO_THREADID *tid) { int ERR_get_next_error_library(void) { int ret; - CRYPTO_STATIC_MUTEX_lock_write(&global_next_library_mutex); + CRYPTO_MUTEX_lock_write(&global_next_library_mutex); ret = global_next_library++; - CRYPTO_STATIC_MUTEX_unlock_write(&global_next_library_mutex); + CRYPTO_MUTEX_unlock_write(&global_next_library_mutex); return ret; } @@ -553,22 +552,21 @@ char *ERR_error_string_n(uint32_t packed_error, char *buf, size_t len) { const char *lib_str = err_lib_error_string(packed_error); const char *reason_str = err_reason_error_string(packed_error); - char lib_buf[64], reason_buf[64]; + char lib_buf[32], reason_buf[32]; if (lib_str == NULL) { - BIO_snprintf(lib_buf, sizeof(lib_buf), "lib(%u)", lib); + snprintf(lib_buf, sizeof(lib_buf), "lib(%u)", lib); lib_str = lib_buf; } - if (reason_str == NULL) { - BIO_snprintf(reason_buf, sizeof(reason_buf), "reason(%u)", reason); + if (reason_str == NULL) { + snprintf(reason_buf, sizeof(reason_buf), "reason(%u)", reason); reason_str = reason_buf; } - BIO_snprintf(buf, len, "error:%08" PRIx32 ":%s:OPENSSL_internal:%s", - packed_error, lib_str, reason_str); - - if (strlen(buf) == len - 1) { - // output may be truncated; make sure we always have 5 colon-separated + int ret = snprintf(buf, len, "error:%08" PRIx32 ":%s:OPENSSL_internal:%s", + packed_error, lib_str, reason_str); + if (ret >= 0 && (size_t)ret >= len) { + // The output was truncated; make sure we always have 5 colon-separated // fields, i.e. 4 colons. static const unsigned num_colons = 4; unsigned i; @@ -618,8 +616,8 @@ void ERR_print_errors_cb(ERR_print_errors_callback_t callback, void *ctx) { } ERR_error_string_n(packed_error, buf, sizeof(buf)); - BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", thread_hash, buf, - file, line, (flags & ERR_FLAG_STRING) ? data : ""); + snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", thread_hash, buf, file, + line, (flags & ERR_FLAG_STRING) ? data : ""); if (callback(buf2, strlen(buf2), ctx) <= 0) { break; } @@ -867,6 +865,10 @@ void ERR_restore_state(const ERR_SAVE_STATE *state) { return; } + if (state->num_errors >= ERR_NUM_ERRORS) { + abort(); + } + ERR_STATE *const dst = err_get_state(); if (dst == NULL) { return; @@ -875,6 +877,6 @@ void ERR_restore_state(const ERR_SAVE_STATE *state) { for (size_t i = 0; i < state->num_errors; i++) { err_copy(&dst->errors[i], &state->errors[i]); } - dst->top = state->num_errors - 1; + dst->top = (unsigned)(state->num_errors - 1); dst->bottom = ERR_NUM_ERRORS - 1; } diff --git a/Sources/CCryptoBoringSSL/crypto/err/err_data.c b/Sources/CCryptoBoringSSL/crypto/err/err_data.c index f74935cf..2163a55a 100644 --- a/Sources/CCryptoBoringSSL/crypto/err/err_data.c +++ b/Sources/CCryptoBoringSSL/crypto/err/err_data.c @@ -76,169 +76,169 @@ const uint32_t kOpenSSLReasonValues[] = { 0xc3b00f7, 0xc3b8921, 0x10320892, - 0x10329620, - 0x1033162c, - 0x10339645, - 0x10341658, - 0x10348f72, - 0x10350cab, - 0x1035966b, - 0x10361695, - 0x103696a8, - 0x103716c7, - 0x103796e0, - 0x103816f5, - 0x10389713, - 0x10391722, - 0x1039973e, - 0x103a1759, - 0x103a9768, - 0x103b1784, - 0x103b979f, - 0x103c17c5, + 0x10329641, + 0x1033164d, + 0x10339666, + 0x10341679, + 0x10348f93, + 0x10350ccc, + 0x1035968c, + 0x103616b6, + 0x103696c9, + 0x103716e8, + 0x10379701, + 0x10381716, + 0x10389734, + 0x10391743, + 0x1039975f, + 0x103a177a, + 0x103a9789, + 0x103b17a5, + 0x103b97c0, + 0x103c17e6, 0x103c80f7, - 0x103d17d6, - 0x103d97ea, - 0x103e1809, - 0x103e9818, - 0x103f182f, - 0x103f9842, - 0x10400c6f, - 0x10409855, - 0x10411873, - 0x10419886, - 0x104218a0, - 0x104298b0, - 0x104318c4, - 0x104398da, - 0x104418f2, - 0x10449907, - 0x1045191b, - 0x1045992d, + 0x103d17f7, + 0x103d980b, + 0x103e182a, + 0x103e9839, + 0x103f1850, + 0x103f9863, + 0x10400c90, + 0x10409876, + 0x10411894, + 0x104198a7, + 0x104218c1, + 0x104298d1, + 0x104318e5, + 0x104398fb, + 0x10441913, + 0x10449928, + 0x1045193c, + 0x1045994e, 0x10460635, 0x1046899a, - 0x10471942, - 0x10479959, - 0x1048196e, - 0x1048997c, - 0x10490ebe, - 0x104997b6, - 0x104a1680, - 0x14320c52, - 0x14328c60, - 0x14330c6f, - 0x14338c81, + 0x10471963, + 0x1047997a, + 0x1048198f, + 0x1048999d, + 0x10490edf, + 0x104997d7, + 0x104a16a1, + 0x14320c73, + 0x14328c81, + 0x14330c90, + 0x14338ca2, 0x143400b9, 0x143480f7, 0x18320090, - 0x18328fc8, + 0x18328fe9, 0x183300b9, - 0x18338fde, - 0x18340ff2, + 0x18338fff, + 0x18341013, 0x183480f7, - 0x18351011, - 0x18359029, - 0x1836103e, - 0x18369052, - 0x1837108a, - 0x183790a0, - 0x183810b4, - 0x183890c4, + 0x18351032, + 0x1835904a, + 0x1836105f, + 0x18369073, + 0x183710ab, + 0x183790c1, + 0x183810d5, + 0x183890e5, 0x18390ac0, - 0x183990d4, - 0x183a10fa, - 0x183a9120, - 0x183b0cca, - 0x183b916f, - 0x183c1181, - 0x183c918c, - 0x183d119c, - 0x183d91ad, - 0x183e11be, - 0x183e91d0, - 0x183f11f9, - 0x183f9212, - 0x1840122a, + 0x183990f5, + 0x183a111b, + 0x183a9141, + 0x183b0ceb, + 0x183b9190, + 0x183c11a2, + 0x183c91ad, + 0x183d11bd, + 0x183d91ce, + 0x183e11df, + 0x183e91f1, + 0x183f121a, + 0x183f9233, + 0x1840124b, 0x1840870d, - 0x18411143, - 0x1841910e, - 0x1842112d, - 0x18428cb7, - 0x184310e9, - 0x18439155, - 0x18441007, - 0x18449076, - 0x20321264, - 0x20329251, - 0x24321270, + 0x18411164, + 0x1841912f, + 0x1842114e, + 0x18428cd8, + 0x1843110a, + 0x18439176, + 0x18441028, + 0x18449097, + 0x20321285, + 0x20329272, + 0x24321291, 0x243289e0, - 0x24331282, - 0x2433928f, - 0x2434129c, - 0x243492ae, - 0x243512bd, - 0x243592da, - 0x243612e7, - 0x243692f5, - 0x24371303, - 0x24379311, - 0x2438131a, - 0x24389327, - 0x2439133a, - 0x28320c9f, - 0x28328cca, - 0x28330c6f, - 0x28338cdd, - 0x28340cab, + 0x243312a3, + 0x243392b0, + 0x243412bd, + 0x243492cf, + 0x243512de, + 0x243592fb, + 0x24361308, + 0x24369316, + 0x24371324, + 0x24379332, + 0x2438133b, + 0x24389348, + 0x2439135b, + 0x28320cc0, + 0x28328ceb, + 0x28330c90, + 0x28338cfe, + 0x28340ccc, 0x283480b9, 0x283500f7, - 0x28358cb7, + 0x28358cd8, 0x2836099a, - 0x2c3232bf, - 0x2c329351, - 0x2c3332cd, - 0x2c33b2df, - 0x2c3432f3, - 0x2c34b305, - 0x2c353320, - 0x2c35b332, - 0x2c363362, + 0x2c3232d0, + 0x2c329372, + 0x2c3332de, + 0x2c33b2f0, + 0x2c343304, + 0x2c34b316, + 0x2c353331, + 0x2c35b343, + 0x2c363373, 0x2c36833a, - 0x2c37336f, - 0x2c37b39b, - 0x2c3833d9, - 0x2c38b3f0, - 0x2c39340e, - 0x2c39b41e, - 0x2c3a3430, - 0x2c3ab444, - 0x2c3b3455, - 0x2c3bb474, - 0x2c3c1363, - 0x2c3c9379, - 0x2c3d34b9, - 0x2c3d9392, - 0x2c3e34e3, - 0x2c3eb4f1, - 0x2c3f3509, - 0x2c3fb521, - 0x2c40354b, - 0x2c409264, - 0x2c41355c, - 0x2c41b56f, - 0x2c42122a, - 0x2c42b580, + 0x2c373380, + 0x2c37b3ac, + 0x2c3833ea, + 0x2c38b401, + 0x2c39341f, + 0x2c39b42f, + 0x2c3a3441, + 0x2c3ab455, + 0x2c3b3466, + 0x2c3bb485, + 0x2c3c1384, + 0x2c3c939a, + 0x2c3d34ca, + 0x2c3d93b3, + 0x2c3e34f4, + 0x2c3eb502, + 0x2c3f351a, + 0x2c3fb532, + 0x2c40355c, + 0x2c409285, + 0x2c41356d, + 0x2c41b580, + 0x2c42124b, + 0x2c42b591, 0x2c43076d, - 0x2c43b466, - 0x2c4433ae, - 0x2c44b52e, - 0x2c453345, - 0x2c45b381, - 0x2c4633fe, - 0x2c46b488, - 0x2c47349d, - 0x2c47b4d6, - 0x2c4833c0, + 0x2c43b477, + 0x2c4433bf, + 0x2c44b53f, + 0x2c453356, + 0x2c45b392, + 0x2c46340f, + 0x2c46b499, + 0x2c4734ae, + 0x2c47b4e7, + 0x2c4833d1, 0x30320000, 0x30328015, 0x3033001f, @@ -341,297 +341,297 @@ const uint32_t kOpenSSLReasonValues[] = { 0x34330be1, 0x34338bf4, 0x34340c03, - 0x34348c3c, - 0x34350c20, + 0x34348c5d, + 0x34350c41, + 0x34358c20, 0x3c320090, - 0x3c328d07, - 0x3c330d20, - 0x3c338d3b, - 0x3c340d58, - 0x3c348d82, - 0x3c350d9d, - 0x3c358dc3, - 0x3c360ddc, - 0x3c368df4, - 0x3c370e05, - 0x3c378e13, - 0x3c380e20, - 0x3c388e34, - 0x3c390cca, - 0x3c398e57, - 0x3c3a0e6b, + 0x3c328d28, + 0x3c330d41, + 0x3c338d5c, + 0x3c340d79, + 0x3c348da3, + 0x3c350dbe, + 0x3c358de4, + 0x3c360dfd, + 0x3c368e15, + 0x3c370e26, + 0x3c378e34, + 0x3c380e41, + 0x3c388e55, + 0x3c390ceb, + 0x3c398e78, + 0x3c3a0e8c, 0x3c3a895a, - 0x3c3b0e7b, - 0x3c3b8e96, - 0x3c3c0ea8, - 0x3c3c8edb, - 0x3c3d0ee5, - 0x3c3d8ef9, - 0x3c3e0f07, - 0x3c3e8f2c, - 0x3c3f0cf3, - 0x3c3f8f15, + 0x3c3b0e9c, + 0x3c3b8eb7, + 0x3c3c0ec9, + 0x3c3c8efc, + 0x3c3d0f06, + 0x3c3d8f1a, + 0x3c3e0f28, + 0x3c3e8f4d, + 0x3c3f0d14, + 0x3c3f8f36, 0x3c4000b9, 0x3c4080f7, - 0x3c410d73, - 0x3c418db2, - 0x3c420ebe, - 0x3c428e48, - 0x40321a0e, - 0x40329a24, - 0x40331a52, - 0x40339a5c, - 0x40341a73, - 0x40349a91, - 0x40351aa1, - 0x40359ab3, - 0x40361ac0, - 0x40369acc, - 0x40371ae1, - 0x40379af3, - 0x40381afe, - 0x40389b10, - 0x40390f72, - 0x40399b20, - 0x403a1b33, - 0x403a9b54, - 0x403b1b65, - 0x403b9b75, + 0x3c410d94, + 0x3c418dd3, + 0x3c420edf, + 0x3c428e69, + 0x40321a2f, + 0x40329a45, + 0x40331a73, + 0x40339a7d, + 0x40341a94, + 0x40349ab2, + 0x40351ac2, + 0x40359ad4, + 0x40361ae1, + 0x40369aed, + 0x40371b02, + 0x40379b14, + 0x40381b1f, + 0x40389b31, + 0x40390f93, + 0x40399b41, + 0x403a1b54, + 0x403a9b75, + 0x403b1b86, + 0x403b9b96, 0x403c0071, 0x403c8090, - 0x403d1bd6, - 0x403d9bec, - 0x403e1bfb, - 0x403e9c33, - 0x403f1c4d, - 0x403f9c75, - 0x40401c8a, - 0x40409c9e, - 0x40411cd9, - 0x40419cf4, - 0x40421d0d, - 0x40429d20, - 0x40431d34, - 0x40439d62, - 0x40441d79, + 0x403d1bf7, + 0x403d9c0d, + 0x403e1c1c, + 0x403e9c54, + 0x403f1c6e, + 0x403f9c96, + 0x40401cab, + 0x40409cbf, + 0x40411cfa, + 0x40419d15, + 0x40421d2e, + 0x40429d41, + 0x40431d55, + 0x40439d83, + 0x40441d9a, 0x404480b9, - 0x40451d8e, - 0x40459da0, - 0x40461dc4, - 0x40469de4, - 0x40471df2, - 0x40479e19, - 0x40481e8a, - 0x40489f44, - 0x40491f5b, - 0x40499f75, - 0x404a1f8c, - 0x404a9faa, - 0x404b1fc2, - 0x404b9fef, - 0x404c2005, - 0x404ca017, - 0x404d2038, - 0x404da071, - 0x404e2085, - 0x404ea092, - 0x404f212c, - 0x404fa1a2, - 0x40502211, - 0x4050a225, - 0x40512258, - 0x40522268, - 0x4052a28c, - 0x405322a4, - 0x4053a2b7, - 0x405422cc, - 0x4054a2ef, - 0x4055231a, - 0x4055a357, - 0x4056237c, - 0x4056a395, - 0x405723ad, - 0x4057a3c0, - 0x405823d5, - 0x4058a3fc, - 0x4059242b, - 0x4059a458, - 0x405a246c, - 0x405aa47c, - 0x405b2494, - 0x405ba4a5, - 0x405c24b8, - 0x405ca4f7, - 0x405d2504, - 0x405da529, - 0x405e2567, + 0x40451daf, + 0x40459dc1, + 0x40461de5, + 0x40469e05, + 0x40471e13, + 0x40479e3a, + 0x40481eab, + 0x40489f65, + 0x40491f7c, + 0x40499f96, + 0x404a1fad, + 0x404a9fcb, + 0x404b1fe3, + 0x404ba010, + 0x404c2026, + 0x404ca038, + 0x404d2059, + 0x404da092, + 0x404e20a6, + 0x404ea0b3, + 0x404f214d, + 0x404fa1c3, + 0x40502232, + 0x4050a246, + 0x40512279, + 0x40522289, + 0x4052a2ad, + 0x405322c5, + 0x4053a2d8, + 0x405422ed, + 0x4054a310, + 0x4055233b, + 0x4055a378, + 0x4056239d, + 0x4056a3b6, + 0x405723ce, + 0x4057a3e1, + 0x405823f6, + 0x4058a41d, + 0x4059244c, + 0x4059a479, + 0x405aa48d, + 0x405b24a5, + 0x405ba4b6, + 0x405c24c9, + 0x405ca508, + 0x405d2515, + 0x405da53a, + 0x405e2578, 0x405e8afe, - 0x405f2588, - 0x405fa595, - 0x406025a3, - 0x4060a5c5, - 0x40612626, - 0x4061a65e, - 0x40622675, - 0x4062a686, - 0x406326d3, - 0x4063a6e8, - 0x406426ff, - 0x4064a72b, - 0x40652746, - 0x4065a75d, - 0x40662775, - 0x4066a79f, - 0x406727ca, - 0x4067a80f, - 0x40682857, - 0x4068a878, - 0x406928aa, - 0x4069a8d8, - 0x406a28f9, - 0x406aa919, - 0x406b2aa1, - 0x406baac4, - 0x406c2ada, - 0x406cade4, - 0x406d2e13, - 0x406dae3b, - 0x406e2e69, - 0x406eaeb6, - 0x406f2f0f, - 0x406faf47, - 0x40702f5a, - 0x4070af77, + 0x405f2599, + 0x405fa5a6, + 0x406025b4, + 0x4060a5d6, + 0x40612637, + 0x4061a66f, + 0x40622686, + 0x4062a697, + 0x406326e4, + 0x4063a6f9, + 0x40642710, + 0x4064a73c, + 0x40652757, + 0x4065a76e, + 0x40662786, + 0x4066a7b0, + 0x406727db, + 0x4067a820, + 0x40682868, + 0x4068a889, + 0x406928bb, + 0x4069a8e9, + 0x406a290a, + 0x406aa92a, + 0x406b2ab2, + 0x406baad5, + 0x406c2aeb, + 0x406cadf5, + 0x406d2e24, + 0x406dae4c, + 0x406e2e7a, + 0x406eaec7, + 0x406f2f20, + 0x406faf58, + 0x40702f6b, + 0x4070af88, 0x4071084d, - 0x4071af89, - 0x40722f9c, - 0x4072afd2, - 0x40732fea, - 0x4073957b, - 0x40742ffe, - 0x4074b018, - 0x40753029, - 0x4075b03d, - 0x4076304b, - 0x40769327, - 0x40773070, - 0x4077b0b0, - 0x407830cb, - 0x4078b104, - 0x4079311b, - 0x4079b131, - 0x407a315d, - 0x407ab170, - 0x407b3185, - 0x407bb197, - 0x407c31c8, - 0x407cb1d1, - 0x407d2893, - 0x407da1ca, - 0x407e30e0, - 0x407ea40c, - 0x407f1e06, - 0x407f9fd9, - 0x4080213c, - 0x40809e2e, - 0x4081227a, - 0x4081a0e0, - 0x40822e54, - 0x40829b81, - 0x408323e7, - 0x4083a710, - 0x40841e42, - 0x4084a444, - 0x408524c9, - 0x4085a5ed, - 0x40862549, - 0x4086a1e4, - 0x40872e9a, - 0x4087a63b, - 0x40881bbf, - 0x4088a822, - 0x40891c0e, - 0x40899b9b, - 0x408a2b12, - 0x408a9993, - 0x408b31ac, - 0x408baf24, - 0x408c24d9, - 0x408c99cb, - 0x408d1f2a, - 0x408d9e74, - 0x408e205a, - 0x408ea337, - 0x408f2836, - 0x408fa609, - 0x409027eb, - 0x4090a51b, - 0x40912afa, - 0x409199f1, - 0x40921c5b, - 0x4092aed5, - 0x40932fb5, - 0x4093a1f5, - 0x40941e56, - 0x4094ab2b, - 0x40952697, - 0x4095b13d, - 0x40962e81, - 0x4096a155, - 0x40972240, - 0x4097a0a9, - 0x40981cbb, - 0x4098a6ab, - 0x40992ef1, - 0x4099a364, - 0x409a22fd, - 0x409a99af, - 0x409b1eb0, - 0x409b9edb, - 0x409c3092, - 0x409c9f03, - 0x409d2111, - 0x409da0f6, - 0x409e1d4c, - 0x409ea18a, - 0x409f2172, - 0x409f9ea3, - 0x40a021b2, - 0x40a0a0c3, - 0x41f429cc, - 0x41f92a5e, - 0x41fe2951, - 0x41feac07, - 0x41ff2d35, - 0x420329e5, - 0x42082a07, - 0x4208aa43, - 0x42092935, - 0x4209aa7d, - 0x420a298c, - 0x420aa96c, - 0x420b29ac, - 0x420baa25, - 0x420c2d51, - 0x420cab3b, - 0x420d2bee, - 0x420dac25, - 0x42122c58, - 0x42172d18, - 0x4217ac9a, - 0x421c2cbc, - 0x421f2c77, - 0x42212dc9, - 0x42262cfb, - 0x422b2da7, - 0x422babc9, - 0x422c2d89, - 0x422cab7c, - 0x422d2b55, - 0x422dad68, - 0x422e2ba8, - 0x42302cd7, - 0x4230ac3f, + 0x4071af9a, + 0x40722fad, + 0x4072afe3, + 0x40732ffb, + 0x4073959c, + 0x4074300f, + 0x4074b029, + 0x4075303a, + 0x4075b04e, + 0x4076305c, + 0x40769348, + 0x40773081, + 0x4077b0c1, + 0x407830dc, + 0x4078b115, + 0x4079312c, + 0x4079b142, + 0x407a316e, + 0x407ab181, + 0x407b3196, + 0x407bb1a8, + 0x407c31d9, + 0x407cb1e2, + 0x407d28a4, + 0x407da1eb, + 0x407e30f1, + 0x407ea42d, + 0x407f1e27, + 0x407f9ffa, + 0x4080215d, + 0x40809e4f, + 0x4081229b, + 0x4081a101, + 0x40822e65, + 0x40829ba2, + 0x40832408, + 0x4083a721, + 0x40841e63, + 0x4084a465, + 0x408524da, + 0x4085a5fe, + 0x4086255a, + 0x4086a205, + 0x40872eab, + 0x4087a64c, + 0x40881be0, + 0x4088a833, + 0x40891c2f, + 0x40899bbc, + 0x408a2b23, + 0x408a99b4, + 0x408b31bd, + 0x408baf35, + 0x408c24ea, + 0x408c99ec, + 0x408d1f4b, + 0x408d9e95, + 0x408e207b, + 0x408ea358, + 0x408f2847, + 0x408fa61a, + 0x409027fc, + 0x4090a52c, + 0x40912b0b, + 0x40919a12, + 0x40921c7c, + 0x4092aee6, + 0x40932fc6, + 0x4093a216, + 0x40941e77, + 0x4094ab3c, + 0x409526a8, + 0x4095b14e, + 0x40962e92, + 0x4096a176, + 0x40972261, + 0x4097a0ca, + 0x40981cdc, + 0x4098a6bc, + 0x40992f02, + 0x4099a385, + 0x409a231e, + 0x409a99d0, + 0x409b1ed1, + 0x409b9efc, + 0x409c30a3, + 0x409c9f24, + 0x409d2132, + 0x409da117, + 0x409e1d6d, + 0x409ea1ab, + 0x409f2193, + 0x409f9ec4, + 0x40a021d3, + 0x40a0a0e4, + 0x41f429dd, + 0x41f92a6f, + 0x41fe2962, + 0x41feac18, + 0x41ff2d46, + 0x420329f6, + 0x42082a18, + 0x4208aa54, + 0x42092946, + 0x4209aa8e, + 0x420a299d, + 0x420aa97d, + 0x420b29bd, + 0x420baa36, + 0x420c2d62, + 0x420cab4c, + 0x420d2bff, + 0x420dac36, + 0x42122c69, + 0x42172d29, + 0x4217acab, + 0x421c2ccd, + 0x421f2c88, + 0x42212dda, + 0x42262d0c, + 0x422b2db8, + 0x422babda, + 0x422c2d9a, + 0x422cab8d, + 0x422d2b66, + 0x422dad79, + 0x422e2bb9, + 0x42302ce8, + 0x4230ac50, 0x44320778, 0x44328787, 0x44330793, @@ -649,124 +649,124 @@ const uint32_t kOpenSSLReasonValues[] = { 0x4439084d, 0x4439885b, 0x443a086e, - 0x48321351, - 0x48329363, - 0x48331379, - 0x48339392, - 0x4c3213cf, - 0x4c3293df, - 0x4c3313f2, - 0x4c339412, + 0x48321372, + 0x48329384, + 0x4833139a, + 0x483393b3, + 0x4c3213f0, + 0x4c329400, + 0x4c331413, + 0x4c339433, 0x4c3400b9, 0x4c3480f7, - 0x4c35141e, - 0x4c35942c, - 0x4c361448, - 0x4c36946e, - 0x4c37147d, - 0x4c37948b, - 0x4c3814a0, - 0x4c3894ac, - 0x4c3914cc, - 0x4c3994f6, - 0x4c3a150f, - 0x4c3a9528, + 0x4c35143f, + 0x4c35944d, + 0x4c361469, + 0x4c36948f, + 0x4c37149e, + 0x4c3794ac, + 0x4c3814c1, + 0x4c3894cd, + 0x4c3914ed, + 0x4c399517, + 0x4c3a1530, + 0x4c3a9549, 0x4c3b0635, - 0x4c3b9541, - 0x4c3c1553, - 0x4c3c9562, - 0x4c3d157b, - 0x4c3d8c92, - 0x4c3e15e8, - 0x4c3e958a, - 0x4c3f160a, - 0x4c3f9327, - 0x4c4015a0, - 0x4c4093bb, - 0x4c4115d8, - 0x4c41945b, - 0x4c4215c4, - 0x4c4293a3, - 0x50323592, - 0x5032b5a1, - 0x503335ac, - 0x5033b5bc, - 0x503435d5, - 0x5034b5ef, - 0x503535fd, - 0x5035b613, - 0x50363625, - 0x5036b63b, - 0x50373654, - 0x5037b667, - 0x5038367f, - 0x5038b690, - 0x503936a5, - 0x5039b6b9, - 0x503a36d9, - 0x503ab6ef, - 0x503b3707, - 0x503bb719, - 0x503c3735, - 0x503cb74c, - 0x503d3765, - 0x503db77b, - 0x503e3788, - 0x503eb79e, - 0x503f37b0, + 0x4c3b9562, + 0x4c3c1574, + 0x4c3c9583, + 0x4c3d159c, + 0x4c3d8cb3, + 0x4c3e1609, + 0x4c3e95ab, + 0x4c3f162b, + 0x4c3f9348, + 0x4c4015c1, + 0x4c4093dc, + 0x4c4115f9, + 0x4c41947c, + 0x4c4215e5, + 0x4c4293c4, + 0x503235a3, + 0x5032b5b2, + 0x503335bd, + 0x5033b5cd, + 0x503435e6, + 0x5034b600, + 0x5035360e, + 0x5035b624, + 0x50363636, + 0x5036b64c, + 0x50373665, + 0x5037b678, + 0x50383690, + 0x5038b6a1, + 0x503936b6, + 0x5039b6ca, + 0x503a36ea, + 0x503ab700, + 0x503b3718, + 0x503bb72a, + 0x503c3746, + 0x503cb75d, + 0x503d3776, + 0x503db78c, + 0x503e3799, + 0x503eb7af, + 0x503f37c1, 0x503f83b3, - 0x504037c3, - 0x5040b7d3, - 0x504137ed, - 0x5041b7fc, - 0x50423816, - 0x5042b833, - 0x50433843, - 0x5043b853, - 0x50443870, + 0x504037d4, + 0x5040b7e4, + 0x504137fe, + 0x5041b80d, + 0x50423827, + 0x5042b844, + 0x50433854, + 0x5043b864, + 0x50443881, 0x50448469, - 0x50453884, - 0x5045b8a2, - 0x504638b5, - 0x5046b8cb, - 0x504738dd, - 0x5047b8f2, - 0x50483918, - 0x5048b926, - 0x50493939, - 0x5049b94e, - 0x504a3964, - 0x504ab974, - 0x504b3994, - 0x504bb9a7, - 0x504c39ca, - 0x504cb9f8, - 0x504d3a25, - 0x504dba42, - 0x504e3a5d, - 0x504eba79, - 0x504f3a8b, - 0x504fbaa2, - 0x50503ab1, + 0x50453895, + 0x5045b8b3, + 0x504638c6, + 0x5046b8dc, + 0x504738ee, + 0x5047b903, + 0x50483929, + 0x5048b937, + 0x5049394a, + 0x5049b95f, + 0x504a3975, + 0x504ab985, + 0x504b39a5, + 0x504bb9b8, + 0x504c39db, + 0x504cba09, + 0x504d3a36, + 0x504dba53, + 0x504e3a6e, + 0x504eba8a, + 0x504f3a9c, + 0x504fbab3, + 0x50503ac2, 0x50508729, - 0x50513ac4, - 0x5051b862, - 0x50523a0a, - 0x58320fb0, - 0x68320f72, - 0x68328cca, - 0x68330cdd, - 0x68338f80, - 0x68340f90, + 0x50513ad5, + 0x5051b873, + 0x50523a1b, + 0x58320fd1, + 0x68320f93, + 0x68328ceb, + 0x68330cfe, + 0x68338fa1, + 0x68340fb1, 0x683480f7, 0x6835099a, - 0x6c320f38, - 0x6c328c81, - 0x6c330f43, - 0x6c338f5c, + 0x6c320f59, + 0x6c328ca2, + 0x6c330f64, + 0x6c338f7d, 0x74320a66, 0x743280b9, - 0x74330c92, + 0x74330cb3, 0x783209cb, 0x783289e0, 0x783309ec, @@ -793,22 +793,22 @@ const uint32_t kOpenSSLReasonValues[] = { 0x783d8b97, 0x783e0aed, 0x783e8a9f, - 0x7c321240, - 0x8032146e, + 0x7c321261, + 0x8032148f, 0x80328090, - 0x8033328e, + 0x8033329f, 0x803380b9, - 0x8034329d, - 0x8034b205, - 0x80353223, - 0x8035b2b1, - 0x80363265, - 0x8036b214, - 0x80373257, - 0x8037b1f2, - 0x80383278, - 0x8038b234, - 0x80393249, + 0x803432ae, + 0x8034b216, + 0x80353234, + 0x8035b2c2, + 0x80363276, + 0x8036b225, + 0x80373268, + 0x8037b203, + 0x80383289, + 0x8038b245, + 0x8039325a, }; const size_t kOpenSSLReasonValuesLen = sizeof(kOpenSSLReasonValues) / sizeof(kOpenSSLReasonValues[0]); @@ -977,6 +977,7 @@ const char kOpenSSLReasonStringData[] = "MISSING_EQUAL_SIGN\0" "NO_CLOSE_BRACE\0" "UNABLE_TO_CREATE_NEW_SECTION\0" + "VARIABLE_EXPANSION_NOT_SUPPORTED\0" "VARIABLE_EXPANSION_TOO_LONG\0" "VARIABLE_HAS_NO_VALUE\0" "BAD_GENERATOR\0" @@ -1266,7 +1267,6 @@ const char kOpenSSLReasonStringData[] = "NO_COMPRESSION_SPECIFIED\0" "NO_GROUPS_SPECIFIED\0" "NO_METHOD_SPECIFIED\0" - "NO_P256_SUPPORT\0" "NO_PRIVATE_KEY_ASSIGNED\0" "NO_RENEGOTIATION\0" "NO_REQUIRED_DIGEST\0" diff --git a/Sources/CCryptoBoringSSL/crypto/evp/evp.c b/Sources/CCryptoBoringSSL/crypto/evp/evp.c index 84e393f7..efc97d75 100644 --- a/Sources/CCryptoBoringSSL/crypto/evp/evp.c +++ b/Sources/CCryptoBoringSSL/crypto/evp/evp.c @@ -229,6 +229,13 @@ static const EVP_PKEY_ASN1_METHOD *evp_pkey_asn1_find(int nid) { } } +static void evp_pkey_set_method(EVP_PKEY *pkey, + const EVP_PKEY_ASN1_METHOD *method) { + free_it(pkey); + pkey->ameth = method; + pkey->type = pkey->ameth->pkey_id; +} + int EVP_PKEY_type(int nid) { const EVP_PKEY_ASN1_METHOD *meth = evp_pkey_asn1_find(nid); if (meth == NULL) { @@ -246,7 +253,9 @@ int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key) { } int EVP_PKEY_assign_RSA(EVP_PKEY *pkey, RSA *key) { - return EVP_PKEY_assign(pkey, EVP_PKEY_RSA, key); + evp_pkey_set_method(pkey, &rsa_asn1_meth); + pkey->pkey = key; + return key != NULL; } RSA *EVP_PKEY_get0_RSA(const EVP_PKEY *pkey) { @@ -274,7 +283,9 @@ int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key) { } int EVP_PKEY_assign_DSA(EVP_PKEY *pkey, DSA *key) { - return EVP_PKEY_assign(pkey, EVP_PKEY_DSA, key); + evp_pkey_set_method(pkey, &dsa_asn1_meth); + pkey->pkey = key; + return key != NULL; } DSA *EVP_PKEY_get0_DSA(const EVP_PKEY *pkey) { @@ -302,7 +313,9 @@ int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key) { } int EVP_PKEY_assign_EC_KEY(EVP_PKEY *pkey, EC_KEY *key) { - return EVP_PKEY_assign(pkey, EVP_PKEY_EC, key); + evp_pkey_set_method(pkey, &ec_asn1_meth); + pkey->pkey = key; + return key != NULL; } EC_KEY *EVP_PKEY_get0_EC_KEY(const EVP_PKEY *pkey) { @@ -325,21 +338,32 @@ DH *EVP_PKEY_get0_DH(const EVP_PKEY *pkey) { return NULL; } DH *EVP_PKEY_get1_DH(const EVP_PKEY *pkey) { return NULL; } int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key) { - if (!EVP_PKEY_set_type(pkey, type)) { - return 0; + // This function can only be used to assign RSA, DSA, and EC keys. Other key + // types have internal representations which are not exposed through the + // public API. + switch (type) { + case EVP_PKEY_RSA: + return EVP_PKEY_assign_RSA(pkey, key); + case EVP_PKEY_DSA: + return EVP_PKEY_assign_DSA(pkey, key); + case EVP_PKEY_EC: + return EVP_PKEY_assign_EC_KEY(pkey, key); } - pkey->pkey = key; - return key != NULL; + + OPENSSL_PUT_ERROR(EVP, EVP_R_UNSUPPORTED_ALGORITHM); + ERR_add_error_dataf("algorithm %d", type); + return 0; } int EVP_PKEY_set_type(EVP_PKEY *pkey, int type) { - const EVP_PKEY_ASN1_METHOD *ameth; - if (pkey && pkey->pkey) { + // This isn't strictly necessary, but historically |EVP_PKEY_set_type| would + // clear |pkey| even if |evp_pkey_asn1_find| failed, so we preserve that + // behavior. free_it(pkey); } - ameth = evp_pkey_asn1_find(type); + const EVP_PKEY_ASN1_METHOD *ameth = evp_pkey_asn1_find(type); if (ameth == NULL) { OPENSSL_PUT_ERROR(EVP, EVP_R_UNSUPPORTED_ALGORITHM); ERR_add_error_dataf("algorithm %d", type); @@ -347,8 +371,7 @@ int EVP_PKEY_set_type(EVP_PKEY *pkey, int type) { } if (pkey) { - pkey->ameth = ameth; - pkey->type = pkey->ameth->pkey_id; + evp_pkey_set_method(pkey, ameth); } return 1; diff --git a/Sources/CCryptoBoringSSL/crypto/evp/p_ec.c b/Sources/CCryptoBoringSSL/crypto/evp/p_ec.c index 1cffc236..90b34177 100644 --- a/Sources/CCryptoBoringSSL/crypto/evp/p_ec.c +++ b/Sources/CCryptoBoringSSL/crypto/evp/p_ec.c @@ -75,7 +75,7 @@ typedef struct { // message digest const EVP_MD *md; - EC_GROUP *gen_group; + const EC_GROUP *gen_group; } EC_PKEY_CTX; @@ -111,7 +111,6 @@ static void pkey_ec_cleanup(EVP_PKEY_CTX *ctx) { return; } - EC_GROUP_free(dctx->gen_group); OPENSSL_free(dctx); } @@ -195,11 +194,10 @@ static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) { return 1; case EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID: { - EC_GROUP *group = EC_GROUP_new_by_curve_name(p1); + const EC_GROUP *group = EC_GROUP_new_by_curve_name(p1); if (group == NULL) { return 0; } - EC_GROUP_free(dctx->gen_group); dctx->gen_group = group; return 1; } diff --git a/Sources/CCryptoBoringSSL/crypto/evp/p_ec_asn1.c b/Sources/CCryptoBoringSSL/crypto/evp/p_ec_asn1.c index 362ed63c..2724e590 100644 --- a/Sources/CCryptoBoringSSL/crypto/evp/p_ec_asn1.c +++ b/Sources/CCryptoBoringSSL/crypto/evp/p_ec_asn1.c @@ -94,7 +94,7 @@ static int eckey_pub_decode(EVP_PKEY *out, CBS *params, CBS *key) { // The parameters are a named curve. EC_KEY *eckey = NULL; - EC_GROUP *group = EC_KEY_parse_curve_name(params); + const EC_GROUP *group = EC_KEY_parse_curve_name(params); if (group == NULL || CBS_len(params) != 0) { OPENSSL_PUT_ERROR(EVP, EVP_R_DECODE_ERROR); goto err; @@ -107,12 +107,10 @@ static int eckey_pub_decode(EVP_PKEY *out, CBS *params, CBS *key) { goto err; } - EC_GROUP_free(group); EVP_PKEY_assign_EC_KEY(out, eckey); return 1; err: - EC_GROUP_free(group); EC_KEY_free(eckey); return 0; } @@ -135,15 +133,13 @@ static int eckey_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) { static int eckey_priv_decode(EVP_PKEY *out, CBS *params, CBS *key) { // See RFC 5915. - EC_GROUP *group = EC_KEY_parse_parameters(params); + const EC_GROUP *group = EC_KEY_parse_parameters(params); if (group == NULL || CBS_len(params) != 0) { OPENSSL_PUT_ERROR(EVP, EVP_R_DECODE_ERROR); - EC_GROUP_free(group); return 0; } EC_KEY *ec_key = EC_KEY_parse_private_key(key, group); - EC_GROUP_free(group); if (ec_key == NULL || CBS_len(key) != 0) { OPENSSL_PUT_ERROR(EVP, EVP_R_DECODE_ERROR); EC_KEY_free(ec_key); @@ -215,7 +211,7 @@ static int ec_bits(const EVP_PKEY *pkey) { ERR_clear_error(); return 0; } - return BN_num_bits(EC_GROUP_get0_order(group)); + return EC_GROUP_order_bits(group); } static int ec_missing_parameters(const EVP_PKEY *pkey) { diff --git a/Sources/CCryptoBoringSSL/crypto/evp/pbkdf.c b/Sources/CCryptoBoringSSL/crypto/evp/pbkdf.c index 627d860d..c5d41284 100644 --- a/Sources/CCryptoBoringSSL/crypto/evp/pbkdf.c +++ b/Sources/CCryptoBoringSSL/crypto/evp/pbkdf.c @@ -63,7 +63,7 @@ int PKCS5_PBKDF2_HMAC(const char *password, size_t password_len, - const uint8_t *salt, size_t salt_len, unsigned iterations, + const uint8_t *salt, size_t salt_len, uint32_t iterations, const EVP_MD *digest, size_t key_len, uint8_t *out_key) { // See RFC 8018, section 5.2. int ret = 0; @@ -98,7 +98,7 @@ int PKCS5_PBKDF2_HMAC(const char *password, size_t password_len, } OPENSSL_memcpy(out_key, digest_tmp, todo); - for (unsigned j = 1; j < iterations; j++) { + for (uint32_t j = 1; j < iterations; j++) { // Compute the remaining U_* values and XOR. if (!HMAC_Init_ex(&hctx, NULL, 0, NULL, NULL) || !HMAC_Update(&hctx, digest_tmp, md_len) || @@ -139,7 +139,7 @@ err: int PKCS5_PBKDF2_HMAC_SHA1(const char *password, size_t password_len, const uint8_t *salt, size_t salt_len, - unsigned iterations, size_t key_len, + uint32_t iterations, size_t key_len, uint8_t *out_key) { return PKCS5_PBKDF2_HMAC(password, password_len, salt, salt_len, iterations, EVP_sha1(), key_len, out_key); diff --git a/Sources/CCryptoBoringSSL/crypto/evp/print.c b/Sources/CCryptoBoringSSL/crypto/evp/print.c index b3cd9c3b..6e4c9a55 100644 --- a/Sources/CCryptoBoringSSL/crypto/evp/print.c +++ b/Sources/CCryptoBoringSSL/crypto/evp/print.c @@ -196,12 +196,12 @@ static int rsa_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent) { static int do_dsa_print(BIO *bp, const DSA *x, int off, int ptype) { const BIGNUM *priv_key = NULL; if (ptype == 2) { - priv_key = x->priv_key; + priv_key = DSA_get0_priv_key(x); } const BIGNUM *pub_key = NULL; if (ptype > 0) { - pub_key = x->pub_key; + pub_key = DSA_get0_pub_key(x); } const char *ktype = "DSA-Parameters"; @@ -212,14 +212,15 @@ static int do_dsa_print(BIO *bp, const DSA *x, int off, int ptype) { } if (!BIO_indent(bp, off, 128) || - BIO_printf(bp, "%s: (%u bit)\n", ktype, BN_num_bits(x->p)) <= 0 || + BIO_printf(bp, "%s: (%u bit)\n", ktype, BN_num_bits(DSA_get0_p(x))) <= + 0 || // |priv_key| and |pub_key| may be NULL, in which case |bn_print| will // silently skip them. !bn_print(bp, "priv:", priv_key, off) || !bn_print(bp, "pub:", pub_key, off) || - !bn_print(bp, "P:", x->p, off) || - !bn_print(bp, "Q:", x->q, off) || - !bn_print(bp, "G:", x->g, off)) { + !bn_print(bp, "P:", DSA_get0_p(x), off) || + !bn_print(bp, "Q:", DSA_get0_q(x), off) || + !bn_print(bp, "G:", DSA_get0_g(x), off)) { return 0; } diff --git a/Sources/CCryptoBoringSSL/crypto/ex_data.c b/Sources/CCryptoBoringSSL/crypto/ex_data.c index 621aed3f..e37bb6e1 100644 --- a/Sources/CCryptoBoringSSL/crypto/ex_data.c +++ b/Sources/CCryptoBoringSSL/crypto/ex_data.c @@ -116,7 +116,6 @@ #include #include #include -#include #include #include "internal.h" @@ -128,14 +127,14 @@ struct crypto_ex_data_func_st { long argl; // Arbitary long void *argp; // Arbitary void pointer CRYPTO_EX_free *free_func; + // next points to the next |CRYPTO_EX_DATA_FUNCS| or NULL if this is the last + // one. It may only be read if synchronized with a read from |num_funcs|. + CRYPTO_EX_DATA_FUNCS *next; }; int CRYPTO_get_ex_new_index(CRYPTO_EX_DATA_CLASS *ex_data_class, int *out_index, long argl, void *argp, CRYPTO_EX_free *free_func) { - CRYPTO_EX_DATA_FUNCS *funcs; - int ret = 0; - - funcs = OPENSSL_malloc(sizeof(CRYPTO_EX_DATA_FUNCS)); + CRYPTO_EX_DATA_FUNCS *funcs = OPENSSL_malloc(sizeof(CRYPTO_EX_DATA_FUNCS)); if (funcs == NULL) { return 0; } @@ -143,37 +142,32 @@ int CRYPTO_get_ex_new_index(CRYPTO_EX_DATA_CLASS *ex_data_class, int *out_index, funcs->argl = argl; funcs->argp = argp; funcs->free_func = free_func; + funcs->next = NULL; - CRYPTO_STATIC_MUTEX_lock_write(&ex_data_class->lock); - - if (ex_data_class->meth == NULL) { - ex_data_class->meth = sk_CRYPTO_EX_DATA_FUNCS_new_null(); - } - - if (ex_data_class->meth == NULL) { - goto err; - } + CRYPTO_MUTEX_lock_write(&ex_data_class->lock); + uint32_t num_funcs = CRYPTO_atomic_load_u32(&ex_data_class->num_funcs); // The index must fit in |int|. - if (sk_CRYPTO_EX_DATA_FUNCS_num(ex_data_class->meth) > - (size_t)(INT_MAX - ex_data_class->num_reserved)) { + if (num_funcs > (size_t)(INT_MAX - ex_data_class->num_reserved)) { OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); - goto err; + CRYPTO_MUTEX_unlock_write(&ex_data_class->lock); + return 0; } - if (!sk_CRYPTO_EX_DATA_FUNCS_push(ex_data_class->meth, funcs)) { - goto err; + // Append |funcs| to the linked list. + if (ex_data_class->last == NULL) { + assert(num_funcs == 0); + ex_data_class->funcs = funcs; + ex_data_class->last = funcs; + } else { + ex_data_class->last->next = funcs; + ex_data_class->last = funcs; } - funcs = NULL; // |sk_CRYPTO_EX_DATA_FUNCS_push| takes ownership. - *out_index = (int)sk_CRYPTO_EX_DATA_FUNCS_num(ex_data_class->meth) - 1 + - ex_data_class->num_reserved; - ret = 1; - -err: - CRYPTO_STATIC_MUTEX_unlock_write(&ex_data_class->lock); - OPENSSL_free(funcs); - return ret; + CRYPTO_atomic_store_u32(&ex_data_class->num_funcs, num_funcs + 1); + CRYPTO_MUTEX_unlock_write(&ex_data_class->lock); + *out_index = (int)num_funcs + ex_data_class->num_reserved; + return 1; } int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int index, void *val) { @@ -209,33 +203,6 @@ void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx) { return sk_void_value(ad->sk, idx); } -// get_func_pointers takes a copy of the CRYPTO_EX_DATA_FUNCS pointers, if any, -// for the given class. If there are some pointers, it sets |*out| to point to -// a fresh stack of them. Otherwise it sets |*out| to NULL. It returns one on -// success or zero on error. -static int get_func_pointers(STACK_OF(CRYPTO_EX_DATA_FUNCS) **out, - CRYPTO_EX_DATA_CLASS *ex_data_class) { - size_t n; - - *out = NULL; - - // CRYPTO_EX_DATA_FUNCS structures are static once set, so we can take a - // shallow copy of the list under lock and then use the structures without - // the lock held. - CRYPTO_STATIC_MUTEX_lock_read(&ex_data_class->lock); - n = sk_CRYPTO_EX_DATA_FUNCS_num(ex_data_class->meth); - if (n > 0) { - *out = sk_CRYPTO_EX_DATA_FUNCS_dup(ex_data_class->meth); - } - CRYPTO_STATIC_MUTEX_unlock_read(&ex_data_class->lock); - - if (n > 0 && *out == NULL) { - return 0; - } - - return 1; -} - void CRYPTO_new_ex_data(CRYPTO_EX_DATA *ad) { ad->sk = NULL; } @@ -247,26 +214,21 @@ void CRYPTO_free_ex_data(CRYPTO_EX_DATA_CLASS *ex_data_class, void *obj, return; } - STACK_OF(CRYPTO_EX_DATA_FUNCS) *func_pointers; - if (!get_func_pointers(&func_pointers, ex_data_class)) { - // TODO(davidben): This leaks memory on malloc error. - return; - } - + uint32_t num_funcs = CRYPTO_atomic_load_u32(&ex_data_class->num_funcs); // |CRYPTO_get_ex_new_index| will not allocate indices beyond |INT_MAX|. - assert(sk_CRYPTO_EX_DATA_FUNCS_num(func_pointers) <= - (size_t)(INT_MAX - ex_data_class->num_reserved)); - for (int i = 0; i < (int)sk_CRYPTO_EX_DATA_FUNCS_num(func_pointers); i++) { - CRYPTO_EX_DATA_FUNCS *func_pointer = - sk_CRYPTO_EX_DATA_FUNCS_value(func_pointers, i); - if (func_pointer->free_func) { - void *ptr = CRYPTO_get_ex_data(ad, i + ex_data_class->num_reserved); - func_pointer->free_func(obj, ptr, ad, i + ex_data_class->num_reserved, - func_pointer->argl, func_pointer->argp); - } - } + assert(num_funcs <= (size_t)(INT_MAX - ex_data_class->num_reserved)); - sk_CRYPTO_EX_DATA_FUNCS_free(func_pointers); + // Defer dereferencing |ex_data_class->funcs| and |funcs->next|. It must come + // after the |num_funcs| comparison to be correctly synchronized. + CRYPTO_EX_DATA_FUNCS *const *funcs = &ex_data_class->funcs; + for (uint32_t i = 0; i < num_funcs; i++) { + if ((*funcs)->free_func != NULL) { + int index = (int)i + ex_data_class->num_reserved; + void *ptr = CRYPTO_get_ex_data(ad, index); + (*funcs)->free_func(obj, ptr, ad, index, (*funcs)->argl, (*funcs)->argp); + } + funcs = &(*funcs)->next; + } sk_void_free(ad->sk); ad->sk = NULL; diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-gcm-x86_64-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-gcm-x86_64-linux.linux.x86_64.S index c80f4121..11df9e2f 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-gcm-x86_64-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-gcm-x86_64-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .type _aesni_ctr32_ghash_6x,@function @@ -355,6 +348,7 @@ _aesni_ctr32_ghash_6x: aesni_gcm_decrypt: .cfi_startproc +_CET_ENDBR xorq %rax,%rax @@ -385,17 +379,18 @@ aesni_gcm_decrypt: vzeroupper + movq 16(%rbp),%r12 vmovdqu (%r8),%xmm1 addq $-128,%rsp movl 12(%r8),%ebx leaq .Lbswap_mask(%rip),%r11 leaq -128(%rcx),%r14 movq $0xf80,%r15 - vmovdqu (%r9),%xmm8 + vmovdqu (%r12),%xmm8 andq $-128,%rsp vmovdqu (%r11),%xmm0 leaq 128(%rcx),%rcx - leaq 32+32(%r9),%r9 + leaq 32(%r9),%r9 movl 240-128(%rcx),%r10d vpshufb %xmm0,%xmm8,%xmm8 @@ -440,6 +435,7 @@ aesni_gcm_decrypt: call _aesni_ctr32_ghash_6x + movq 16(%rbp),%r12 vmovups %xmm9,-96(%rsi) vmovups %xmm10,-80(%rsi) vmovups %xmm11,-64(%rsi) @@ -448,7 +444,7 @@ aesni_gcm_decrypt: vmovups %xmm14,-16(%rsi) vpshufb (%r11),%xmm8,%xmm8 - vmovdqu %xmm8,-64(%r9) + vmovdqu %xmm8,(%r12) vzeroupper leaq -40(%rbp),%rsp @@ -576,6 +572,7 @@ _aesni_ctr32_6x: aesni_gcm_encrypt: .cfi_startproc +_CET_ENDBR #ifdef BORINGSSL_DISPATCH_TEST .extern BORINGSSL_function_hit .hidden BORINGSSL_function_hit @@ -660,8 +657,9 @@ aesni_gcm_encrypt: call _aesni_ctr32_6x - vmovdqu (%r9),%xmm8 - leaq 32+32(%r9),%r9 + movq 16(%rbp),%r12 + leaq 32(%r9),%r9 + vmovdqu (%r12),%xmm8 subq $12,%rdx movq $192,%rax vpshufb %xmm0,%xmm8,%xmm8 @@ -839,8 +837,9 @@ aesni_gcm_encrypt: vpclmulqdq $0x10,%xmm3,%xmm8,%xmm8 vpxor %xmm7,%xmm2,%xmm2 vpxor %xmm2,%xmm8,%xmm8 + movq 16(%rbp),%r12 vpshufb (%r11),%xmm8,%xmm8 - vmovdqu %xmm8,-64(%r9) + vmovdqu %xmm8,(%r12) vzeroupper leaq -40(%rbp),%rsp @@ -884,10 +883,6 @@ aesni_gcm_encrypt: .align 64 .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-gcm-x86_64-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-gcm-x86_64-mac.mac.x86_64.S index 88533324..2efaf37a 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-gcm-x86_64-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-gcm-x86_64-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text @@ -355,6 +348,7 @@ L$6x_done: _aesni_gcm_decrypt: +_CET_ENDBR xorq %rax,%rax @@ -384,17 +378,18 @@ _aesni_gcm_decrypt: vzeroupper + movq 16(%rbp),%r12 vmovdqu (%r8),%xmm1 addq $-128,%rsp movl 12(%r8),%ebx leaq L$bswap_mask(%rip),%r11 leaq -128(%rcx),%r14 movq $0xf80,%r15 - vmovdqu (%r9),%xmm8 + vmovdqu (%r12),%xmm8 andq $-128,%rsp vmovdqu (%r11),%xmm0 leaq 128(%rcx),%rcx - leaq 32+32(%r9),%r9 + leaq 32(%r9),%r9 movl 240-128(%rcx),%r10d vpshufb %xmm0,%xmm8,%xmm8 @@ -439,6 +434,7 @@ L$dec_no_key_aliasing: call _aesni_ctr32_ghash_6x + movq 16(%rbp),%r12 vmovups %xmm9,-96(%rsi) vmovups %xmm10,-80(%rsi) vmovups %xmm11,-64(%rsi) @@ -447,7 +443,7 @@ L$dec_no_key_aliasing: vmovups %xmm14,-16(%rsi) vpshufb (%r11),%xmm8,%xmm8 - vmovdqu %xmm8,-64(%r9) + vmovdqu %xmm8,(%r12) vzeroupper leaq -40(%rbp),%rsp @@ -569,6 +565,7 @@ L$handle_ctr32_2: _aesni_gcm_encrypt: +_CET_ENDBR #ifdef BORINGSSL_DISPATCH_TEST movb $1,_BORINGSSL_function_hit+2(%rip) @@ -651,8 +648,9 @@ L$enc_no_key_aliasing: call _aesni_ctr32_6x - vmovdqu (%r9),%xmm8 - leaq 32+32(%r9),%r9 + movq 16(%rbp),%r12 + leaq 32(%r9),%r9 + vmovdqu (%r12),%xmm8 subq $12,%rdx movq $192,%rax vpshufb %xmm0,%xmm8,%xmm8 @@ -830,8 +828,9 @@ L$enc_no_key_aliasing: vpclmulqdq $0x10,%xmm3,%xmm8,%xmm8 vpxor %xmm7,%xmm2,%xmm2 vpxor %xmm2,%xmm8,%xmm8 + movq 16(%rbp),%r12 vpshufb (%r11),%xmm8,%xmm8 - vmovdqu %xmm8,-64(%r9) + vmovdqu %xmm8,(%r12) vzeroupper leaq -40(%rbp),%rsp @@ -869,10 +868,6 @@ L$one_lsb: .p2align 6 .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-x86-linux.linux.x86.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-x86-linux.linux.x86.S index eb190575..8d6cf17d 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-x86-linux.linux.x86.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-x86-linux.linux.x86.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) .text #ifdef BORINGSSL_DISPATCH_TEST #endif @@ -2517,11 +2510,7 @@ aes_hw_set_decrypt_key: .byte 83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83 .byte 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115 .byte 115,108,46,111,114,103,62,0 -#endif // !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-x86_64-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-x86_64-linux.linux.x86_64.S index b0339ec7..901c5e61 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-x86_64-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-x86_64-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .extern OPENSSL_ia32cap_P .hidden OPENSSL_ia32cap_P @@ -22,6 +15,7 @@ .align 16 aes_hw_encrypt: .cfi_startproc +_CET_ENDBR #ifdef BORINGSSL_DISPATCH_TEST .extern BORINGSSL_function_hit .hidden BORINGSSL_function_hit @@ -54,6 +48,7 @@ aes_hw_encrypt: .align 16 aes_hw_decrypt: .cfi_startproc +_CET_ENDBR movups (%rdi),%xmm2 movl 240(%rdx),%eax movups (%rdx),%xmm0 @@ -542,6 +537,7 @@ _aesni_decrypt8: .align 16 aes_hw_ecb_encrypt: .cfi_startproc +_CET_ENDBR andq $-16,%rdx jz .Lecb_ret @@ -887,6 +883,7 @@ aes_hw_ecb_encrypt: .align 16 aes_hw_ctr32_encrypt_blocks: .cfi_startproc +_CET_ENDBR #ifdef BORINGSSL_DISPATCH_TEST movb $1,BORINGSSL_function_hit(%rip) #endif @@ -1264,6 +1261,8 @@ aes_hw_ctr32_encrypt_blocks: pxor %xmm0,%xmm13 movdqu 80(%rdi),%xmm15 pxor %xmm0,%xmm14 + prefetcht0 448(%rdi) + prefetcht0 512(%rdi) pxor %xmm0,%xmm15 .byte 102,15,56,220,209 .byte 102,15,56,220,217 @@ -1470,6 +1469,7 @@ aes_hw_ctr32_encrypt_blocks: .align 16 aes_hw_cbc_encrypt: .cfi_startproc +_CET_ENDBR testq %rdx,%rdx jz .Lcbc_ret @@ -2063,6 +2063,7 @@ aes_hw_cbc_encrypt: .align 16 aes_hw_set_decrypt_key: .cfi_startproc +_CET_ENDBR .byte 0x48,0x83,0xEC,0x08 .cfi_adjust_cfa_offset 8 call __aesni_set_encrypt_key @@ -2109,6 +2110,7 @@ aes_hw_set_decrypt_key: aes_hw_set_encrypt_key: __aesni_set_encrypt_key: .cfi_startproc +_CET_ENDBR #ifdef BORINGSSL_DISPATCH_TEST movb $1,BORINGSSL_function_hit+3(%rip) #endif @@ -2507,10 +2509,6 @@ __aesni_set_encrypt_key: .align 64 .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-x86_64-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-x86_64-mac.mac.x86_64.S index 8e826e64..aa5ab80c 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-x86_64-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesni-x86_64-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text .globl _aes_hw_encrypt @@ -21,6 +14,7 @@ .p2align 4 _aes_hw_encrypt: +_CET_ENDBR #ifdef BORINGSSL_DISPATCH_TEST movb $1,_BORINGSSL_function_hit+1(%rip) @@ -52,6 +46,7 @@ L$oop_enc1_1: .p2align 4 _aes_hw_decrypt: +_CET_ENDBR movups (%rdi),%xmm2 movl 240(%rdx),%eax movups (%rdx),%xmm0 @@ -540,6 +535,7 @@ L$dec_loop8_enter: .p2align 4 _aes_hw_ecb_encrypt: +_CET_ENDBR andq $-16,%rdx jz L$ecb_ret @@ -885,6 +881,7 @@ L$ecb_ret: .p2align 4 _aes_hw_ctr32_encrypt_blocks: +_CET_ENDBR #ifdef BORINGSSL_DISPATCH_TEST movb $1,_BORINGSSL_function_hit(%rip) #endif @@ -1262,6 +1259,8 @@ L$ctr32_enc_done: pxor %xmm0,%xmm13 movdqu 80(%rdi),%xmm15 pxor %xmm0,%xmm14 + prefetcht0 448(%rdi) + prefetcht0 512(%rdi) pxor %xmm0,%xmm15 .byte 102,15,56,220,209 .byte 102,15,56,220,217 @@ -1468,6 +1467,7 @@ L$ctr32_epilogue: .p2align 4 _aes_hw_cbc_encrypt: +_CET_ENDBR testq %rdx,%rdx jz L$cbc_ret @@ -2061,6 +2061,7 @@ L$cbc_ret: .p2align 4 _aes_hw_set_decrypt_key: +_CET_ENDBR .byte 0x48,0x83,0xEC,0x08 call __aesni_set_encrypt_key @@ -2107,6 +2108,7 @@ L$SEH_end_set_decrypt_key: _aes_hw_set_encrypt_key: __aesni_set_encrypt_key: +_CET_ENDBR #ifdef BORINGSSL_DISPATCH_TEST movb $1,_BORINGSSL_function_hit+3(%rip) #endif @@ -2505,10 +2507,6 @@ L$key_rcon1b: .p2align 6 .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv7-ios.ios.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv7-ios.ios.arm.S index 86fe4aca..9d4c1984 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv7-ios.ios.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv7-ios.ios.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__APPLE__) #include #if __ARM_MAX_ARCH__>=7 @@ -808,11 +800,7 @@ Lctr32_done: ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,pc} #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__APPLE__) #endif // defined(__arm__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv7-linux.linux.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv7-linux.linux.arm.S index 87a5e1c6..f38e85e4 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv7-linux.linux.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv7-linux.linux.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) #include #if __ARM_MAX_ARCH__>=7 @@ -796,11 +788,7 @@ aes_hw_ctr32_encrypt_blocks: ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,pc} .size aes_hw_ctr32_encrypt_blocks,.-aes_hw_ctr32_encrypt_blocks #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv8-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv8-ios.ios.aarch64.S index daefcaf1..71e56359 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv8-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv8-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) #include #if __ARM_MAX_ARCH__>=7 @@ -798,11 +790,7 @@ Lctr32_done: ret #endif -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv8-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv8-linux.linux.aarch64.S index fa64f3c6..7f98e4bc 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv8-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-armv8-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) #include #if __ARM_MAX_ARCH__>=7 @@ -798,11 +790,7 @@ aes_hw_ctr32_encrypt_blocks: ret .size aes_hw_ctr32_encrypt_blocks,.-aes_hw_ctr32_encrypt_blocks #endif -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-gcm-armv8-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-gcm-armv8-ios.ios.aarch64.S index f60a6469..e6a85f0c 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-gcm-armv8-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-gcm-armv8-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) #include #if __ARM_MAX_ARCH__ >= 8 @@ -85,7 +77,7 @@ _aes_gcm_enc_kernel: ldr q23, [x8, #80] // load rk5 aese v1.16b, v19.16b aesmc v1.16b, v1.16b // AES block 1 - round 1 - ldr q14, [x3, #80] // load h3l | h3h + ldr q14, [x6, #48] // load h3l | h3h ext v14.16b, v14.16b, v14.16b, #8 aese v3.16b, v18.16b aesmc v3.16b, v3.16b // AES block 3 - round 0 @@ -94,14 +86,14 @@ _aes_gcm_enc_kernel: ldr q22, [x8, #64] // load rk4 aese v1.16b, v20.16b aesmc v1.16b, v1.16b // AES block 1 - round 2 - ldr q13, [x3, #64] // load h2l | h2h + ldr q13, [x6, #32] // load h2l | h2h ext v13.16b, v13.16b, v13.16b, #8 aese v3.16b, v19.16b aesmc v3.16b, v3.16b // AES block 3 - round 1 ldr q30, [x8, #192] // load rk12 aese v2.16b, v20.16b aesmc v2.16b, v2.16b // AES block 2 - round 2 - ldr q15, [x3, #112] // load h4l | h4h + ldr q15, [x6, #80] // load h4l | h4h ext v15.16b, v15.16b, v15.16b, #8 aese v1.16b, v21.16b aesmc v1.16b, v1.16b // AES block 1 - round 3 @@ -144,7 +136,7 @@ _aes_gcm_enc_kernel: ldr q27, [x8, #144] // load rk9 aese v0.16b, v24.16b aesmc v0.16b, v0.16b // AES block 0 - round 6 - ldr q12, [x3, #32] // load h1l | h1h + ldr q12, [x6] // load h1l | h1h ext v12.16b, v12.16b, v12.16b, #8 aese v2.16b, v24.16b aesmc v2.16b, v2.16b // AES block 2 - round 6 @@ -845,15 +837,15 @@ _aes_gcm_dec_kernel: ldr q19, [x8, #16] // load rk1 aese v0.16b, v18.16b aesmc v0.16b, v0.16b // AES block 0 - round 0 - ldr q14, [x3, #80] // load h3l | h3h + ldr q14, [x6, #48] // load h3l | h3h ext v14.16b, v14.16b, v14.16b, #8 aese v3.16b, v18.16b aesmc v3.16b, v3.16b // AES block 3 - round 0 - ldr q15, [x3, #112] // load h4l | h4h + ldr q15, [x6, #80] // load h4l | h4h ext v15.16b, v15.16b, v15.16b, #8 aese v1.16b, v18.16b aesmc v1.16b, v1.16b // AES block 1 - round 0 - ldr q13, [x3, #64] // load h2l | h2h + ldr q13, [x6, #32] // load h2l | h2h ext v13.16b, v13.16b, v13.16b, #8 aese v2.16b, v18.16b aesmc v2.16b, v2.16b // AES block 2 - round 0 @@ -873,7 +865,7 @@ _aes_gcm_dec_kernel: ldr q30, [x8, #192] // load rk12 aese v0.16b, v20.16b aesmc v0.16b, v0.16b // AES block 0 - round 2 - ldr q12, [x3, #32] // load h1l | h1h + ldr q12, [x6] // load h1l | h1h ext v12.16b, v12.16b, v12.16b, #8 aese v2.16b, v20.16b aesmc v2.16b, v2.16b // AES block 2 - round 2 @@ -1562,11 +1554,7 @@ Ldec_blocks_less_than_1: // blocks left <= 1 ret #endif -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-gcm-armv8-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-gcm-armv8-linux.linux.aarch64.S index cb452a48..8ff6cd7f 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-gcm-armv8-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/aesv8-gcm-armv8-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) #include #if __ARM_MAX_ARCH__ >= 8 @@ -85,7 +77,7 @@ aes_gcm_enc_kernel: ldr q23, [x8, #80] // load rk5 aese v1.16b, v19.16b aesmc v1.16b, v1.16b // AES block 1 - round 1 - ldr q14, [x3, #80] // load h3l | h3h + ldr q14, [x6, #48] // load h3l | h3h ext v14.16b, v14.16b, v14.16b, #8 aese v3.16b, v18.16b aesmc v3.16b, v3.16b // AES block 3 - round 0 @@ -94,14 +86,14 @@ aes_gcm_enc_kernel: ldr q22, [x8, #64] // load rk4 aese v1.16b, v20.16b aesmc v1.16b, v1.16b // AES block 1 - round 2 - ldr q13, [x3, #64] // load h2l | h2h + ldr q13, [x6, #32] // load h2l | h2h ext v13.16b, v13.16b, v13.16b, #8 aese v3.16b, v19.16b aesmc v3.16b, v3.16b // AES block 3 - round 1 ldr q30, [x8, #192] // load rk12 aese v2.16b, v20.16b aesmc v2.16b, v2.16b // AES block 2 - round 2 - ldr q15, [x3, #112] // load h4l | h4h + ldr q15, [x6, #80] // load h4l | h4h ext v15.16b, v15.16b, v15.16b, #8 aese v1.16b, v21.16b aesmc v1.16b, v1.16b // AES block 1 - round 3 @@ -144,7 +136,7 @@ aes_gcm_enc_kernel: ldr q27, [x8, #144] // load rk9 aese v0.16b, v24.16b aesmc v0.16b, v0.16b // AES block 0 - round 6 - ldr q12, [x3, #32] // load h1l | h1h + ldr q12, [x6] // load h1l | h1h ext v12.16b, v12.16b, v12.16b, #8 aese v2.16b, v24.16b aesmc v2.16b, v2.16b // AES block 2 - round 6 @@ -845,15 +837,15 @@ aes_gcm_dec_kernel: ldr q19, [x8, #16] // load rk1 aese v0.16b, v18.16b aesmc v0.16b, v0.16b // AES block 0 - round 0 - ldr q14, [x3, #80] // load h3l | h3h + ldr q14, [x6, #48] // load h3l | h3h ext v14.16b, v14.16b, v14.16b, #8 aese v3.16b, v18.16b aesmc v3.16b, v3.16b // AES block 3 - round 0 - ldr q15, [x3, #112] // load h4l | h4h + ldr q15, [x6, #80] // load h4l | h4h ext v15.16b, v15.16b, v15.16b, #8 aese v1.16b, v18.16b aesmc v1.16b, v1.16b // AES block 1 - round 0 - ldr q13, [x3, #64] // load h2l | h2h + ldr q13, [x6, #32] // load h2l | h2h ext v13.16b, v13.16b, v13.16b, #8 aese v2.16b, v18.16b aesmc v2.16b, v2.16b // AES block 2 - round 0 @@ -873,7 +865,7 @@ aes_gcm_dec_kernel: ldr q30, [x8, #192] // load rk12 aese v0.16b, v20.16b aesmc v0.16b, v0.16b // AES block 0 - round 2 - ldr q12, [x3, #32] // load h1l | h1h + ldr q12, [x6] // load h1l | h1h ext v12.16b, v12.16b, v12.16b, #8 aese v2.16b, v20.16b aesmc v2.16b, v2.16b // AES block 2 - round 2 @@ -1562,11 +1554,7 @@ aes_gcm_dec_kernel: ret .size aes_gcm_dec_kernel,.-aes_gcm_dec_kernel #endif -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv4-mont-ios.ios.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv4-mont-ios.ios.arm.S index 99ff3c29..cffd664c 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv4-mont-ios.ios.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv4-mont-ios.ios.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__APPLE__) #include @ Silence ARMv8 deprecated IT instruction warnings. This file is used by both @@ -981,11 +973,7 @@ OPENSSL_armcap_P: .long 0 .private_extern _OPENSSL_armcap_P #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__APPLE__) #endif // defined(__arm__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv4-mont-linux.linux.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv4-mont-linux.linux.arm.S index 791ab706..ab7259d0 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv4-mont-linux.linux.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv4-mont-linux.linux.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) #include @ Silence ARMv8 deprecated IT instruction warnings. This file is used by both @@ -973,11 +965,7 @@ bn_mul8x_mont_neon: .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv8-mont-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv8-mont-ios.ios.aarch64.S index 4ee81faf..82b43294 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv8-mont-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv8-mont-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) #include .text @@ -1432,11 +1424,7 @@ Lmul4x_done: .byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 2 .align 4 -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv8-mont-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv8-mont-linux.linux.aarch64.S index 3b98634b..5d56f5b2 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv8-mont-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/armv8-mont-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) #include .text @@ -1432,11 +1424,7 @@ __bn_mul4x_mont: .byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 2 .align 4 -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn-586-linux.linux.x86.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn-586-linux.linux.x86.S index d68ea031..ff3c9b61 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn-586-linux.linux.x86.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn-586-linux.linux.x86.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) .text .globl bn_mul_add_words .hidden bn_mul_add_words @@ -1001,11 +994,7 @@ bn_sub_words: popl %ebp ret .size bn_sub_words,.-.L_bn_sub_words_begin -#endif // !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn-armv8-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn-armv8-ios.ios.aarch64.S index 4d878cf6..4efdfa89 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn-armv8-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn-armv8-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) #include .text @@ -96,11 +88,7 @@ Lsub_exit: cset x0, cc ret -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn-armv8-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn-armv8-linux.linux.aarch64.S index 95f0df46..14d9eeee 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn-armv8-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn-armv8-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) #include .text @@ -96,11 +88,7 @@ bn_sub_words: cset x0, cc ret .size bn_sub_words,.-bn_sub_words -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/div.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/div.c index bcc9a385..4233f4a9 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/div.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/div.c @@ -711,15 +711,22 @@ int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, int bn_mod_lshift_consttime(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx) { - if (!BN_copy(r, a)) { + if (!BN_copy(r, a) || + !bn_resize_words(r, m->width)) { return 0; } - for (int i = 0; i < n; i++) { - if (!bn_mod_lshift1_consttime(r, r, m, ctx)) { - return 0; + + BN_CTX_start(ctx); + BIGNUM *tmp = bn_scratch_space_from_ctx(m->width, ctx); + int ok = tmp != NULL; + if (ok) { + for (int i = 0; i < n; i++) { + bn_mod_add_words(r->d, r->d, r->d, m->d, tmp->d, m->width); } + r->neg = 0; } - return 1; + BN_CTX_end(ctx); + return ok; } int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m) { diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/gcd.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/gcd.c index 179c1657..cfdb84d3 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/gcd.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/gcd.c @@ -263,15 +263,14 @@ int BN_mod_inverse_odd(BIGNUM *out, int *out_no_inverse, const BIGNUM *a, // Now Y*a == A (mod |n|). // Y*a == 1 (mod |n|) - if (!Y->neg && BN_ucmp(Y, n) < 0) { - if (!BN_copy(R, Y)) { - goto err; - } - } else { - if (!BN_nnmod(R, Y, n, ctx)) { + if (Y->neg || BN_ucmp(Y, n) >= 0) { + if (!BN_nnmod(Y, Y, n, ctx)) { goto err; } } + if (!BN_copy(R, Y)) { + goto err; + } ret = 1; diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/internal.h b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/internal.h index 52b99092..e372412b 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/internal.h @@ -431,12 +431,11 @@ void bn_power5(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *table, uint64_t bn_mont_n0(const BIGNUM *n); -// bn_mod_exp_base_2_consttime calculates r = 2**p (mod n). |p| must be larger -// than log_2(n); i.e. 2**p must be larger than |n|. |n| must be positive and -// odd. |p| and the bit width of |n| are assumed public, but |n| is otherwise -// treated as secret. -int bn_mod_exp_base_2_consttime(BIGNUM *r, unsigned p, const BIGNUM *n, - BN_CTX *ctx); +// bn_mont_ctx_set_RR_consttime initializes |mont->RR|. It returns one on +// success and zero on error. |mont->N| and |mont->n0| must have been +// initialized already. The bit width of |mont->N| is assumed public, but +// |mont->N| is otherwise treated as secret. +int bn_mont_ctx_set_RR_consttime(BN_MONT_CTX *mont, BN_CTX *ctx); #if defined(_MSC_VER) #if defined(OPENSSL_X86_64) @@ -600,6 +599,13 @@ OPENSSL_EXPORT int bn_is_relatively_prime(int *out_relatively_prime, OPENSSL_EXPORT int bn_lcm_consttime(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); +// bn_mont_ctx_init zero-initialies |mont|. +void bn_mont_ctx_init(BN_MONT_CTX *mont); + +// bn_mont_ctx_cleanup releases memory associated with |mont|, without freeing +// |mont| itself. +void bn_mont_ctx_cleanup(BN_MONT_CTX *mont); + // Constant-time modular arithmetic. // diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/montgomery.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/montgomery.c index a0896b58..530875f5 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/montgomery.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/montgomery.c @@ -121,17 +121,24 @@ #include "../../internal.h" +void bn_mont_ctx_init(BN_MONT_CTX *mont) { + OPENSSL_memset(mont, 0, sizeof(BN_MONT_CTX)); + BN_init(&mont->RR); + BN_init(&mont->N); +} + +void bn_mont_ctx_cleanup(BN_MONT_CTX *mont) { + BN_free(&mont->RR); + BN_free(&mont->N); +} + BN_MONT_CTX *BN_MONT_CTX_new(void) { BN_MONT_CTX *ret = OPENSSL_malloc(sizeof(BN_MONT_CTX)); - if (ret == NULL) { return NULL; } - OPENSSL_memset(ret, 0, sizeof(BN_MONT_CTX)); - BN_init(&ret->RR); - BN_init(&ret->N); - + bn_mont_ctx_init(ret); return ret; } @@ -140,8 +147,7 @@ void BN_MONT_CTX_free(BN_MONT_CTX *mont) { return; } - BN_free(&mont->RR); - BN_free(&mont->N); + bn_mont_ctx_cleanup(mont); OPENSSL_free(mont); } @@ -248,19 +254,12 @@ BN_MONT_CTX *BN_MONT_CTX_new_for_modulus(const BIGNUM *mod, BN_CTX *ctx) { BN_MONT_CTX *BN_MONT_CTX_new_consttime(const BIGNUM *mod, BN_CTX *ctx) { BN_MONT_CTX *mont = BN_MONT_CTX_new(); if (mont == NULL || - !bn_mont_ctx_set_N_and_n0(mont, mod)) { - goto err; - } - unsigned lgBigR = mont->N.width * BN_BITS2; - if (!bn_mod_exp_base_2_consttime(&mont->RR, lgBigR * 2, &mont->N, ctx) || - !bn_resize_words(&mont->RR, mont->N.width)) { - goto err; + !bn_mont_ctx_set_N_and_n0(mont, mod) || + !bn_mont_ctx_set_RR_consttime(mont, ctx)) { + BN_MONT_CTX_free(mont); + return NULL; } return mont; - -err: - BN_MONT_CTX_free(mont); - return NULL; } int BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, CRYPTO_MUTEX *lock, diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/montgomery_inv.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/montgomery_inv.c index 4d3a87c9..1929dbdb 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/montgomery_inv.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/montgomery_inv.c @@ -159,27 +159,63 @@ static uint64_t bn_neg_inv_mod_r_u64(uint64_t n) { return v; } -int bn_mod_exp_base_2_consttime(BIGNUM *r, unsigned p, const BIGNUM *n, - BN_CTX *ctx) { - assert(!BN_is_zero(n)); - assert(!BN_is_negative(n)); - assert(BN_is_odd(n)); +int bn_mont_ctx_set_RR_consttime(BN_MONT_CTX *mont, BN_CTX *ctx) { + assert(!BN_is_zero(&mont->N)); + assert(!BN_is_negative(&mont->N)); + assert(BN_is_odd(&mont->N)); + assert(bn_minimal_width(&mont->N) == mont->N.width); - BN_zero(r); - - unsigned n_bits = BN_num_bits(n); + unsigned n_bits = BN_num_bits(&mont->N); assert(n_bits != 0); - assert(p > n_bits); if (n_bits == 1) { - return 1; + BN_zero(&mont->RR); + return bn_resize_words(&mont->RR, mont->N.width); } - // Set |r| to the larger power of two smaller than |n|, then shift with - // reductions the rest of the way. - if (!BN_set_bit(r, n_bits - 1) || - !bn_mod_lshift_consttime(r, r, p - (n_bits - 1), n, ctx)) { + unsigned lgBigR = mont->N.width * BN_BITS2; + assert(lgBigR >= n_bits); + + // RR is R, or 2^lgBigR, in the Montgomery domain. We can compute 2 in the + // Montgomery domain, 2R or 2^(lgBigR+1), and then use Montgomery + // square-and-multiply to exponentiate. + // + // The multiply steps take 2^n R to 2^(n+1) R. It is faster to double + // the value instead. The square steps take 2^n R to 2^(2n) R. This is + // equivalent to doubling n times. When n is below some threshold, doubling is + // faster. When above, squaring is faster. + // + // We double to this threshold, then switch to Montgomery squaring. From + // benchmarking various 32-bit and 64-bit architectures, the word count seems + // to work well as a threshold. (Doubling scales linearly and Montgomery + // reduction scales quadratically, so the threshold should scale roughly + // linearly.) + unsigned threshold = mont->N.width; + unsigned iters; + for (iters = 0; iters < sizeof(lgBigR) * 8; iters++) { + if ((lgBigR >> iters) <= threshold) { + break; + } + } + + // Compute 2^(lgBigR >> iters) R, or 2^((lgBigR >> iters) + lgBigR), by + // doubling. The first n_bits - 1 doubles can be skipped because we don't need + // to reduce. + if (!BN_set_bit(&mont->RR, n_bits - 1) || + !bn_mod_lshift_consttime(&mont->RR, &mont->RR, + (lgBigR >> iters) + lgBigR - (n_bits - 1), + &mont->N, ctx)) { return 0; } - return 1; + for (unsigned i = iters - 1; i < iters; i--) { + if (!BN_mod_mul_montgomery(&mont->RR, &mont->RR, &mont->RR, mont, ctx)) { + return 0; + } + if ((lgBigR & (1u << i)) != 0 && + !bn_mod_lshift1_consttime(&mont->RR, &mont->RR, &mont->N, ctx)) { + return 0; + } + } + + return bn_resize_words(&mont->RR, mont->N.width); } diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/rsaz_exp.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/rsaz_exp.c index 3acff1c0..c1e505d8 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/rsaz_exp.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bn/rsaz_exp.c @@ -24,13 +24,13 @@ #include "../../internal.h" -// one is 1 in RSAZ's representation. -alignas(64) static const BN_ULONG one[40] = { +// rsaz_one is 1 in RSAZ's representation. +alignas(64) static const BN_ULONG rsaz_one[40] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -// two80 is 2^80 in RSAZ's representation. Note RSAZ uses base 2^29, so this is +// rsaz_two80 is 2^80 in RSAZ's representation. Note RSAZ uses base 2^29, so this is // 2^(29*2 + 22) = 2^80, not 2^(64*2 + 22). -alignas(64) static const BN_ULONG two80[40] = { +alignas(64) static const BN_ULONG rsaz_two80[40] = { 0, 0, 1 << 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -64,12 +64,12 @@ void RSAZ_1024_mod_exp_avx2(BN_ULONG result_norm[16], // giving R = 2^(36*29) = 2^1044. rsaz_1024_mul_avx2(R2, R2, R2, m, k0); // R2 = 2^2048 * 2^2048 / 2^1044 = 2^3052 - rsaz_1024_mul_avx2(R2, R2, two80, m, k0); + rsaz_1024_mul_avx2(R2, R2, rsaz_two80, m, k0); // R2 = 2^3052 * 2^80 / 2^1044 = 2^2088 = (2^1044)^2 // table[0] = 1 // table[1] = a_inv^1 - rsaz_1024_mul_avx2(result, R2, one, m, k0); + rsaz_1024_mul_avx2(result, R2, rsaz_one, m, k0); rsaz_1024_mul_avx2(a_inv, a_inv, R2, m, k0); rsaz_1024_scatter5_avx2(table_s, result, 0); rsaz_1024_scatter5_avx2(table_s, a_inv, 1); @@ -125,7 +125,7 @@ void RSAZ_1024_mod_exp_avx2(BN_ULONG result_norm[16], rsaz_1024_mul_avx2(result, result, a_inv, m, k0); // Convert from Montgomery. - rsaz_1024_mul_avx2(result, result, one, m, k0); + rsaz_1024_mul_avx2(result, result, rsaz_one, m, k0); rsaz_1024_red2norm_avx2(result_norm, result); BN_ULONG scratch[16]; diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bsaes-armv7-ios.ios.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bsaes-armv7-ios.ios.arm.S index 6ed18a9a..d9e9e90e 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bsaes-armv7-ios.ios.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bsaes-armv7-ios.ios.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__APPLE__) @ Copyright 2012-2016 The OpenSSL Project Authors. All Rights Reserved. @ @ Licensed under the OpenSSL license (the "License"). You may not use @@ -1535,11 +1527,7 @@ Lctr_enc_bzero:@ wipe key schedule [if any] @ out to retain a constant-time implementation. #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__APPLE__) #endif // defined(__arm__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bsaes-armv7-linux.linux.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bsaes-armv7-linux.linux.arm.S index 11e8e7f9..eda246e5 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/bsaes-armv7-linux.linux.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/bsaes-armv7-linux.linux.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) @ Copyright 2012-2016 The OpenSSL Project Authors. All Rights Reserved. @ @ Licensed under the OpenSSL license (the "License"). You may not use @@ -1525,11 +1517,7 @@ bsaes_ctr32_encrypt_blocks: @ out to retain a constant-time implementation. .size bsaes_ctr32_encrypt_blocks,.-bsaes_ctr32_encrypt_blocks #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/co-586-linux.linux.x86.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/co-586-linux.linux.x86.S index 4ab23509..4c61741a 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/co-586-linux.linux.x86.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/co-586-linux.linux.x86.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) .text .globl bn_mul_comba8 .hidden bn_mul_comba8 @@ -1270,11 +1263,7 @@ bn_sqr_comba4: popl %esi ret .size bn_sqr_comba4,.-.L_bn_sqr_comba4_begin -#endif // !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/delocate.h b/Sources/CCryptoBoringSSL/crypto/fipsmodule/delocate.h index dcd03f49..8be14a2d 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/delocate.h +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/delocate.h @@ -27,9 +27,8 @@ type *name##_bss_get(void) __attribute__((const)); // For FIPS builds we require that CRYPTO_ONCE_INIT be zero. #define DEFINE_STATIC_ONCE(name) DEFINE_BSS_GET(CRYPTO_once_t, name) -// For FIPS builds we require that CRYPTO_STATIC_MUTEX_INIT be zero. -#define DEFINE_STATIC_MUTEX(name) \ - DEFINE_BSS_GET(struct CRYPTO_STATIC_MUTEX, name) +// For FIPS builds we require that CRYPTO_MUTEX_INIT be zero. +#define DEFINE_STATIC_MUTEX(name) DEFINE_BSS_GET(CRYPTO_MUTEX, name) // For FIPS builds we require that CRYPTO_EX_DATA_CLASS_INIT be zero. #define DEFINE_STATIC_EX_DATA_CLASS(name) \ DEFINE_BSS_GET(CRYPTO_EX_DATA_CLASS, name) @@ -40,9 +39,9 @@ #define DEFINE_STATIC_ONCE(name) \ static CRYPTO_once_t name = CRYPTO_ONCE_INIT; \ static CRYPTO_once_t *name##_bss_get(void) { return &name; } -#define DEFINE_STATIC_MUTEX(name) \ - static struct CRYPTO_STATIC_MUTEX name = CRYPTO_STATIC_MUTEX_INIT; \ - static struct CRYPTO_STATIC_MUTEX *name##_bss_get(void) { return &name; } +#define DEFINE_STATIC_MUTEX(name) \ + static CRYPTO_MUTEX name = CRYPTO_MUTEX_INIT; \ + static CRYPTO_MUTEX *name##_bss_get(void) { return &name; } #define DEFINE_STATIC_EX_DATA_CLASS(name) \ static CRYPTO_EX_DATA_CLASS name = CRYPTO_EX_DATA_CLASS_INIT; \ static CRYPTO_EX_DATA_CLASS *name##_bss_get(void) { return &name; } diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/dh/dh.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/dh/dh.c index f9fd59c8..eb565468 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/dh/dh.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/dh/dh.c @@ -177,6 +177,9 @@ int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) { dh->g = g; } + // Invalidate the cached Montgomery parameters. + BN_MONT_CTX_free(dh->method_mont_p); + dh->method_mont_p = NULL; return 1; } diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/dh/internal.h b/Sources/CCryptoBoringSSL/crypto/fipsmodule/dh/internal.h index 54542066..c340c928 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/dh/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/dh/internal.h @@ -19,6 +19,8 @@ #include +#include "../../internal.h" + #if defined(__cplusplus) extern "C" { #endif diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/builtin_curves.h b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/builtin_curves.h new file mode 100644 index 00000000..0b489ab5 --- /dev/null +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/builtin_curves.h @@ -0,0 +1,277 @@ +/* Copyright (c) 2023, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +// This file is generated by make_tables.go. + +// P-224 +OPENSSL_UNUSED static const uint64_t kP224FieldN0 = 0xffffffffffffffff; +OPENSSL_UNUSED static const uint64_t kP224OrderN0 = 0xd6e242706a1fc2eb; +#if defined(OPENSSL_64_BIT) +OPENSSL_UNUSED static const uint64_t kP224Field[] = { + 0x0000000000000001, 0xffffffff00000000, 0xffffffffffffffff, + 0x00000000ffffffff}; +OPENSSL_UNUSED static const uint64_t kP224Order[] = { + 0x13dd29455c5c2a3d, 0xffff16a2e0b8f03e, 0xffffffffffffffff, + 0x00000000ffffffff}; +OPENSSL_UNUSED static const uint64_t kP224B[] = { + 0x270b39432355ffb4, 0x5044b0b7d7bfd8ba, 0x0c04b3abf5413256, + 0x00000000b4050a85}; +OPENSSL_UNUSED static const uint64_t kP224GX[] = { + 0x343280d6115c1d21, 0x4a03c1d356c21122, 0x6bb4bf7f321390b9, + 0x00000000b70e0cbd}; +OPENSSL_UNUSED static const uint64_t kP224GY[] = { + 0x44d5819985007e34, 0xcd4375a05a074764, 0xb5f723fb4c22dfe6, + 0x00000000bd376388}; +OPENSSL_UNUSED static const uint64_t kP224FieldR[] = { + 0xffffffff00000000, 0xffffffffffffffff, 0x0000000000000000, + 0x0000000000000000}; +OPENSSL_UNUSED static const uint64_t kP224FieldRR[] = { + 0xffffffff00000001, 0xffffffff00000000, 0xfffffffe00000000, + 0x00000000ffffffff}; +OPENSSL_UNUSED static const uint64_t kP224OrderRR[] = { + 0x29947a695f517d15, 0xabc8ff5931d63f4b, 0x6ad15f7cd9714856, + 0x00000000b1e97961}; +OPENSSL_UNUSED static const uint64_t kP224MontB[] = { + 0xe768cdf663c059cd, 0x107ac2f3ccf01310, 0x3dceba98c8528151, + 0x000000007fc02f93}; +OPENSSL_UNUSED static const uint64_t kP224MontGX[] = { + 0xbc9052266d0a4aea, 0x852597366018bfaa, 0x6dd3af9bf96bec05, + 0x00000000a21b5e60}; +OPENSSL_UNUSED static const uint64_t kP224MontGY[] = { + 0x2edca1e5eff3ede8, 0xf8cd672b05335a6b, 0xaea9c5ae03dfe878, + 0x00000000614786f1}; +#elif defined(OPENSSL_32_BIT) +OPENSSL_UNUSED static const uint32_t kP224Field[] = { + 0x00000001, 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff}; +OPENSSL_UNUSED static const uint32_t kP224Order[] = { + 0x5c5c2a3d, 0x13dd2945, 0xe0b8f03e, 0xffff16a2, 0xffffffff, 0xffffffff, + 0xffffffff}; +OPENSSL_UNUSED static const uint32_t kP224B[] = { + 0x2355ffb4, 0x270b3943, 0xd7bfd8ba, 0x5044b0b7, 0xf5413256, 0x0c04b3ab, + 0xb4050a85}; +OPENSSL_UNUSED static const uint32_t kP224GX[] = { + 0x115c1d21, 0x343280d6, 0x56c21122, 0x4a03c1d3, 0x321390b9, 0x6bb4bf7f, + 0xb70e0cbd}; +OPENSSL_UNUSED static const uint32_t kP224GY[] = { + 0x85007e34, 0x44d58199, 0x5a074764, 0xcd4375a0, 0x4c22dfe6, 0xb5f723fb, + 0xbd376388}; +OPENSSL_UNUSED static const uint32_t kP224FieldR[] = { + 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, + 0x00000000}; +OPENSSL_UNUSED static const uint32_t kP224FieldRR[] = { + 0x00000001, 0x00000000, 0x00000000, 0xfffffffe, 0xffffffff, 0xffffffff, + 0x00000000}; +OPENSSL_UNUSED static const uint32_t kP224OrderRR[] = { + 0x3ad01289, 0x6bdaae6c, 0x97a54552, 0x6ad09d91, 0xb1e97961, 0x1822bc47, + 0xd4baa4cf}; +OPENSSL_UNUSED static const uint32_t kP224MontB[] = { + 0xe768cdf7, 0xccf01310, 0x743b1cc0, 0xc8528150, 0x3dceba98, 0x7fc02f93, + 0x9c3fa633}; +OPENSSL_UNUSED static const uint32_t kP224MontGX[] = { + 0xbc905227, 0x6018bfaa, 0xf22fe220, 0xf96bec04, 0x6dd3af9b, 0xa21b5e60, + 0x92f5b516}; +OPENSSL_UNUSED static const uint32_t kP224MontGY[] = { + 0x2edca1e6, 0x05335a6b, 0xe8c15513, 0x03dfe878, 0xaea9c5ae, 0x614786f1, + 0x100c1218}; +#else +#error "unknown word size" +#endif + +// P-256 +OPENSSL_UNUSED static const uint64_t kP256FieldN0 = 0x0000000000000001; +OPENSSL_UNUSED static const uint64_t kP256OrderN0 = 0xccd1c8aaee00bc4f; +#if defined(OPENSSL_64_BIT) +OPENSSL_UNUSED static const uint64_t kP256Field[] = { + 0xffffffffffffffff, 0x00000000ffffffff, 0x0000000000000000, + 0xffffffff00000001}; +OPENSSL_UNUSED static const uint64_t kP256Order[] = { + 0xf3b9cac2fc632551, 0xbce6faada7179e84, 0xffffffffffffffff, + 0xffffffff00000000}; +OPENSSL_UNUSED static const uint64_t kP256FieldR[] = { + 0x0000000000000001, 0xffffffff00000000, 0xffffffffffffffff, + 0x00000000fffffffe}; +OPENSSL_UNUSED static const uint64_t kP256FieldRR[] = { + 0x0000000000000003, 0xfffffffbffffffff, 0xfffffffffffffffe, + 0x00000004fffffffd}; +OPENSSL_UNUSED static const uint64_t kP256OrderRR[] = { + 0x83244c95be79eea2, 0x4699799c49bd6fa6, 0x2845b2392b6bec59, + 0x66e12d94f3d95620}; +OPENSSL_UNUSED static const uint64_t kP256MontB[] = { + 0xd89cdf6229c4bddf, 0xacf005cd78843090, 0xe5a220abf7212ed6, + 0xdc30061d04874834}; +OPENSSL_UNUSED static const uint64_t kP256MontGX[] = { + 0x79e730d418a9143c, 0x75ba95fc5fedb601, 0x79fb732b77622510, + 0x18905f76a53755c6}; +OPENSSL_UNUSED static const uint64_t kP256MontGY[] = { + 0xddf25357ce95560a, 0x8b4ab8e4ba19e45c, 0xd2e88688dd21f325, + 0x8571ff1825885d85}; +#elif defined(OPENSSL_32_BIT) +OPENSSL_UNUSED static const uint32_t kP256Field[] = { + 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0xffffffff}; +OPENSSL_UNUSED static const uint32_t kP256Order[] = { + 0xfc632551, 0xf3b9cac2, 0xa7179e84, 0xbce6faad, 0xffffffff, 0xffffffff, + 0x00000000, 0xffffffff}; +OPENSSL_UNUSED static const uint32_t kP256FieldR[] = { + 0x00000001, 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, + 0xfffffffe, 0x00000000}; +OPENSSL_UNUSED static const uint32_t kP256FieldRR[] = { + 0x00000003, 0x00000000, 0xffffffff, 0xfffffffb, 0xfffffffe, 0xffffffff, + 0xfffffffd, 0x00000004}; +OPENSSL_UNUSED static const uint32_t kP256OrderRR[] = { + 0xbe79eea2, 0x83244c95, 0x49bd6fa6, 0x4699799c, 0x2b6bec59, 0x2845b239, + 0xf3d95620, 0x66e12d94}; +OPENSSL_UNUSED static const uint32_t kP256MontB[] = { + 0x29c4bddf, 0xd89cdf62, 0x78843090, 0xacf005cd, 0xf7212ed6, 0xe5a220ab, + 0x04874834, 0xdc30061d}; +OPENSSL_UNUSED static const uint32_t kP256MontGX[] = { + 0x18a9143c, 0x79e730d4, 0x5fedb601, 0x75ba95fc, 0x77622510, 0x79fb732b, + 0xa53755c6, 0x18905f76}; +OPENSSL_UNUSED static const uint32_t kP256MontGY[] = { + 0xce95560a, 0xddf25357, 0xba19e45c, 0x8b4ab8e4, 0xdd21f325, 0xd2e88688, + 0x25885d85, 0x8571ff18}; +#else +#error "unknown word size" +#endif + +// P-384 +OPENSSL_UNUSED static const uint64_t kP384FieldN0 = 0x0000000100000001; +OPENSSL_UNUSED static const uint64_t kP384OrderN0 = 0x6ed46089e88fdc45; +#if defined(OPENSSL_64_BIT) +OPENSSL_UNUSED static const uint64_t kP384Field[] = { + 0x00000000ffffffff, 0xffffffff00000000, 0xfffffffffffffffe, + 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; +OPENSSL_UNUSED static const uint64_t kP384Order[] = { + 0xecec196accc52973, 0x581a0db248b0a77a, 0xc7634d81f4372ddf, + 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; +OPENSSL_UNUSED static const uint64_t kP384FieldR[] = { + 0xffffffff00000001, 0x00000000ffffffff, 0x0000000000000001, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000}; +OPENSSL_UNUSED static const uint64_t kP384FieldRR[] = { + 0xfffffffe00000001, 0x0000000200000000, 0xfffffffe00000000, + 0x0000000200000000, 0x0000000000000001, 0x0000000000000000}; +OPENSSL_UNUSED static const uint64_t kP384OrderRR[] = { + 0x2d319b2419b409a9, 0xff3d81e5df1aa419, 0xbc3e483afcb82947, + 0xd40d49174aab1cc5, 0x3fb05b7a28266895, 0x0c84ee012b39bf21}; +OPENSSL_UNUSED static const uint64_t kP384MontB[] = { + 0x081188719d412dcc, 0xf729add87a4c32ec, 0x77f2209b1920022e, + 0xe3374bee94938ae2, 0xb62b21f41f022094, 0xcd08114b604fbff9}; +OPENSSL_UNUSED static const uint64_t kP384MontGX[] = { + 0x3dd0756649c0b528, 0x20e378e2a0d6ce38, 0x879c3afc541b4d6e, + 0x6454868459a30eff, 0x812ff723614ede2b, 0x4d3aadc2299e1513}; +OPENSSL_UNUSED static const uint64_t kP384MontGY[] = { + 0x23043dad4b03a4fe, 0xa1bfa8bf7bb4a9ac, 0x8bade7562e83b050, + 0xc6c3521968f4ffd9, 0xdd8002263969a840, 0x2b78abc25a15c5e9}; +#elif defined(OPENSSL_32_BIT) +OPENSSL_UNUSED static const uint32_t kP384Field[] = { + 0xffffffff, 0x00000000, 0x00000000, 0xffffffff, 0xfffffffe, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}; +OPENSSL_UNUSED static const uint32_t kP384Order[] = { + 0xccc52973, 0xecec196a, 0x48b0a77a, 0x581a0db2, 0xf4372ddf, 0xc7634d81, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}; +OPENSSL_UNUSED static const uint32_t kP384FieldR[] = { + 0x00000001, 0xffffffff, 0xffffffff, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}; +OPENSSL_UNUSED static const uint32_t kP384FieldRR[] = { + 0x00000001, 0xfffffffe, 0x00000000, 0x00000002, 0x00000000, 0xfffffffe, + 0x00000000, 0x00000002, 0x00000001, 0x00000000, 0x00000000, 0x00000000}; +OPENSSL_UNUSED static const uint32_t kP384OrderRR[] = { + 0x19b409a9, 0x2d319b24, 0xdf1aa419, 0xff3d81e5, 0xfcb82947, 0xbc3e483a, + 0x4aab1cc5, 0xd40d4917, 0x28266895, 0x3fb05b7a, 0x2b39bf21, 0x0c84ee01}; +OPENSSL_UNUSED static const uint32_t kP384MontB[] = { + 0x9d412dcc, 0x08118871, 0x7a4c32ec, 0xf729add8, 0x1920022e, 0x77f2209b, + 0x94938ae2, 0xe3374bee, 0x1f022094, 0xb62b21f4, 0x604fbff9, 0xcd08114b}; +OPENSSL_UNUSED static const uint32_t kP384MontGX[] = { + 0x49c0b528, 0x3dd07566, 0xa0d6ce38, 0x20e378e2, 0x541b4d6e, 0x879c3afc, + 0x59a30eff, 0x64548684, 0x614ede2b, 0x812ff723, 0x299e1513, 0x4d3aadc2}; +OPENSSL_UNUSED static const uint32_t kP384MontGY[] = { + 0x4b03a4fe, 0x23043dad, 0x7bb4a9ac, 0xa1bfa8bf, 0x2e83b050, 0x8bade756, + 0x68f4ffd9, 0xc6c35219, 0x3969a840, 0xdd800226, 0x5a15c5e9, 0x2b78abc2}; +#else +#error "unknown word size" +#endif + +// P-521 +OPENSSL_UNUSED static const uint64_t kP521FieldN0 = 0x0000000000000001; +OPENSSL_UNUSED static const uint64_t kP521OrderN0 = 0x1d2f5ccd79a995c7; +#if defined(OPENSSL_64_BIT) +OPENSSL_UNUSED static const uint64_t kP521Field[] = { + 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, + 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, + 0xffffffffffffffff, 0xffffffffffffffff, 0x00000000000001ff}; +OPENSSL_UNUSED static const uint64_t kP521Order[] = { + 0xbb6fb71e91386409, 0x3bb5c9b8899c47ae, 0x7fcc0148f709a5d0, + 0x51868783bf2f966b, 0xfffffffffffffffa, 0xffffffffffffffff, + 0xffffffffffffffff, 0xffffffffffffffff, 0x00000000000001ff}; +OPENSSL_UNUSED static const uint64_t kP521FieldR[] = { + 0x0080000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000}; +OPENSSL_UNUSED static const uint64_t kP521FieldRR[] = { + 0x0000000000000000, 0x0000400000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000}; +OPENSSL_UNUSED static const uint64_t kP521OrderRR[] = { + 0x137cd04dcf15dd04, 0xf707badce5547ea3, 0x12a78d38794573ff, + 0xd3721ef557f75e06, 0xdd6e23d82e49c7db, 0xcff3d142b7756e3e, + 0x5bcc6d61a8e567bc, 0x2d8e03d1492d0d45, 0x000000000000003d}; +OPENSSL_UNUSED static const uint64_t kP521MontB[] = { + 0x8014654fae586387, 0x78f7a28fea35a81f, 0x839ab9efc41e961a, + 0xbd8b29605e9dd8df, 0xf0ab0c9ca8f63f49, 0xf9dc5a44c8c77884, + 0x77516d392dccd98a, 0x0fc94d10d05b42a0, 0x000000000000004d}; +OPENSSL_UNUSED static const uint64_t kP521MontGX[] = { + 0xb331a16381adc101, 0x4dfcbf3f18e172de, 0x6f19a459e0c2b521, + 0x947f0ee093d17fd4, 0xdd50a5af3bf7f3ac, 0x90fc1457b035a69e, + 0x214e32409c829fda, 0xe6cf1f65b311cada, 0x0000000000000074}; +OPENSSL_UNUSED static const uint64_t kP521MontGY[] = { + 0x28460e4a5a9e268e, 0x20445f4a3b4fe8b3, 0xb09a9e3843513961, + 0x2062a85c809fd683, 0x164bf7394caf7a13, 0x340bd7de8b939f33, + 0xeccc7aa224abcda2, 0x022e452fda163e8d, 0x00000000000001e0}; +#elif defined(OPENSSL_32_BIT) +OPENSSL_UNUSED static const uint32_t kP521Field[] = { + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x000001ff}; +OPENSSL_UNUSED static const uint32_t kP521Order[] = { + 0x91386409, 0xbb6fb71e, 0x899c47ae, 0x3bb5c9b8, 0xf709a5d0, 0x7fcc0148, + 0xbf2f966b, 0x51868783, 0xfffffffa, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x000001ff}; +OPENSSL_UNUSED static const uint32_t kP521FieldR[] = { + 0x00800000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}; +OPENSSL_UNUSED static const uint32_t kP521FieldRR[] = { + 0x00000000, 0x00004000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000}; +OPENSSL_UNUSED static const uint32_t kP521OrderRR[] = { + 0x61c64ca7, 0x1163115a, 0x4374a642, 0x18354a56, 0x0791d9dc, 0x5d4dd6d3, + 0xd3402705, 0x4fb35b72, 0xb7756e3a, 0xcff3d142, 0xa8e567bc, 0x5bcc6d61, + 0x492d0d45, 0x2d8e03d1, 0x8c44383d, 0x5b5a3afe, 0x0000019a}; +OPENSSL_UNUSED static const uint32_t kP521MontB[] = { + 0x8014654f, 0xea35a81f, 0x78f7a28f, 0xc41e961a, 0x839ab9ef, 0x5e9dd8df, + 0xbd8b2960, 0xa8f63f49, 0xf0ab0c9c, 0xc8c77884, 0xf9dc5a44, 0x2dccd98a, + 0x77516d39, 0xd05b42a0, 0x0fc94d10, 0xb0c70e4d, 0x0000015c}; +OPENSSL_UNUSED static const uint32_t kP521MontGX[] = { + 0xb331a163, 0x18e172de, 0x4dfcbf3f, 0xe0c2b521, 0x6f19a459, 0x93d17fd4, + 0x947f0ee0, 0x3bf7f3ac, 0xdd50a5af, 0xb035a69e, 0x90fc1457, 0x9c829fda, + 0x214e3240, 0xb311cada, 0xe6cf1f65, 0x5b820274, 0x00000103}; +OPENSSL_UNUSED static const uint32_t kP521MontGY[] = { + 0x28460e4a, 0x3b4fe8b3, 0x20445f4a, 0x43513961, 0xb09a9e38, 0x809fd683, + 0x2062a85c, 0x4caf7a13, 0x164bf739, 0x8b939f33, 0x340bd7de, 0x24abcda2, + 0xeccc7aa2, 0xda163e8d, 0x022e452f, 0x3c4d1de0, 0x000000b5}; +#else +#error "unknown word size" +#endif diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/ec.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/ec.c index df26d766..57ffa3ef 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/ec.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/ec.c @@ -80,270 +80,147 @@ #include "../bn/internal.h" #include "../delocate.h" +#include "builtin_curves.h" + static void ec_point_free(EC_POINT *point, int free_group); -static const uint8_t kP224Params[6 * 28] = { - // p = 2^224 - 2^96 + 1 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - // a - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFE, - // b - 0xB4, 0x05, 0x0A, 0x85, 0x0C, 0x04, 0xB3, 0xAB, 0xF5, 0x41, 0x32, 0x56, - 0x50, 0x44, 0xB0, 0xB7, 0xD7, 0xBF, 0xD8, 0xBA, 0x27, 0x0B, 0x39, 0x43, - 0x23, 0x55, 0xFF, 0xB4, - // x - 0xB7, 0x0E, 0x0C, 0xBD, 0x6B, 0xB4, 0xBF, 0x7F, 0x32, 0x13, 0x90, 0xB9, - 0x4A, 0x03, 0xC1, 0xD3, 0x56, 0xC2, 0x11, 0x22, 0x34, 0x32, 0x80, 0xD6, - 0x11, 0x5C, 0x1D, 0x21, - // y - 0xbd, 0x37, 0x63, 0x88, 0xb5, 0xf7, 0x23, 0xfb, 0x4c, 0x22, 0xdf, 0xe6, - 0xcd, 0x43, 0x75, 0xa0, 0x5a, 0x07, 0x47, 0x64, 0x44, 0xd5, 0x81, 0x99, - 0x85, 0x00, 0x7e, 0x34, - // order - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x16, 0xA2, 0xE0, 0xB8, 0xF0, 0x3E, 0x13, 0xDD, 0x29, 0x45, - 0x5C, 0x5C, 0x2A, 0x3D, -}; +static void ec_group_init_static_mont(BN_MONT_CTX *mont, size_t num_words, + const BN_ULONG *modulus, + const BN_ULONG *rr, uint64_t n0) { + bn_set_static_words(&mont->N, modulus, num_words); + bn_set_static_words(&mont->RR, rr, num_words); +#if defined(OPENSSL_64_BIT) + mont->n0[0] = n0; +#elif defined(OPENSSL_32_BIT) + mont->n0[0] = (uint32_t)n0; + mont->n0[1] = (uint32_t)(n0 >> 32); +#else +#error "unknown word length" +#endif +} -static const uint8_t kP256Params[6 * 32] = { - // p = 2^256 - 2^224 + 2^192 + 2^96 - 1 - 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - // a - 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, - // b - 0x5A, 0xC6, 0x35, 0xD8, 0xAA, 0x3A, 0x93, 0xE7, 0xB3, 0xEB, 0xBD, 0x55, - 0x76, 0x98, 0x86, 0xBC, 0x65, 0x1D, 0x06, 0xB0, 0xCC, 0x53, 0xB0, 0xF6, - 0x3B, 0xCE, 0x3C, 0x3E, 0x27, 0xD2, 0x60, 0x4B, - // x - 0x6B, 0x17, 0xD1, 0xF2, 0xE1, 0x2C, 0x42, 0x47, 0xF8, 0xBC, 0xE6, 0xE5, - 0x63, 0xA4, 0x40, 0xF2, 0x77, 0x03, 0x7D, 0x81, 0x2D, 0xEB, 0x33, 0xA0, - 0xF4, 0xA1, 0x39, 0x45, 0xD8, 0x98, 0xC2, 0x96, - // y - 0x4f, 0xe3, 0x42, 0xe2, 0xfe, 0x1a, 0x7f, 0x9b, 0x8e, 0xe7, 0xeb, 0x4a, - 0x7c, 0x0f, 0x9e, 0x16, 0x2b, 0xce, 0x33, 0x57, 0x6b, 0x31, 0x5e, 0xce, - 0xcb, 0xb6, 0x40, 0x68, 0x37, 0xbf, 0x51, 0xf5, - // order - 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84, - 0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51, -}; +static void ec_group_set_a_minus3(EC_GROUP *group) { + const EC_FELEM *one = ec_felem_one(group); + group->a_is_minus3 = 1; + ec_felem_neg(group, &group->a, one); + ec_felem_sub(group, &group->a, &group->a, one); + ec_felem_sub(group, &group->a, &group->a, one); +} -static const uint8_t kP384Params[6 * 48] = { - // p = 2^384 - 2^128 - 2^96 + 2^32 - 1 - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - // a - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFC, - // b - 0xB3, 0x31, 0x2F, 0xA7, 0xE2, 0x3E, 0xE7, 0xE4, 0x98, 0x8E, 0x05, 0x6B, - 0xE3, 0xF8, 0x2D, 0x19, 0x18, 0x1D, 0x9C, 0x6E, 0xFE, 0x81, 0x41, 0x12, - 0x03, 0x14, 0x08, 0x8F, 0x50, 0x13, 0x87, 0x5A, 0xC6, 0x56, 0x39, 0x8D, - 0x8A, 0x2E, 0xD1, 0x9D, 0x2A, 0x85, 0xC8, 0xED, 0xD3, 0xEC, 0x2A, 0xEF, - // x - 0xAA, 0x87, 0xCA, 0x22, 0xBE, 0x8B, 0x05, 0x37, 0x8E, 0xB1, 0xC7, 0x1E, - 0xF3, 0x20, 0xAD, 0x74, 0x6E, 0x1D, 0x3B, 0x62, 0x8B, 0xA7, 0x9B, 0x98, - 0x59, 0xF7, 0x41, 0xE0, 0x82, 0x54, 0x2A, 0x38, 0x55, 0x02, 0xF2, 0x5D, - 0xBF, 0x55, 0x29, 0x6C, 0x3A, 0x54, 0x5E, 0x38, 0x72, 0x76, 0x0A, 0xB7, - // y - 0x36, 0x17, 0xde, 0x4a, 0x96, 0x26, 0x2c, 0x6f, 0x5d, 0x9e, 0x98, 0xbf, - 0x92, 0x92, 0xdc, 0x29, 0xf8, 0xf4, 0x1d, 0xbd, 0x28, 0x9a, 0x14, 0x7c, - 0xe9, 0xda, 0x31, 0x13, 0xb5, 0xf0, 0xb8, 0xc0, 0x0a, 0x60, 0xb1, 0xce, - 0x1d, 0x7e, 0x81, 0x9d, 0x7a, 0x43, 0x1d, 0x7c, 0x90, 0xea, 0x0e, 0x5f, - // order - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xC7, 0x63, 0x4D, 0x81, 0xF4, 0x37, 0x2D, 0xDF, 0x58, 0x1A, 0x0D, 0xB2, - 0x48, 0xB0, 0xA7, 0x7A, 0xEC, 0xEC, 0x19, 0x6A, 0xCC, 0xC5, 0x29, 0x73, -}; +DEFINE_METHOD_FUNCTION(EC_GROUP, EC_group_p224) { + out->curve_name = NID_secp224r1; + out->comment = "NIST P-224"; + // 1.3.132.0.33 + static const uint8_t kOIDP224[] = {0x2b, 0x81, 0x04, 0x00, 0x21}; + OPENSSL_memcpy(out->oid, kOIDP224, sizeof(kOIDP224)); + out->oid_len = sizeof(kOIDP224); -static const uint8_t kP521Params[6 * 66] = { - // p = 2^521 - 1 - 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - // a - 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, - // b - 0x00, 0x51, 0x95, 0x3E, 0xB9, 0x61, 0x8E, 0x1C, 0x9A, 0x1F, 0x92, 0x9A, - 0x21, 0xA0, 0xB6, 0x85, 0x40, 0xEE, 0xA2, 0xDA, 0x72, 0x5B, 0x99, 0xB3, - 0x15, 0xF3, 0xB8, 0xB4, 0x89, 0x91, 0x8E, 0xF1, 0x09, 0xE1, 0x56, 0x19, - 0x39, 0x51, 0xEC, 0x7E, 0x93, 0x7B, 0x16, 0x52, 0xC0, 0xBD, 0x3B, 0xB1, - 0xBF, 0x07, 0x35, 0x73, 0xDF, 0x88, 0x3D, 0x2C, 0x34, 0xF1, 0xEF, 0x45, - 0x1F, 0xD4, 0x6B, 0x50, 0x3F, 0x00, - // x - 0x00, 0xC6, 0x85, 0x8E, 0x06, 0xB7, 0x04, 0x04, 0xE9, 0xCD, 0x9E, 0x3E, - 0xCB, 0x66, 0x23, 0x95, 0xB4, 0x42, 0x9C, 0x64, 0x81, 0x39, 0x05, 0x3F, - 0xB5, 0x21, 0xF8, 0x28, 0xAF, 0x60, 0x6B, 0x4D, 0x3D, 0xBA, 0xA1, 0x4B, - 0x5E, 0x77, 0xEF, 0xE7, 0x59, 0x28, 0xFE, 0x1D, 0xC1, 0x27, 0xA2, 0xFF, - 0xA8, 0xDE, 0x33, 0x48, 0xB3, 0xC1, 0x85, 0x6A, 0x42, 0x9B, 0xF9, 0x7E, - 0x7E, 0x31, 0xC2, 0xE5, 0xBD, 0x66, - // y - 0x01, 0x18, 0x39, 0x29, 0x6a, 0x78, 0x9a, 0x3b, 0xc0, 0x04, 0x5c, 0x8a, - 0x5f, 0xb4, 0x2c, 0x7d, 0x1b, 0xd9, 0x98, 0xf5, 0x44, 0x49, 0x57, 0x9b, - 0x44, 0x68, 0x17, 0xaf, 0xbd, 0x17, 0x27, 0x3e, 0x66, 0x2c, 0x97, 0xee, - 0x72, 0x99, 0x5e, 0xf4, 0x26, 0x40, 0xc5, 0x50, 0xb9, 0x01, 0x3f, 0xad, - 0x07, 0x61, 0x35, 0x3c, 0x70, 0x86, 0xa2, 0x72, 0xc2, 0x40, 0x88, 0xbe, - 0x94, 0x76, 0x9f, 0xd1, 0x66, 0x50, - // order - 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA, 0x51, 0x86, - 0x87, 0x83, 0xBF, 0x2F, 0x96, 0x6B, 0x7F, 0xCC, 0x01, 0x48, 0xF7, 0x09, - 0xA5, 0xD0, 0x3B, 0xB5, 0xC9, 0xB8, 0x89, 0x9C, 0x47, 0xAE, 0xBB, 0x6F, - 0xB7, 0x1E, 0x91, 0x38, 0x64, 0x09, -}; + ec_group_init_static_mont(&out->field, OPENSSL_ARRAY_SIZE(kP224Field), + kP224Field, kP224FieldRR, kP224FieldN0); + ec_group_init_static_mont(&out->order, OPENSSL_ARRAY_SIZE(kP224Order), + kP224Order, kP224OrderRR, kP224OrderN0); -DEFINE_METHOD_FUNCTION(struct built_in_curves, OPENSSL_built_in_curves) { - // 1.3.132.0.35 - static const uint8_t kOIDP521[] = {0x2b, 0x81, 0x04, 0x00, 0x23}; - out->curves[0].nid = NID_secp521r1; - out->curves[0].oid = kOIDP521; - out->curves[0].oid_len = sizeof(kOIDP521); - out->curves[0].comment = "NIST P-521"; - out->curves[0].param_len = 66; - out->curves[0].params = kP521Params; - out->curves[0].method = EC_GFp_mont_method(); +#if defined(BORINGSSL_HAS_UINT128) && !defined(OPENSSL_SMALL) + out->meth = EC_GFp_nistp224_method(); + OPENSSL_memcpy(out->generator.raw.X.words, kP224GX, sizeof(kP224GX)); + OPENSSL_memcpy(out->generator.raw.Y.words, kP224GY, sizeof(kP224GY)); + out->generator.raw.Z.words[0] = 1; + OPENSSL_memcpy(out->b.words, kP224B, sizeof(kP224B)); +#else + out->meth = EC_GFp_mont_method(); + OPENSSL_memcpy(out->generator.raw.X.words, kP224MontGX, sizeof(kP224MontGX)); + OPENSSL_memcpy(out->generator.raw.Y.words, kP224MontGY, sizeof(kP224MontGY)); + OPENSSL_memcpy(out->generator.raw.Z.words, kP224FieldR, sizeof(kP224FieldR)); + OPENSSL_memcpy(out->b.words, kP224MontB, sizeof(kP224MontB)); +#endif + out->generator.group = out; - // 1.3.132.0.34 - static const uint8_t kOIDP384[] = {0x2b, 0x81, 0x04, 0x00, 0x22}; - out->curves[1].nid = NID_secp384r1; - out->curves[1].oid = kOIDP384; - out->curves[1].oid_len = sizeof(kOIDP384); - out->curves[1].comment = "NIST P-384"; - out->curves[1].param_len = 48; - out->curves[1].params = kP384Params; - out->curves[1].method = EC_GFp_mont_method(); + ec_group_set_a_minus3(out); + out->has_order = 1; + out->field_greater_than_order = 1; +} +DEFINE_METHOD_FUNCTION(EC_GROUP, EC_group_p256) { + out->curve_name = NID_X9_62_prime256v1; + out->comment = "NIST P-256"; // 1.2.840.10045.3.1.7 static const uint8_t kOIDP256[] = {0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07}; - out->curves[2].nid = NID_X9_62_prime256v1; - out->curves[2].oid = kOIDP256; - out->curves[2].oid_len = sizeof(kOIDP256); - out->curves[2].comment = "NIST P-256"; - out->curves[2].param_len = 32; - out->curves[2].params = kP256Params; - out->curves[2].method = -#if !defined(OPENSSL_NO_ASM) && \ - (defined(OPENSSL_X86_64) || defined(OPENSSL_AARCH64)) && \ + OPENSSL_memcpy(out->oid, kOIDP256, sizeof(kOIDP256)); + out->oid_len = sizeof(kOIDP256); + + ec_group_init_static_mont(&out->field, OPENSSL_ARRAY_SIZE(kP256Field), + kP256Field, kP256FieldRR, kP256FieldN0); + ec_group_init_static_mont(&out->order, OPENSSL_ARRAY_SIZE(kP256Order), + kP256Order, kP256OrderRR, kP256OrderN0); + +#if !defined(OPENSSL_NO_ASM) && \ + (defined(OPENSSL_X86_64) || defined(OPENSSL_AARCH64)) && \ !defined(OPENSSL_SMALL) - EC_GFp_nistz256_method(); + out->meth = EC_GFp_nistz256_method(); #else - EC_GFp_nistp256_method(); + out->meth = EC_GFp_nistp256_method(); #endif + out->generator.group = out; + OPENSSL_memcpy(out->generator.raw.X.words, kP256MontGX, sizeof(kP256MontGX)); + OPENSSL_memcpy(out->generator.raw.Y.words, kP256MontGY, sizeof(kP256MontGY)); + OPENSSL_memcpy(out->generator.raw.Z.words, kP256FieldR, sizeof(kP256FieldR)); + OPENSSL_memcpy(out->b.words, kP256MontB, sizeof(kP256MontB)); - // 1.3.132.0.33 - static const uint8_t kOIDP224[] = {0x2b, 0x81, 0x04, 0x00, 0x21}; - out->curves[3].nid = NID_secp224r1; - out->curves[3].oid = kOIDP224; - out->curves[3].oid_len = sizeof(kOIDP224); - out->curves[3].comment = "NIST P-224"; - out->curves[3].param_len = 28; - out->curves[3].params = kP224Params; - out->curves[3].method = -#if defined(BORINGSSL_HAS_UINT128) && !defined(OPENSSL_SMALL) - EC_GFp_nistp224_method(); -#else - EC_GFp_mont_method(); -#endif + ec_group_set_a_minus3(out); + out->has_order = 1; + out->field_greater_than_order = 1; } -EC_GROUP *ec_group_new(const EC_METHOD *meth) { - EC_GROUP *ret; +DEFINE_METHOD_FUNCTION(EC_GROUP, EC_group_p384) { + out->curve_name = NID_secp384r1; + out->comment = "NIST P-384"; + // 1.3.132.0.34 + static const uint8_t kOIDP384[] = {0x2b, 0x81, 0x04, 0x00, 0x22}; + OPENSSL_memcpy(out->oid, kOIDP384, sizeof(kOIDP384)); + out->oid_len = sizeof(kOIDP384); - if (meth == NULL) { - OPENSSL_PUT_ERROR(EC, EC_R_SLOT_FULL); - return NULL; - } + ec_group_init_static_mont(&out->field, OPENSSL_ARRAY_SIZE(kP384Field), + kP384Field, kP384FieldRR, kP384FieldN0); + ec_group_init_static_mont(&out->order, OPENSSL_ARRAY_SIZE(kP384Order), + kP384Order, kP384OrderRR, kP384OrderN0); - if (meth->group_init == 0) { - OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); - return NULL; - } + out->meth = EC_GFp_mont_method(); + out->generator.group = out; + OPENSSL_memcpy(out->generator.raw.X.words, kP384MontGX, sizeof(kP384MontGX)); + OPENSSL_memcpy(out->generator.raw.Y.words, kP384MontGY, sizeof(kP384MontGY)); + OPENSSL_memcpy(out->generator.raw.Z.words, kP384FieldR, sizeof(kP384FieldR)); + OPENSSL_memcpy(out->b.words, kP384MontB, sizeof(kP384MontB)); - ret = OPENSSL_malloc(sizeof(EC_GROUP)); - if (ret == NULL) { - return NULL; - } - OPENSSL_memset(ret, 0, sizeof(EC_GROUP)); - - ret->references = 1; - ret->meth = meth; - BN_init(&ret->order); - - if (!meth->group_init(ret)) { - OPENSSL_free(ret); - return NULL; - } - - return ret; + ec_group_set_a_minus3(out); + out->has_order = 1; + out->field_greater_than_order = 1; } -static int ec_group_set_generator(EC_GROUP *group, const EC_AFFINE *generator, - const BIGNUM *order) { - assert(group->generator == NULL); +DEFINE_METHOD_FUNCTION(EC_GROUP, EC_group_p521) { + out->curve_name = NID_secp521r1; + out->comment = "NIST P-521"; + // 1.3.132.0.35 + static const uint8_t kOIDP521[] = {0x2b, 0x81, 0x04, 0x00, 0x23}; + OPENSSL_memcpy(out->oid, kOIDP521, sizeof(kOIDP521)); + out->oid_len = sizeof(kOIDP521); - if (!BN_copy(&group->order, order)) { - return 0; - } - // Store the order in minimal form, so it can be used with |BN_ULONG| arrays. - bn_set_minimal_width(&group->order); + ec_group_init_static_mont(&out->field, OPENSSL_ARRAY_SIZE(kP521Field), + kP521Field, kP521FieldRR, kP521FieldN0); + ec_group_init_static_mont(&out->order, OPENSSL_ARRAY_SIZE(kP521Order), + kP521Order, kP521OrderRR, kP521OrderN0); - BN_MONT_CTX_free(group->order_mont); - group->order_mont = BN_MONT_CTX_new_for_modulus(&group->order, NULL); - if (group->order_mont == NULL) { - return 0; - } + out->meth = EC_GFp_mont_method(); + out->generator.group = out; + OPENSSL_memcpy(out->generator.raw.X.words, kP521MontGX, sizeof(kP521MontGX)); + OPENSSL_memcpy(out->generator.raw.Y.words, kP521MontGY, sizeof(kP521MontGY)); + OPENSSL_memcpy(out->generator.raw.Z.words, kP521FieldR, sizeof(kP521FieldR)); + OPENSSL_memcpy(out->b.words, kP521MontB, sizeof(kP521MontB)); - group->field_greater_than_order = BN_cmp(&group->field, order) > 0; - if (group->field_greater_than_order) { - BIGNUM tmp; - BN_init(&tmp); - int ok = - BN_sub(&tmp, &group->field, order) && - bn_copy_words(group->field_minus_order.words, group->field.width, &tmp); - BN_free(&tmp); - if (!ok) { - return 0; - } - } - - group->generator = EC_POINT_new(group); - if (group->generator == NULL) { - return 0; - } - ec_affine_to_jacobian(group, &group->generator->raw, generator); - assert(ec_felem_equal(group, &group->one, &group->generator->raw.Z)); - - // Avoid a reference cycle. |group->generator| does not maintain an owning - // pointer to |group|. - int is_zero = CRYPTO_refcount_dec_and_test_zero(&group->references); - - assert(!is_zero); - (void)is_zero; - return 1; + ec_group_set_a_minus3(out); + out->has_order = 1; + out->field_greater_than_order = 1; } EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, @@ -373,9 +250,17 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, goto err; } - ret = ec_group_new(EC_GFp_mont_method()); - if (ret == NULL || - !ret->meth->group_set_curve(ret, p, a_reduced, b_reduced, ctx)) { + ret = OPENSSL_malloc(sizeof(EC_GROUP)); + if (ret == NULL) { + return NULL; + } + OPENSSL_memset(ret, 0, sizeof(EC_GROUP)); + ret->references = 1; + ret->meth = EC_GFp_mont_method(); + bn_mont_ctx_init(&ret->field); + bn_mont_ctx_init(&ret->order); + ret->generator.group = ret; + if (!ec_GFp_simple_group_set_curve(ret, p, a_reduced, b_reduced, ctx)) { EC_GROUP_free(ret); ret = NULL; goto err; @@ -389,7 +274,7 @@ err: int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor) { - if (group->curve_name != NID_undef || group->generator != NULL || + if (group->curve_name != NID_undef || group->has_order || generator->group != group) { // |EC_GROUP_set_generator| may only be used with |EC_GROUP|s returned by // |EC_GROUP_new_curve_GFp| and may only used once on each group. @@ -421,17 +306,22 @@ int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, !BN_lshift1(tmp, order)) { goto err; } - if (BN_cmp(tmp, &group->field) <= 0) { + if (BN_cmp(tmp, &group->field.N) <= 0) { OPENSSL_PUT_ERROR(EC, EC_R_INVALID_GROUP_ORDER); goto err; } EC_AFFINE affine; if (!ec_jacobian_to_affine(group, &affine, &generator->raw) || - !ec_group_set_generator(group, &affine, order)) { + !BN_MONT_CTX_set(&group->order, order, NULL)) { goto err; } + group->field_greater_than_order = BN_cmp(&group->field.N, order) > 0; + group->generator.raw.X = affine.X; + group->generator.raw.Y = affine.Y; + // |raw.Z| was set to 1 by |EC_GROUP_new_curve_GFp|. + group->has_order = 1; ret = 1; err: @@ -439,114 +329,20 @@ err: return ret; } -static EC_GROUP *ec_group_new_from_data(const struct built_in_curve *curve) { - EC_GROUP *group = NULL; - BIGNUM *p = NULL, *a = NULL, *b = NULL, *order = NULL; - int ok = 0; - - BN_CTX *ctx = BN_CTX_new(); - if (ctx == NULL) { - goto err; - } - - const unsigned param_len = curve->param_len; - const uint8_t *params = curve->params; - - if (!(p = BN_bin2bn(params + 0 * param_len, param_len, NULL)) || - !(a = BN_bin2bn(params + 1 * param_len, param_len, NULL)) || - !(b = BN_bin2bn(params + 2 * param_len, param_len, NULL)) || - !(order = BN_bin2bn(params + 5 * param_len, param_len, NULL))) { - OPENSSL_PUT_ERROR(EC, ERR_R_BN_LIB); - goto err; - } - - group = ec_group_new(curve->method); - if (group == NULL || - !group->meth->group_set_curve(group, p, a, b, ctx)) { - OPENSSL_PUT_ERROR(EC, ERR_R_EC_LIB); - goto err; - } - - EC_AFFINE G; - EC_FELEM x, y; - if (!ec_felem_from_bytes(group, &x, params + 3 * param_len, param_len) || - !ec_felem_from_bytes(group, &y, params + 4 * param_len, param_len) || - !ec_point_set_affine_coordinates(group, &G, &x, &y)) { - goto err; - } - - if (!ec_group_set_generator(group, &G, order)) { - goto err; - } - - ok = 1; - -err: - if (!ok) { - EC_GROUP_free(group); - group = NULL; - } - BN_CTX_free(ctx); - BN_free(p); - BN_free(a); - BN_free(b); - BN_free(order); - return group; -} - -// Built-in groups are allocated lazily and static once allocated. -// TODO(davidben): Make these actually static. https://crbug.com/boringssl/20. -struct built_in_groups_st { - EC_GROUP *groups[OPENSSL_NUM_BUILT_IN_CURVES]; -}; -DEFINE_BSS_GET(struct built_in_groups_st, built_in_groups) -DEFINE_STATIC_MUTEX(built_in_groups_lock) - EC_GROUP *EC_GROUP_new_by_curve_name(int nid) { - struct built_in_groups_st *groups = built_in_groups_bss_get(); - EC_GROUP **group_ptr = NULL; - const struct built_in_curves *const curves = OPENSSL_built_in_curves(); - const struct built_in_curve *curve = NULL; - for (size_t i = 0; i < OPENSSL_NUM_BUILT_IN_CURVES; i++) { - if (curves->curves[i].nid == nid) { - curve = &curves->curves[i]; - group_ptr = &groups->groups[i]; - break; - } + switch (nid) { + case NID_secp224r1: + return (EC_GROUP *)EC_group_p224(); + case NID_X9_62_prime256v1: + return (EC_GROUP *)EC_group_p256(); + case NID_secp384r1: + return (EC_GROUP *)EC_group_p384(); + case NID_secp521r1: + return (EC_GROUP *)EC_group_p521(); + default: + OPENSSL_PUT_ERROR(EC, EC_R_UNKNOWN_GROUP); + return NULL; } - - if (curve == NULL) { - OPENSSL_PUT_ERROR(EC, EC_R_UNKNOWN_GROUP); - return NULL; - } - - CRYPTO_STATIC_MUTEX_lock_read(built_in_groups_lock_bss_get()); - EC_GROUP *ret = *group_ptr; - CRYPTO_STATIC_MUTEX_unlock_read(built_in_groups_lock_bss_get()); - if (ret != NULL) { - return ret; - } - - ret = ec_group_new_from_data(curve); - if (ret == NULL) { - return NULL; - } - - EC_GROUP *to_free = NULL; - CRYPTO_STATIC_MUTEX_lock_write(built_in_groups_lock_bss_get()); - if (*group_ptr == NULL) { - *group_ptr = ret; - // Filling in |ret->curve_name| makes |EC_GROUP_free| and |EC_GROUP_dup| - // into no-ops. At this point, |ret| is considered static. - ret->curve_name = nid; - } else { - to_free = ret; - ret = *group_ptr; - } - CRYPTO_STATIC_MUTEX_unlock_write(built_in_groups_lock_bss_get()); - - EC_GROUP_free(to_free); - return ret; } void EC_GROUP_free(EC_GROUP *group) { @@ -557,14 +353,8 @@ void EC_GROUP_free(EC_GROUP *group) { return; } - if (group->meth->group_finish != NULL) { - group->meth->group_finish(group); - } - - ec_point_free(group->generator, 0 /* don't free group */); - BN_free(&group->order); - BN_MONT_CTX_free(group->order_mont); - + bn_mont_ctx_cleanup(&group->order); + bn_mont_ctx_cleanup(&group->field); OPENSSL_free(group); } @@ -599,23 +389,22 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ignored) { // structure. If |a| or |b| is incomplete (due to legacy OpenSSL mistakes, // custom curve construction is sadly done in two parts) but otherwise not the // same object, we consider them always unequal. - return a->meth != b->meth || - a->generator == NULL || - b->generator == NULL || - BN_cmp(&a->order, &b->order) != 0 || - BN_cmp(&a->field, &b->field) != 0 || - !ec_felem_equal(a, &a->a, &b->a) || + return a->meth != b->meth || // + !a->has_order || !b->has_order || + BN_cmp(&a->order.N, &b->order.N) != 0 || + BN_cmp(&a->field.N, &b->field.N) != 0 || + !ec_felem_equal(a, &a->a, &b->a) || // !ec_felem_equal(a, &a->b, &b->b) || - !ec_GFp_simple_points_equal(a, &a->generator->raw, &b->generator->raw); + !ec_GFp_simple_points_equal(a, &a->generator.raw, &b->generator.raw); } const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group) { - return group->generator; + return group->has_order ? &group->generator : NULL; } const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group) { - assert(!BN_is_zero(&group->order)); - return &group->order; + assert(group->has_order); + return &group->order.N; } int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx) { @@ -626,7 +415,7 @@ int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx) { } int EC_GROUP_order_bits(const EC_GROUP *group) { - return BN_num_bits(&group->order); + return BN_num_bits(&group->order.N); } int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, @@ -643,7 +432,7 @@ int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *out_p, BIGNUM *out_a, int EC_GROUP_get_curve_name(const EC_GROUP *group) { return group->curve_name; } unsigned EC_GROUP_get_degree(const EC_GROUP *group) { - return BN_num_bits(&group->field); + return BN_num_bits(&group->field.N); } const char *EC_curve_nid2nist(int nid) { @@ -801,20 +590,20 @@ int EC_POINT_get_affine_coordinates(const EC_GROUP *group, return EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx); } -void ec_affine_to_jacobian(const EC_GROUP *group, EC_RAW_POINT *out, +void ec_affine_to_jacobian(const EC_GROUP *group, EC_JACOBIAN *out, const EC_AFFINE *p) { out->X = p->X; out->Y = p->Y; - out->Z = group->one; + out->Z = *ec_felem_one(group); } int ec_jacobian_to_affine(const EC_GROUP *group, EC_AFFINE *out, - const EC_RAW_POINT *p) { + const EC_JACOBIAN *p) { return group->meth->point_get_affine_coordinates(group, p, &out->X, &out->Y); } int ec_jacobian_to_affine_batch(const EC_GROUP *group, EC_AFFINE *out, - const EC_RAW_POINT *in, size_t num) { + const EC_JACOBIAN *in, size_t num) { if (group->meth->jacobian_to_affine_batch == NULL) { OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; @@ -842,10 +631,9 @@ int ec_point_set_affine_coordinates(const EC_GROUP *group, EC_AFFINE *out, // return value by setting a known safe value. Note this may not be possible // if the caller is in the process of constructing an arbitrary group and // the generator is missing. - if (group->generator != NULL) { - assert(ec_felem_equal(group, &group->one, &group->generator->raw.Z)); - out->X = group->generator->raw.X; - out->Y = group->generator->raw.Y; + if (group->has_order) { + out->X = group->generator.raw.X; + out->Y = group->generator.raw.Y; } return 0; } @@ -931,11 +719,10 @@ static int arbitrary_bignum_to_scalar(const EC_GROUP *group, EC_SCALAR *out, ERR_clear_error(); // This is an unusual input, so we do not guarantee constant-time processing. - const BIGNUM *order = &group->order; BN_CTX_start(ctx); BIGNUM *tmp = BN_CTX_get(ctx); int ok = tmp != NULL && - BN_nnmod(tmp, in, order, ctx) && + BN_nnmod(tmp, in, EC_GROUP_get0_order(group), ctx) && ec_bignum_to_scalar(group, out, tmp); BN_CTX_end(ctx); return ok; @@ -990,13 +777,13 @@ int ec_point_mul_no_self_test(const EC_GROUP *group, EC_POINT *r, if (p_scalar != NULL) { EC_SCALAR scalar; - EC_RAW_POINT tmp; + EC_JACOBIAN tmp; if (!arbitrary_bignum_to_scalar(group, &scalar, p_scalar, ctx) || !ec_point_mul_scalar(group, &tmp, &p->raw, &scalar)) { goto err; } if (g_scalar == NULL) { - OPENSSL_memcpy(&r->raw, &tmp, sizeof(EC_RAW_POINT)); + OPENSSL_memcpy(&r->raw, &tmp, sizeof(EC_JACOBIAN)); } else { group->meth->add(group, &r->raw, &r->raw, &tmp); } @@ -1016,8 +803,8 @@ int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar, return ec_point_mul_no_self_test(group, r, g_scalar, p, p_scalar, ctx); } -int ec_point_mul_scalar_public(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_SCALAR *g_scalar, const EC_RAW_POINT *p, +int ec_point_mul_scalar_public(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_SCALAR *g_scalar, const EC_JACOBIAN *p, const EC_SCALAR *p_scalar) { if (g_scalar == NULL || p_scalar == NULL || p == NULL) { OPENSSL_PUT_ERROR(EC, ERR_R_PASSED_NULL_PARAMETER); @@ -1032,9 +819,9 @@ int ec_point_mul_scalar_public(const EC_GROUP *group, EC_RAW_POINT *r, return 1; } -int ec_point_mul_scalar_public_batch(const EC_GROUP *group, EC_RAW_POINT *r, +int ec_point_mul_scalar_public_batch(const EC_GROUP *group, EC_JACOBIAN *r, const EC_SCALAR *g_scalar, - const EC_RAW_POINT *points, + const EC_JACOBIAN *points, const EC_SCALAR *scalars, size_t num) { if (group->meth->mul_public_batch == NULL) { OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); @@ -1045,8 +832,8 @@ int ec_point_mul_scalar_public_batch(const EC_GROUP *group, EC_RAW_POINT *r, num); } -int ec_point_mul_scalar(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *p, const EC_SCALAR *scalar) { +int ec_point_mul_scalar(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *p, const EC_SCALAR *scalar) { if (p == NULL || scalar == NULL) { OPENSSL_PUT_ERROR(EC, ERR_R_PASSED_NULL_PARAMETER); return 0; @@ -1064,7 +851,7 @@ int ec_point_mul_scalar(const EC_GROUP *group, EC_RAW_POINT *r, return 1; } -int ec_point_mul_scalar_base(const EC_GROUP *group, EC_RAW_POINT *r, +int ec_point_mul_scalar_base(const EC_GROUP *group, EC_JACOBIAN *r, const EC_SCALAR *scalar) { if (scalar == NULL) { OPENSSL_PUT_ERROR(EC, ERR_R_PASSED_NULL_PARAMETER); @@ -1074,8 +861,10 @@ int ec_point_mul_scalar_base(const EC_GROUP *group, EC_RAW_POINT *r, group->meth->mul_base(group, r, scalar); // Check the result is on the curve to defend against fault attacks or bugs. - // This has negligible cost compared to the multiplication. - if (!ec_GFp_simple_is_on_curve(group, r)) { + // This has negligible cost compared to the multiplication. This can only + // happen on bug or CPU fault, so it okay to leak this. The alternative would + // be to proceed with bad data. + if (!constant_time_declassify_int(ec_GFp_simple_is_on_curve(group, r))) { OPENSSL_PUT_ERROR(EC, ERR_R_INTERNAL_ERROR); return 0; } @@ -1083,10 +872,10 @@ int ec_point_mul_scalar_base(const EC_GROUP *group, EC_RAW_POINT *r, return 1; } -int ec_point_mul_scalar_batch(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *p0, const EC_SCALAR *scalar0, - const EC_RAW_POINT *p1, const EC_SCALAR *scalar1, - const EC_RAW_POINT *p2, +int ec_point_mul_scalar_batch(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *p0, const EC_SCALAR *scalar0, + const EC_JACOBIAN *p1, const EC_SCALAR *scalar1, + const EC_JACOBIAN *p2, const EC_SCALAR *scalar2) { if (group->meth->mul_batch == NULL) { OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); @@ -1106,7 +895,7 @@ int ec_point_mul_scalar_batch(const EC_GROUP *group, EC_RAW_POINT *r, } int ec_init_precomp(const EC_GROUP *group, EC_PRECOMP *out, - const EC_RAW_POINT *p) { + const EC_JACOBIAN *p) { if (group->meth->init_precomp == NULL) { OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; @@ -1115,7 +904,7 @@ int ec_init_precomp(const EC_GROUP *group, EC_PRECOMP *out, return group->meth->init_precomp(group, out, p); } -int ec_point_mul_scalar_precomp(const EC_GROUP *group, EC_RAW_POINT *r, +int ec_point_mul_scalar_precomp(const EC_GROUP *group, EC_JACOBIAN *r, const EC_PRECOMP *p0, const EC_SCALAR *scalar0, const EC_PRECOMP *p1, const EC_SCALAR *scalar1, const EC_PRECOMP *p2, @@ -1137,8 +926,8 @@ int ec_point_mul_scalar_precomp(const EC_GROUP *group, EC_RAW_POINT *r, return 1; } -void ec_point_select(const EC_GROUP *group, EC_RAW_POINT *out, BN_ULONG mask, - const EC_RAW_POINT *a, const EC_RAW_POINT *b) { +void ec_point_select(const EC_GROUP *group, EC_JACOBIAN *out, BN_ULONG mask, + const EC_JACOBIAN *a, const EC_JACOBIAN *b) { ec_felem_select(group, &out->X, mask, &a->X, &b->X); ec_felem_select(group, &out->Y, mask, &a->Y, &b->Y); ec_felem_select(group, &out->Z, mask, &a->Z, &b->Z); @@ -1159,13 +948,13 @@ void ec_precomp_select(const EC_GROUP *group, EC_PRECOMP *out, BN_ULONG mask, } } -int ec_cmp_x_coordinate(const EC_GROUP *group, const EC_RAW_POINT *p, +int ec_cmp_x_coordinate(const EC_GROUP *group, const EC_JACOBIAN *p, const EC_SCALAR *r) { return group->meth->cmp_x_coordinate(group, p, r); } int ec_get_x_coordinate_as_scalar(const EC_GROUP *group, EC_SCALAR *out, - const EC_RAW_POINT *p) { + const EC_JACOBIAN *p) { uint8_t bytes[EC_MAX_BYTES]; size_t len; if (!ec_get_x_coordinate_as_bytes(group, bytes, &len, sizeof(bytes), p)) { @@ -1191,7 +980,7 @@ int ec_get_x_coordinate_as_scalar(const EC_GROUP *group, EC_SCALAR *out, // // Additionally, one can manually check this property for built-in curves. It // is enforced for legacy custom curves in |EC_GROUP_set_generator|. - const BIGNUM *order = &group->order; + const BIGNUM *order = EC_GROUP_get0_order(group); BN_ULONG words[EC_MAX_WORDS + 1] = {0}; bn_big_endian_to_words(words, order->width + 1, bytes, len); bn_reduce_once(out->words, words, /*carry=*/words[order->width], order->d, @@ -1201,8 +990,8 @@ int ec_get_x_coordinate_as_scalar(const EC_GROUP *group, EC_SCALAR *out, int ec_get_x_coordinate_as_bytes(const EC_GROUP *group, uint8_t *out, size_t *out_len, size_t max_out, - const EC_RAW_POINT *p) { - size_t len = BN_num_bytes(&group->field); + const EC_JACOBIAN *p) { + size_t len = BN_num_bytes(&group->field.N); assert(len <= EC_MAX_BYTES); if (max_out < len) { OPENSSL_PUT_ERROR(EC, EC_R_BUFFER_TOO_SMALL); @@ -1219,9 +1008,9 @@ int ec_get_x_coordinate_as_bytes(const EC_GROUP *group, uint8_t *out, return 1; } -void ec_set_to_safe_point(const EC_GROUP *group, EC_RAW_POINT *out) { - if (group->generator != NULL) { - ec_GFp_simple_point_copy(out, &group->generator->raw); +void ec_set_to_safe_point(const EC_GROUP *group, EC_JACOBIAN *out) { + if (group->has_order) { + ec_GFp_simple_point_copy(out, &group->generator.raw); } else { // The generator can be missing if the caller is in the process of // constructing an arbitrary group. In this case, we give up and use the @@ -1253,16 +1042,3 @@ void EC_GROUP_set_point_conversion_form(EC_GROUP *group, abort(); } } - -size_t EC_get_builtin_curves(EC_builtin_curve *out_curves, - size_t max_num_curves) { - const struct built_in_curves *const curves = OPENSSL_built_in_curves(); - - for (size_t i = 0; i < max_num_curves && i < OPENSSL_NUM_BUILT_IN_CURVES; - i++) { - out_curves[i].comment = curves->curves[i].comment; - out_curves[i].nid = curves->curves[i].nid; - } - - return OPENSSL_NUM_BUILT_IN_CURVES; -} diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/ec_key.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/ec_key.c index fe9afc06..4cb8bd81 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/ec_key.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/ec_key.c @@ -93,8 +93,8 @@ static EC_WRAPPED_SCALAR *ec_wrapped_scalar_new(const EC_GROUP *group) { OPENSSL_memset(wrapped, 0, sizeof(EC_WRAPPED_SCALAR)); wrapped->bignum.d = wrapped->scalar.words; - wrapped->bignum.width = group->order.width; - wrapped->bignum.dmax = group->order.width; + wrapped->bignum.width = group->order.N.width; + wrapped->bignum.dmax = group->order.N.width; wrapped->bignum.flags = BN_FLG_STATIC_DATA; return wrapped; } @@ -311,7 +311,7 @@ int EC_KEY_check_key(const EC_KEY *eckey) { // NOTE: this is a FIPS pair-wise consistency check for the ECDH case. See SP // 800-56Ar3, page 36. if (eckey->priv_key != NULL) { - EC_RAW_POINT point; + EC_JACOBIAN point; if (!ec_point_mul_scalar_base(eckey->group, &point, &eckey->priv_key->scalar)) { OPENSSL_PUT_ERROR(EC, ERR_R_EC_LIB); @@ -485,7 +485,7 @@ int EC_KEY_generate_key(EC_KEY *key) { } // Check that the group order is FIPS compliant (FIPS 186-4 B.4.2). - if (BN_num_bits(EC_GROUP_get0_order(key->group)) < 160) { + if (EC_GROUP_order_bits(key->group) < 160) { OPENSSL_PUT_ERROR(EC, EC_R_INVALID_GROUP_ORDER); return 0; } diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/ec_montgomery.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/ec_montgomery.c index 5d0b1ba4..1b2abb08 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/ec_montgomery.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/ec_montgomery.c @@ -76,67 +76,35 @@ #include "internal.h" -int ec_GFp_mont_group_init(EC_GROUP *group) { - int ok; - - ok = ec_GFp_simple_group_init(group); - group->mont = NULL; - return ok; -} - -void ec_GFp_mont_group_finish(EC_GROUP *group) { - BN_MONT_CTX_free(group->mont); - group->mont = NULL; - ec_GFp_simple_group_finish(group); -} - -int ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, - const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { - BN_MONT_CTX_free(group->mont); - group->mont = BN_MONT_CTX_new_for_modulus(p, ctx); - if (group->mont == NULL) { - OPENSSL_PUT_ERROR(EC, ERR_R_BN_LIB); - return 0; - } - - if (!ec_GFp_simple_group_set_curve(group, p, a, b, ctx)) { - BN_MONT_CTX_free(group->mont); - group->mont = NULL; - return 0; - } - - return 1; -} - static void ec_GFp_mont_felem_to_montgomery(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *in) { - bn_to_montgomery_small(out->words, in->words, group->field.width, - group->mont); + bn_to_montgomery_small(out->words, in->words, group->field.N.width, + &group->field); } static void ec_GFp_mont_felem_from_montgomery(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *in) { - bn_from_montgomery_small(out->words, group->field.width, in->words, - group->field.width, group->mont); + bn_from_montgomery_small(out->words, group->field.N.width, in->words, + group->field.N.width, &group->field); } static void ec_GFp_mont_felem_inv0(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a) { - bn_mod_inverse0_prime_mont_small(out->words, a->words, group->field.width, - group->mont); + bn_mod_inverse0_prime_mont_small(out->words, a->words, group->field.N.width, + &group->field); } void ec_GFp_mont_felem_mul(const EC_GROUP *group, EC_FELEM *r, const EC_FELEM *a, const EC_FELEM *b) { - bn_mod_mul_montgomery_small(r->words, a->words, b->words, group->field.width, - group->mont); + bn_mod_mul_montgomery_small(r->words, a->words, b->words, + group->field.N.width, &group->field); } void ec_GFp_mont_felem_sqr(const EC_GROUP *group, EC_FELEM *r, const EC_FELEM *a) { - bn_mod_mul_montgomery_small(r->words, a->words, a->words, group->field.width, - group->mont); + bn_mod_mul_montgomery_small(r->words, a->words, a->words, + group->field.N.width, &group->field); } void ec_GFp_mont_felem_to_bytes(const EC_GROUP *group, uint8_t *out, @@ -159,8 +127,8 @@ int ec_GFp_mont_felem_from_bytes(const EC_GROUP *group, EC_FELEM *out, void ec_GFp_mont_felem_reduce(const EC_GROUP *group, EC_FELEM *out, const BN_ULONG *words, size_t num) { // Convert "from" Montgomery form so the value is reduced mod p. - bn_from_montgomery_small(out->words, group->field.width, words, num, - group->mont); + bn_from_montgomery_small(out->words, group->field.N.width, words, num, + &group->field); // Convert "to" Montgomery form to remove the R^-1 factor added. ec_GFp_mont_felem_to_montgomery(group, out, out); // Convert to Montgomery form to match this implementation's representation. @@ -170,14 +138,15 @@ void ec_GFp_mont_felem_reduce(const EC_GROUP *group, EC_FELEM *out, void ec_GFp_mont_felem_exp(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a, const BN_ULONG *exp, size_t num_exp) { - bn_mod_exp_mont_small(out->words, a->words, group->field.width, exp, num_exp, - group->mont); + bn_mod_exp_mont_small(out->words, a->words, group->field.N.width, exp, + num_exp, &group->field); } static int ec_GFp_mont_point_get_affine_coordinates(const EC_GROUP *group, - const EC_RAW_POINT *point, + const EC_JACOBIAN *point, EC_FELEM *x, EC_FELEM *y) { - if (ec_GFp_simple_is_at_infinity(group, point)) { + if (constant_time_declassify_int( + ec_GFp_simple_is_at_infinity(group, point))) { OPENSSL_PUT_ERROR(EC, EC_R_POINT_AT_INFINITY); return 0; } @@ -202,7 +171,7 @@ static int ec_GFp_mont_point_get_affine_coordinates(const EC_GROUP *group, static int ec_GFp_mont_jacobian_to_affine_batch(const EC_GROUP *group, EC_AFFINE *out, - const EC_RAW_POINT *in, + const EC_JACOBIAN *in, size_t num) { if (num == 0) { return 1; @@ -246,8 +215,8 @@ static int ec_GFp_mont_jacobian_to_affine_batch(const EC_GROUP *group, return 1; } -void ec_GFp_mont_add(const EC_GROUP *group, EC_RAW_POINT *out, - const EC_RAW_POINT *a, const EC_RAW_POINT *b) { +void ec_GFp_mont_add(const EC_GROUP *group, EC_JACOBIAN *out, + const EC_JACOBIAN *a, const EC_JACOBIAN *b) { if (a == b) { ec_GFp_mont_dbl(group, out, a); return; @@ -317,7 +286,7 @@ void ec_GFp_mont_add(const EC_GROUP *group, EC_RAW_POINT *out, // This case will never occur in the constant-time |ec_GFp_mont_mul|. BN_ULONG is_nontrivial_double = ~xneq & ~yneq & z1nz & z2nz; - if (is_nontrivial_double) { + if (constant_time_declassify_w(is_nontrivial_double)) { ec_GFp_mont_dbl(group, out, a); return; } @@ -357,8 +326,8 @@ void ec_GFp_mont_add(const EC_GROUP *group, EC_RAW_POINT *out, ec_felem_select(group, &out->Z, z2nz, &z_out, &a->Z); } -void ec_GFp_mont_dbl(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *a) { +void ec_GFp_mont_dbl(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *a) { if (group->a_is_minus3) { // The method is taken from: // http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b @@ -453,10 +422,10 @@ void ec_GFp_mont_dbl(const EC_GROUP *group, EC_RAW_POINT *r, } static int ec_GFp_mont_cmp_x_coordinate(const EC_GROUP *group, - const EC_RAW_POINT *p, + const EC_JACOBIAN *p, const EC_SCALAR *r) { if (!group->field_greater_than_order || - group->field.width != group->order.width) { + group->field.N.width != group->order.N.width) { // Do not bother optimizing this case. p > order in all commonly-used // curves. return ec_GFp_simple_cmp_x_coordinate(group, p, r); @@ -472,7 +441,7 @@ static int ec_GFp_mont_cmp_x_coordinate(const EC_GROUP *group, EC_FELEM r_Z2, Z2_mont, X; ec_GFp_mont_felem_mul(group, &Z2_mont, &p->Z, &p->Z); // r < order < p, so this is valid. - OPENSSL_memcpy(r_Z2.words, r->words, group->field.width * sizeof(BN_ULONG)); + OPENSSL_memcpy(r_Z2.words, r->words, group->field.N.width * sizeof(BN_ULONG)); ec_GFp_mont_felem_mul(group, &r_Z2, &r_Z2, &Z2_mont); ec_GFp_mont_felem_from_montgomery(group, &X, &p->X); @@ -484,10 +453,11 @@ static int ec_GFp_mont_cmp_x_coordinate(const EC_GROUP *group, // Therefore there is a small possibility, less than 1/2^128, that group_order // < p.x < P. in that case we need not only to compare against |r| but also to // compare against r+group_order. - if (bn_less_than_words(r->words, group->field_minus_order.words, - group->field.width)) { - // We can ignore the carry because: r + group_order < p < 2^256. - bn_add_words(r_Z2.words, r->words, group->order.d, group->field.width); + BN_ULONG carry = bn_add_words(r_Z2.words, r->words, group->order.N.d, + group->field.N.width); + if (carry == 0 && + bn_less_than_words(r_Z2.words, group->field.N.d, group->field.N.width)) { + // r + group_order < p, so compare (r + group_order) * Z^2 against X. ec_GFp_mont_felem_mul(group, &r_Z2, &r_Z2, &Z2_mont); if (ec_felem_equal(group, &r_Z2, &X)) { return 1; @@ -498,9 +468,6 @@ static int ec_GFp_mont_cmp_x_coordinate(const EC_GROUP *group, } DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_mont_method) { - out->group_init = ec_GFp_mont_group_init; - out->group_finish = ec_GFp_mont_group_finish; - out->group_set_curve = ec_GFp_mont_group_set_curve; out->point_get_affine_coordinates = ec_GFp_mont_point_get_affine_coordinates; out->jacobian_to_affine_batch = ec_GFp_mont_jacobian_to_affine_batch; out->add = ec_GFp_mont_add; diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/felem.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/felem.c index 4935fda7..8212f9fa 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/felem.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/felem.c @@ -23,12 +23,16 @@ #include "../../internal.h" +const EC_FELEM *ec_felem_one(const EC_GROUP *group) { + // We reuse generator.Z as a cache for 1 in the field. + return &group->generator.raw.Z; +} + int ec_bignum_to_felem(const EC_GROUP *group, EC_FELEM *out, const BIGNUM *in) { uint8_t bytes[EC_MAX_BYTES]; - size_t len = BN_num_bytes(&group->field); + size_t len = BN_num_bytes(&group->field.N); assert(sizeof(bytes) >= len); - if (BN_is_negative(in) || - BN_cmp(in, &group->field) >= 0 || + if (BN_is_negative(in) || BN_cmp(in, &group->field.N) >= 0 || !BN_bn2bin_padded(bytes, len, in)) { OPENSSL_PUT_ERROR(EC, EC_R_COORDINATES_OUT_OF_RANGE); return 0; @@ -57,11 +61,11 @@ int ec_felem_from_bytes(const EC_GROUP *group, EC_FELEM *out, const uint8_t *in, void ec_felem_neg(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a) { // -a is zero if a is zero and p-a otherwise. BN_ULONG mask = ec_felem_non_zero_mask(group, a); - BN_ULONG borrow = - bn_sub_words(out->words, group->field.d, a->words, group->field.width); + BN_ULONG borrow = bn_sub_words(out->words, group->field.N.d, a->words, + group->field.N.width); assert(borrow == 0); (void)borrow; - for (int i = 0; i < group->field.width; i++) { + for (int i = 0; i < group->field.N.width; i++) { out->words[i] &= mask; } } @@ -69,20 +73,20 @@ void ec_felem_neg(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a) { void ec_felem_add(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a, const EC_FELEM *b) { EC_FELEM tmp; - bn_mod_add_words(out->words, a->words, b->words, group->field.d, tmp.words, - group->field.width); + bn_mod_add_words(out->words, a->words, b->words, group->field.N.d, tmp.words, + group->field.N.width); } void ec_felem_sub(const EC_GROUP *group, EC_FELEM *out, const EC_FELEM *a, const EC_FELEM *b) { EC_FELEM tmp; - bn_mod_sub_words(out->words, a->words, b->words, group->field.d, tmp.words, - group->field.width); + bn_mod_sub_words(out->words, a->words, b->words, group->field.N.d, tmp.words, + group->field.N.width); } BN_ULONG ec_felem_non_zero_mask(const EC_GROUP *group, const EC_FELEM *a) { BN_ULONG mask = 0; - for (int i = 0; i < group->field.width; i++) { + for (int i = 0; i < group->field.N.width; i++) { mask |= a->words[i]; } return ~constant_time_is_zero_w(mask); @@ -90,11 +94,11 @@ BN_ULONG ec_felem_non_zero_mask(const EC_GROUP *group, const EC_FELEM *a) { void ec_felem_select(const EC_GROUP *group, EC_FELEM *out, BN_ULONG mask, const EC_FELEM *a, const EC_FELEM *b) { - bn_select_words(out->words, mask, a->words, b->words, group->field.width); + bn_select_words(out->words, mask, a->words, b->words, group->field.N.width); } int ec_felem_equal(const EC_GROUP *group, const EC_FELEM *a, const EC_FELEM *b) { return CRYPTO_memcmp(a->words, b->words, - group->field.width * sizeof(BN_ULONG)) == 0; + group->field.N.width * sizeof(BN_ULONG)) == 0; } diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/internal.h b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/internal.h index b3137505..95005223 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/internal.h @@ -91,6 +91,8 @@ extern "C" { // be the largest fields anyone plausibly uses. #define EC_MAX_BYTES 66 #define EC_MAX_WORDS ((EC_MAX_BYTES + BN_BYTES - 1) / BN_BYTES) +#define EC_MAX_COMPRESSED (EC_MAX_BYTES + 1) +#define EC_MAX_UNCOMPRESSED (2 * EC_MAX_BYTES + 1) static_assert(EC_MAX_WORDS <= BN_SMALL_MAX_WORDS, "bn_*_small functions not usable"); @@ -119,8 +121,8 @@ OPENSSL_EXPORT void ec_scalar_to_bytes(const EC_GROUP *group, uint8_t *out, // ec_scalar_from_bytes deserializes |in| and stores the resulting scalar over // group |group| to |out|. It returns one on success and zero if |in| is // invalid. -int ec_scalar_from_bytes(const EC_GROUP *group, EC_SCALAR *out, - const uint8_t *in, size_t len); +OPENSSL_EXPORT int ec_scalar_from_bytes(const EC_GROUP *group, EC_SCALAR *out, + const uint8_t *in, size_t len); // ec_scalar_reduce sets |out| to |words|, reduced modulo the group order. // |words| must be less than order^2. |num| must be at most twice the width of @@ -195,6 +197,9 @@ typedef struct { BN_ULONG words[EC_MAX_WORDS]; } EC_FELEM; +// ec_felem_one returns one in |group|'s field. +const EC_FELEM *ec_felem_one(const EC_GROUP *group); + // ec_bignum_to_felem converts |in| to an |EC_FELEM|. It returns one on success // and zero if |in| is out of range. int ec_bignum_to_felem(const EC_GROUP *group, EC_FELEM *out, const BIGNUM *in); @@ -241,16 +246,14 @@ int ec_felem_equal(const EC_GROUP *group, const EC_FELEM *a, const EC_FELEM *b); // Points. // // Points may represented in affine coordinates as |EC_AFFINE| or Jacobian -// coordinates as |EC_RAW_POINT|. Affine coordinates directly represent a +// coordinates as |EC_JACOBIAN|. Affine coordinates directly represent a // point on the curve, but point addition over affine coordinates requires // costly field inversions, so arithmetic is done in Jacobian coordinates. // Converting from affine to Jacobian is cheap, while converting from Jacobian // to affine costs a field inversion. (Jacobian coordinates amortize the field // inversions needed in a sequence of point operations.) -// -// TODO(davidben): Rename |EC_RAW_POINT| to |EC_JACOBIAN|. -// An EC_RAW_POINT represents an elliptic curve point in Jacobian coordinates. +// An EC_JACOBIAN represents an elliptic curve point in Jacobian coordinates. // Unlike |EC_POINT|, it is a plain struct which can be stack-allocated and // needs no cleanup. It is specific to an |EC_GROUP| and must not be mixed // between groups. @@ -258,7 +261,7 @@ typedef struct { // X, Y, and Z are Jacobian projective coordinates. They represent // (X/Z^2, Y/Z^3) if Z != 0 and the point at infinity otherwise. EC_FELEM X, Y, Z; -} EC_RAW_POINT; +} EC_JACOBIAN; // An EC_AFFINE represents an elliptic curve point in affine coordinates. // coordinates. Note the point at infinity cannot be represented in affine @@ -269,7 +272,7 @@ typedef struct { // ec_affine_to_jacobian converts |p| to Jacobian form and writes the result to // |*out|. This operation is very cheap and only costs a few copies. -void ec_affine_to_jacobian(const EC_GROUP *group, EC_RAW_POINT *out, +void ec_affine_to_jacobian(const EC_GROUP *group, EC_JACOBIAN *out, const EC_AFFINE *p); // ec_jacobian_to_affine converts |p| to affine form and writes the result to @@ -279,8 +282,8 @@ void ec_affine_to_jacobian(const EC_GROUP *group, EC_RAW_POINT *out, // // If only extracting the x-coordinate, use |ec_get_x_coordinate_*| which is // slightly faster. -int ec_jacobian_to_affine(const EC_GROUP *group, EC_AFFINE *out, - const EC_RAW_POINT *p); +OPENSSL_EXPORT int ec_jacobian_to_affine(const EC_GROUP *group, EC_AFFINE *out, + const EC_JACOBIAN *p); // ec_jacobian_to_affine_batch converts |num| points in |in| from Jacobian // coordinates to affine coordinates and writes the results to |out|. It returns @@ -289,7 +292,7 @@ int ec_jacobian_to_affine(const EC_GROUP *group, EC_AFFINE *out, // This function is not implemented for all curves. Add implementations as // needed. int ec_jacobian_to_affine_batch(const EC_GROUP *group, EC_AFFINE *out, - const EC_RAW_POINT *in, size_t num); + const EC_JACOBIAN *in, size_t num); // ec_point_set_affine_coordinates sets |out|'s to a point with affine // coordinates |x| and |y|. It returns one if the point is on the curve and @@ -307,12 +310,12 @@ int ec_point_mul_no_self_test(const EC_GROUP *group, EC_POINT *r, // ec_point_mul_scalar sets |r| to |p| * |scalar|. Both inputs are considered // secret. -int ec_point_mul_scalar(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *p, const EC_SCALAR *scalar); +int ec_point_mul_scalar(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *p, const EC_SCALAR *scalar); // ec_point_mul_scalar_base sets |r| to generator * |scalar|. |scalar| is // treated as secret. -int ec_point_mul_scalar_base(const EC_GROUP *group, EC_RAW_POINT *r, +int ec_point_mul_scalar_base(const EC_GROUP *group, EC_JACOBIAN *r, const EC_SCALAR *scalar); // ec_point_mul_scalar_batch sets |r| to |p0| * |scalar0| + |p1| * |scalar1| + @@ -333,10 +336,10 @@ int ec_point_mul_scalar_base(const EC_GROUP *group, EC_RAW_POINT *r, // none. If generalizing to tuned curves, this may be useful. However, we still // must double up to the least efficient input, so precomputed tables can only // save table setup and allow a wider window size. -int ec_point_mul_scalar_batch(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *p0, const EC_SCALAR *scalar0, - const EC_RAW_POINT *p1, const EC_SCALAR *scalar1, - const EC_RAW_POINT *p2, const EC_SCALAR *scalar2); +int ec_point_mul_scalar_batch(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *p0, const EC_SCALAR *scalar0, + const EC_JACOBIAN *p1, const EC_SCALAR *scalar1, + const EC_JACOBIAN *p2, const EC_SCALAR *scalar2); #define EC_MONT_PRECOMP_COMB_SIZE 5 @@ -355,7 +358,7 @@ typedef union { // This function is not implemented for all curves. Add implementations as // needed. int ec_init_precomp(const EC_GROUP *group, EC_PRECOMP *out, - const EC_RAW_POINT *p); + const EC_JACOBIAN *p); // ec_point_mul_scalar_precomp sets |r| to |p0| * |scalar0| + |p1| * |scalar1| + // |p2| * |scalar2|. |p1| or |p2| may be NULL to skip the corresponding term. @@ -379,7 +382,7 @@ int ec_init_precomp(const EC_GROUP *group, EC_PRECOMP *out, // none. If generalizing to tuned curves, we should add a parameter for the base // point and arrange for the generic implementation to have base point tables // available. -int ec_point_mul_scalar_precomp(const EC_GROUP *group, EC_RAW_POINT *r, +int ec_point_mul_scalar_precomp(const EC_GROUP *group, EC_JACOBIAN *r, const EC_PRECOMP *p0, const EC_SCALAR *scalar0, const EC_PRECOMP *p1, const EC_SCALAR *scalar1, const EC_PRECOMP *p2, const EC_SCALAR *scalar2); @@ -388,9 +391,9 @@ int ec_point_mul_scalar_precomp(const EC_GROUP *group, EC_RAW_POINT *r, // generator * |g_scalar| + |p| * |p_scalar|. It assumes that the inputs are // public so there is no concern about leaking their values through timing. OPENSSL_EXPORT int ec_point_mul_scalar_public(const EC_GROUP *group, - EC_RAW_POINT *r, + EC_JACOBIAN *r, const EC_SCALAR *g_scalar, - const EC_RAW_POINT *p, + const EC_JACOBIAN *p, const EC_SCALAR *p_scalar); // ec_point_mul_scalar_public_batch sets |r| to the sum of generator * @@ -401,15 +404,15 @@ OPENSSL_EXPORT int ec_point_mul_scalar_public(const EC_GROUP *group, // // This function is not implemented for all curves. Add implementations as // needed. -int ec_point_mul_scalar_public_batch(const EC_GROUP *group, EC_RAW_POINT *r, +int ec_point_mul_scalar_public_batch(const EC_GROUP *group, EC_JACOBIAN *r, const EC_SCALAR *g_scalar, - const EC_RAW_POINT *points, + const EC_JACOBIAN *points, const EC_SCALAR *scalars, size_t num); // ec_point_select, in constant time, sets |out| to |a| if |mask| is all ones // and |b| if |mask| is all zeros. -void ec_point_select(const EC_GROUP *group, EC_RAW_POINT *out, BN_ULONG mask, - const EC_RAW_POINT *a, const EC_RAW_POINT *b); +void ec_point_select(const EC_GROUP *group, EC_JACOBIAN *out, BN_ULONG mask, + const EC_JACOBIAN *a, const EC_JACOBIAN *b); // ec_affine_select behaves like |ec_point_select| but acts on affine points. void ec_affine_select(const EC_GROUP *group, EC_AFFINE *out, BN_ULONG mask, @@ -421,15 +424,15 @@ void ec_precomp_select(const EC_GROUP *group, EC_PRECOMP *out, BN_ULONG mask, // ec_cmp_x_coordinate compares the x (affine) coordinate of |p|, mod the group // order, with |r|. It returns one if the values match and zero if |p| is the -// point at infinity of the values do not match. -int ec_cmp_x_coordinate(const EC_GROUP *group, const EC_RAW_POINT *p, +// point at infinity of the values do not match. |p| is treated as public. +int ec_cmp_x_coordinate(const EC_GROUP *group, const EC_JACOBIAN *p, const EC_SCALAR *r); // ec_get_x_coordinate_as_scalar sets |*out| to |p|'s x-coordinate, modulo // |group->order|. It returns one on success and zero if |p| is the point at // infinity. int ec_get_x_coordinate_as_scalar(const EC_GROUP *group, EC_SCALAR *out, - const EC_RAW_POINT *p); + const EC_JACOBIAN *p); // ec_get_x_coordinate_as_bytes writes |p|'s affine x-coordinate to |out|, which // must have at must |max_out| bytes. It sets |*out_len| to the number of bytes @@ -437,7 +440,7 @@ int ec_get_x_coordinate_as_scalar(const EC_GROUP *group, EC_SCALAR *out, // field. This function returns one on success and zero on failure. int ec_get_x_coordinate_as_bytes(const EC_GROUP *group, uint8_t *out, size_t *out_len, size_t max_out, - const EC_RAW_POINT *p); + const EC_JACOBIAN *p); // ec_point_byte_len returns the number of bytes in the byte representation of // a non-infinity point in |group|, encoded according to |form|, or zero if @@ -461,67 +464,63 @@ int ec_point_from_uncompressed(const EC_GROUP *group, EC_AFFINE *out, // ec_set_to_safe_point sets |out| to an arbitrary point on |group|, either the // generator or the point at infinity. This is used to guard against callers of // external APIs not checking the return value. -void ec_set_to_safe_point(const EC_GROUP *group, EC_RAW_POINT *out); +void ec_set_to_safe_point(const EC_GROUP *group, EC_JACOBIAN *out); // ec_affine_jacobian_equal returns one if |a| and |b| represent the same point // and zero otherwise. It treats both inputs as secret. int ec_affine_jacobian_equal(const EC_GROUP *group, const EC_AFFINE *a, - const EC_RAW_POINT *b); + const EC_JACOBIAN *b); // Implementation details. struct ec_method_st { - int (*group_init)(EC_GROUP *); - void (*group_finish)(EC_GROUP *); - int (*group_set_curve)(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, - const BIGNUM *b, BN_CTX *); - // point_get_affine_coordinates sets |*x| and |*y| to the affine coordinates // of |p|. Either |x| or |y| may be NULL to omit it. It returns one on success - // and zero if |p| is the point at infinity. - int (*point_get_affine_coordinates)(const EC_GROUP *, const EC_RAW_POINT *p, + // and zero if |p| is the point at infinity. It leaks whether |p| was the + // point at infinity, but otherwise treats |p| as secret. + int (*point_get_affine_coordinates)(const EC_GROUP *, const EC_JACOBIAN *p, EC_FELEM *x, EC_FELEM *y); // jacobian_to_affine_batch implements |ec_jacobian_to_affine_batch|. int (*jacobian_to_affine_batch)(const EC_GROUP *group, EC_AFFINE *out, - const EC_RAW_POINT *in, size_t num); + const EC_JACOBIAN *in, size_t num); // add sets |r| to |a| + |b|. - void (*add)(const EC_GROUP *group, EC_RAW_POINT *r, const EC_RAW_POINT *a, - const EC_RAW_POINT *b); + void (*add)(const EC_GROUP *group, EC_JACOBIAN *r, const EC_JACOBIAN *a, + const EC_JACOBIAN *b); // dbl sets |r| to |a| + |a|. - void (*dbl)(const EC_GROUP *group, EC_RAW_POINT *r, const EC_RAW_POINT *a); + void (*dbl)(const EC_GROUP *group, EC_JACOBIAN *r, const EC_JACOBIAN *a); // mul sets |r| to |scalar|*|p|. - void (*mul)(const EC_GROUP *group, EC_RAW_POINT *r, const EC_RAW_POINT *p, + void (*mul)(const EC_GROUP *group, EC_JACOBIAN *r, const EC_JACOBIAN *p, const EC_SCALAR *scalar); // mul_base sets |r| to |scalar|*generator. - void (*mul_base)(const EC_GROUP *group, EC_RAW_POINT *r, + void (*mul_base)(const EC_GROUP *group, EC_JACOBIAN *r, const EC_SCALAR *scalar); // mul_batch implements |ec_mul_scalar_batch|. - void (*mul_batch)(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *p0, const EC_SCALAR *scalar0, - const EC_RAW_POINT *p1, const EC_SCALAR *scalar1, - const EC_RAW_POINT *p2, const EC_SCALAR *scalar2); + void (*mul_batch)(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *p0, const EC_SCALAR *scalar0, + const EC_JACOBIAN *p1, const EC_SCALAR *scalar1, + const EC_JACOBIAN *p2, const EC_SCALAR *scalar2); // mul_public sets |r| to |g_scalar|*generator + |p_scalar|*|p|. It assumes // that the inputs are public so there is no concern about leaking their // values through timing. // // This function may be omitted if |mul_public_batch| is provided. - void (*mul_public)(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_SCALAR *g_scalar, const EC_RAW_POINT *p, + void (*mul_public)(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_SCALAR *g_scalar, const EC_JACOBIAN *p, const EC_SCALAR *p_scalar); // mul_public_batch implements |ec_point_mul_scalar_public_batch|. - int (*mul_public_batch)(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_SCALAR *g_scalar, const EC_RAW_POINT *points, + int (*mul_public_batch)(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_SCALAR *g_scalar, const EC_JACOBIAN *points, const EC_SCALAR *scalars, size_t num); // init_precomp implements |ec_init_precomp|. int (*init_precomp)(const EC_GROUP *group, EC_PRECOMP *out, - const EC_RAW_POINT *p); + const EC_JACOBIAN *p); // mul_precomp implements |ec_point_mul_scalar_precomp|. - void (*mul_precomp)(const EC_GROUP *group, EC_RAW_POINT *r, + void (*mul_precomp)(const EC_GROUP *group, EC_JACOBIAN *r, const EC_PRECOMP *p0, const EC_SCALAR *scalar0, const EC_PRECOMP *p1, const EC_SCALAR *scalar1, const EC_PRECOMP *p2, const EC_SCALAR *scalar2); @@ -581,78 +580,72 @@ struct ec_method_st { // cmp_x_coordinate compares the x (affine) coordinate of |p|, mod the group // order, with |r|. It returns one if the values match and zero if |p| is the // point at infinity of the values do not match. - int (*cmp_x_coordinate)(const EC_GROUP *group, const EC_RAW_POINT *p, + int (*cmp_x_coordinate)(const EC_GROUP *group, const EC_JACOBIAN *p, const EC_SCALAR *r); } /* EC_METHOD */; const EC_METHOD *EC_GFp_mont_method(void); -struct ec_group_st { - const EC_METHOD *meth; - - // Unlike all other |EC_POINT|s, |generator| does not own |generator->group| - // to avoid a reference cycle. Additionally, Z is guaranteed to be one, so X - // and Y are suitable for use as an |EC_AFFINE|. - EC_POINT *generator; - BIGNUM order; - - int curve_name; // optional NID for named curve - - BN_MONT_CTX *order_mont; // data for ECDSA inverse - - // The following members are handled by the method functions, - // even if they appear generic - - BIGNUM field; // For curves over GF(p), this is the modulus. - - EC_FELEM a, b; // Curve coefficients. - - // a_is_minus3 is one if |a| is -3 mod |field| and zero otherwise. Point - // arithmetic is optimized for -3. - int a_is_minus3; - - // field_greater_than_order is one if |field| is greate than |order| and zero - // otherwise. - int field_greater_than_order; - - // field_minus_order, if |field_greater_than_order| is true, is |field| minus - // |order| represented as an |EC_FELEM|. Otherwise, it is zero. - // - // Note: unlike |EC_FELEM|s used as intermediate values internal to the - // |EC_METHOD|, this value is not encoded in Montgomery form. - EC_FELEM field_minus_order; - - CRYPTO_refcount_t references; - - BN_MONT_CTX *mont; // Montgomery structure. - - EC_FELEM one; // The value one. -} /* EC_GROUP */; - struct ec_point_st { // group is an owning reference to |group|, unless this is // |group->generator|. EC_GROUP *group; // raw is the group-specific point data. Functions that take |EC_POINT| // typically check consistency with |EC_GROUP| while functions that take - // |EC_RAW_POINT| do not. Thus accesses to this field should be externally + // |EC_JACOBIAN| do not. Thus accesses to this field should be externally // checked for consistency. - EC_RAW_POINT raw; + EC_JACOBIAN raw; } /* EC_POINT */; -EC_GROUP *ec_group_new(const EC_METHOD *meth); +struct ec_group_st { + const EC_METHOD *meth; -void ec_GFp_mont_mul(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *p, const EC_SCALAR *scalar); -void ec_GFp_mont_mul_base(const EC_GROUP *group, EC_RAW_POINT *r, + // Unlike all other |EC_POINT|s, |generator| does not own |generator->group| + // to avoid a reference cycle. Additionally, Z is guaranteed to be one, so X + // and Y are suitable for use as an |EC_AFFINE|. Before |has_order| is set, Z + // is one, but X and Y are uninitialized. + EC_POINT generator; + + BN_MONT_CTX order; + BN_MONT_CTX field; + + EC_FELEM a, b; // Curve coefficients. + + // comment is a human-readable string describing the curve. + const char *comment; + + int curve_name; // optional NID for named curve + uint8_t oid[9]; + uint8_t oid_len; + + // a_is_minus3 is one if |a| is -3 mod |field| and zero otherwise. Point + // arithmetic is optimized for -3. + int a_is_minus3; + + // has_order is one if |generator| and |order| have been initialized. + int has_order; + + // field_greater_than_order is one if |field| is greate than |order| and zero + // otherwise. + int field_greater_than_order; + + CRYPTO_refcount_t references; +} /* EC_GROUP */; + +EC_GROUP *ec_group_new(const EC_METHOD *meth, const BIGNUM *p, const BIGNUM *a, + const BIGNUM *b, BN_CTX *ctx); + +void ec_GFp_mont_mul(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *p, const EC_SCALAR *scalar); +void ec_GFp_mont_mul_base(const EC_GROUP *group, EC_JACOBIAN *r, const EC_SCALAR *scalar); -void ec_GFp_mont_mul_batch(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *p0, const EC_SCALAR *scalar0, - const EC_RAW_POINT *p1, const EC_SCALAR *scalar1, - const EC_RAW_POINT *p2, const EC_SCALAR *scalar2); +void ec_GFp_mont_mul_batch(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *p0, const EC_SCALAR *scalar0, + const EC_JACOBIAN *p1, const EC_SCALAR *scalar1, + const EC_JACOBIAN *p2, const EC_SCALAR *scalar2); int ec_GFp_mont_init_precomp(const EC_GROUP *group, EC_PRECOMP *out, - const EC_RAW_POINT *p); -void ec_GFp_mont_mul_precomp(const EC_GROUP *group, EC_RAW_POINT *r, + const EC_JACOBIAN *p); +void ec_GFp_mont_mul_precomp(const EC_GROUP *group, EC_JACOBIAN *r, const EC_PRECOMP *p0, const EC_SCALAR *scalar0, const EC_PRECOMP *p1, const EC_SCALAR *scalar1, const EC_PRECOMP *p2, const EC_SCALAR *scalar2); @@ -673,29 +666,27 @@ void ec_GFp_mont_felem_exp(const EC_GROUP *group, EC_FELEM *out, void ec_compute_wNAF(const EC_GROUP *group, int8_t *out, const EC_SCALAR *scalar, size_t bits, int w); -int ec_GFp_mont_mul_public_batch(const EC_GROUP *group, EC_RAW_POINT *r, +int ec_GFp_mont_mul_public_batch(const EC_GROUP *group, EC_JACOBIAN *r, const EC_SCALAR *g_scalar, - const EC_RAW_POINT *points, + const EC_JACOBIAN *points, const EC_SCALAR *scalars, size_t num); // method functions in simple.c -int ec_GFp_simple_group_init(EC_GROUP *); -void ec_GFp_simple_group_finish(EC_GROUP *); int ec_GFp_simple_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int ec_GFp_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b); -void ec_GFp_simple_point_init(EC_RAW_POINT *); -void ec_GFp_simple_point_copy(EC_RAW_POINT *, const EC_RAW_POINT *); -void ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_RAW_POINT *); -void ec_GFp_mont_add(const EC_GROUP *, EC_RAW_POINT *r, const EC_RAW_POINT *a, - const EC_RAW_POINT *b); -void ec_GFp_mont_dbl(const EC_GROUP *, EC_RAW_POINT *r, const EC_RAW_POINT *a); -void ec_GFp_simple_invert(const EC_GROUP *, EC_RAW_POINT *); -int ec_GFp_simple_is_at_infinity(const EC_GROUP *, const EC_RAW_POINT *); -int ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_RAW_POINT *); -int ec_GFp_simple_points_equal(const EC_GROUP *, const EC_RAW_POINT *a, - const EC_RAW_POINT *b); +void ec_GFp_simple_point_init(EC_JACOBIAN *); +void ec_GFp_simple_point_copy(EC_JACOBIAN *, const EC_JACOBIAN *); +void ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_JACOBIAN *); +void ec_GFp_mont_add(const EC_GROUP *, EC_JACOBIAN *r, const EC_JACOBIAN *a, + const EC_JACOBIAN *b); +void ec_GFp_mont_dbl(const EC_GROUP *, EC_JACOBIAN *r, const EC_JACOBIAN *a); +void ec_GFp_simple_invert(const EC_GROUP *, EC_JACOBIAN *); +int ec_GFp_simple_is_at_infinity(const EC_GROUP *, const EC_JACOBIAN *); +int ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_JACOBIAN *); +int ec_GFp_simple_points_equal(const EC_GROUP *, const EC_JACOBIAN *a, + const EC_JACOBIAN *b); void ec_simple_scalar_inv0_montgomery(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a); @@ -703,7 +694,7 @@ int ec_simple_scalar_to_montgomery_inv_vartime(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a); -int ec_GFp_simple_cmp_x_coordinate(const EC_GROUP *group, const EC_RAW_POINT *p, +int ec_GFp_simple_cmp_x_coordinate(const EC_GROUP *group, const EC_JACOBIAN *p, const EC_SCALAR *r); void ec_GFp_simple_felem_to_bytes(const EC_GROUP *group, uint8_t *out, @@ -712,10 +703,6 @@ int ec_GFp_simple_felem_from_bytes(const EC_GROUP *group, EC_FELEM *out, const uint8_t *in, size_t len); // method functions in montgomery.c -int ec_GFp_mont_group_init(EC_GROUP *); -int ec_GFp_mont_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, - const BIGNUM *b, BN_CTX *); -void ec_GFp_mont_group_finish(EC_GROUP *); void ec_GFp_mont_felem_mul(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a, const EC_FELEM *b); void ec_GFp_mont_felem_sqr(const EC_GROUP *, EC_FELEM *r, const EC_FELEM *a); @@ -761,31 +748,6 @@ struct ec_key_st { CRYPTO_EX_DATA ex_data; } /* EC_KEY */; -struct built_in_curve { - int nid; - const uint8_t *oid; - uint8_t oid_len; - // comment is a human-readable string describing the curve. - const char *comment; - // param_len is the number of bytes needed to store a field element. - uint8_t param_len; - // params points to an array of 6*|param_len| bytes which hold the field - // elements of the following (in big-endian order): prime, a, b, generator x, - // generator y, order. - const uint8_t *params; - const EC_METHOD *method; -}; - -#define OPENSSL_NUM_BUILT_IN_CURVES 4 - -struct built_in_curves { - struct built_in_curve curves[OPENSSL_NUM_BUILT_IN_CURVES]; -}; - -// OPENSSL_built_in_curves returns a pointer to static information about -// standard curves. The array is terminated with an entry where |nid| is -// |NID_undef|. -const struct built_in_curves *OPENSSL_built_in_curves(void); #if defined(__cplusplus) } // extern C diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/oct.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/oct.c index 292ec053..425cf4f1 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/oct.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/oct.c @@ -80,7 +80,7 @@ size_t ec_point_byte_len(const EC_GROUP *group, point_conversion_form_t form) { return 0; } - const size_t field_len = BN_num_bytes(&group->field); + const size_t field_len = BN_num_bytes(&group->field.N); size_t output_len = 1 /* type byte */ + field_len; if (form == POINT_CONVERSION_UNCOMPRESSED) { // Uncompressed points have a second coordinate. @@ -100,11 +100,11 @@ size_t ec_point_to_bytes(const EC_GROUP *group, const EC_AFFINE *point, size_t field_len; ec_felem_to_bytes(group, buf + 1, &field_len, &point->X); - assert(field_len == BN_num_bytes(&group->field)); + assert(field_len == BN_num_bytes(&group->field.N)); if (form == POINT_CONVERSION_UNCOMPRESSED) { ec_felem_to_bytes(group, buf + 1 + field_len, &field_len, &point->Y); - assert(field_len == BN_num_bytes(&group->field)); + assert(field_len == BN_num_bytes(&group->field.N)); buf[0] = form; } else { uint8_t y_buf[EC_MAX_BYTES]; @@ -117,7 +117,7 @@ size_t ec_point_to_bytes(const EC_GROUP *group, const EC_AFFINE *point, int ec_point_from_uncompressed(const EC_GROUP *group, EC_AFFINE *out, const uint8_t *in, size_t len) { - const size_t field_len = BN_num_bytes(&group->field); + const size_t field_len = BN_num_bytes(&group->field.N); if (len != 1 + 2 * field_len || in[0] != POINT_CONVERSION_UNCOMPRESSED) { OPENSSL_PUT_ERROR(EC, EC_R_INVALID_ENCODING); return 0; @@ -155,7 +155,7 @@ static int ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point, } const int y_bit = form & 1; - const size_t field_len = BN_num_bytes(&group->field); + const size_t field_len = BN_num_bytes(&group->field.N); form = form & ~1u; if (form != POINT_CONVERSION_COMPRESSED || len != 1 /* type byte */ + field_len) { @@ -182,7 +182,7 @@ static int ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point, if (x == NULL || !BN_bin2bn(buf + 1, field_len, x)) { goto err; } - if (BN_ucmp(x, &group->field) >= 0) { + if (BN_ucmp(x, &group->field.N) >= 0) { OPENSSL_PUT_ERROR(EC, EC_R_INVALID_ENCODING); goto err; } @@ -260,7 +260,8 @@ int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, return 0; } - if (BN_is_negative(x) || BN_cmp(x, &group->field) >= 0) { + const BIGNUM *field = &group->field.N; + if (BN_is_negative(x) || BN_cmp(x, field) >= 0) { OPENSSL_PUT_ERROR(EC, EC_R_INVALID_COMPRESSED_POINT); return 0; } @@ -295,31 +296,31 @@ int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, // so y is one of the square roots of x^3 + a*x + b. // tmp1 := x^3 - if (!BN_mod_sqr(tmp2, x, &group->field, ctx) || - !BN_mod_mul(tmp1, tmp2, x, &group->field, ctx)) { + if (!BN_mod_sqr(tmp2, x, field, ctx) || + !BN_mod_mul(tmp1, tmp2, x, field, ctx)) { goto err; } // tmp1 := tmp1 + a*x if (group->a_is_minus3) { - if (!bn_mod_lshift1_consttime(tmp2, x, &group->field, ctx) || - !bn_mod_add_consttime(tmp2, tmp2, x, &group->field, ctx) || - !bn_mod_sub_consttime(tmp1, tmp1, tmp2, &group->field, ctx)) { + if (!bn_mod_lshift1_consttime(tmp2, x, field, ctx) || + !bn_mod_add_consttime(tmp2, tmp2, x, field, ctx) || + !bn_mod_sub_consttime(tmp1, tmp1, tmp2, field, ctx)) { goto err; } } else { - if (!BN_mod_mul(tmp2, a, x, &group->field, ctx) || - !bn_mod_add_consttime(tmp1, tmp1, tmp2, &group->field, ctx)) { + if (!BN_mod_mul(tmp2, a, x, field, ctx) || + !bn_mod_add_consttime(tmp1, tmp1, tmp2, field, ctx)) { goto err; } } // tmp1 := tmp1 + b - if (!bn_mod_add_consttime(tmp1, tmp1, b, &group->field, ctx)) { + if (!bn_mod_add_consttime(tmp1, tmp1, b, field, ctx)) { goto err; } - if (!BN_mod_sqrt(y, tmp1, &group->field, ctx)) { + if (!BN_mod_sqrt(y, tmp1, field, ctx)) { uint32_t err = ERR_peek_last_error(); if (ERR_GET_LIB(err) == ERR_LIB_BN && ERR_GET_REASON(err) == BN_R_NOT_A_SQUARE) { @@ -336,7 +337,7 @@ int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, OPENSSL_PUT_ERROR(EC, EC_R_INVALID_COMPRESSION_BIT); goto err; } - if (!BN_usub(y, &group->field, y)) { + if (!BN_usub(y, field, y)) { goto err; } } diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p224-64.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p224-64.c index 97840678..d03e5d31 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p224-64.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p224-64.c @@ -734,8 +734,8 @@ static void p224_point_add(p224_felem x3, p224_felem y3, p224_felem z3, // tmp[i] < 2^116 + 2^64 + 8 < 2^117 p224_felem_reduce(ftmp, tmp); - // the formulae are incorrect if the points are equal - // so we check for this and do doubling if this happens + // The formulae are incorrect if the points are equal, so we check for this + // and do doubling if this happens. x_equal = p224_felem_is_zero(ftmp); y_equal = p224_felem_is_zero(ftmp3); z1_is_zero = p224_felem_is_zero(z1); @@ -743,7 +743,7 @@ static void p224_point_add(p224_felem x3, p224_felem y3, p224_felem z3, // In affine coordinates, (X_1, Y_1) == (X_2, Y_2) p224_limb is_nontrivial_double = x_equal & y_equal & (1 - z1_is_zero) & (1 - z2_is_zero); - if (is_nontrivial_double) { + if (constant_time_declassify_w(is_nontrivial_double)) { p224_point_double(x3, y3, z3, x1, y1, z1); return; } @@ -860,9 +860,10 @@ static crypto_word_t p224_get_bit(const EC_SCALAR *in, size_t i) { // Takes the Jacobian coordinates (X, Y, Z) of a point and returns // (X', Y') = (X/Z^2, Y/Z^3) static int ec_GFp_nistp224_point_get_affine_coordinates( - const EC_GROUP *group, const EC_RAW_POINT *point, EC_FELEM *x, + const EC_GROUP *group, const EC_JACOBIAN *point, EC_FELEM *x, EC_FELEM *y) { - if (ec_GFp_simple_is_at_infinity(group, point)) { + if (constant_time_declassify_int( + ec_GFp_simple_is_at_infinity(group, point))) { OPENSSL_PUT_ERROR(EC, EC_R_POINT_AT_INFINITY); return 0; } @@ -895,8 +896,8 @@ static int ec_GFp_nistp224_point_get_affine_coordinates( return 1; } -static void ec_GFp_nistp224_add(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *a, const EC_RAW_POINT *b) { +static void ec_GFp_nistp224_add(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *a, const EC_JACOBIAN *b) { p224_felem x1, y1, z1, x2, y2, z2; p224_generic_to_felem(x1, &a->X); p224_generic_to_felem(y1, &a->Y); @@ -911,8 +912,8 @@ static void ec_GFp_nistp224_add(const EC_GROUP *group, EC_RAW_POINT *r, p224_felem_to_generic(&r->Z, z1); } -static void ec_GFp_nistp224_dbl(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *a) { +static void ec_GFp_nistp224_dbl(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *a) { p224_felem x, y, z; p224_generic_to_felem(x, &a->X); p224_generic_to_felem(y, &a->Y); @@ -925,7 +926,7 @@ static void ec_GFp_nistp224_dbl(const EC_GROUP *group, EC_RAW_POINT *r, } static void ec_GFp_nistp224_make_precomp(p224_felem out[17][3], - const EC_RAW_POINT *p) { + const EC_JACOBIAN *p) { OPENSSL_memset(out[0], 0, sizeof(p224_felem) * 3); p224_generic_to_felem(out[1][0], &p->X); @@ -943,8 +944,8 @@ static void ec_GFp_nistp224_make_precomp(p224_felem out[17][3], } } -static void ec_GFp_nistp224_point_mul(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *p, +static void ec_GFp_nistp224_point_mul(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *p, const EC_SCALAR *scalar) { p224_felem p_pre_comp[17][3]; ec_GFp_nistp224_make_precomp(p_pre_comp, p); @@ -992,7 +993,7 @@ static void ec_GFp_nistp224_point_mul(const EC_GROUP *group, EC_RAW_POINT *r, } static void ec_GFp_nistp224_point_mul_base(const EC_GROUP *group, - EC_RAW_POINT *r, + EC_JACOBIAN *r, const EC_SCALAR *scalar) { // Set nq to the point at infinity. p224_felem nq[3], tmp[3]; @@ -1039,9 +1040,9 @@ static void ec_GFp_nistp224_point_mul_base(const EC_GROUP *group, } static void ec_GFp_nistp224_point_mul_public(const EC_GROUP *group, - EC_RAW_POINT *r, + EC_JACOBIAN *r, const EC_SCALAR *g_scalar, - const EC_RAW_POINT *p, + const EC_JACOBIAN *p, const EC_SCALAR *p_scalar) { // TODO(davidben): If P-224 ECDSA verify performance ever matters, using // |ec_compute_wNAF| for |p_scalar| would likely be an easy improvement. @@ -1141,9 +1142,6 @@ static void ec_GFp_nistp224_felem_sqr(const EC_GROUP *group, EC_FELEM *r, } DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_nistp224_method) { - out->group_init = ec_GFp_simple_group_init; - out->group_finish = ec_GFp_simple_group_finish; - out->group_set_curve = ec_GFp_simple_group_set_curve; out->point_get_affine_coordinates = ec_GFp_nistp224_point_get_affine_coordinates; out->add = ec_GFp_nistp224_add; diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p256-nistz.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p256-nistz.c index 59175565..7d63708a 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p256-nistz.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p256-nistz.c @@ -187,11 +187,11 @@ static void ecp_nistz256_mod_inverse_sqr_mont(BN_ULONG r[P256_LIMBS], // r = p * p_scalar static void ecp_nistz256_windowed_mul(const EC_GROUP *group, P256_POINT *r, - const EC_RAW_POINT *p, + const EC_JACOBIAN *p, const EC_SCALAR *p_scalar) { assert(p != NULL); assert(p_scalar != NULL); - assert(group->field.width == P256_LIMBS); + assert(group->field.N.width == P256_LIMBS); static const size_t kWindowSize = 5; static const crypto_word_t kMask = (1 << (5 /* kWindowSize */ + 1)) - 1; @@ -208,7 +208,7 @@ static void ecp_nistz256_windowed_mul(const EC_GROUP *group, P256_POINT *r, // not stored. All other values are actually stored with an offset of -1 in // table. P256_POINT *row = table; - assert(group->field.width == P256_LIMBS); + assert(group->field.N.width == P256_LIMBS); OPENSSL_memcpy(row[1 - 1].X, p->X.words, P256_LIMBS * sizeof(BN_ULONG)); OPENSSL_memcpy(row[1 - 1].Y, p->Y.words, P256_LIMBS * sizeof(BN_ULONG)); OPENSSL_memcpy(row[1 - 1].Z, p->Z.words, P256_LIMBS * sizeof(BN_ULONG)); @@ -299,19 +299,19 @@ static crypto_word_t calc_wvalue(size_t *index, const uint8_t p_str[33]) { return booth_recode_w7(wvalue); } -static void ecp_nistz256_point_mul(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *p, +static void ecp_nistz256_point_mul(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *p, const EC_SCALAR *scalar) { alignas(32) P256_POINT out; ecp_nistz256_windowed_mul(group, &out, p, scalar); - assert(group->field.width == P256_LIMBS); + assert(group->field.N.width == P256_LIMBS); OPENSSL_memcpy(r->X.words, out.X, P256_LIMBS * sizeof(BN_ULONG)); OPENSSL_memcpy(r->Y.words, out.Y, P256_LIMBS * sizeof(BN_ULONG)); OPENSSL_memcpy(r->Z.words, out.Z, P256_LIMBS * sizeof(BN_ULONG)); } -static void ecp_nistz256_point_mul_base(const EC_GROUP *group, EC_RAW_POINT *r, +static void ecp_nistz256_point_mul_base(const EC_GROUP *group, EC_JACOBIAN *r, const EC_SCALAR *scalar) { uint8_t p_str[33]; OPENSSL_memcpy(p_str, scalar->words, 32); @@ -349,16 +349,16 @@ static void ecp_nistz256_point_mul_base(const EC_GROUP *group, EC_RAW_POINT *r, ecp_nistz256_point_add_affine(&p, &p, &t); } - assert(group->field.width == P256_LIMBS); + assert(group->field.N.width == P256_LIMBS); OPENSSL_memcpy(r->X.words, p.X, P256_LIMBS * sizeof(BN_ULONG)); OPENSSL_memcpy(r->Y.words, p.Y, P256_LIMBS * sizeof(BN_ULONG)); OPENSSL_memcpy(r->Z.words, p.Z, P256_LIMBS * sizeof(BN_ULONG)); } static void ecp_nistz256_points_mul_public(const EC_GROUP *group, - EC_RAW_POINT *r, + EC_JACOBIAN *r, const EC_SCALAR *g_scalar, - const EC_RAW_POINT *p_, + const EC_JACOBIAN *p_, const EC_SCALAR *p_scalar) { assert(p_ != NULL && p_scalar != NULL && g_scalar != NULL); @@ -413,22 +413,23 @@ static void ecp_nistz256_points_mul_public(const EC_GROUP *group, ecp_nistz256_windowed_mul(group, &tmp, p_, p_scalar); ecp_nistz256_point_add(&p, &p, &tmp); - assert(group->field.width == P256_LIMBS); + assert(group->field.N.width == P256_LIMBS); OPENSSL_memcpy(r->X.words, p.X, P256_LIMBS * sizeof(BN_ULONG)); OPENSSL_memcpy(r->Y.words, p.Y, P256_LIMBS * sizeof(BN_ULONG)); OPENSSL_memcpy(r->Z.words, p.Z, P256_LIMBS * sizeof(BN_ULONG)); } static int ecp_nistz256_get_affine(const EC_GROUP *group, - const EC_RAW_POINT *point, EC_FELEM *x, + const EC_JACOBIAN *point, EC_FELEM *x, EC_FELEM *y) { - if (ec_GFp_simple_is_at_infinity(group, point)) { + if (constant_time_declassify_int( + ec_GFp_simple_is_at_infinity(group, point))) { OPENSSL_PUT_ERROR(EC, EC_R_POINT_AT_INFINITY); return 0; } BN_ULONG z_inv2[P256_LIMBS]; - assert(group->field.width == P256_LIMBS); + assert(group->field.N.width == P256_LIMBS); ecp_nistz256_mod_inverse_sqr_mont(z_inv2, point->Z.words); if (x != NULL) { @@ -444,8 +445,8 @@ static int ecp_nistz256_get_affine(const EC_GROUP *group, return 1; } -static void ecp_nistz256_add(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *a_, const EC_RAW_POINT *b_) { +static void ecp_nistz256_add(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *a_, const EC_JACOBIAN *b_) { P256_POINT a, b; OPENSSL_memcpy(a.X, a_->X.words, P256_LIMBS * sizeof(BN_ULONG)); OPENSSL_memcpy(a.Y, a_->Y.words, P256_LIMBS * sizeof(BN_ULONG)); @@ -459,8 +460,8 @@ static void ecp_nistz256_add(const EC_GROUP *group, EC_RAW_POINT *r, OPENSSL_memcpy(r->Z.words, a.Z, P256_LIMBS * sizeof(BN_ULONG)); } -static void ecp_nistz256_dbl(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *a_) { +static void ecp_nistz256_dbl(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *a_) { P256_POINT a; OPENSSL_memcpy(a.X, a_->X.words, P256_LIMBS * sizeof(BN_ULONG)); OPENSSL_memcpy(a.Y, a_->Y.words, P256_LIMBS * sizeof(BN_ULONG)); @@ -562,8 +563,8 @@ static int ecp_nistz256_scalar_to_montgomery_inv_vartime(const EC_GROUP *group, } #endif - assert(group->order.width == P256_LIMBS); - if (!beeu_mod_inverse_vartime(out->words, in->words, group->order.d)) { + assert(group->order.N.width == P256_LIMBS); + if (!beeu_mod_inverse_vartime(out->words, in->words, group->order.N.d)) { return 0; } @@ -573,14 +574,14 @@ static int ecp_nistz256_scalar_to_montgomery_inv_vartime(const EC_GROUP *group, } static int ecp_nistz256_cmp_x_coordinate(const EC_GROUP *group, - const EC_RAW_POINT *p, + const EC_JACOBIAN *p, const EC_SCALAR *r) { if (ec_GFp_simple_is_at_infinity(group, p)) { return 0; } - assert(group->order.width == P256_LIMBS); - assert(group->field.width == P256_LIMBS); + assert(group->order.N.width == P256_LIMBS); + assert(group->field.N.width == P256_LIMBS); // We wish to compare X/Z^2 with r. This is equivalent to comparing X with // r*Z^2. Note that X and Z are represented in Montgomery form, while r is @@ -598,10 +599,9 @@ static int ecp_nistz256_cmp_x_coordinate(const EC_GROUP *group, // Therefore there is a small possibility, less than 1/2^128, that group_order // < p.x < P. in that case we need not only to compare against |r| but also to // compare against r+group_order. - if (bn_less_than_words(r->words, group->field_minus_order.words, - P256_LIMBS)) { - // We can ignore the carry because: r + group_order < p < 2^256. - bn_add_words(r_Z2, r->words, group->order.d, P256_LIMBS); + BN_ULONG carry = bn_add_words(r_Z2, r->words, group->order.N.d, P256_LIMBS); + if (carry == 0 && bn_less_than_words(r_Z2, group->field.N.d, P256_LIMBS)) { + // r + group_order < p, so compare (r + group_order) * Z^2 against X. ecp_nistz256_mul_mont(r_Z2, r_Z2, Z2_mont); if (OPENSSL_memcmp(r_Z2, X, sizeof(r_Z2)) == 0) { return 1; @@ -612,9 +612,6 @@ static int ecp_nistz256_cmp_x_coordinate(const EC_GROUP *group, } DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_nistz256_method) { - out->group_init = ec_GFp_mont_group_init; - out->group_finish = ec_GFp_mont_group_finish; - out->group_set_curve = ec_GFp_mont_group_set_curve; out->point_get_affine_coordinates = ecp_nistz256_get_affine; out->add = ecp_nistz256_add; out->dbl = ecp_nistz256_dbl; diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p256.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p256.c index 5443f3c9..27bf8799 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p256.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p256.c @@ -31,8 +31,9 @@ #include "./internal.h" #if defined(BORINGSSL_HAS_UINT128) -#define BORINGSSL_NISTP256_64BIT 1 #include "../../../third_party/fiat/p256_64.h" +#elif defined(OPENSSL_64_BIT) +#include "../../../third_party/fiat/p256_64_msvc.h" #else #include "../../../third_party/fiat/p256_32.h" #endif @@ -40,7 +41,7 @@ // utility functions, handwritten -#if defined(BORINGSSL_NISTP256_64BIT) +#if defined(OPENSSL_64_BIT) #define FIAT_P256_NLIMBS 4 typedef uint64_t fiat_p256_limb_t; typedef uint64_t fiat_p256_felem[FIAT_P256_NLIMBS]; @@ -323,7 +324,7 @@ static void fiat_p256_point_add(fiat_p256_felem x3, fiat_p256_felem y3, fiat_p256_limb_t is_nontrivial_double = constant_time_is_zero_w(xneq | yneq) & ~constant_time_is_zero_w(z1nz) & ~constant_time_is_zero_w(z2nz); - if (is_nontrivial_double) { + if (constant_time_declassify_w(is_nontrivial_double)) { fiat_p256_point_double(x3, y3, z3, x1, y1, z1); return; } @@ -413,9 +414,10 @@ static crypto_word_t fiat_p256_get_bit(const EC_SCALAR *in, int i) { // Takes the Jacobian coordinates (X, Y, Z) of a point and returns (X', Y') = // (X/Z^2, Y/Z^3). static int ec_GFp_nistp256_point_get_affine_coordinates( - const EC_GROUP *group, const EC_RAW_POINT *point, EC_FELEM *x_out, + const EC_GROUP *group, const EC_JACOBIAN *point, EC_FELEM *x_out, EC_FELEM *y_out) { - if (ec_GFp_simple_is_at_infinity(group, point)) { + if (constant_time_declassify_int( + ec_GFp_simple_is_at_infinity(group, point))) { OPENSSL_PUT_ERROR(EC, EC_R_POINT_AT_INFINITY); return 0; } @@ -443,8 +445,8 @@ static int ec_GFp_nistp256_point_get_affine_coordinates( return 1; } -static void ec_GFp_nistp256_add(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *a, const EC_RAW_POINT *b) { +static void ec_GFp_nistp256_add(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *a, const EC_JACOBIAN *b) { fiat_p256_felem x1, y1, z1, x2, y2, z2; fiat_p256_from_generic(x1, &a->X); fiat_p256_from_generic(y1, &a->Y); @@ -459,8 +461,8 @@ static void ec_GFp_nistp256_add(const EC_GROUP *group, EC_RAW_POINT *r, fiat_p256_to_generic(&r->Z, z1); } -static void ec_GFp_nistp256_dbl(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *a) { +static void ec_GFp_nistp256_dbl(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *a) { fiat_p256_felem x, y, z; fiat_p256_from_generic(x, &a->X); fiat_p256_from_generic(y, &a->Y); @@ -471,8 +473,8 @@ static void ec_GFp_nistp256_dbl(const EC_GROUP *group, EC_RAW_POINT *r, fiat_p256_to_generic(&r->Z, z); } -static void ec_GFp_nistp256_point_mul(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *p, +static void ec_GFp_nistp256_point_mul(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *p, const EC_SCALAR *scalar) { fiat_p256_felem p_pre_comp[17][3]; OPENSSL_memset(&p_pre_comp, 0, sizeof(p_pre_comp)); @@ -539,7 +541,7 @@ static void ec_GFp_nistp256_point_mul(const EC_GROUP *group, EC_RAW_POINT *r, } static void ec_GFp_nistp256_point_mul_base(const EC_GROUP *group, - EC_RAW_POINT *r, + EC_JACOBIAN *r, const EC_SCALAR *scalar) { // Set nq to the point at infinity. fiat_p256_felem nq[3] = {{0}, {0}, {0}}, tmp[3]; @@ -587,9 +589,9 @@ static void ec_GFp_nistp256_point_mul_base(const EC_GROUP *group, } static void ec_GFp_nistp256_point_mul_public(const EC_GROUP *group, - EC_RAW_POINT *r, + EC_JACOBIAN *r, const EC_SCALAR *g_scalar, - const EC_RAW_POINT *p, + const EC_JACOBIAN *p, const EC_SCALAR *p_scalar) { #define P256_WSIZE_PUBLIC 4 // Precompute multiples of |p|. p_pre_comp[i] is (2*i+1) * |p|. @@ -679,7 +681,7 @@ static void ec_GFp_nistp256_point_mul_public(const EC_GROUP *group, } static int ec_GFp_nistp256_cmp_x_coordinate(const EC_GROUP *group, - const EC_RAW_POINT *p, + const EC_JACOBIAN *p, const EC_SCALAR *r) { if (ec_GFp_simple_is_at_infinity(group, p)) { return 0; @@ -708,12 +710,12 @@ static int ec_GFp_nistp256_cmp_x_coordinate(const EC_GROUP *group, // Therefore there is a small possibility, less than 1/2^128, that group_order // < p.x < P. in that case we need not only to compare against |r| but also to // compare against r+group_order. - assert(group->field.width == group->order.width); - if (bn_less_than_words(r->words, group->field_minus_order.words, - group->field.width)) { - // We can ignore the carry because: r + group_order < p < 2^256. - EC_FELEM tmp; - bn_add_words(tmp.words, r->words, group->order.d, group->order.width); + assert(group->field.N.width == group->order.N.width); + EC_FELEM tmp; + BN_ULONG carry = + bn_add_words(tmp.words, r->words, group->order.N.d, group->field.N.width); + if (carry == 0 && + bn_less_than_words(tmp.words, group->field.N.d, group->field.N.width)) { fiat_p256_from_generic(r_Z2, &tmp); fiat_p256_mul(r_Z2, r_Z2, Z2_mont); if (OPENSSL_memcmp(&r_Z2, &X, sizeof(r_Z2)) == 0) { @@ -725,9 +727,6 @@ static int ec_GFp_nistp256_cmp_x_coordinate(const EC_GROUP *group, } DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_nistp256_method) { - out->group_init = ec_GFp_mont_group_init; - out->group_finish = ec_GFp_mont_group_finish; - out->group_set_curve = ec_GFp_mont_group_set_curve; out->point_get_affine_coordinates = ec_GFp_nistp256_point_get_affine_coordinates; out->add = ec_GFp_nistp256_add; @@ -748,5 +747,3 @@ DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_nistp256_method) { ec_simple_scalar_to_montgomery_inv_vartime; out->cmp_x_coordinate = ec_GFp_nistp256_cmp_x_coordinate; } - -#undef BORINGSSL_NISTP256_64BIT diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p256_table.h b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p256_table.h index 14129a36..d823d37f 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p256_table.h +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/p256_table.h @@ -50,7 +50,7 @@ // Tables for other points have table[i] = iG for i in 0 .. 16. // fiat_p256_g_pre_comp is the table of precomputed base points -#if defined(BORINGSSL_NISTP256_64BIT) +#if defined(OPENSSL_64_BIT) static const fiat_p256_felem fiat_p256_g_pre_comp[2][15][2] = { {{{0x79e730d418a9143c, 0x75ba95fc5fedb601, 0x79fb732b77622510, 0x18905f76a53755c6}, diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/scalar.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/scalar.c index 91440fc4..0850c077 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/scalar.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/scalar.c @@ -23,8 +23,8 @@ int ec_bignum_to_scalar(const EC_GROUP *group, EC_SCALAR *out, const BIGNUM *in) { - if (!bn_copy_words(out->words, group->order.width, in) || - !bn_less_than_words(out->words, group->order.d, group->order.width)) { + if (!bn_copy_words(out->words, group->order.N.width, in) || + !bn_less_than_words(out->words, group->order.N.d, group->order.N.width)) { OPENSSL_PUT_ERROR(EC, EC_R_INVALID_SCALAR); return 0; } @@ -34,12 +34,12 @@ int ec_bignum_to_scalar(const EC_GROUP *group, EC_SCALAR *out, int ec_scalar_equal_vartime(const EC_GROUP *group, const EC_SCALAR *a, const EC_SCALAR *b) { return OPENSSL_memcmp(a->words, b->words, - group->order.width * sizeof(BN_ULONG)) == 0; + group->order.N.width * sizeof(BN_ULONG)) == 0; } int ec_scalar_is_zero(const EC_GROUP *group, const EC_SCALAR *a) { BN_ULONG mask = 0; - for (int i = 0; i < group->order.width; i++) { + for (int i = 0; i < group->order.N.width; i++) { mask |= a->words[i]; } return mask == 0; @@ -47,27 +47,27 @@ int ec_scalar_is_zero(const EC_GROUP *group, const EC_SCALAR *a) { int ec_random_nonzero_scalar(const EC_GROUP *group, EC_SCALAR *out, const uint8_t additional_data[32]) { - return bn_rand_range_words(out->words, 1, group->order.d, group->order.width, - additional_data); + return bn_rand_range_words(out->words, 1, group->order.N.d, + group->order.N.width, additional_data); } void ec_scalar_to_bytes(const EC_GROUP *group, uint8_t *out, size_t *out_len, const EC_SCALAR *in) { - size_t len = BN_num_bytes(&group->order); - bn_words_to_big_endian(out, len, in->words, group->order.width); + size_t len = BN_num_bytes(&group->order.N); + bn_words_to_big_endian(out, len, in->words, group->order.N.width); *out_len = len; } int ec_scalar_from_bytes(const EC_GROUP *group, EC_SCALAR *out, const uint8_t *in, size_t len) { - if (len != BN_num_bytes(&group->order)) { + if (len != BN_num_bytes(&group->order.N)) { OPENSSL_PUT_ERROR(EC, EC_R_INVALID_SCALAR); return 0; } - bn_big_endian_to_words(out->words, group->order.width, in, len); + bn_big_endian_to_words(out->words, group->order.N.width, in, len); - if (!bn_less_than_words(out->words, group->order.d, group->order.width)) { + if (!bn_less_than_words(out->words, group->order.N.d, group->order.N.width)) { OPENSSL_PUT_ERROR(EC, EC_R_INVALID_SCALAR); return 0; } @@ -78,15 +78,15 @@ int ec_scalar_from_bytes(const EC_GROUP *group, EC_SCALAR *out, void ec_scalar_reduce(const EC_GROUP *group, EC_SCALAR *out, const BN_ULONG *words, size_t num) { // Convert "from" Montgomery form so the value is reduced modulo the order. - bn_from_montgomery_small(out->words, group->order.width, words, num, - group->order_mont); + bn_from_montgomery_small(out->words, group->order.N.width, words, num, + &group->order); // Convert "to" Montgomery form to remove the R^-1 factor added. ec_scalar_to_montgomery(group, out, out); } void ec_scalar_add(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a, const EC_SCALAR *b) { - const BIGNUM *order = &group->order; + const BIGNUM *order = &group->order.N; BN_ULONG tmp[EC_MAX_WORDS]; bn_mod_add_words(r->words, a->words, b->words, order->d, tmp, order->width); OPENSSL_cleanse(tmp, sizeof(tmp)); @@ -94,7 +94,7 @@ void ec_scalar_add(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a, void ec_scalar_sub(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a, const EC_SCALAR *b) { - const BIGNUM *order = &group->order; + const BIGNUM *order = &group->order.N; BN_ULONG tmp[EC_MAX_WORDS]; bn_mod_sub_words(r->words, a->words, b->words, order->d, tmp, order->width); OPENSSL_cleanse(tmp, sizeof(tmp)); @@ -108,35 +108,35 @@ void ec_scalar_neg(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a) { void ec_scalar_select(const EC_GROUP *group, EC_SCALAR *out, BN_ULONG mask, const EC_SCALAR *a, const EC_SCALAR *b) { - const BIGNUM *order = &group->order; + const BIGNUM *order = &group->order.N; bn_select_words(out->words, mask, a->words, b->words, order->width); } void ec_scalar_to_montgomery(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a) { - const BIGNUM *order = &group->order; - bn_to_montgomery_small(r->words, a->words, order->width, group->order_mont); + const BIGNUM *order = &group->order.N; + bn_to_montgomery_small(r->words, a->words, order->width, &group->order); } void ec_scalar_from_montgomery(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a) { - const BIGNUM *order = &group->order; + const BIGNUM *order = &group->order.N; bn_from_montgomery_small(r->words, order->width, a->words, order->width, - group->order_mont); + &group->order); } void ec_scalar_mul_montgomery(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a, const EC_SCALAR *b) { - const BIGNUM *order = &group->order; + const BIGNUM *order = &group->order.N; bn_mod_mul_montgomery_small(r->words, a->words, b->words, order->width, - group->order_mont); + &group->order); } void ec_simple_scalar_inv0_montgomery(const EC_GROUP *group, EC_SCALAR *r, const EC_SCALAR *a) { - const BIGNUM *order = &group->order; + const BIGNUM *order = &group->order.N; bn_mod_inverse0_prime_mont_small(r->words, a->words, order->width, - group->order_mont); + &group->order); } int ec_simple_scalar_to_montgomery_inv_vartime(const EC_GROUP *group, diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/simple.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/simple.c index 42235a39..d994988f 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/simple.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/simple.c @@ -88,16 +88,6 @@ // used, it is a Montgomery representation (i.e. 'encoding' means multiplying // by some factor R). -int ec_GFp_simple_group_init(EC_GROUP *group) { - BN_init(&group->field); - group->a_is_minus3 = 0; - return 1; -} - -void ec_GFp_simple_group_finish(EC_GROUP *group) { - BN_free(&group->field); -} - int ec_GFp_simple_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { @@ -114,17 +104,11 @@ int ec_GFp_simple_group_set_curve(EC_GROUP *group, const BIGNUM *p, goto err; } - // group->field - if (!BN_copy(&group->field, p)) { - goto err; - } - BN_set_negative(&group->field, 0); - // Store the field in minimal form, so it can be used with |BN_ULONG| arrays. - bn_set_minimal_width(&group->field); - - if (!ec_bignum_to_felem(group, &group->a, a) || + if (!BN_MONT_CTX_set(&group->field, p, ctx) || + !ec_bignum_to_felem(group, &group->a, a) || !ec_bignum_to_felem(group, &group->b, b) || - !ec_bignum_to_felem(group, &group->one, BN_value_one())) { + // Reuse Z from the generator to cache the value one. + !ec_bignum_to_felem(group, &group->generator.raw.Z, BN_value_one())) { goto err; } @@ -133,7 +117,7 @@ int ec_GFp_simple_group_set_curve(EC_GROUP *group, const BIGNUM *p, !BN_add_word(tmp, 3)) { goto err; } - group->a_is_minus3 = (0 == BN_cmp(tmp, &group->field)); + group->a_is_minus3 = (0 == BN_cmp(tmp, &group->field.N)); ret = 1; @@ -144,7 +128,7 @@ err: int ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b) { - if ((p != NULL && !BN_copy(p, &group->field)) || + if ((p != NULL && !BN_copy(p, &group->field.N)) || (a != NULL && !ec_felem_to_bignum(group, a, &group->a)) || (b != NULL && !ec_felem_to_bignum(group, b, &group->b))) { return 0; @@ -152,36 +136,36 @@ int ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, return 1; } -void ec_GFp_simple_point_init(EC_RAW_POINT *point) { +void ec_GFp_simple_point_init(EC_JACOBIAN *point) { OPENSSL_memset(&point->X, 0, sizeof(EC_FELEM)); OPENSSL_memset(&point->Y, 0, sizeof(EC_FELEM)); OPENSSL_memset(&point->Z, 0, sizeof(EC_FELEM)); } -void ec_GFp_simple_point_copy(EC_RAW_POINT *dest, const EC_RAW_POINT *src) { +void ec_GFp_simple_point_copy(EC_JACOBIAN *dest, const EC_JACOBIAN *src) { OPENSSL_memcpy(&dest->X, &src->X, sizeof(EC_FELEM)); OPENSSL_memcpy(&dest->Y, &src->Y, sizeof(EC_FELEM)); OPENSSL_memcpy(&dest->Z, &src->Z, sizeof(EC_FELEM)); } void ec_GFp_simple_point_set_to_infinity(const EC_GROUP *group, - EC_RAW_POINT *point) { + EC_JACOBIAN *point) { // Although it is strictly only necessary to zero Z, we zero the entire point // in case |point| was stack-allocated and yet to be initialized. ec_GFp_simple_point_init(point); } -void ec_GFp_simple_invert(const EC_GROUP *group, EC_RAW_POINT *point) { +void ec_GFp_simple_invert(const EC_GROUP *group, EC_JACOBIAN *point) { ec_felem_neg(group, &point->Y, &point->Y); } int ec_GFp_simple_is_at_infinity(const EC_GROUP *group, - const EC_RAW_POINT *point) { + const EC_JACOBIAN *point) { return ec_felem_non_zero_mask(group, &point->Z) == 0; } int ec_GFp_simple_is_on_curve(const EC_GROUP *group, - const EC_RAW_POINT *point) { + const EC_JACOBIAN *point) { // We have a curve defined by a Weierstrass equation // y^2 = x^3 + a*x + b. // The point to consider is given in Jacobian projective coordinates @@ -237,8 +221,8 @@ int ec_GFp_simple_is_on_curve(const EC_GROUP *group, return 1 & ~(not_infinity & not_equal); } -int ec_GFp_simple_points_equal(const EC_GROUP *group, const EC_RAW_POINT *a, - const EC_RAW_POINT *b) { +int ec_GFp_simple_points_equal(const EC_GROUP *group, const EC_JACOBIAN *a, + const EC_JACOBIAN *b) { // This function is implemented in constant-time for two reasons. First, // although EC points are usually public, their Jacobian Z coordinates may be // secret, or at least are not obviously public. Second, more complex @@ -285,7 +269,7 @@ int ec_GFp_simple_points_equal(const EC_GROUP *group, const EC_RAW_POINT *a, } int ec_affine_jacobian_equal(const EC_GROUP *group, const EC_AFFINE *a, - const EC_RAW_POINT *b) { + const EC_JACOBIAN *b) { // If |b| is not infinity, we have to decide whether // (X_a, Y_a) = (X_b/Z_b^2, Y_b/Z_b^3), // or equivalently, whether @@ -314,7 +298,7 @@ int ec_affine_jacobian_equal(const EC_GROUP *group, const EC_AFFINE *a, return equal & 1; } -int ec_GFp_simple_cmp_x_coordinate(const EC_GROUP *group, const EC_RAW_POINT *p, +int ec_GFp_simple_cmp_x_coordinate(const EC_GROUP *group, const EC_JACOBIAN *p, const EC_SCALAR *r) { if (ec_GFp_simple_is_at_infinity(group, p)) { // |ec_get_x_coordinate_as_scalar| will check this internally, but this way @@ -329,21 +313,21 @@ int ec_GFp_simple_cmp_x_coordinate(const EC_GROUP *group, const EC_RAW_POINT *p, void ec_GFp_simple_felem_to_bytes(const EC_GROUP *group, uint8_t *out, size_t *out_len, const EC_FELEM *in) { - size_t len = BN_num_bytes(&group->field); - bn_words_to_big_endian(out, len, in->words, group->field.width); + size_t len = BN_num_bytes(&group->field.N); + bn_words_to_big_endian(out, len, in->words, group->field.N.width); *out_len = len; } int ec_GFp_simple_felem_from_bytes(const EC_GROUP *group, EC_FELEM *out, const uint8_t *in, size_t len) { - if (len != BN_num_bytes(&group->field)) { + if (len != BN_num_bytes(&group->field.N)) { OPENSSL_PUT_ERROR(EC, EC_R_DECODE_ERROR); return 0; } - bn_big_endian_to_words(out->words, group->field.width, in, len); + bn_big_endian_to_words(out->words, group->field.N.width, in, len); - if (!bn_less_than_words(out->words, group->field.d, group->field.width)) { + if (!bn_less_than_words(out->words, group->field.N.d, group->field.N.width)) { OPENSSL_PUT_ERROR(EC, EC_R_DECODE_ERROR); return 0; } diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/simple_mul.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/simple_mul.c index fbda1be2..fbe53d33 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/simple_mul.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/simple_mul.c @@ -21,14 +21,14 @@ #include "../../internal.h" -void ec_GFp_mont_mul(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *p, const EC_SCALAR *scalar) { +void ec_GFp_mont_mul(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *p, const EC_SCALAR *scalar) { // This is a generic implementation for uncommon curves that not do not // warrant a tuned one. It uses unsigned digits so that the doubling case in // |ec_GFp_mont_add| is always unreachable, erring on safety and simplicity. // Compute a table of the first 32 multiples of |p| (including infinity). - EC_RAW_POINT precomp[32]; + EC_JACOBIAN precomp[32]; ec_GFp_simple_point_set_to_infinity(group, &precomp[0]); ec_GFp_simple_point_copy(&precomp[1], p); for (size_t j = 2; j < OPENSSL_ARRAY_SIZE(precomp); j++) { @@ -40,7 +40,7 @@ void ec_GFp_mont_mul(const EC_GROUP *group, EC_RAW_POINT *r, } // Divide bits in |scalar| into windows. - unsigned bits = BN_num_bits(&group->order); + unsigned bits = EC_GROUP_order_bits(group); int r_is_at_infinity = 1; for (unsigned i = bits - 1; i < bits; i--) { if (!r_is_at_infinity) { @@ -48,7 +48,7 @@ void ec_GFp_mont_mul(const EC_GROUP *group, EC_RAW_POINT *r, } if (i % 5 == 0) { // Compute the next window value. - const size_t width = group->order.width; + const size_t width = group->order.N.width; uint8_t window = bn_is_bit_set_words(scalar->words, width, i + 4) << 4; window |= bn_is_bit_set_words(scalar->words, width, i + 3) << 3; window |= bn_is_bit_set_words(scalar->words, width, i + 2) << 2; @@ -56,8 +56,8 @@ void ec_GFp_mont_mul(const EC_GROUP *group, EC_RAW_POINT *r, window |= bn_is_bit_set_words(scalar->words, width, i); // Select the entry in constant-time. - EC_RAW_POINT tmp; - OPENSSL_memset(&tmp, 0, sizeof(EC_RAW_POINT)); + EC_JACOBIAN tmp; + OPENSSL_memset(&tmp, 0, sizeof(EC_JACOBIAN)); for (size_t j = 0; j < OPENSSL_ARRAY_SIZE(precomp); j++) { BN_ULONG mask = constant_time_eq_w(j, window); ec_point_select(group, &tmp, mask, &precomp[j], &tmp); @@ -76,13 +76,13 @@ void ec_GFp_mont_mul(const EC_GROUP *group, EC_RAW_POINT *r, } } -void ec_GFp_mont_mul_base(const EC_GROUP *group, EC_RAW_POINT *r, +void ec_GFp_mont_mul_base(const EC_GROUP *group, EC_JACOBIAN *r, const EC_SCALAR *scalar) { - ec_GFp_mont_mul(group, r, &group->generator->raw, scalar); + ec_GFp_mont_mul(group, r, &group->generator.raw, scalar); } -static void ec_GFp_mont_batch_precomp(const EC_GROUP *group, EC_RAW_POINT *out, - size_t num, const EC_RAW_POINT *p) { +static void ec_GFp_mont_batch_precomp(const EC_GROUP *group, EC_JACOBIAN *out, + size_t num, const EC_JACOBIAN *p) { assert(num > 1); ec_GFp_simple_point_set_to_infinity(group, &out[0]); ec_GFp_simple_point_copy(&out[1], p); @@ -96,10 +96,10 @@ static void ec_GFp_mont_batch_precomp(const EC_GROUP *group, EC_RAW_POINT *out, } static void ec_GFp_mont_batch_get_window(const EC_GROUP *group, - EC_RAW_POINT *out, - const EC_RAW_POINT precomp[17], + EC_JACOBIAN *out, + const EC_JACOBIAN precomp[17], const EC_SCALAR *scalar, unsigned i) { - const size_t width = group->order.width; + const size_t width = group->order.N.width; uint8_t window = bn_is_bit_set_words(scalar->words, width, i + 4) << 5; window |= bn_is_bit_set_words(scalar->words, width, i + 3) << 4; window |= bn_is_bit_set_words(scalar->words, width, i + 2) << 3; @@ -112,7 +112,7 @@ static void ec_GFp_mont_batch_get_window(const EC_GROUP *group, ec_GFp_nistp_recode_scalar_bits(&sign, &digit, window); // Select the entry in constant-time. - OPENSSL_memset(out, 0, sizeof(EC_RAW_POINT)); + OPENSSL_memset(out, 0, sizeof(EC_JACOBIAN)); for (size_t j = 0; j < 17; j++) { BN_ULONG mask = constant_time_eq_w(j, digit); ec_point_select(group, out, mask, &precomp[j], out); @@ -126,11 +126,11 @@ static void ec_GFp_mont_batch_get_window(const EC_GROUP *group, ec_felem_select(group, &out->Y, sign_mask, &neg_Y, &out->Y); } -void ec_GFp_mont_mul_batch(const EC_GROUP *group, EC_RAW_POINT *r, - const EC_RAW_POINT *p0, const EC_SCALAR *scalar0, - const EC_RAW_POINT *p1, const EC_SCALAR *scalar1, - const EC_RAW_POINT *p2, const EC_SCALAR *scalar2) { - EC_RAW_POINT precomp[3][17]; +void ec_GFp_mont_mul_batch(const EC_GROUP *group, EC_JACOBIAN *r, + const EC_JACOBIAN *p0, const EC_SCALAR *scalar0, + const EC_JACOBIAN *p1, const EC_SCALAR *scalar1, + const EC_JACOBIAN *p2, const EC_SCALAR *scalar2) { + EC_JACOBIAN precomp[3][17]; ec_GFp_mont_batch_precomp(group, precomp[0], 17, p0); ec_GFp_mont_batch_precomp(group, precomp[1], 17, p1); if (p2 != NULL) { @@ -138,14 +138,14 @@ void ec_GFp_mont_mul_batch(const EC_GROUP *group, EC_RAW_POINT *r, } // Divide bits in |scalar| into windows. - unsigned bits = BN_num_bits(&group->order); + unsigned bits = EC_GROUP_order_bits(group); int r_is_at_infinity = 1; for (unsigned i = bits; i <= bits; i--) { if (!r_is_at_infinity) { ec_GFp_mont_dbl(group, r, r); } if (i % 5 == 0) { - EC_RAW_POINT tmp; + EC_JACOBIAN tmp; ec_GFp_mont_batch_get_window(group, &tmp, precomp[0], scalar0, i); if (r_is_at_infinity) { ec_GFp_simple_point_copy(r, &tmp); @@ -169,18 +169,18 @@ void ec_GFp_mont_mul_batch(const EC_GROUP *group, EC_RAW_POINT *r, } static unsigned ec_GFp_mont_comb_stride(const EC_GROUP *group) { - return (BN_num_bits(&group->field) + EC_MONT_PRECOMP_COMB_SIZE - 1) / + return (EC_GROUP_get_degree(group) + EC_MONT_PRECOMP_COMB_SIZE - 1) / EC_MONT_PRECOMP_COMB_SIZE; } int ec_GFp_mont_init_precomp(const EC_GROUP *group, EC_PRECOMP *out, - const EC_RAW_POINT *p) { + const EC_JACOBIAN *p) { // comb[i - 1] stores the ith element of the comb. That is, if i is // b4 * 2^4 + b3 * 2^3 + ... + b0 * 2^0, it stores k * |p|, where k is // b4 * 2^(4*stride) + b3 * 2^(3*stride) + ... + b0 * 2^(0*stride). stride // here is |ec_GFp_mont_comb_stride|. We store at index i - 1 because the 0th // comb entry is always infinity. - EC_RAW_POINT comb[(1 << EC_MONT_PRECOMP_COMB_SIZE) - 1]; + EC_JACOBIAN comb[(1 << EC_MONT_PRECOMP_COMB_SIZE) - 1]; unsigned stride = ec_GFp_mont_comb_stride(group); // We compute the comb sequentially by the highest set bit. Initially, all @@ -209,10 +209,10 @@ int ec_GFp_mont_init_precomp(const EC_GROUP *group, EC_PRECOMP *out, } static void ec_GFp_mont_get_comb_window(const EC_GROUP *group, - EC_RAW_POINT *out, + EC_JACOBIAN *out, const EC_PRECOMP *precomp, const EC_SCALAR *scalar, unsigned i) { - const size_t width = group->order.width; + const size_t width = group->order.N.width; unsigned stride = ec_GFp_mont_comb_stride(group); // Select the bits corresponding to the comb shifted up by |i|. unsigned window = 0; @@ -223,17 +223,17 @@ static void ec_GFp_mont_get_comb_window(const EC_GROUP *group, // Select precomp->comb[window - 1]. If |window| is zero, |match| will always // be zero, which will leave |out| at infinity. - OPENSSL_memset(out, 0, sizeof(EC_RAW_POINT)); + OPENSSL_memset(out, 0, sizeof(EC_JACOBIAN)); for (unsigned j = 0; j < OPENSSL_ARRAY_SIZE(precomp->comb); j++) { BN_ULONG match = constant_time_eq_w(window, j + 1); ec_felem_select(group, &out->X, match, &precomp->comb[j].X, &out->X); ec_felem_select(group, &out->Y, match, &precomp->comb[j].Y, &out->Y); } BN_ULONG is_infinity = constant_time_is_zero_w(window); - ec_felem_select(group, &out->Z, is_infinity, &out->Z, &group->one); + ec_felem_select(group, &out->Z, is_infinity, &out->Z, ec_felem_one(group)); } -void ec_GFp_mont_mul_precomp(const EC_GROUP *group, EC_RAW_POINT *r, +void ec_GFp_mont_mul_precomp(const EC_GROUP *group, EC_JACOBIAN *r, const EC_PRECOMP *p0, const EC_SCALAR *scalar0, const EC_PRECOMP *p1, const EC_SCALAR *scalar1, const EC_PRECOMP *p2, const EC_SCALAR *scalar2) { @@ -244,7 +244,7 @@ void ec_GFp_mont_mul_precomp(const EC_GROUP *group, EC_RAW_POINT *r, ec_GFp_mont_dbl(group, r, r); } - EC_RAW_POINT tmp; + EC_JACOBIAN tmp; ec_GFp_mont_get_comb_window(group, &tmp, p0, scalar0, i); if (r_is_at_infinity) { ec_GFp_simple_point_copy(r, &tmp); diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/wnaf.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/wnaf.c index 8faa244f..6f84e665 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/wnaf.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ec/wnaf.c @@ -138,8 +138,8 @@ void ec_compute_wNAF(const EC_GROUP *group, int8_t *out, // we shift and add at most one copy of |bit|, this will continue to hold // afterwards. window_val >>= 1; - window_val += - bit * bn_is_bit_set_words(scalar->words, group->order.width, j + w + 1); + window_val += bit * bn_is_bit_set_words(scalar->words, group->order.N.width, + j + w + 1); assert(window_val <= next_bit); } @@ -148,18 +148,18 @@ void ec_compute_wNAF(const EC_GROUP *group, int8_t *out, } // compute_precomp sets |out[i]| to (2*i+1)*p, for i from 0 to |len|. -static void compute_precomp(const EC_GROUP *group, EC_RAW_POINT *out, - const EC_RAW_POINT *p, size_t len) { +static void compute_precomp(const EC_GROUP *group, EC_JACOBIAN *out, + const EC_JACOBIAN *p, size_t len) { ec_GFp_simple_point_copy(&out[0], p); - EC_RAW_POINT two_p; + EC_JACOBIAN two_p; ec_GFp_mont_dbl(group, &two_p, p); for (size_t i = 1; i < len; i++) { ec_GFp_mont_add(group, &out[i], &out[i - 1], &two_p); } } -static void lookup_precomp(const EC_GROUP *group, EC_RAW_POINT *out, - const EC_RAW_POINT *precomp, int digit) { +static void lookup_precomp(const EC_GROUP *group, EC_JACOBIAN *out, + const EC_JACOBIAN *precomp, int digit) { if (digit < 0) { digit = -digit; ec_GFp_simple_point_copy(out, &precomp[digit >> 1]); @@ -179,20 +179,20 @@ static void lookup_precomp(const EC_GROUP *group, EC_RAW_POINT *out, // avoid a malloc. #define EC_WNAF_STACK 3 -int ec_GFp_mont_mul_public_batch(const EC_GROUP *group, EC_RAW_POINT *r, +int ec_GFp_mont_mul_public_batch(const EC_GROUP *group, EC_JACOBIAN *r, const EC_SCALAR *g_scalar, - const EC_RAW_POINT *points, + const EC_JACOBIAN *points, const EC_SCALAR *scalars, size_t num) { - size_t bits = BN_num_bits(&group->order); + size_t bits = EC_GROUP_order_bits(group); size_t wNAF_len = bits + 1; int ret = 0; int8_t wNAF_stack[EC_WNAF_STACK][EC_MAX_BYTES * 8 + 1]; int8_t (*wNAF_alloc)[EC_MAX_BYTES * 8 + 1] = NULL; int8_t (*wNAF)[EC_MAX_BYTES * 8 + 1]; - EC_RAW_POINT precomp_stack[EC_WNAF_STACK][EC_WNAF_TABLE_SIZE]; - EC_RAW_POINT (*precomp_alloc)[EC_WNAF_TABLE_SIZE] = NULL; - EC_RAW_POINT (*precomp)[EC_WNAF_TABLE_SIZE]; + EC_JACOBIAN precomp_stack[EC_WNAF_STACK][EC_WNAF_TABLE_SIZE]; + EC_JACOBIAN (*precomp_alloc)[EC_WNAF_TABLE_SIZE] = NULL; + EC_JACOBIAN (*precomp)[EC_WNAF_TABLE_SIZE]; if (num <= EC_WNAF_STACK) { wNAF = wNAF_stack; precomp = precomp_stack; @@ -212,9 +212,9 @@ int ec_GFp_mont_mul_public_batch(const EC_GROUP *group, EC_RAW_POINT *r, } int8_t g_wNAF[EC_MAX_BYTES * 8 + 1]; - EC_RAW_POINT g_precomp[EC_WNAF_TABLE_SIZE]; + EC_JACOBIAN g_precomp[EC_WNAF_TABLE_SIZE]; assert(wNAF_len <= OPENSSL_ARRAY_SIZE(g_wNAF)); - const EC_RAW_POINT *g = &group->generator->raw; + const EC_JACOBIAN *g = &group->generator.raw; if (g_scalar != NULL) { ec_compute_wNAF(group, g_wNAF, g_scalar, bits, EC_WNAF_WINDOW_BITS); compute_precomp(group, g_precomp, g, EC_WNAF_TABLE_SIZE); @@ -226,7 +226,7 @@ int ec_GFp_mont_mul_public_batch(const EC_GROUP *group, EC_RAW_POINT *r, compute_precomp(group, precomp[i], &points[i], EC_WNAF_TABLE_SIZE); } - EC_RAW_POINT tmp; + EC_JACOBIAN tmp; int r_is_at_infinity = 1; for (size_t k = wNAF_len - 1; k < wNAF_len; k--) { if (!r_is_at_infinity) { diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ecdh/ecdh.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ecdh/ecdh.c index a7ae6010..323aebef 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ecdh/ecdh.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ecdh/ecdh.c @@ -94,7 +94,7 @@ int ECDH_compute_key_fips(uint8_t *out, size_t out_len, const EC_POINT *pub_key, return 0; } - EC_RAW_POINT shared_point; + EC_JACOBIAN shared_point; uint8_t buf[EC_MAX_BYTES]; size_t buflen; if (!ec_point_mul_scalar(group, &shared_point, &pub_key->raw, priv) || diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ecdsa/ecdsa.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ecdsa/ecdsa.c index 6b07e902..053235bc 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ecdsa/ecdsa.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ecdsa/ecdsa.c @@ -71,7 +71,7 @@ // ECDSA. static void digest_to_scalar(const EC_GROUP *group, EC_SCALAR *out, const uint8_t *digest, size_t digest_len) { - const BIGNUM *order = &group->order; + const BIGNUM *order = EC_GROUP_get0_order(group); size_t num_bits = BN_num_bits(order); // Need to truncate digest if it is too long: first truncate whole bytes. size_t num_bytes = (num_bits + 7) / 8; @@ -181,7 +181,7 @@ int ecdsa_do_verify_no_self_test(const uint8_t *digest, size_t digest_len, ec_scalar_mul_montgomery(group, &u1, &m, &s_inv_mont); ec_scalar_mul_montgomery(group, &u2, &r, &s_inv_mont); - EC_RAW_POINT point; + EC_JACOBIAN point; if (!ec_point_mul_scalar_public(group, &point, &u1, &pub_key->raw, &u2)) { OPENSSL_PUT_ERROR(ECDSA, ERR_R_EC_LIB); return 0; @@ -216,14 +216,14 @@ static ECDSA_SIG *ecdsa_sign_impl(const EC_GROUP *group, int *out_retry, } // Compute r, the x-coordinate of k * generator. - EC_RAW_POINT tmp_point; + EC_JACOBIAN tmp_point; EC_SCALAR r; if (!ec_point_mul_scalar_base(group, &tmp_point, k) || !ec_get_x_coordinate_as_scalar(group, &r, &tmp_point)) { return NULL; } - if (ec_scalar_is_zero(group, &r)) { + if (constant_time_declassify_int(ec_scalar_is_zero(group, &r))) { *out_retry = 1; return NULL; } @@ -250,11 +250,13 @@ static ECDSA_SIG *ecdsa_sign_impl(const EC_GROUP *group, int *out_retry, ec_scalar_inv0_montgomery(group, &tmp, k); // tmp = k^-1 R^2 ec_scalar_from_montgomery(group, &tmp, &tmp); // tmp = k^-1 R ec_scalar_mul_montgomery(group, &s, &s, &tmp); - if (ec_scalar_is_zero(group, &s)) { + if (constant_time_declassify_int(ec_scalar_is_zero(group, &s))) { *out_retry = 1; return NULL; } + CONSTTIME_DECLASSIFY(r.words, sizeof(r.words)); + CONSTTIME_DECLASSIFY(s.words, sizeof(r.words)); ECDSA_SIG *ret = ECDSA_SIG_new(); if (ret == NULL || // !bn_set_words(ret->r, r.words, order->width) || @@ -347,6 +349,10 @@ ECDSA_SIG *ECDSA_do_sign(const uint8_t *digest, size_t digest_len, goto out; } + // TODO(davidben): Move this inside |ec_random_nonzero_scalar| or lower, so + // that all scalars we generate are, by default, secret. + CONSTTIME_SECRET(k.words, sizeof(k.words)); + int retry; ret = ecdsa_sign_impl(group, &retry, priv_key, &k, digest, digest_len); if (ret != NULL || !retry) { diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-armv4-ios.ios.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-armv4-ios.ios.arm.S index e537b2ef..d6ddf144 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-armv4-ios.ios.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-armv4-ios.ios.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__APPLE__) #include @ Silence ARMv8 deprecated IT instruction warnings. This file is used by both @@ -257,11 +249,7 @@ Lgmult_neon: .byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,52,47,78,69,79,78,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 2 .align 2 -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__APPLE__) #endif // defined(__arm__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-armv4-linux.linux.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-armv4-linux.linux.arm.S index ae95a0e4..33cb9b7c 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-armv4-linux.linux.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-armv4-linux.linux.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) #include @ Silence ARMv8 deprecated IT instruction warnings. This file is used by both @@ -251,11 +243,7 @@ gcm_ghash_neon: .byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,52,47,78,69,79,78,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 2 .align 2 -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-neon-armv8-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-neon-armv8-ios.ios.aarch64.S index 3ec99c72..a1fa2e04 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-neon-armv8-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-neon-armv8-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) #include .text @@ -342,11 +334,7 @@ Lmasks: .byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,56,44,32,100,101,114,105,118,101,100,32,102,114,111,109,32,65,82,77,118,52,32,118,101,114,115,105,111,110,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 2 .align 2 -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-neon-armv8-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-neon-armv8-linux.linux.aarch64.S index 56da9b5b..fd4185bd 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-neon-armv8-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-neon-armv8-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) #include .text @@ -342,11 +334,7 @@ gcm_ghash_neon: .byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,56,44,32,100,101,114,105,118,101,100,32,102,114,111,109,32,65,82,77,118,52,32,118,101,114,115,105,111,110,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 2 .align 2 -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-ssse3-x86-linux.linux.x86.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-ssse3-x86-linux.linux.x86.S index 5afe890c..cfa55517 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-ssse3-x86-linux.linux.x86.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-ssse3-x86-linux.linux.x86.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) .text .globl gcm_gmult_ssse3 .hidden gcm_gmult_ssse3 @@ -298,11 +291,7 @@ gcm_ghash_ssse3: .align 16 .Llow4_mask: .long 252645135,252645135,252645135,252645135 -#endif // !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-ssse3-x86_64-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-ssse3-x86_64-linux.linux.x86_64.S index c6769ad3..62f6083d 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-ssse3-x86_64-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-ssse3-x86_64-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text @@ -26,6 +19,7 @@ gcm_gmult_ssse3: .cfi_startproc +_CET_ENDBR movdqu (%rdi),%xmm0 movdqa .Lreverse_bytes(%rip),%xmm10 movdqa .Llow4_mask(%rip),%xmm2 @@ -216,6 +210,7 @@ gcm_gmult_ssse3: gcm_ghash_ssse3: .cfi_startproc +_CET_ENDBR movdqu (%rdi),%xmm0 movdqa .Lreverse_bytes(%rip),%xmm10 movdqa .Llow4_mask(%rip),%xmm11 @@ -428,10 +423,6 @@ gcm_ghash_ssse3: .quad 0x0f0f0f0f0f0f0f0f, 0x0f0f0f0f0f0f0f0f .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-ssse3-x86_64-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-ssse3-x86_64-mac.mac.x86_64.S index bdae83ef..36ae42cc 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-ssse3-x86_64-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-ssse3-x86_64-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text @@ -26,6 +19,7 @@ _gcm_gmult_ssse3: +_CET_ENDBR movdqu (%rdi),%xmm0 movdqa L$reverse_bytes(%rip),%xmm10 movdqa L$low4_mask(%rip),%xmm2 @@ -216,6 +210,7 @@ L$oop_row_3: _gcm_ghash_ssse3: +_CET_ENDBR movdqu (%rdi),%xmm0 movdqa L$reverse_bytes(%rip),%xmm10 movdqa L$low4_mask(%rip),%xmm11 @@ -428,10 +423,6 @@ L$low4_mask: .quad 0x0f0f0f0f0f0f0f0f, 0x0f0f0f0f0f0f0f0f .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-x86-linux.linux.x86.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-x86-linux.linux.x86.S index 98b2c2f8..1acf76aa 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-x86-linux.linux.x86.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-x86-linux.linux.x86.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) .text .globl gcm_init_clmul .hidden gcm_init_clmul @@ -334,11 +327,7 @@ gcm_ghash_clmul: .byte 82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112 .byte 112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62 .byte 0 -#endif // !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-x86_64-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-x86_64-linux.linux.x86_64.S index ac97974c..a8baaf87 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-x86_64-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-x86_64-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .extern OPENSSL_ia32cap_P .hidden OPENSSL_ia32cap_P @@ -23,6 +16,7 @@ gcm_init_clmul: .cfi_startproc +_CET_ENDBR .L_init_clmul: movdqu (%rsi),%xmm2 pshufd $78,%xmm2,%xmm2 @@ -183,6 +177,7 @@ gcm_init_clmul: .align 16 gcm_gmult_clmul: .cfi_startproc +_CET_ENDBR .L_gmult_clmul: movdqu (%rdi),%xmm0 movdqa .Lbswap_mask(%rip),%xmm5 @@ -238,6 +233,7 @@ gcm_gmult_clmul: gcm_ghash_clmul: .cfi_startproc +_CET_ENDBR .L_ghash_clmul: movdqa .Lbswap_mask(%rip),%xmm10 @@ -626,6 +622,7 @@ gcm_ghash_clmul: .align 32 gcm_init_avx: .cfi_startproc +_CET_ENDBR vzeroupper vmovdqu (%rsi),%xmm2 @@ -737,6 +734,7 @@ gcm_init_avx: .align 32 gcm_gmult_avx: .cfi_startproc +_CET_ENDBR jmp .L_gmult_clmul .cfi_endproc .size gcm_gmult_avx,.-gcm_gmult_avx @@ -746,6 +744,7 @@ gcm_gmult_avx: .align 32 gcm_ghash_avx: .cfi_startproc +_CET_ENDBR vzeroupper vmovdqu (%rdi),%xmm10 @@ -1134,10 +1133,6 @@ gcm_ghash_avx: .align 64 .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-x86_64-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-x86_64-mac.mac.x86_64.S index 618185ca..21900ff6 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-x86_64-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghash-x86_64-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text .globl _gcm_init_clmul @@ -22,6 +15,7 @@ _gcm_init_clmul: +_CET_ENDBR L$_init_clmul: movdqu (%rsi),%xmm2 pshufd $78,%xmm2,%xmm2 @@ -182,6 +176,7 @@ L$_init_clmul: .p2align 4 _gcm_gmult_clmul: +_CET_ENDBR L$_gmult_clmul: movdqu (%rdi),%xmm0 movdqa L$bswap_mask(%rip),%xmm5 @@ -237,6 +232,7 @@ L$_gmult_clmul: _gcm_ghash_clmul: +_CET_ENDBR L$_ghash_clmul: movdqa L$bswap_mask(%rip),%xmm10 @@ -625,6 +621,7 @@ L$done: .p2align 5 _gcm_init_avx: +_CET_ENDBR vzeroupper vmovdqu (%rsi),%xmm2 @@ -736,6 +733,7 @@ L$init_start_avx: .p2align 5 _gcm_gmult_avx: +_CET_ENDBR jmp L$_gmult_clmul @@ -745,6 +743,7 @@ _gcm_gmult_avx: .p2align 5 _gcm_ghash_avx: +_CET_ENDBR vzeroupper vmovdqu (%rdi),%xmm10 @@ -1133,10 +1132,6 @@ L$7_mask: .p2align 6 .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv7-ios.ios.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv7-ios.ios.arm.S index f19c4595..2c9d309e 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv7-ios.ios.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv7-ios.ios.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__APPLE__) #include #if __ARM_MAX_ARCH__>=7 @@ -259,11 +251,7 @@ Ldone_v8: .align 2 .align 2 #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__APPLE__) #endif // defined(__arm__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv7-linux.linux.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv7-linux.linux.arm.S index b3f087dc..2d9c60b5 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv7-linux.linux.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv7-linux.linux.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) #include #if __ARM_MAX_ARCH__>=7 @@ -253,11 +245,7 @@ gcm_ghash_v8: .align 2 .align 2 #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv8-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv8-ios.ios.aarch64.S index 9d63d77e..0e7c3c4a 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv8-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv8-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) #include #if __ARM_MAX_ARCH__>=7 @@ -572,11 +564,7 @@ Ldone4x: .align 2 .align 2 #endif -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv8-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv8-linux.linux.aarch64.S index ee040544..6f861858 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv8-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/ghashv8-armv8-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) #include #if __ARM_MAX_ARCH__>=7 @@ -572,11 +564,7 @@ gcm_ghash_v8_4x: .align 2 .align 2 #endif -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/hkdf/hkdf.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/hkdf/hkdf.c similarity index 98% rename from Sources/CCryptoBoringSSL/crypto/hkdf/hkdf.c rename to Sources/CCryptoBoringSSL/crypto/fipsmodule/hkdf/hkdf.c index 8989e5e7..5cf017cb 100644 --- a/Sources/CCryptoBoringSSL/crypto/hkdf/hkdf.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/hkdf/hkdf.c @@ -20,7 +20,7 @@ #include #include -#include "../internal.h" +#include "../../internal.h" int HKDF(uint8_t *out_key, size_t out_len, const EVP_MD *digest, @@ -94,7 +94,7 @@ int HKDF_expand(uint8_t *out_key, size_t out_len, const EVP_MD *digest, } todo = digest_len; - if (done + todo > out_len) { + if (todo > out_len - done) { todo = out_len - done; } OPENSSL_memcpy(out_key + done, previous, todo); diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/md5-586-linux.linux.x86.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/md5-586-linux.linux.x86.S index ea9b03dc..6de63f48 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/md5-586-linux.linux.x86.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/md5-586-linux.linux.x86.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) .text .globl md5_block_asm_data_order .hidden md5_block_asm_data_order @@ -692,11 +685,7 @@ md5_block_asm_data_order: popl %esi ret .size md5_block_asm_data_order,.-.L_md5_block_asm_data_order_begin -#endif // !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/md5-x86_64-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/md5-x86_64-linux.linux.x86_64.S index cbd7665b..6b1dd0d2 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/md5-x86_64-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/md5-x86_64-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .align 16 @@ -21,6 +14,7 @@ .type md5_block_asm_data_order,@function md5_block_asm_data_order: .cfi_startproc +_CET_ENDBR pushq %rbp .cfi_adjust_cfa_offset 8 .cfi_offset rbp,-16 @@ -701,10 +695,6 @@ md5_block_asm_data_order: .cfi_endproc .size md5_block_asm_data_order,.-md5_block_asm_data_order #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/md5-x86_64-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/md5-x86_64-mac.mac.x86_64.S index 03ac3331..0f240adb 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/md5-x86_64-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/md5-x86_64-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text .p2align 4 @@ -21,6 +14,7 @@ _md5_block_asm_data_order: +_CET_ENDBR pushq %rbp pushq %rbx @@ -695,10 +689,6 @@ L$epilogue: .byte 0xf3,0xc3 -#endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits #endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/cbc.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/cbc.c index df8f9ce8..511a5de4 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/cbc.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/cbc.c @@ -66,10 +66,7 @@ void CRYPTO_cbc128_encrypt(const uint8_t *in, uint8_t *out, size_t len, size_t n; const uint8_t *iv = ivec; while (len >= 16) { - for (n = 0; n < 16; n += sizeof(crypto_word_t)) { - CRYPTO_store_word_le( - out + n, CRYPTO_load_word_le(in + n) ^ CRYPTO_load_word_le(iv + n)); - } + CRYPTO_xor16(out, in, iv); (*block)(out, out, key); iv = out; len -= 16; @@ -118,15 +115,10 @@ void CRYPTO_cbc128_decrypt(const uint8_t *in, uint8_t *out, size_t len, if ((inptr >= 32 && outptr <= inptr - 32) || inptr < outptr) { // If |out| is at least two blocks behind |in| or completely disjoint, there // is no need to decrypt to a temporary block. - static_assert(16 % sizeof(crypto_word_t) == 0, - "block cannot be evenly divided into words"); const uint8_t *iv = ivec; while (len >= 16) { (*block)(in, out, key); - for (n = 0; n < 16; n += sizeof(crypto_word_t)) { - CRYPTO_store_word_le(out + n, CRYPTO_load_word_le(out + n) ^ - CRYPTO_load_word_le(iv + n)); - } + CRYPTO_xor16(out, out, iv); iv = in; len -= 16; in += 16; diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/ctr.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/ctr.c index 1688f823..8c333bb1 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/ctr.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/ctr.c @@ -101,10 +101,7 @@ void CRYPTO_ctr128_encrypt(const uint8_t *in, uint8_t *out, size_t len, while (len >= 16) { (*block)(ivec, ecount_buf, key); ctr128_inc(ivec); - for (n = 0; n < 16; n += sizeof(crypto_word_t)) { - CRYPTO_store_word_le(out + n, CRYPTO_load_word_le(in + n) ^ - CRYPTO_load_word_le(ecount_buf + n)); - } + CRYPTO_xor16(out, in, ecount_buf); len -= 16; out += 16; in += 16; diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/gcm.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/gcm.c index 4805ad5d..98862544 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/gcm.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/gcm.c @@ -62,9 +62,9 @@ static const size_t kSizeTWithoutLower4Bits = (size_t) -16; -#define GCM_MUL(ctx, Xi) gcm_gmult_nohw((ctx)->Xi.u, (ctx)->gcm_key.Htable) +#define GCM_MUL(ctx, Xi) gcm_gmult_nohw((ctx)->Xi, (ctx)->gcm_key.Htable) #define GHASH(ctx, in, len) \ - gcm_ghash_nohw((ctx)->Xi.u, (ctx)->gcm_key.Htable, in, len) + gcm_ghash_nohw((ctx)->Xi, (ctx)->gcm_key.Htable, in, len) // GHASH_CHUNK is "stride parameter" missioned to mitigate cache // trashing effect. In other words idea is to hash data while it's // still in L1 cache after encryption pass... @@ -126,23 +126,23 @@ void gcm_init_ssse3(u128 Htable[16], const uint64_t H[2]) { #ifdef GCM_FUNCREF #undef GCM_MUL -#define GCM_MUL(ctx, Xi) (*gcm_gmult_p)((ctx)->Xi.u, (ctx)->gcm_key.Htable) +#define GCM_MUL(ctx, Xi) (*gcm_gmult_p)((ctx)->Xi, (ctx)->gcm_key.Htable) #undef GHASH #define GHASH(ctx, in, len) \ - (*gcm_ghash_p)((ctx)->Xi.u, (ctx)->gcm_key.Htable, in, len) + (*gcm_ghash_p)((ctx)->Xi, (ctx)->gcm_key.Htable, in, len) #endif // GCM_FUNCREF #if defined(HW_GCM) && defined(OPENSSL_X86_64) static size_t hw_gcm_encrypt(const uint8_t *in, uint8_t *out, size_t len, const AES_KEY *key, uint8_t ivec[16], - uint64_t *Xi) { - return aesni_gcm_encrypt(in, out, len, key, ivec, Xi); + uint8_t Xi[16], const u128 Htable[16]) { + return aesni_gcm_encrypt(in, out, len, key, ivec, Htable, Xi); } static size_t hw_gcm_decrypt(const uint8_t *in, uint8_t *out, size_t len, const AES_KEY *key, uint8_t ivec[16], - uint64_t *Xi) { - return aesni_gcm_decrypt(in, out, len, key, ivec, Xi); + uint8_t Xi[16], const u128 Htable[16]) { + return aesni_gcm_decrypt(in, out, len, key, ivec, Htable, Xi); } #endif // HW_GCM && X86_64 @@ -150,38 +150,36 @@ static size_t hw_gcm_decrypt(const uint8_t *in, uint8_t *out, size_t len, static size_t hw_gcm_encrypt(const uint8_t *in, uint8_t *out, size_t len, const AES_KEY *key, uint8_t ivec[16], - uint64_t *Xi) { + uint8_t Xi[16], const u128 Htable[16]) { const size_t len_blocks = len & kSizeTWithoutLower4Bits; if (!len_blocks) { return 0; } - aes_gcm_enc_kernel(in, len_blocks * 8, out, Xi, ivec, key); + aes_gcm_enc_kernel(in, len_blocks * 8, out, Xi, ivec, key, Htable); return len_blocks; } static size_t hw_gcm_decrypt(const uint8_t *in, uint8_t *out, size_t len, const AES_KEY *key, uint8_t ivec[16], - uint64_t *Xi) { + uint8_t Xi[16], const u128 Htable[16]) { const size_t len_blocks = len & kSizeTWithoutLower4Bits; if (!len_blocks) { return 0; } - aes_gcm_dec_kernel(in, len_blocks * 8, out, Xi, ivec, key); + aes_gcm_dec_kernel(in, len_blocks * 8, out, Xi, ivec, key, Htable); return len_blocks; } #endif // HW_GCM && AARCH64 void CRYPTO_ghash_init(gmult_func *out_mult, ghash_func *out_hash, - u128 *out_key, u128 out_table[16], int *out_is_avx, + u128 out_table[16], int *out_is_avx, const uint8_t gcm_key[16]) { *out_is_avx = 0; - // H is stored in host byte order. + // H is passed to |gcm_init_*| as a pair of byte-swapped, 64-bit values. uint64_t H[2] = {CRYPTO_load_u64_be(gcm_key), CRYPTO_load_u64_be(gcm_key + 8)}; - out_key->hi = H[0]; - out_key->lo = H[1]; #if defined(GHASH_ASM_X86_64) if (crypto_gcm_clmul_enabled()) { @@ -247,89 +245,88 @@ void CRYPTO_gcm128_init_key(GCM128_KEY *gcm_key, const AES_KEY *aes_key, (*block)(ghash_key, ghash_key, aes_key); int is_avx; - CRYPTO_ghash_init(&gcm_key->gmult, &gcm_key->ghash, &gcm_key->H, - gcm_key->Htable, &is_avx, ghash_key); + CRYPTO_ghash_init(&gcm_key->gmult, &gcm_key->ghash, gcm_key->Htable, &is_avx, + ghash_key); #if defined(OPENSSL_AARCH64) && !defined(OPENSSL_NO_ASM) - gcm_key->use_hw_gcm_crypt = (gcm_pmull_capable() && block_is_hwaes) ? 1 : - 0; + gcm_key->use_hw_gcm_crypt = (gcm_pmull_capable() && block_is_hwaes) ? 1 : 0; #else - gcm_key->use_hw_gcm_crypt = (is_avx && block_is_hwaes) ? 1 : 0; + gcm_key->use_hw_gcm_crypt = (is_avx && block_is_hwaes) ? 1 : 0; #endif } void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const AES_KEY *key, const uint8_t *iv, size_t len) { #ifdef GCM_FUNCREF - void (*gcm_gmult_p)(uint64_t Xi[2], const u128 Htable[16]) = + void (*gcm_gmult_p)(uint8_t Xi[16], const u128 Htable[16]) = ctx->gcm_key.gmult; #endif - ctx->Yi.u[0] = 0; - ctx->Yi.u[1] = 0; - ctx->Xi.u[0] = 0; - ctx->Xi.u[1] = 0; - ctx->len.u[0] = 0; // AAD length - ctx->len.u[1] = 0; // message length + OPENSSL_memset(&ctx->Yi, 0, sizeof(ctx->Yi)); + OPENSSL_memset(&ctx->Xi, 0, sizeof(ctx->Xi)); + ctx->len.aad = 0; + ctx->len.msg = 0; ctx->ares = 0; ctx->mres = 0; uint32_t ctr; if (len == 12) { - OPENSSL_memcpy(ctx->Yi.c, iv, 12); - ctx->Yi.c[15] = 1; + OPENSSL_memcpy(ctx->Yi, iv, 12); + ctx->Yi[15] = 1; ctr = 1; } else { uint64_t len0 = len; while (len >= 16) { - for (size_t i = 0; i < 16; ++i) { - ctx->Yi.c[i] ^= iv[i]; - } + CRYPTO_xor16(ctx->Yi, ctx->Yi, iv); GCM_MUL(ctx, Yi); iv += 16; len -= 16; } if (len) { for (size_t i = 0; i < len; ++i) { - ctx->Yi.c[i] ^= iv[i]; + ctx->Yi[i] ^= iv[i]; } GCM_MUL(ctx, Yi); } - len0 <<= 3; - ctx->Yi.u[1] ^= CRYPTO_bswap8(len0); + + uint8_t len_block[16]; + OPENSSL_memset(len_block, 0, 8); + CRYPTO_store_u64_be(len_block + 8, len0 << 3); + CRYPTO_xor16(ctx->Yi, ctx->Yi, len_block); GCM_MUL(ctx, Yi); - ctr = CRYPTO_bswap4(ctx->Yi.d[3]); + ctr = CRYPTO_load_u32_be(ctx->Yi + 12); } - (*ctx->gcm_key.block)(ctx->Yi.c, ctx->EK0.c, key); + (*ctx->gcm_key.block)(ctx->Yi, ctx->EK0, key); ++ctr; - ctx->Yi.d[3] = CRYPTO_bswap4(ctr); + CRYPTO_store_u32_be(ctx->Yi + 12, ctr); } int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const uint8_t *aad, size_t len) { #ifdef GCM_FUNCREF - void (*gcm_gmult_p)(uint64_t Xi[2], const u128 Htable[16]) = + void (*gcm_gmult_p)(uint8_t Xi[16], const u128 Htable[16]) = ctx->gcm_key.gmult; - void (*gcm_ghash_p)(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, + void (*gcm_ghash_p)(uint8_t Xi[16], const u128 Htable[16], const uint8_t *inp, size_t len) = ctx->gcm_key.ghash; #endif - if (ctx->len.u[1]) { + if (ctx->len.msg != 0) { + // The caller must have finished the AAD before providing other input. return 0; } - uint64_t alen = ctx->len.u[0] + len; + uint64_t alen = ctx->len.aad + len; if (alen > (UINT64_C(1) << 61) || (sizeof(len) == 8 && alen < len)) { return 0; } - ctx->len.u[0] = alen; + ctx->len.aad = alen; unsigned n = ctx->ares; if (n) { while (n && len) { - ctx->Xi.c[n] ^= *(aad++); + ctx->Xi[n] ^= *(aad++); --len; n = (n + 1) % 16; } @@ -353,7 +350,7 @@ int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const uint8_t *aad, size_t len) { if (len != 0) { n = (unsigned int)len; for (size_t i = 0; i < len; ++i) { - ctx->Xi.c[i] ^= aad[i]; + ctx->Xi[i] ^= aad[i]; } } @@ -365,18 +362,18 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, const AES_KEY *key, const uint8_t *in, uint8_t *out, size_t len) { block128_f block = ctx->gcm_key.block; #ifdef GCM_FUNCREF - void (*gcm_gmult_p)(uint64_t Xi[2], const u128 Htable[16]) = + void (*gcm_gmult_p)(uint8_t Xi[16], const u128 Htable[16]) = ctx->gcm_key.gmult; - void (*gcm_ghash_p)(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, + void (*gcm_ghash_p)(uint8_t Xi[16], const u128 Htable[16], const uint8_t *inp, size_t len) = ctx->gcm_key.ghash; #endif - uint64_t mlen = ctx->len.u[1] + len; + uint64_t mlen = ctx->len.msg + len; if (mlen > ((UINT64_C(1) << 36) - 32) || (sizeof(len) == 8 && mlen < len)) { return 0; } - ctx->len.u[1] = mlen; + ctx->len.msg = mlen; if (ctx->ares) { // First call to encrypt finalizes GHASH(AAD) @@ -387,7 +384,7 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, const AES_KEY *key, unsigned n = ctx->mres; if (n) { while (n && len) { - ctx->Xi.c[n] ^= *(out++) = *(in++) ^ ctx->EKi.c[n]; + ctx->Xi[n] ^= *(out++) = *(in++) ^ ctx->EKi[n]; --len; n = (n + 1) % 16; } @@ -399,19 +396,15 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, const AES_KEY *key, } } - uint32_t ctr = CRYPTO_bswap4(ctx->Yi.d[3]); + uint32_t ctr = CRYPTO_load_u32_be(ctx->Yi + 12); while (len >= GHASH_CHUNK) { size_t j = GHASH_CHUNK; while (j) { - (*block)(ctx->Yi.c, ctx->EKi.c, key); + (*block)(ctx->Yi, ctx->EKi, key); ++ctr; - ctx->Yi.d[3] = CRYPTO_bswap4(ctr); - for (size_t i = 0; i < 16; i += sizeof(crypto_word_t)) { - CRYPTO_store_word_le(out + i, - CRYPTO_load_word_le(in + i) ^ - ctx->EKi.t[i / sizeof(crypto_word_t)]); - } + CRYPTO_store_u32_be(ctx->Yi + 12, ctr); + CRYPTO_xor16(out, in, ctx->EKi); out += 16; in += 16; j -= 16; @@ -422,14 +415,10 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, const AES_KEY *key, size_t len_blocks = len & kSizeTWithoutLower4Bits; if (len_blocks != 0) { while (len >= 16) { - (*block)(ctx->Yi.c, ctx->EKi.c, key); + (*block)(ctx->Yi, ctx->EKi, key); ++ctr; - ctx->Yi.d[3] = CRYPTO_bswap4(ctr); - for (size_t i = 0; i < 16; i += sizeof(crypto_word_t)) { - CRYPTO_store_word_le(out + i, - CRYPTO_load_word_le(in + i) ^ - ctx->EKi.t[i / sizeof(crypto_word_t)]); - } + CRYPTO_store_u32_be(ctx->Yi + 12, ctr); + CRYPTO_xor16(out, in, ctx->EKi); out += 16; in += 16; len -= 16; @@ -437,11 +426,11 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, const AES_KEY *key, GHASH(ctx, out - len_blocks, len_blocks); } if (len) { - (*block)(ctx->Yi.c, ctx->EKi.c, key); + (*block)(ctx->Yi, ctx->EKi, key); ++ctr; - ctx->Yi.d[3] = CRYPTO_bswap4(ctr); + CRYPTO_store_u32_be(ctx->Yi + 12, ctr); while (len--) { - ctx->Xi.c[n] ^= out[n] = in[n] ^ ctx->EKi.c[n]; + ctx->Xi[n] ^= out[n] = in[n] ^ ctx->EKi[n]; ++n; } } @@ -455,18 +444,18 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, const AES_KEY *key, size_t len) { block128_f block = ctx->gcm_key.block; #ifdef GCM_FUNCREF - void (*gcm_gmult_p)(uint64_t Xi[2], const u128 Htable[16]) = + void (*gcm_gmult_p)(uint8_t Xi[16], const u128 Htable[16]) = ctx->gcm_key.gmult; - void (*gcm_ghash_p)(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, + void (*gcm_ghash_p)(uint8_t Xi[16], const u128 Htable[16], const uint8_t *inp, size_t len) = ctx->gcm_key.ghash; #endif - uint64_t mlen = ctx->len.u[1] + len; + uint64_t mlen = ctx->len.msg + len; if (mlen > ((UINT64_C(1) << 36) - 32) || (sizeof(len) == 8 && mlen < len)) { return 0; } - ctx->len.u[1] = mlen; + ctx->len.msg = mlen; if (ctx->ares) { // First call to decrypt finalizes GHASH(AAD) @@ -478,8 +467,8 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, const AES_KEY *key, if (n) { while (n && len) { uint8_t c = *(in++); - *(out++) = c ^ ctx->EKi.c[n]; - ctx->Xi.c[n] ^= c; + *(out++) = c ^ ctx->EKi[n]; + ctx->Xi[n] ^= c; --len; n = (n + 1) % 16; } @@ -491,20 +480,16 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, const AES_KEY *key, } } - uint32_t ctr = CRYPTO_bswap4(ctx->Yi.d[3]); + uint32_t ctr = CRYPTO_load_u32_be(ctx->Yi + 12); while (len >= GHASH_CHUNK) { size_t j = GHASH_CHUNK; GHASH(ctx, in, GHASH_CHUNK); while (j) { - (*block)(ctx->Yi.c, ctx->EKi.c, key); + (*block)(ctx->Yi, ctx->EKi, key); ++ctr; - ctx->Yi.d[3] = CRYPTO_bswap4(ctr); - for (size_t i = 0; i < 16; i += sizeof(crypto_word_t)) { - CRYPTO_store_word_le(out + i, - CRYPTO_load_word_le(in + i) ^ - ctx->EKi.t[i / sizeof(crypto_word_t)]); - } + CRYPTO_store_u32_be(ctx->Yi + 12, ctr); + CRYPTO_xor16(out, in, ctx->EKi); out += 16; in += 16; j -= 16; @@ -515,27 +500,23 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, const AES_KEY *key, if (len_blocks != 0) { GHASH(ctx, in, len_blocks); while (len >= 16) { - (*block)(ctx->Yi.c, ctx->EKi.c, key); + (*block)(ctx->Yi, ctx->EKi, key); ++ctr; - ctx->Yi.d[3] = CRYPTO_bswap4(ctr); - for (size_t i = 0; i < 16; i += sizeof(crypto_word_t)) { - CRYPTO_store_word_le(out + i, - CRYPTO_load_word_le(in + i) ^ - ctx->EKi.t[i / sizeof(crypto_word_t)]); - } + CRYPTO_store_u32_be(ctx->Yi + 12, ctr); + CRYPTO_xor16(out, in, ctx->EKi); out += 16; in += 16; len -= 16; } } if (len) { - (*block)(ctx->Yi.c, ctx->EKi.c, key); + (*block)(ctx->Yi, ctx->EKi, key); ++ctr; - ctx->Yi.d[3] = CRYPTO_bswap4(ctr); + CRYPTO_store_u32_be(ctx->Yi + 12, ctr); while (len--) { uint8_t c = in[n]; - ctx->Xi.c[n] ^= c; - out[n] = c ^ ctx->EKi.c[n]; + ctx->Xi[n] ^= c; + out[n] = c ^ ctx->EKi[n]; ++n; } } @@ -548,18 +529,18 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key, const uint8_t *in, uint8_t *out, size_t len, ctr128_f stream) { #ifdef GCM_FUNCREF - void (*gcm_gmult_p)(uint64_t Xi[2], const u128 Htable[16]) = + void (*gcm_gmult_p)(uint8_t Xi[16], const u128 Htable[16]) = ctx->gcm_key.gmult; - void (*gcm_ghash_p)(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, + void (*gcm_ghash_p)(uint8_t Xi[16], const u128 Htable[16], const uint8_t *inp, size_t len) = ctx->gcm_key.ghash; #endif - uint64_t mlen = ctx->len.u[1] + len; + uint64_t mlen = ctx->len.msg + len; if (mlen > ((UINT64_C(1) << 36) - 32) || (sizeof(len) == 8 && mlen < len)) { return 0; } - ctx->len.u[1] = mlen; + ctx->len.msg = mlen; if (ctx->ares) { // First call to encrypt finalizes GHASH(AAD) @@ -570,7 +551,7 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key, unsigned n = ctx->mres; if (n) { while (n && len) { - ctx->Xi.c[n] ^= *(out++) = *(in++) ^ ctx->EKi.c[n]; + ctx->Xi[n] ^= *(out++) = *(in++) ^ ctx->EKi[n]; --len; n = (n + 1) % 16; } @@ -587,18 +568,19 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key, if (ctx->gcm_key.use_hw_gcm_crypt && len > 0) { // |hw_gcm_encrypt| may not process all the input given to it. It may // not process *any* of its input if it is deemed too small. - size_t bulk = hw_gcm_encrypt(in, out, len, key, ctx->Yi.c, ctx->Xi.u); + size_t bulk = hw_gcm_encrypt(in, out, len, key, ctx->Yi, ctx->Xi, + ctx->gcm_key.Htable); in += bulk; out += bulk; len -= bulk; } #endif - uint32_t ctr = CRYPTO_bswap4(ctx->Yi.d[3]); + uint32_t ctr = CRYPTO_load_u32_be(ctx->Yi + 12); while (len >= GHASH_CHUNK) { - (*stream)(in, out, GHASH_CHUNK / 16, key, ctx->Yi.c); + (*stream)(in, out, GHASH_CHUNK / 16, key, ctx->Yi); ctr += GHASH_CHUNK / 16; - ctx->Yi.d[3] = CRYPTO_bswap4(ctr); + CRYPTO_store_u32_be(ctx->Yi + 12, ctr); GHASH(ctx, out, GHASH_CHUNK); out += GHASH_CHUNK; in += GHASH_CHUNK; @@ -608,20 +590,20 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key, if (len_blocks != 0) { size_t j = len_blocks / 16; - (*stream)(in, out, j, key, ctx->Yi.c); + (*stream)(in, out, j, key, ctx->Yi); ctr += (unsigned int)j; - ctx->Yi.d[3] = CRYPTO_bswap4(ctr); + CRYPTO_store_u32_be(ctx->Yi + 12, ctr); in += len_blocks; len -= len_blocks; GHASH(ctx, out, len_blocks); out += len_blocks; } if (len) { - (*ctx->gcm_key.block)(ctx->Yi.c, ctx->EKi.c, key); + (*ctx->gcm_key.block)(ctx->Yi, ctx->EKi, key); ++ctr; - ctx->Yi.d[3] = CRYPTO_bswap4(ctr); + CRYPTO_store_u32_be(ctx->Yi + 12, ctr); while (len--) { - ctx->Xi.c[n] ^= out[n] = in[n] ^ ctx->EKi.c[n]; + ctx->Xi[n] ^= out[n] = in[n] ^ ctx->EKi[n]; ++n; } } @@ -634,18 +616,18 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key, const uint8_t *in, uint8_t *out, size_t len, ctr128_f stream) { #ifdef GCM_FUNCREF - void (*gcm_gmult_p)(uint64_t Xi[2], const u128 Htable[16]) = + void (*gcm_gmult_p)(uint8_t Xi[16], const u128 Htable[16]) = ctx->gcm_key.gmult; - void (*gcm_ghash_p)(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, + void (*gcm_ghash_p)(uint8_t Xi[16], const u128 Htable[16], const uint8_t *inp, size_t len) = ctx->gcm_key.ghash; #endif - uint64_t mlen = ctx->len.u[1] + len; + uint64_t mlen = ctx->len.msg + len; if (mlen > ((UINT64_C(1) << 36) - 32) || (sizeof(len) == 8 && mlen < len)) { return 0; } - ctx->len.u[1] = mlen; + ctx->len.msg = mlen; if (ctx->ares) { // First call to decrypt finalizes GHASH(AAD) @@ -657,8 +639,8 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key, if (n) { while (n && len) { uint8_t c = *(in++); - *(out++) = c ^ ctx->EKi.c[n]; - ctx->Xi.c[n] ^= c; + *(out++) = c ^ ctx->EKi[n]; + ctx->Xi[n] ^= c; --len; n = (n + 1) % 16; } @@ -675,19 +657,20 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key, if (ctx->gcm_key.use_hw_gcm_crypt && len > 0) { // |hw_gcm_decrypt| may not process all the input given to it. It may // not process *any* of its input if it is deemed too small. - size_t bulk = hw_gcm_decrypt(in, out, len, key, ctx->Yi.c, ctx->Xi.u); + size_t bulk = hw_gcm_decrypt(in, out, len, key, ctx->Yi, ctx->Xi, + ctx->gcm_key.Htable); in += bulk; out += bulk; len -= bulk; } #endif - uint32_t ctr = CRYPTO_bswap4(ctx->Yi.d[3]); + uint32_t ctr = CRYPTO_load_u32_be(ctx->Yi + 12); while (len >= GHASH_CHUNK) { GHASH(ctx, in, GHASH_CHUNK); - (*stream)(in, out, GHASH_CHUNK / 16, key, ctx->Yi.c); + (*stream)(in, out, GHASH_CHUNK / 16, key, ctx->Yi); ctr += GHASH_CHUNK / 16; - ctx->Yi.d[3] = CRYPTO_bswap4(ctr); + CRYPTO_store_u32_be(ctx->Yi + 12, ctr); out += GHASH_CHUNK; in += GHASH_CHUNK; len -= GHASH_CHUNK; @@ -697,21 +680,21 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key, size_t j = len_blocks / 16; GHASH(ctx, in, len_blocks); - (*stream)(in, out, j, key, ctx->Yi.c); + (*stream)(in, out, j, key, ctx->Yi); ctr += (unsigned int)j; - ctx->Yi.d[3] = CRYPTO_bswap4(ctr); + CRYPTO_store_u32_be(ctx->Yi + 12, ctr); out += len_blocks; in += len_blocks; len -= len_blocks; } if (len) { - (*ctx->gcm_key.block)(ctx->Yi.c, ctx->EKi.c, key); + (*ctx->gcm_key.block)(ctx->Yi, ctx->EKi, key); ++ctr; - ctx->Yi.d[3] = CRYPTO_bswap4(ctr); + CRYPTO_store_u32_be(ctx->Yi + 12, ctr); while (len--) { uint8_t c = in[n]; - ctx->Xi.c[n] ^= c; - out[n] = c ^ ctx->EKi.c[n]; + ctx->Xi[n] ^= c; + out[n] = c ^ ctx->EKi[n]; ++n; } } @@ -722,7 +705,7 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key, int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const uint8_t *tag, size_t len) { #ifdef GCM_FUNCREF - void (*gcm_gmult_p)(uint64_t Xi[2], const u128 Htable[16]) = + void (*gcm_gmult_p)(uint8_t Xi[16], const u128 Htable[16]) = ctx->gcm_key.gmult; #endif @@ -730,15 +713,15 @@ int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const uint8_t *tag, size_t len) { GCM_MUL(ctx, Xi); } - ctx->Xi.u[0] ^= CRYPTO_bswap8(ctx->len.u[0] << 3); - ctx->Xi.u[1] ^= CRYPTO_bswap8(ctx->len.u[1] << 3); + uint8_t len_block[16]; + CRYPTO_store_u64_be(len_block, ctx->len.aad << 3); + CRYPTO_store_u64_be(len_block + 8, ctx->len.msg << 3); + CRYPTO_xor16(ctx->Xi, ctx->Xi, len_block); GCM_MUL(ctx, Xi); - - ctx->Xi.u[0] ^= ctx->EK0.u[0]; - ctx->Xi.u[1] ^= ctx->EK0.u[1]; + CRYPTO_xor16(ctx->Xi, ctx->Xi, ctx->EK0); if (tag && len <= sizeof(ctx->Xi)) { - return CRYPTO_memcmp(ctx->Xi.c, tag, len) == 0; + return CRYPTO_memcmp(ctx->Xi, tag, len) == 0; } else { return 0; } @@ -746,8 +729,7 @@ int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const uint8_t *tag, size_t len) { void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len) { CRYPTO_gcm128_finish(ctx, NULL, 0); - OPENSSL_memcpy(tag, ctx->Xi.c, - len <= sizeof(ctx->Xi.c) ? len : sizeof(ctx->Xi.c)); + OPENSSL_memcpy(tag, ctx->Xi, len <= sizeof(ctx->Xi) ? len : sizeof(ctx->Xi)); } #if defined(OPENSSL_X86) || defined(OPENSSL_X86_64) diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/gcm_nohw.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/gcm_nohw.c index 3503c7f6..4859cbd0 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/gcm_nohw.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/gcm_nohw.c @@ -274,31 +274,29 @@ static void gcm_polyval_nohw(uint64_t Xi[2], const u128 *H) { Xi[1] = r3; } -void gcm_gmult_nohw(uint64_t Xi[2], const u128 Htable[16]) { +void gcm_gmult_nohw(uint8_t Xi[16], const u128 Htable[16]) { uint64_t swapped[2]; - swapped[0] = CRYPTO_bswap8(Xi[1]); - swapped[1] = CRYPTO_bswap8(Xi[0]); + swapped[0] = CRYPTO_load_u64_be(Xi + 8); + swapped[1] = CRYPTO_load_u64_be(Xi); gcm_polyval_nohw(swapped, &Htable[0]); - Xi[0] = CRYPTO_bswap8(swapped[1]); - Xi[1] = CRYPTO_bswap8(swapped[0]); + CRYPTO_store_u64_be(Xi, swapped[1]); + CRYPTO_store_u64_be(Xi + 8, swapped[0]); } -void gcm_ghash_nohw(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, +void gcm_ghash_nohw(uint8_t Xi[16], const u128 Htable[16], const uint8_t *inp, size_t len) { uint64_t swapped[2]; - swapped[0] = CRYPTO_bswap8(Xi[1]); - swapped[1] = CRYPTO_bswap8(Xi[0]); + swapped[0] = CRYPTO_load_u64_be(Xi + 8); + swapped[1] = CRYPTO_load_u64_be(Xi); while (len >= 16) { - uint64_t block[2]; - OPENSSL_memcpy(block, inp, 16); - swapped[0] ^= CRYPTO_bswap8(block[1]); - swapped[1] ^= CRYPTO_bswap8(block[0]); + swapped[0] ^= CRYPTO_load_u64_be(inp + 8); + swapped[1] ^= CRYPTO_load_u64_be(inp); gcm_polyval_nohw(swapped, &Htable[0]); inp += 16; len -= 16; } - Xi[0] = CRYPTO_bswap8(swapped[1]); - Xi[1] = CRYPTO_bswap8(swapped[0]); + CRYPTO_store_u64_be(Xi, swapped[1]); + CRYPTO_store_u64_be(Xi + 8, swapped[0]); } diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/internal.h b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/internal.h index 5901be96..cd2079e1 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/internal.h @@ -53,6 +53,7 @@ #include +#include #include #include @@ -75,6 +76,20 @@ extern "C" { typedef void (*block128_f)(const uint8_t in[16], uint8_t out[16], const AES_KEY *key); +OPENSSL_INLINE void CRYPTO_xor16(uint8_t out[16], const uint8_t a[16], + const uint8_t b[16]) { + // TODO(davidben): Ideally we'd leave this to the compiler, which could use + // vector registers, etc. But the compiler doesn't know that |in| and |out| + // cannot partially alias. |restrict| is slightly two strict (we allow exact + // aliasing), but perhaps in-place could be a separate function? + static_assert(16 % sizeof(crypto_word_t) == 0, + "block cannot be evenly divided into words"); + for (size_t i = 0; i < 16; i += sizeof(crypto_word_t)) { + CRYPTO_store_word_le( + out + i, CRYPTO_load_word_le(a + i) ^ CRYPTO_load_word_le(b + i)); + } +} + // CTR. @@ -115,21 +130,19 @@ typedef struct { uint64_t hi,lo; } u128; // gmult_func multiplies |Xi| by the GCM key and writes the result back to // |Xi|. -typedef void (*gmult_func)(uint64_t Xi[2], const u128 Htable[16]); +typedef void (*gmult_func)(uint8_t Xi[16], const u128 Htable[16]); // ghash_func repeatedly multiplies |Xi| by the GCM key and adds in blocks from // |inp|. The result is written back to |Xi| and the |len| argument must be a // multiple of 16. -typedef void (*ghash_func)(uint64_t Xi[2], const u128 Htable[16], +typedef void (*ghash_func)(uint8_t Xi[16], const u128 Htable[16], const uint8_t *inp, size_t len); typedef struct gcm128_key_st { - // Note the MOVBE-based, x86-64, GHASH assembly requires |H| and |Htable| to - // be the first two elements of this struct. Additionally, some assembly - // routines require a 16-byte-aligned |Htable| when hashing data, but not + // |gcm_*_ssse3| require a 16-byte-aligned |Htable| when hashing data, but not // initialization. |GCM128_KEY| is not itself aligned to simplify embedding in // |EVP_AEAD_CTX|, but |Htable|'s offset must be a multiple of 16. - u128 H; + // TODO(crbug.com/boringssl/604): Revisit this. u128 Htable[16]; gmult_func gmult; ghash_func ghash; @@ -145,17 +158,17 @@ typedef struct gcm128_key_st { // should be zero-initialized before use. typedef struct { // The following 5 names follow names in GCM specification - union { - uint64_t u[2]; - uint32_t d[4]; - uint8_t c[16]; - crypto_word_t t[16 / sizeof(crypto_word_t)]; - } Yi, EKi, EK0, len, Xi; + uint8_t Yi[16]; + uint8_t EKi[16]; + uint8_t EK0[16]; + struct { + uint64_t aad; + uint64_t msg; + } len; + uint8_t Xi[16]; - // Note that the order of |Xi| and |gcm_key| is fixed by the MOVBE-based, - // x86-64, GHASH assembly. Additionally, some assembly routines require - // |gcm_key| to be 16-byte aligned. |GCM128_KEY| is not itself aligned to - // simplify embedding in |EVP_AEAD_CTX|. + // |gcm_*_ssse3| require |Htable| to be 16-byte-aligned. + // TODO(crbug.com/boringssl/604): Revisit this. alignas(16) GCM128_KEY gcm_key; unsigned mres, ares; @@ -172,7 +185,7 @@ int crypto_gcm_clmul_enabled(void); // accelerated) functions for performing operations in the GHASH field. If the // AVX implementation was used |*out_is_avx| will be true. void CRYPTO_ghash_init(gmult_func *out_mult, ghash_func *out_hash, - u128 *out_key, u128 out_table[16], int *out_is_avx, + u128 out_table[16], int *out_is_avx, const uint8_t gcm_key[16]); // CRYPTO_gcm128_init_key initialises |gcm_key| to use |block| (typically AES) @@ -240,8 +253,8 @@ OPENSSL_EXPORT void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, uint8_t *tag, // GCM assembly. void gcm_init_nohw(u128 Htable[16], const uint64_t H[2]); -void gcm_gmult_nohw(uint64_t Xi[2], const u128 Htable[16]); -void gcm_ghash_nohw(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, +void gcm_gmult_nohw(uint8_t Xi[16], const u128 Htable[16]); +void gcm_ghash_nohw(uint8_t Xi[16], const u128 Htable[16], const uint8_t *inp, size_t len); #if !defined(OPENSSL_NO_ASM) @@ -249,29 +262,31 @@ void gcm_ghash_nohw(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, #if defined(OPENSSL_X86) || defined(OPENSSL_X86_64) #define GCM_FUNCREF void gcm_init_clmul(u128 Htable[16], const uint64_t Xi[2]); -void gcm_gmult_clmul(uint64_t Xi[2], const u128 Htable[16]); -void gcm_ghash_clmul(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, +void gcm_gmult_clmul(uint8_t Xi[16], const u128 Htable[16]); +void gcm_ghash_clmul(uint8_t Xi[16], const u128 Htable[16], const uint8_t *inp, size_t len); // |gcm_gmult_ssse3| and |gcm_ghash_ssse3| require |Htable| to be // 16-byte-aligned, but |gcm_init_ssse3| does not. void gcm_init_ssse3(u128 Htable[16], const uint64_t Xi[2]); -void gcm_gmult_ssse3(uint64_t Xi[2], const u128 Htable[16]); -void gcm_ghash_ssse3(uint64_t Xi[2], const u128 Htable[16], const uint8_t *in, +void gcm_gmult_ssse3(uint8_t Xi[16], const u128 Htable[16]); +void gcm_ghash_ssse3(uint8_t Xi[16], const u128 Htable[16], const uint8_t *in, size_t len); #if defined(OPENSSL_X86_64) #define GHASH_ASM_X86_64 void gcm_init_avx(u128 Htable[16], const uint64_t Xi[2]); -void gcm_gmult_avx(uint64_t Xi[2], const u128 Htable[16]); -void gcm_ghash_avx(uint64_t Xi[2], const u128 Htable[16], const uint8_t *in, +void gcm_gmult_avx(uint8_t Xi[16], const u128 Htable[16]); +void gcm_ghash_avx(uint8_t Xi[16], const u128 Htable[16], const uint8_t *in, size_t len); #define HW_GCM size_t aesni_gcm_encrypt(const uint8_t *in, uint8_t *out, size_t len, - const AES_KEY *key, uint8_t ivec[16], uint64_t *Xi); + const AES_KEY *key, uint8_t ivec[16], + const u128 Htable[16], uint8_t Xi[16]); size_t aesni_gcm_decrypt(const uint8_t *in, uint8_t *out, size_t len, - const AES_KEY *key, uint8_t ivec[16], uint64_t *Xi); + const AES_KEY *key, uint8_t ivec[16], + const u128 Htable[16], uint8_t Xi[16]); #endif // OPENSSL_X86_64 #if defined(OPENSSL_X86) @@ -287,25 +302,27 @@ OPENSSL_INLINE int gcm_pmull_capable(void) { return CRYPTO_is_ARMv8_PMULL_capable(); } -void gcm_init_v8(u128 Htable[16], const uint64_t Xi[2]); -void gcm_gmult_v8(uint64_t Xi[2], const u128 Htable[16]); -void gcm_ghash_v8(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, +void gcm_init_v8(u128 Htable[16], const uint64_t H[2]); +void gcm_gmult_v8(uint8_t Xi[16], const u128 Htable[16]); +void gcm_ghash_v8(uint8_t Xi[16], const u128 Htable[16], const uint8_t *inp, size_t len); OPENSSL_INLINE int gcm_neon_capable(void) { return CRYPTO_is_NEON_capable(); } -void gcm_init_neon(u128 Htable[16], const uint64_t Xi[2]); -void gcm_gmult_neon(uint64_t Xi[2], const u128 Htable[16]); -void gcm_ghash_neon(uint64_t Xi[2], const u128 Htable[16], const uint8_t *inp, +void gcm_init_neon(u128 Htable[16], const uint64_t H[2]); +void gcm_gmult_neon(uint8_t Xi[16], const u128 Htable[16]); +void gcm_ghash_neon(uint8_t Xi[16], const u128 Htable[16], const uint8_t *inp, size_t len); #if defined(OPENSSL_AARCH64) #define HW_GCM // These functions are defined in aesv8-gcm-armv8.pl. void aes_gcm_enc_kernel(const uint8_t *in, uint64_t in_bits, void *out, - void *Xi, uint8_t *ivec, const AES_KEY *key); + void *Xi, uint8_t *ivec, const AES_KEY *key, + const u128 Htable[16]); void aes_gcm_dec_kernel(const uint8_t *in, uint64_t in_bits, void *out, - void *Xi, uint8_t *ivec, const AES_KEY *key); + void *Xi, uint8_t *ivec, const AES_KEY *key, + const u128 Htable[16]); #endif #endif @@ -380,19 +397,12 @@ size_t CRYPTO_cts128_encrypt_block(const uint8_t *in, uint8_t *out, size_t len, // // POLYVAL is a polynomial authenticator that operates over a field very // similar to the one that GHASH uses. See -// https://tools.ietf.org/html/draft-irtf-cfrg-gcmsiv-02#section-3. - -typedef union { - uint64_t u[2]; - uint8_t c[16]; -} polyval_block; +// https://www.rfc-editor.org/rfc/rfc8452.html#section-3. struct polyval_ctx { - // Note that the order of |S|, |H| and |Htable| is fixed by the MOVBE-based, - // x86-64, GHASH assembly. Additionally, some assembly routines require - // |Htable| to be 16-byte aligned. - polyval_block S; - u128 H; + uint8_t S[16]; + // |gcm_*_ssse3| require |Htable| to be 16-byte-aligned. + // TODO(crbug.com/boringssl/604): Revisit this. alignas(16) u128 Htable[16]; gmult_func gmult; ghash_func ghash; diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/ofb.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/ofb.c index 5effba66..9260f2d4 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/ofb.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/ofb.c @@ -70,14 +70,7 @@ void CRYPTO_ofb128_encrypt(const uint8_t *in, uint8_t *out, size_t len, while (len >= 16) { (*block)(ivec, ivec, key); - for (; n < 16; n += sizeof(size_t)) { - size_t a, b; - OPENSSL_memcpy(&a, in + n, sizeof(size_t)); - OPENSSL_memcpy(&b, ivec + n, sizeof(size_t)); - - const size_t c = a ^ b; - OPENSSL_memcpy(out + n, &c, sizeof(size_t)); - } + CRYPTO_xor16(out, in, ivec); len -= 16; out += 16; in += 16; diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/polyval.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/polyval.c index ccffdc9e..88cb52f0 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/polyval.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/modes/polyval.c @@ -22,70 +22,69 @@ // byte_reverse reverses the order of the bytes in |b->c|. -static void byte_reverse(polyval_block *b) { - const uint64_t t = CRYPTO_bswap8(b->u[0]); - b->u[0] = CRYPTO_bswap8(b->u[1]); - b->u[1] = t; +static void byte_reverse(uint8_t b[16]) { + uint64_t hi = CRYPTO_load_u64_le(b); + uint64_t lo = CRYPTO_load_u64_le(b + 8); + CRYPTO_store_u64_le(b, CRYPTO_bswap8(lo)); + CRYPTO_store_u64_le(b + 8, CRYPTO_bswap8(hi)); } -// reverse_and_mulX_ghash interprets the bytes |b->c| as a reversed element of -// the GHASH field, multiplies that by 'x' and serialises the result back into -// |b|, but with GHASH's backwards bit ordering. -static void reverse_and_mulX_ghash(polyval_block *b) { - uint64_t hi = b->u[0]; - uint64_t lo = b->u[1]; +// reverse_and_mulX_ghash interprets |b| as a reversed element of the GHASH +// field, multiplies that by 'x' and serialises the result back into |b|, but +// with GHASH's backwards bit ordering. +static void reverse_and_mulX_ghash(uint8_t b[16]) { + uint64_t hi = CRYPTO_load_u64_le(b); + uint64_t lo = CRYPTO_load_u64_le(b + 8); const crypto_word_t carry = constant_time_eq_w(hi & 1, 1); hi >>= 1; hi |= lo << 63; lo >>= 1; lo ^= ((uint64_t) constant_time_select_w(carry, 0xe1, 0)) << 56; - b->u[0] = CRYPTO_bswap8(lo); - b->u[1] = CRYPTO_bswap8(hi); + CRYPTO_store_u64_le(b, CRYPTO_bswap8(lo)); + CRYPTO_store_u64_le(b + 8, CRYPTO_bswap8(hi)); } // POLYVAL(H, X_1, ..., X_n) = // ByteReverse(GHASH(mulX_GHASH(ByteReverse(H)), ByteReverse(X_1), ..., // ByteReverse(X_n))). // -// See https://tools.ietf.org/html/draft-irtf-cfrg-gcmsiv-02#appendix-A. +// See https://www.rfc-editor.org/rfc/rfc8452.html#appendix-A. void CRYPTO_POLYVAL_init(struct polyval_ctx *ctx, const uint8_t key[16]) { - polyval_block H; - OPENSSL_memcpy(H.c, key, 16); - reverse_and_mulX_ghash(&H); + alignas(8) uint8_t H[16]; + OPENSSL_memcpy(H, key, 16); + reverse_and_mulX_ghash(H); int is_avx; - CRYPTO_ghash_init(&ctx->gmult, &ctx->ghash, &ctx->H, ctx->Htable, &is_avx, - H.c); + CRYPTO_ghash_init(&ctx->gmult, &ctx->ghash, ctx->Htable, &is_avx, H); OPENSSL_memset(&ctx->S, 0, sizeof(ctx->S)); } void CRYPTO_POLYVAL_update_blocks(struct polyval_ctx *ctx, const uint8_t *in, size_t in_len) { assert((in_len & 15) == 0); - polyval_block reversed[32]; + alignas(8) uint8_t buf[32 * 16]; while (in_len > 0) { size_t todo = in_len; - if (todo > sizeof(reversed)) { - todo = sizeof(reversed); + if (todo > sizeof(buf)) { + todo = sizeof(buf); } - OPENSSL_memcpy(reversed, in, todo); + OPENSSL_memcpy(buf, in, todo); in += todo; in_len -= todo; - size_t blocks = todo / sizeof(polyval_block); + size_t blocks = todo / 16; for (size_t i = 0; i < blocks; i++) { - byte_reverse(&reversed[i]); + byte_reverse(buf + 16 * i); } - ctx->ghash(ctx->S.u, ctx->Htable, (const uint8_t *) reversed, todo); + ctx->ghash(ctx->S, ctx->Htable, buf, todo); } } void CRYPTO_POLYVAL_finish(const struct polyval_ctx *ctx, uint8_t out[16]) { - polyval_block S = ctx->S; - byte_reverse(&S); - OPENSSL_memcpy(out, &S.c, sizeof(polyval_block)); + OPENSSL_memcpy(out, &ctx->S, 16); + byte_reverse(out); } diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-armv8-asm-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-armv8-asm-ios.ios.aarch64.S index 82412e66..41f40276 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-armv8-asm-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-armv8-asm-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) #include "CCryptoBoringSSL_arm_arch.h" .section __TEXT,__const @@ -1733,11 +1725,7 @@ Lselect_w7_loop: ret -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-armv8-asm-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-armv8-asm-linux.linux.aarch64.S index 64368096..a3a54045 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-armv8-asm-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-armv8-asm-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) #include "CCryptoBoringSSL_arm_arch.h" .section .rodata @@ -1733,11 +1725,7 @@ ecp_nistz256_select_w7: ret .size ecp_nistz256_select_w7,.-ecp_nistz256_select_w7 -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-x86_64-asm-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-x86_64-asm-linux.linux.x86_64.S index 2661da6f..c9a2c957 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-x86_64-asm-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-x86_64-asm-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .extern OPENSSL_ia32cap_P .hidden OPENSSL_ia32cap_P @@ -47,6 +40,7 @@ .align 32 ecp_nistz256_neg: .cfi_startproc +_CET_ENDBR pushq %r12 .cfi_adjust_cfa_offset 8 .cfi_offset %r12,-16 @@ -109,6 +103,7 @@ ecp_nistz256_neg: .align 32 ecp_nistz256_ord_mul_mont: .cfi_startproc +_CET_ENDBR leaq OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -443,6 +438,7 @@ ecp_nistz256_ord_mul_mont: .align 32 ecp_nistz256_ord_sqr_mont: .cfi_startproc +_CET_ENDBR leaq OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -1202,6 +1198,7 @@ ecp_nistz256_ord_sqr_montx: .align 32 ecp_nistz256_mul_mont: .cfi_startproc +_CET_ENDBR leaq OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -1499,6 +1496,7 @@ __ecp_nistz256_mul_montq: .align 32 ecp_nistz256_sqr_mont: .cfi_startproc +_CET_ENDBR leaq OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -2029,6 +2027,7 @@ __ecp_nistz256_sqr_montx: .align 32 ecp_nistz256_select_w5: .cfi_startproc +_CET_ENDBR leaq OPENSSL_ia32cap_P(%rip),%rax movq 8(%rax),%rax testl $32,%eax @@ -2096,6 +2095,7 @@ ecp_nistz256_select_w5: .align 32 ecp_nistz256_select_w7: .cfi_startproc +_CET_ENDBR leaq OPENSSL_ia32cap_P(%rip),%rax movq 8(%rax),%rax testl $32,%eax @@ -2216,6 +2216,7 @@ ecp_nistz256_avx2_select_w5: ecp_nistz256_avx2_select_w7: .cfi_startproc .Lavx2_select_w7: +_CET_ENDBR vzeroupper vmovdqa .LThree(%rip),%ymm0 @@ -2422,6 +2423,7 @@ __ecp_nistz256_mul_by_2q: .align 32 ecp_nistz256_point_double: .cfi_startproc +_CET_ENDBR leaq OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -2656,6 +2658,7 @@ ecp_nistz256_point_double: .align 32 ecp_nistz256_point_add: .cfi_startproc +_CET_ENDBR leaq OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -3093,6 +3096,7 @@ ecp_nistz256_point_add: .align 32 ecp_nistz256_point_add_affine: .cfi_startproc +_CET_ENDBR leaq OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -4544,10 +4548,6 @@ ecp_nistz256_point_add_affinex: .cfi_endproc .size ecp_nistz256_point_add_affinex,.-ecp_nistz256_point_add_affinex #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-x86_64-asm-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-x86_64-asm-mac.mac.x86_64.S index 5e124142..9fb36097 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-x86_64-asm-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256-x86_64-asm-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text @@ -46,6 +39,7 @@ L$ordK: .p2align 5 _ecp_nistz256_neg: +_CET_ENDBR pushq %r12 pushq %r13 @@ -106,6 +100,7 @@ L$neg_epilogue: .p2align 5 _ecp_nistz256_ord_mul_mont: +_CET_ENDBR leaq _OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -434,6 +429,7 @@ L$ord_mul_epilogue: .p2align 5 _ecp_nistz256_ord_sqr_mont: +_CET_ENDBR leaq _OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -1175,6 +1171,7 @@ L$ord_sqrx_epilogue: .p2align 5 _ecp_nistz256_mul_mont: +_CET_ENDBR leaq _OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -1466,6 +1463,7 @@ __ecp_nistz256_mul_montq: .p2align 5 _ecp_nistz256_sqr_mont: +_CET_ENDBR leaq _OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -1990,6 +1988,7 @@ __ecp_nistz256_sqr_montx: .p2align 5 _ecp_nistz256_select_w5: +_CET_ENDBR leaq _OPENSSL_ia32cap_P(%rip),%rax movq 8(%rax),%rax testl $32,%eax @@ -2057,6 +2056,7 @@ L$SEH_end_ecp_nistz256_select_w5: .p2align 5 _ecp_nistz256_select_w7: +_CET_ENDBR leaq _OPENSSL_ia32cap_P(%rip),%rax movq 8(%rax),%rax testl $32,%eax @@ -2177,6 +2177,7 @@ L$SEH_end_ecp_nistz256_avx2_select_w5: _ecp_nistz256_avx2_select_w7: L$avx2_select_w7: +_CET_ENDBR vzeroupper vmovdqa L$Three(%rip),%ymm0 @@ -2383,6 +2384,7 @@ __ecp_nistz256_mul_by_2q: .p2align 5 _ecp_nistz256_point_double: +_CET_ENDBR leaq _OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -2611,6 +2613,7 @@ L$point_doubleq_epilogue: .p2align 5 _ecp_nistz256_point_add: +_CET_ENDBR leaq _OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -3042,6 +3045,7 @@ L$point_addq_epilogue: .p2align 5 _ecp_nistz256_point_add_affine: +_CET_ENDBR leaq _OPENSSL_ia32cap_P(%rip),%rcx movq 8(%rcx),%rcx andl $0x80100,%ecx @@ -4468,10 +4472,6 @@ L$add_affinex_epilogue: .byte 0xf3,0xc3 -#endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits #endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-armv8-asm-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-armv8-asm-ios.ios.aarch64.S index 5c9080de..9a5941d6 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-armv8-asm-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-armv8-asm-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) #include "CCryptoBoringSSL_arm_arch.h" .text @@ -316,11 +308,7 @@ Lbeeu_finish: AARCH64_VALIDATE_LINK_REGISTER ret -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-armv8-asm-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-armv8-asm-linux.linux.aarch64.S index 61eaaa60..7f6451f7 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-armv8-asm-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-armv8-asm-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) #include "CCryptoBoringSSL_arm_arch.h" .text @@ -316,11 +308,7 @@ beeu_mod_inverse_vartime: AARCH64_VALIDATE_LINK_REGISTER ret .size beeu_mod_inverse_vartime,.-beeu_mod_inverse_vartime -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-x86_64-asm-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-x86_64-asm-linux.linux.x86_64.S index 2b7c13a1..d755c1cd 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-x86_64-asm-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-x86_64-asm-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .type beeu_mod_inverse_vartime,@function @@ -22,6 +15,7 @@ .align 32 beeu_mod_inverse_vartime: .cfi_startproc +_CET_ENDBR pushq %rbp .cfi_adjust_cfa_offset 8 .cfi_offset rbp,-16 @@ -342,10 +336,6 @@ beeu_mod_inverse_vartime: .size beeu_mod_inverse_vartime, .-beeu_mod_inverse_vartime #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-x86_64-asm-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-x86_64-asm-mac.mac.x86_64.S index 3527a326..afe98ad8 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-x86_64-asm-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/p256_beeu-x86_64-asm-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text @@ -22,6 +15,7 @@ .p2align 5 _beeu_mod_inverse_vartime: +_CET_ENDBR pushq %rbp pushq %r12 @@ -327,10 +321,6 @@ L$beeu_finish: -#endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits #endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/fork_detect.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/fork_detect.c index 456bb82f..463c6031 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/fork_detect.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/fork_detect.c @@ -38,7 +38,7 @@ static_assert(MADV_WIPEONFORK == 18, "MADV_WIPEONFORK is not 18"); DEFINE_STATIC_ONCE(g_fork_detect_once); DEFINE_STATIC_MUTEX(g_fork_detect_lock); -DEFINE_BSS_GET(volatile char *, g_fork_detect_addr); +DEFINE_BSS_GET(CRYPTO_atomic_u32 *, g_fork_detect_addr); DEFINE_BSS_GET(uint64_t, g_fork_generation); DEFINE_BSS_GET(int, g_force_madv_wipeonfork); DEFINE_BSS_GET(int, g_force_madv_wipeonfork_enabled); @@ -70,7 +70,7 @@ static void init_fork_detect(void) { return; } - *((volatile char *) addr) = 1; + CRYPTO_atomic_store_u32(addr, 1); *g_fork_detect_addr_bss_get() = addr; *g_fork_generation_bss_get() = 1; } @@ -83,16 +83,12 @@ uint64_t CRYPTO_get_fork_generation(void) { // is initialised atomically, even if multiple threads enter this function // concurrently. // - // In the limit, the kernel may clear WIPEONFORK pages while a multi-threaded - // process is running. (For example, because a VM was cloned.) Therefore a - // lock is used below to synchronise the potentially multiple threads that may - // concurrently observe the cleared flag. + // Additionally, while the kernel will only clear WIPEONFORK at a point when a + // child process is single-threaded, the child may become multi-threaded + // before it observes this. Therefore, we must synchronize the logic below. CRYPTO_once(g_fork_detect_once_bss_get(), init_fork_detect); - // This pointer is |volatile| because the value pointed to may be changed by - // external forces (i.e. the kernel wiping the page) thus the compiler must - // not assume that it has exclusive access to it. - volatile char *const flag_ptr = *g_fork_detect_addr_bss_get(); + CRYPTO_atomic_u32 *const flag_ptr = *g_fork_detect_addr_bss_get(); if (flag_ptr == NULL) { // Our kernel is too old to support |MADV_WIPEONFORK| or // |g_force_madv_wipeonfork| is set. @@ -105,30 +101,36 @@ uint64_t CRYPTO_get_fork_generation(void) { return 0; } - struct CRYPTO_STATIC_MUTEX *const lock = g_fork_detect_lock_bss_get(); + // In the common case, try to observe the flag without taking a lock. This + // avoids cacheline contention in the PRNG. uint64_t *const generation_ptr = g_fork_generation_bss_get(); - - CRYPTO_STATIC_MUTEX_lock_read(lock); - uint64_t current_generation = *generation_ptr; - if (*flag_ptr) { - CRYPTO_STATIC_MUTEX_unlock_read(lock); - return current_generation; + if (CRYPTO_atomic_load_u32(flag_ptr) != 0) { + // If we observe a non-zero flag, it is safe to read |generation_ptr| + // without a lock. The flag and generation number are fixed for this copy of + // the address space. + return *generation_ptr; } - CRYPTO_STATIC_MUTEX_unlock_read(lock); - CRYPTO_STATIC_MUTEX_lock_write(lock); - current_generation = *generation_ptr; - if (*flag_ptr == 0) { + // The flag was zero. The generation number must be incremented, but other + // threads may have concurrently observed the zero, so take a lock before + // incrementing. + CRYPTO_MUTEX *const lock = g_fork_detect_lock_bss_get(); + CRYPTO_MUTEX_lock_write(lock); + uint64_t current_generation = *generation_ptr; + if (CRYPTO_atomic_load_u32(flag_ptr) == 0) { // A fork has occurred. - *flag_ptr = 1; - current_generation++; if (current_generation == 0) { + // Zero means fork detection isn't supported, so skip that value. current_generation = 1; } + + // We must update |generation_ptr| before |flag_ptr|. Other threads may + // observe |flag_ptr| without taking a lock. *generation_ptr = current_generation; + CRYPTO_atomic_store_u32(flag_ptr, 1); } - CRYPTO_STATIC_MUTEX_unlock_write(lock); + CRYPTO_MUTEX_unlock_write(lock); return current_generation; } @@ -138,8 +140,20 @@ void CRYPTO_fork_detect_force_madv_wipeonfork_for_testing(int on) { *g_force_madv_wipeonfork_enabled_bss_get() = on; } -#else // !OPENSSL_LINUX +#elif defined(OPENSSL_WINDOWS) || defined(OPENSSL_TRUSTY) +// These platforms are guaranteed not to fork, and therefore do not require +// fork detection support. Returning a constant non zero value makes BoringSSL +// assume address space duplication is not a concern and adding entropy to +// every RAND_bytes call is not needed. +uint64_t CRYPTO_get_fork_generation(void) { return 0xc0ffee; } + +#else + +// These platforms may fork, but we do not have a mitigation mechanism in +// place. Returning a constant zero value makes BoringSSL assume that address +// space duplication could have occured on any call entropy must be added to +// every RAND_bytes call. uint64_t CRYPTO_get_fork_generation(void) { return 0; } -#endif // OPENSSL_LINUX +#endif diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/internal.h b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/internal.h index 379b1f7f..7be2ad3d 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/internal.h @@ -26,9 +26,21 @@ extern "C" { #endif -#if !defined(OPENSSL_WINDOWS) && !defined(OPENSSL_FUCHSIA) && \ - !defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) && !defined(OPENSSL_TRUSTY) -#define OPENSSL_URANDOM +#if defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) +#define OPENSSL_RAND_DETERMINISTIC +#elif defined(OPENSSL_TRUSTY) +#define OPENSSL_RAND_TRUSTY +#elif defined(OPENSSL_WINDOWS) +#define OPENSSL_RAND_WINDOWS +#elif defined(OPENSSL_LINUX) +#define OPENSSL_RAND_URANDOM +#elif defined(OPENSSL_APPLE) && !defined(OPENSSL_MACOS) +// Unlike macOS, iOS and similar hide away getentropy(). +#define OPENSSL_RAND_IOS +#else +// By default if you are integrating BoringSSL we expect you to +// provide getentropy from the header file. +#define OPENSSL_RAND_GETENTROPY #endif // RAND_bytes_with_additional_data samples from the RNG after mixing 32 bytes @@ -70,11 +82,15 @@ void CRYPTO_sysrand(uint8_t *buf, size_t len); // depending on the vendor's configuration. void CRYPTO_sysrand_for_seed(uint8_t *buf, size_t len); -#if defined(OPENSSL_URANDOM) +#if defined(OPENSSL_RAND_URANDOM) || defined(OPENSSL_RAND_WINDOWS) // CRYPTO_init_sysrand initializes long-lived resources needed to draw entropy // from the operating system. void CRYPTO_init_sysrand(void); +#else +OPENSSL_INLINE void CRYPTO_init_sysrand(void) {} +#endif // defined(OPENSSL_RAND_URANDOM) || defined(OPENSSL_RAND_WINDOWS) +#if defined(OPENSSL_RAND_URANDOM) // CRYPTO_sysrand_if_available fills |len| bytes at |buf| with entropy from the // operating system, or early /dev/urandom data, and returns 1, _if_ the entropy // pool is initialized or if getrandom() is not available and not in FIPS mode. @@ -82,13 +98,11 @@ void CRYPTO_init_sysrand(void); // return 0. int CRYPTO_sysrand_if_available(uint8_t *buf, size_t len); #else -OPENSSL_INLINE void CRYPTO_init_sysrand(void) {} - OPENSSL_INLINE int CRYPTO_sysrand_if_available(uint8_t *buf, size_t len) { CRYPTO_sysrand(buf, len); return 1; } -#endif +#endif // defined(OPENSSL_RAND_URANDOM) // rand_fork_unsafe_buffering_enabled returns whether fork-unsafe buffering has // been enabled via |RAND_enable_fork_unsafe_buffering|. diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/rand.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/rand.c index 6f0db411..268dece4 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/rand.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/rand.c @@ -65,6 +65,9 @@ struct rand_thread_state { // last_block_valid is non-zero iff |last_block| contains data from // |get_seed_entropy|. int last_block_valid; + // fork_unsafe_buffering is non-zero iff, when |drbg| was last (re)seeded, + // fork-unsafe buffering was enabled. + int fork_unsafe_buffering; #if defined(BORINGSSL_FIPS) // last_block contains the previous block from |get_seed_entropy|. @@ -72,6 +75,10 @@ struct rand_thread_state { // next and prev form a NULL-terminated, double-linked list of all states in // a process. struct rand_thread_state *next, *prev; + // clear_drbg_lock synchronizes between uses of |drbg| and + // |rand_thread_state_clear_all| clearing it. This lock should be uncontended + // in the common case, except on shutdown. + CRYPTO_MUTEX clear_drbg_lock; #endif }; @@ -82,18 +89,19 @@ struct rand_thread_state { // called when the whole process is exiting. DEFINE_BSS_GET(struct rand_thread_state *, thread_states_list); DEFINE_STATIC_MUTEX(thread_states_list_lock); -DEFINE_STATIC_MUTEX(state_clear_all_lock); static void rand_thread_state_clear_all(void) __attribute__((destructor)); static void rand_thread_state_clear_all(void) { - CRYPTO_STATIC_MUTEX_lock_write(thread_states_list_lock_bss_get()); - CRYPTO_STATIC_MUTEX_lock_write(state_clear_all_lock_bss_get()); + CRYPTO_MUTEX_lock_write(thread_states_list_lock_bss_get()); for (struct rand_thread_state *cur = *thread_states_list_bss_get(); cur != NULL; cur = cur->next) { + CRYPTO_MUTEX_lock_write(&cur->clear_drbg_lock); CTR_DRBG_clear(&cur->drbg); } // The locks are deliberately left locked so that any threads that are still - // running will hang if they try to call |RAND_bytes|. + // running will hang if they try to call |RAND_bytes|. It also ensures + // |rand_thread_state_free| cannot free any thread state while we've taken the + // lock. } #endif @@ -107,7 +115,7 @@ static void rand_thread_state_free(void *state_in) { } #if defined(BORINGSSL_FIPS) - CRYPTO_STATIC_MUTEX_lock_write(thread_states_list_lock_bss_get()); + CRYPTO_MUTEX_lock_write(thread_states_list_lock_bss_get()); if (state->prev != NULL) { state->prev->next = state->next; @@ -119,7 +127,7 @@ static void rand_thread_state_free(void *state_in) { state->next->prev = state->prev; } - CRYPTO_STATIC_MUTEX_unlock_write(thread_states_list_lock_bss_get()); + CRYPTO_MUTEX_unlock_write(thread_states_list_lock_bss_get()); CTR_DRBG_clear(&state->drbg); #endif @@ -195,7 +203,7 @@ void RAND_load_entropy(const uint8_t *entropy, size_t entropy_len, int want_additional_input) { struct entropy_buffer *const buffer = entropy_buffer_bss_get(); - CRYPTO_STATIC_MUTEX_lock_write(entropy_buffer_lock_bss_get()); + CRYPTO_MUTEX_lock_write(entropy_buffer_lock_bss_get()); const size_t space = sizeof(buffer->bytes) - buffer->bytes_valid; if (entropy_len > space) { entropy_len = space; @@ -205,7 +213,7 @@ void RAND_load_entropy(const uint8_t *entropy, size_t entropy_len, buffer->bytes_valid += entropy_len; buffer->want_additional_input |= want_additional_input && (entropy_len != 0); - CRYPTO_STATIC_MUTEX_unlock_write(entropy_buffer_lock_bss_get()); + CRYPTO_MUTEX_unlock_write(entropy_buffer_lock_bss_get()); } // get_seed_entropy fills |out_entropy_len| bytes of |out_entropy| from the @@ -217,11 +225,11 @@ static void get_seed_entropy(uint8_t *out_entropy, size_t out_entropy_len, abort(); } - CRYPTO_STATIC_MUTEX_lock_write(entropy_buffer_lock_bss_get()); + CRYPTO_MUTEX_lock_write(entropy_buffer_lock_bss_get()); while (buffer->bytes_valid < out_entropy_len) { - CRYPTO_STATIC_MUTEX_unlock_write(entropy_buffer_lock_bss_get()); + CRYPTO_MUTEX_unlock_write(entropy_buffer_lock_bss_get()); RAND_need_entropy(out_entropy_len - buffer->bytes_valid); - CRYPTO_STATIC_MUTEX_lock_write(entropy_buffer_lock_bss_get()); + CRYPTO_MUTEX_lock_write(entropy_buffer_lock_bss_get()); } *out_want_additional_input = buffer->want_additional_input; @@ -233,7 +241,7 @@ static void get_seed_entropy(uint8_t *out_entropy, size_t out_entropy_len, buffer->want_additional_input = 0; } - CRYPTO_STATIC_MUTEX_unlock_write(entropy_buffer_lock_bss_get()); + CRYPTO_MUTEX_unlock_write(entropy_buffer_lock_bss_get()); } // rand_get_seed fills |seed| with entropy. In some cases, it will additionally @@ -326,6 +334,7 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len, } const uint64_t fork_generation = CRYPTO_get_fork_generation(); + const int fork_unsafe_buffering = rand_fork_unsafe_buffering_enabled(); // Additional data is mixed into every CTR-DRBG call to protect, as best we // can, against forks & VM clones. We do not over-read this information and @@ -340,7 +349,7 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len, // entropy is used. This can be expensive (one read per |RAND_bytes| call) // and so is disabled when we have fork detection, or if the application has // promised not to fork. - if (fork_generation != 0 || rand_fork_unsafe_buffering_enabled()) { + if (fork_generation != 0 || fork_unsafe_buffering) { OPENSSL_memset(additional_data, 0, sizeof(additional_data)); } else if (!have_rdrand()) { // No alternative so block for OS entropy. @@ -383,10 +392,12 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len, } state->calls = 0; state->fork_generation = fork_generation; + state->fork_unsafe_buffering = fork_unsafe_buffering; #if defined(BORINGSSL_FIPS) + CRYPTO_MUTEX_init(&state->clear_drbg_lock); if (state != &stack_state) { - CRYPTO_STATIC_MUTEX_lock_write(thread_states_list_lock_bss_get()); + CRYPTO_MUTEX_lock_write(thread_states_list_lock_bss_get()); struct rand_thread_state **states_list = thread_states_list_bss_get(); state->next = *states_list; if (state->next != NULL) { @@ -394,13 +405,20 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len, } state->prev = NULL; *states_list = state; - CRYPTO_STATIC_MUTEX_unlock_write(thread_states_list_lock_bss_get()); + CRYPTO_MUTEX_unlock_write(thread_states_list_lock_bss_get()); } #endif } if (state->calls >= kReseedInterval || - state->fork_generation != fork_generation) { + // If we've forked since |state| was last seeded, reseed. + state->fork_generation != fork_generation || + // If |state| was seeded from a state with different fork-safety + // preferences, reseed. Suppose |state| was fork-safe, then forked into + // two children, but each of the children never fork and disable fork + // safety. The children must reseed to avoid working from the same PRNG + // state. + state->fork_unsafe_buffering != fork_unsafe_buffering) { uint8_t seed[CTR_DRBG_ENTROPY_LEN]; uint8_t reseed_additional_data[CTR_DRBG_ENTROPY_LEN] = {0}; size_t reseed_additional_data_len = 0; @@ -410,7 +428,7 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len, // Take a read lock around accesses to |state->drbg|. This is needed to // avoid returning bad entropy if we race with // |rand_thread_state_clear_all|. - CRYPTO_STATIC_MUTEX_lock_read(state_clear_all_lock_bss_get()); + CRYPTO_MUTEX_lock_read(&state->clear_drbg_lock); #endif if (!CTR_DRBG_reseed(&state->drbg, seed, reseed_additional_data, reseed_additional_data_len)) { @@ -418,9 +436,10 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len, } state->calls = 0; state->fork_generation = fork_generation; + state->fork_unsafe_buffering = fork_unsafe_buffering; } else { #if defined(BORINGSSL_FIPS) - CRYPTO_STATIC_MUTEX_lock_read(state_clear_all_lock_bss_get()); + CRYPTO_MUTEX_lock_read(&state->clear_drbg_lock); #endif } @@ -449,7 +468,7 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len, } #if defined(BORINGSSL_FIPS) - CRYPTO_STATIC_MUTEX_unlock_read(state_clear_all_lock_bss_get()); + CRYPTO_MUTEX_unlock_read(&state->clear_drbg_lock); #endif } diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/urandom.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/urandom.c index b8764139..5af61e91 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/urandom.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rand/urandom.c @@ -20,7 +20,7 @@ #include "internal.h" -#if defined(OPENSSL_URANDOM) +#if defined(OPENSSL_RAND_URANDOM) #include #include @@ -58,16 +58,6 @@ #endif #endif // OPENSSL_LINUX -#if defined(OPENSSL_MACOS) -#include -#endif - -#if defined(OPENSSL_FREEBSD) && __FreeBSD__ >= 12 -// getrandom is supported in FreeBSD 12 and up. -#define FREEBSD_GETRANDOM -#include -#endif - #include #include @@ -173,20 +163,6 @@ static void init_once(void) { } #endif // USE_NR_getrandom -#if defined(OPENSSL_MACOS) - // getentropy is available in macOS 10.12 and up. iOS 10 and up may also - // support it, but the header is missing. See https://crbug.com/boringssl/287. - if (__builtin_available(macos 10.12, *)) { - *urandom_fd_bss_get() = kHaveGetrandom; - return; - } -#endif - -#if defined(FREEBSD_GETRANDOM) - *urandom_fd_bss_get() = kHaveGetrandom; - return; -#endif - // FIPS builds must support getrandom. // // Historically, only Android FIPS builds required getrandom, while Linux FIPS @@ -298,21 +274,6 @@ static int fill_with_entropy(uint8_t *out, size_t len, int block, int seed) { if (*urandom_fd_bss_get() == kHaveGetrandom) { #if defined(USE_NR_getrandom) r = boringssl_getrandom(out, len, getrandom_flags); -#elif defined(FREEBSD_GETRANDOM) - r = getrandom(out, len, getrandom_flags); -#elif defined(OPENSSL_MACOS) - if (__builtin_available(macos 10.12, *)) { - // |getentropy| can only request 256 bytes at a time. - size_t todo = len <= 256 ? len : 256; - if (getentropy(out, todo) != 0) { - r = -1; - } else { - r = (ssize_t)todo; - } - } else { - fprintf(stderr, "urandom fd corrupt.\n"); - abort(); - } #else // USE_NR_getrandom fprintf(stderr, "urandom fd corrupt.\n"); abort(); @@ -364,4 +325,4 @@ int CRYPTO_sysrand_if_available(uint8_t *out, size_t requested) { } } -#endif // OPENSSL_URANDOM +#endif // OPENSSL_RAND_URANDOM diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rdrand-x86_64-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rdrand-x86_64-linux.linux.x86_64.S index f5431282..99452567 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rdrand-x86_64-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rdrand-x86_64-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text @@ -24,6 +17,7 @@ .align 16 CRYPTO_rdrand: .cfi_startproc +_CET_ENDBR xorq %rax,%rax .byte 72,15,199,242 @@ -43,6 +37,7 @@ CRYPTO_rdrand: .align 16 CRYPTO_rdrand_multiple8_buf: .cfi_startproc +_CET_ENDBR testq %rsi,%rsi jz .Lout movq $8,%rdx @@ -62,10 +57,6 @@ CRYPTO_rdrand_multiple8_buf: .cfi_endproc .size CRYPTO_rdrand_multiple8_buf,.-CRYPTO_rdrand_multiple8_buf #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rdrand-x86_64-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rdrand-x86_64-mac.mac.x86_64.S index 46c21364..82a1b756 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rdrand-x86_64-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rdrand-x86_64-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text @@ -24,6 +17,7 @@ .p2align 4 _CRYPTO_rdrand: +_CET_ENDBR xorq %rax,%rax .byte 72,15,199,242 @@ -43,6 +37,7 @@ _CRYPTO_rdrand: .p2align 4 _CRYPTO_rdrand_multiple8_buf: +_CET_ENDBR testq %rsi,%rsi jz L$out movq $8,%rdx @@ -61,10 +56,6 @@ L$err: .byte 0xf3,0xc3 -#endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits #endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsa/internal.h b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsa/internal.h index 456eea2d..930dc387 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsa/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsa/internal.h @@ -60,13 +60,69 @@ #include #include +#include +#include "../../internal.h" #if defined(__cplusplus) extern "C" { #endif +typedef struct bn_blinding_st BN_BLINDING; + +struct rsa_st { + RSA_METHOD *meth; + + BIGNUM *n; + BIGNUM *e; + BIGNUM *d; + BIGNUM *p; + BIGNUM *q; + BIGNUM *dmp1; + BIGNUM *dmq1; + BIGNUM *iqmp; + + // be careful using this if the RSA structure is shared + CRYPTO_EX_DATA ex_data; + CRYPTO_refcount_t references; + int flags; + + CRYPTO_MUTEX lock; + + // Used to cache montgomery values. The creation of these values is protected + // by |lock|. + BN_MONT_CTX *mont_n; + BN_MONT_CTX *mont_p; + BN_MONT_CTX *mont_q; + + // The following fields are copies of |d|, |dmp1|, and |dmq1|, respectively, + // but with the correct widths to prevent side channels. These must use + // separate copies due to threading concerns caused by OpenSSL's API + // mistakes. See https://github.com/openssl/openssl/issues/5158 and + // the |freeze_private_key| implementation. + BIGNUM *d_fixed, *dmp1_fixed, *dmq1_fixed; + + // iqmp_mont is q^-1 mod p in Montgomery form, using |mont_p|. + BIGNUM *iqmp_mont; + + // num_blindings contains the size of the |blindings| and |blindings_inuse| + // arrays. This member and the |blindings_inuse| array are protected by + // |lock|. + size_t num_blindings; + // blindings is an array of BN_BLINDING structures that can be reserved by a + // thread by locking |lock| and changing the corresponding element in + // |blindings_inuse| from 0 to 1. + BN_BLINDING **blindings; + unsigned char *blindings_inuse; + uint64_t blinding_fork_generation; + + // private_key_frozen is one if the key has been used for a private key + // operation and may no longer be mutated. + unsigned private_key_frozen:1; +}; + + #define RSA_PKCS1_PADDING_SIZE 11 // Default implementations of RSA operations. @@ -116,6 +172,12 @@ int rsa_private_transform_no_self_test(RSA *rsa, uint8_t *out, int rsa_private_transform(RSA *rsa, uint8_t *out, const uint8_t *in, size_t len); +// rsa_invalidate_key is called after |rsa| has been mutated, to invalidate +// fields derived from the original structure. This function assumes exclusive +// access to |rsa|. In particular, no other thread may be concurrently signing, +// etc., with |rsa|. +void rsa_invalidate_key(RSA *rsa); + // This constant is exported for test purposes. extern const BN_ULONG kBoringSSLRSASqrtTwo[]; diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsa/rsa.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsa/rsa.c index 4ad92abc..762d5758 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsa/rsa.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsa/rsa.c @@ -83,6 +83,126 @@ OPENSSL_DECLARE_ERROR_REASON(RSA, BLOCK_TYPE_IS_NOT_02) DEFINE_STATIC_EX_DATA_CLASS(g_rsa_ex_data_class) +static int bn_dup_into(BIGNUM **dst, const BIGNUM *src) { + if (src == NULL) { + OPENSSL_PUT_ERROR(RSA, ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + + BN_free(*dst); + *dst = BN_dup(src); + return *dst != NULL; +} + +RSA *RSA_new_public_key(const BIGNUM *n, const BIGNUM *e) { + RSA *rsa = RSA_new(); + if (rsa == NULL || // + !bn_dup_into(&rsa->n, n) || // + !bn_dup_into(&rsa->e, e) || // + !RSA_check_key(rsa)) { + RSA_free(rsa); + return NULL; + } + + return rsa; +} + +RSA *RSA_new_private_key(const BIGNUM *n, const BIGNUM *e, const BIGNUM *d, + const BIGNUM *p, const BIGNUM *q, const BIGNUM *dmp1, + const BIGNUM *dmq1, const BIGNUM *iqmp) { + RSA *rsa = RSA_new(); + if (rsa == NULL || // + !bn_dup_into(&rsa->n, n) || // + !bn_dup_into(&rsa->e, e) || // + !bn_dup_into(&rsa->d, d) || // + !bn_dup_into(&rsa->p, p) || // + !bn_dup_into(&rsa->q, q) || // + !bn_dup_into(&rsa->dmp1, dmp1) || // + !bn_dup_into(&rsa->dmq1, dmq1) || // + !bn_dup_into(&rsa->iqmp, iqmp) || // + !RSA_check_key(rsa)) { + RSA_free(rsa); + return NULL; + } + + return rsa; +} + +RSA *RSA_new_private_key_no_crt(const BIGNUM *n, const BIGNUM *e, + const BIGNUM *d) { + RSA *rsa = RSA_new(); + if (rsa == NULL || // + !bn_dup_into(&rsa->n, n) || // + !bn_dup_into(&rsa->e, e) || // + !bn_dup_into(&rsa->d, d) || // + !RSA_check_key(rsa)) { + RSA_free(rsa); + return NULL; + } + + return rsa; +} + +RSA *RSA_new_private_key_no_e(const BIGNUM *n, const BIGNUM *d) { + RSA *rsa = RSA_new(); + if (rsa == NULL) { + return NULL; + } + + rsa->flags |= RSA_FLAG_NO_PUBLIC_EXPONENT; + if (!bn_dup_into(&rsa->n, n) || // + !bn_dup_into(&rsa->d, d) || // + !RSA_check_key(rsa)) { + RSA_free(rsa); + return NULL; + } + + return rsa; +} + +RSA *RSA_new_public_key_large_e(const BIGNUM *n, const BIGNUM *e) { + RSA *rsa = RSA_new(); + if (rsa == NULL) { + return NULL; + } + + rsa->flags |= RSA_FLAG_LARGE_PUBLIC_EXPONENT; + if (!bn_dup_into(&rsa->n, n) || // + !bn_dup_into(&rsa->e, e) || // + !RSA_check_key(rsa)) { + RSA_free(rsa); + return NULL; + } + + return rsa; +} + +RSA *RSA_new_private_key_large_e(const BIGNUM *n, const BIGNUM *e, + const BIGNUM *d, const BIGNUM *p, + const BIGNUM *q, const BIGNUM *dmp1, + const BIGNUM *dmq1, const BIGNUM *iqmp) { + RSA *rsa = RSA_new(); + if (rsa == NULL) { + return NULL; + } + + rsa->flags |= RSA_FLAG_LARGE_PUBLIC_EXPONENT; + if (!bn_dup_into(&rsa->n, n) || // + !bn_dup_into(&rsa->e, e) || // + !bn_dup_into(&rsa->d, d) || // + !bn_dup_into(&rsa->p, p) || // + !bn_dup_into(&rsa->q, q) || // + !bn_dup_into(&rsa->dmp1, dmp1) || // + !bn_dup_into(&rsa->dmq1, dmq1) || // + !bn_dup_into(&rsa->iqmp, iqmp) || // + !RSA_check_key(rsa)) { + RSA_free(rsa); + return NULL; + } + + return rsa; +} + RSA *RSA_new(void) { return RSA_new_method(NULL); } RSA *RSA_new_method(const ENGINE *engine) { @@ -118,9 +238,18 @@ RSA *RSA_new_method(const ENGINE *engine) { return rsa; } -void RSA_free(RSA *rsa) { - unsigned u; +RSA *RSA_new_method_no_e(const ENGINE *engine, const BIGNUM *n) { + RSA *rsa = RSA_new_method(engine); + if (rsa == NULL || + !bn_dup_into(&rsa->n, n)) { + RSA_free(rsa); + return NULL; + } + rsa->flags |= RSA_FLAG_NO_PUBLIC_EXPONENT; + return rsa; +} +void RSA_free(RSA *rsa) { if (rsa == NULL) { return; } @@ -144,18 +273,7 @@ void RSA_free(RSA *rsa) { BN_free(rsa->dmp1); BN_free(rsa->dmq1); BN_free(rsa->iqmp); - BN_MONT_CTX_free(rsa->mont_n); - BN_MONT_CTX_free(rsa->mont_p); - BN_MONT_CTX_free(rsa->mont_q); - BN_free(rsa->d_fixed); - BN_free(rsa->dmp1_fixed); - BN_free(rsa->dmq1_fixed); - BN_free(rsa->inv_small_mod_large_mont); - for (u = 0; u < rsa->num_blindings; u++) { - BN_BLINDING_free(rsa->blindings[u]); - } - OPENSSL_free(rsa->blindings); - OPENSSL_free(rsa->blindings_inuse); + rsa_invalidate_key(rsa); CRYPTO_MUTEX_cleanup(&rsa->lock); OPENSSL_free(rsa); } @@ -244,6 +362,7 @@ int RSA_set0_key(RSA *rsa, BIGNUM *n, BIGNUM *e, BIGNUM *d) { rsa->d = d; } + rsa_invalidate_key(rsa); return 1; } @@ -262,6 +381,7 @@ int RSA_set0_factors(RSA *rsa, BIGNUM *p, BIGNUM *q) { rsa->q = q; } + rsa_invalidate_key(rsa); return 1; } @@ -285,6 +405,7 @@ int RSA_set0_crt_params(RSA *rsa, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) { rsa->iqmp = iqmp; } + rsa_invalidate_key(rsa); return 1; } diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsa/rsa_impl.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsa/rsa_impl.c index 2ac674a7..57928c0e 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsa/rsa_impl.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsa/rsa_impl.c @@ -74,53 +74,72 @@ int rsa_check_public_key(const RSA *rsa) { - if (rsa->n == NULL || rsa->e == NULL) { + if (rsa->n == NULL) { OPENSSL_PUT_ERROR(RSA, RSA_R_VALUE_MISSING); return 0; } + // TODO(davidben): 16384-bit RSA is huge. Can we bring this down to a limit of + // 8192-bit? unsigned n_bits = BN_num_bits(rsa->n); if (n_bits > 16 * 1024) { OPENSSL_PUT_ERROR(RSA, RSA_R_MODULUS_TOO_LARGE); return 0; } - // RSA moduli must be odd. In addition to being necessary for RSA in general, - // we cannot setup Montgomery reduction with even moduli. - if (!BN_is_odd(rsa->n)) { + // TODO(crbug.com/boringssl/607): Raise this limit. 512-bit RSA was factored + // in 1999. + if (n_bits < 512) { + OPENSSL_PUT_ERROR(RSA, RSA_R_KEY_SIZE_TOO_SMALL); + return 0; + } + + // RSA moduli must be positive and odd. In addition to being necessary for RSA + // in general, we cannot setup Montgomery reduction with even moduli. + if (!BN_is_odd(rsa->n) || BN_is_negative(rsa->n)) { OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_RSA_PARAMETERS); return 0; } - // Mitigate DoS attacks by limiting the exponent size. 33 bits was chosen as - // the limit based on the recommendations in [1] and [2]. Windows CryptoAPI - // doesn't support values larger than 32 bits [3], so it is unlikely that - // exponents larger than 32 bits are being used for anything Windows commonly - // does. - // - // [1] https://www.imperialviolet.org/2012/03/16/rsae.html - // [2] https://www.imperialviolet.org/2012/03/17/rsados.html - // [3] https://msdn.microsoft.com/en-us/library/aa387685(VS.85).aspx static const unsigned kMaxExponentBits = 33; - unsigned e_bits = BN_num_bits(rsa->e); - if (e_bits > kMaxExponentBits || - // Additionally reject e = 1 or even e. e must be odd to be relatively - // prime with phi(n). - e_bits < 2 || - !BN_is_odd(rsa->e)) { - OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_E_VALUE); - return 0; - } + if (rsa->e != NULL) { + // Reject e = 1, negative e, and even e. e must be odd to be relatively + // prime with phi(n). + unsigned e_bits = BN_num_bits(rsa->e); + if (e_bits < 2 || BN_is_negative(rsa->e) || !BN_is_odd(rsa->e)) { + OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_E_VALUE); + return 0; + } + if (rsa->flags & RSA_FLAG_LARGE_PUBLIC_EXPONENT) { + // The caller has requested disabling DoS protections. Still, e must be + // less than n. + if (BN_ucmp(rsa->n, rsa->e) <= 0) { + OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_E_VALUE); + return 0; + } + } else { + // Mitigate DoS attacks by limiting the exponent size. 33 bits was chosen + // as the limit based on the recommendations in [1] and [2]. Windows + // CryptoAPI doesn't support values larger than 32 bits [3], so it is + // unlikely that exponents larger than 32 bits are being used for anything + // Windows commonly does. + // + // [1] https://www.imperialviolet.org/2012/03/16/rsae.html + // [2] https://www.imperialviolet.org/2012/03/17/rsados.html + // [3] https://msdn.microsoft.com/en-us/library/aa387685(VS.85).aspx + if (e_bits > kMaxExponentBits) { + OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_E_VALUE); + return 0; + } - // Verify |n > e|. Comparing |n_bits| to |kMaxExponentBits| is a small - // shortcut to comparing |n| and |e| directly. In reality, |kMaxExponentBits| - // is much smaller than the minimum RSA key size that any application should - // accept. - if (n_bits <= kMaxExponentBits) { - OPENSSL_PUT_ERROR(RSA, RSA_R_KEY_SIZE_TOO_SMALL); + // The upper bound on |e_bits| and lower bound on |n_bits| imply e is + // bounded by n. + assert(BN_ucmp(rsa->n, rsa->e) > 0); + } + } else if (!(rsa->flags & RSA_FLAG_NO_PUBLIC_EXPONENT)) { + OPENSSL_PUT_ERROR(RSA, RSA_R_VALUE_MISSING); return 0; } - assert(BN_ucmp(rsa->n, rsa->e) > 0); return 1; } @@ -160,6 +179,11 @@ static int freeze_private_key(RSA *rsa, BN_CTX *ctx) { goto err; } + // Check the public components are within DoS bounds. + if (!rsa_check_public_key(rsa)) { + goto err; + } + // Pre-compute various intermediate values, as well as copies of private // exponents with correct widths. Note that other threads may concurrently // read from |rsa->n|, |rsa->e|, etc., so any fixes must be in separate @@ -183,7 +207,7 @@ static int freeze_private_key(RSA *rsa, BN_CTX *ctx) { goto err; } - if (rsa->p != NULL && rsa->q != NULL) { + if (rsa->e != NULL && rsa->p != NULL && rsa->q != NULL) { // TODO: p and q are also CONSTTIME_SECRET but not yet marked as such // because the Montgomery code does things like test whether or not values // are zero. So the secret marking probably needs to happen inside that @@ -219,37 +243,24 @@ static int freeze_private_key(RSA *rsa, BN_CTX *ctx) { } // CRT components are only publicly bounded by their corresponding - // moduli's bit lengths. |rsa->iqmp| is unused outside of this one-time - // setup, so we do not compute a fixed-width version of it. + // moduli's bit lengths. if (!ensure_fixed_copy(&rsa->dmp1_fixed, rsa->dmp1, p_fixed->width) || !ensure_fixed_copy(&rsa->dmq1_fixed, rsa->dmq1, q_fixed->width)) { goto err; } - // Compute |inv_small_mod_large_mont|. Note that it is always modulo the - // larger prime, independent of what is stored in |rsa->iqmp|. - if (rsa->inv_small_mod_large_mont == NULL) { - BIGNUM *inv_small_mod_large_mont = BN_new(); - int ok; - if (BN_cmp(rsa->p, rsa->q) < 0) { - ok = inv_small_mod_large_mont != NULL && - bn_mod_inverse_secret_prime(inv_small_mod_large_mont, rsa->p, - rsa->q, ctx, rsa->mont_q) && - BN_to_montgomery(inv_small_mod_large_mont, - inv_small_mod_large_mont, rsa->mont_q, ctx); - } else { - ok = inv_small_mod_large_mont != NULL && - BN_to_montgomery(inv_small_mod_large_mont, rsa->iqmp, - rsa->mont_p, ctx); - } - if (!ok) { - BN_free(inv_small_mod_large_mont); + // Compute |iqmp_mont|, which is |iqmp| in Montgomery form and with the + // correct bit width. + if (rsa->iqmp_mont == NULL) { + BIGNUM *iqmp_mont = BN_new(); + if (iqmp_mont == NULL || + !BN_to_montgomery(iqmp_mont, rsa->iqmp, rsa->mont_p, ctx)) { + BN_free(iqmp_mont); goto err; } - rsa->inv_small_mod_large_mont = inv_small_mod_large_mont; - CONSTTIME_SECRET( - rsa->inv_small_mod_large_mont->d, - sizeof(BN_ULONG) * rsa->inv_small_mod_large_mont->width); + rsa->iqmp_mont = iqmp_mont; + CONSTTIME_SECRET(rsa->iqmp_mont->d, + sizeof(BN_ULONG) * rsa->iqmp_mont->width); } } } @@ -262,6 +273,36 @@ err: return ret; } +void rsa_invalidate_key(RSA *rsa) { + rsa->private_key_frozen = 0; + + BN_MONT_CTX_free(rsa->mont_n); + rsa->mont_n = NULL; + BN_MONT_CTX_free(rsa->mont_p); + rsa->mont_p = NULL; + BN_MONT_CTX_free(rsa->mont_q); + rsa->mont_q = NULL; + + BN_free(rsa->d_fixed); + rsa->d_fixed = NULL; + BN_free(rsa->dmp1_fixed); + rsa->dmp1_fixed = NULL; + BN_free(rsa->dmq1_fixed); + rsa->dmq1_fixed = NULL; + BN_free(rsa->iqmp_mont); + rsa->iqmp_mont = NULL; + + for (size_t i = 0; i < rsa->num_blindings; i++) { + BN_BLINDING_free(rsa->blindings[i]); + } + OPENSSL_free(rsa->blindings); + rsa->blindings = NULL; + rsa->num_blindings = 0; + OPENSSL_free(rsa->blindings_inuse); + rsa->blindings_inuse = NULL; + rsa->blinding_fork_generation = 0; +} + size_t rsa_default_size(const RSA *rsa) { return BN_num_bytes(rsa->n); } @@ -448,6 +489,11 @@ static int mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx); int rsa_verify_raw_no_self_test(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, const uint8_t *in, size_t in_len, int padding) { + if (rsa->n == NULL || rsa->e == NULL) { + OPENSSL_PUT_ERROR(RSA, RSA_R_VALUE_MISSING); + return 0; + } + if (!rsa_check_public_key(rsa)) { return 0; } @@ -587,13 +633,18 @@ int rsa_default_private_transform(RSA *rsa, uint8_t *out, const uint8_t *in, goto err; } - const int do_blinding = (rsa->flags & RSA_FLAG_NO_BLINDING) == 0; + const int do_blinding = + (rsa->flags & (RSA_FLAG_NO_BLINDING | RSA_FLAG_NO_PUBLIC_EXPONENT)) == 0; if (rsa->e == NULL && do_blinding) { // We cannot do blinding or verification without |e|, and continuing without // those countermeasures is dangerous. However, the Java/Android RSA API // requires support for keys where only |d| and |n| (and not |e|) are known. - // The callers that require that bad behavior set |RSA_FLAG_NO_BLINDING|. + // The callers that require that bad behavior must set + // |RSA_FLAG_NO_BLINDING| or use |RSA_new_private_key_no_e|. + // + // TODO(davidben): Update this comment when Conscrypt is updated to use + // |RSA_new_private_key_no_e|. OPENSSL_PUT_ERROR(RSA, RSA_R_NO_PUBLIC_EXPONENT); goto err; } @@ -734,42 +785,37 @@ static int mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) { goto err; } - // Implementing RSA with CRT in constant-time is sensitive to which prime is - // larger. Canonicalize fields so that |p| is the larger prime. - const BIGNUM *dmp1 = rsa->dmp1_fixed, *dmq1 = rsa->dmq1_fixed; - const BN_MONT_CTX *mont_p = rsa->mont_p, *mont_q = rsa->mont_q; - if (BN_cmp(rsa->p, rsa->q) < 0) { - mont_p = rsa->mont_q; - mont_q = rsa->mont_p; - dmp1 = rsa->dmq1_fixed; - dmq1 = rsa->dmp1_fixed; - } - // Use the minimal-width versions of |n|, |p|, and |q|. Either works, but if // someone gives us non-minimal values, these will be slightly more efficient // on the non-Montgomery operations. const BIGNUM *n = &rsa->mont_n->N; - const BIGNUM *p = &mont_p->N; - const BIGNUM *q = &mont_q->N; + const BIGNUM *p = &rsa->mont_p->N; + const BIGNUM *q = &rsa->mont_q->N; // This is a pre-condition for |mod_montgomery|. It was already checked by the // caller. assert(BN_ucmp(I, n) < 0); if (// |m1| is the result modulo |q|. - !mod_montgomery(r1, I, q, mont_q, p, ctx) || - !BN_mod_exp_mont_consttime(m1, r1, dmq1, q, ctx, mont_q) || + !mod_montgomery(r1, I, q, rsa->mont_q, p, ctx) || + !BN_mod_exp_mont_consttime(m1, r1, rsa->dmq1_fixed, q, ctx, + rsa->mont_q) || // |r0| is the result modulo |p|. - !mod_montgomery(r1, I, p, mont_p, q, ctx) || - !BN_mod_exp_mont_consttime(r0, r1, dmp1, p, ctx, mont_p) || - // Compute r0 = r0 - m1 mod p. |p| is the larger prime, so |m1| is already - // fully reduced mod |p|. - !bn_mod_sub_consttime(r0, r0, m1, p, ctx) || + !mod_montgomery(r1, I, p, rsa->mont_p, q, ctx) || + !BN_mod_exp_mont_consttime(r0, r1, rsa->dmp1_fixed, p, ctx, + rsa->mont_p) || + // Compute r0 = r0 - m1 mod p. |m1| is reduced mod |q|, not |p|, so we + // just run |mod_montgomery| again for simplicity. This could be more + // efficient with more cases: if |p > q|, |m1| is already reduced. If + // |p < q| but they have the same bit width, |bn_reduce_once| suffices. + // However, compared to over 2048 Montgomery multiplications above, this + // difference is not measurable. + !mod_montgomery(r1, m1, p, rsa->mont_p, q, ctx) || + !bn_mod_sub_consttime(r0, r0, r1, p, ctx) || // r0 = r0 * iqmp mod p. We use Montgomery multiplication to compute this - // in constant time. |inv_small_mod_large_mont| is in Montgomery form and - // r0 is not, so the result is taken out of Montgomery form. - !BN_mod_mul_montgomery(r0, r0, rsa->inv_small_mod_large_mont, mont_p, - ctx) || + // in constant time. |iqmp_mont| is in Montgomery form and r0 is not, so + // the result is taken out of Montgomery form. + !BN_mod_mul_montgomery(r0, r0, rsa->iqmp_mont, rsa->mont_p, ctx) || // r0 = r0 * q + m1 gives the final result. Reducing modulo q gives m1, so // it is correct mod p. Reducing modulo p gives (r0-m1)*iqmp*q + m1 = r0, // so it is correct mod q. Finally, the result is bounded by [m1, n + m1), @@ -1229,6 +1275,7 @@ static int RSA_generate_key_ex_maybe_fips(RSA *rsa, int bits, goto out; } + rsa_invalidate_key(rsa); replace_bignum(&rsa->n, &tmp->n); replace_bignum(&rsa->e, &tmp->e); replace_bignum(&rsa->d, &tmp->d); @@ -1243,8 +1290,7 @@ static int RSA_generate_key_ex_maybe_fips(RSA *rsa, int bits, replace_bignum(&rsa->d_fixed, &tmp->d_fixed); replace_bignum(&rsa->dmp1_fixed, &tmp->dmp1_fixed); replace_bignum(&rsa->dmq1_fixed, &tmp->dmq1_fixed); - replace_bignum(&rsa->inv_small_mod_large_mont, - &tmp->inv_small_mod_large_mont); + replace_bignum(&rsa->iqmp_mont, &tmp->iqmp_mont); rsa->private_key_frozen = tmp->private_key_frozen; ret = 1; diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsaz-avx2-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsaz-avx2-linux.linux.x86_64.S index 333560c8..5de69d46 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsaz-avx2-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsaz-avx2-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .globl rsaz_1024_sqr_avx2 @@ -21,6 +14,7 @@ .align 64 rsaz_1024_sqr_avx2: .cfi_startproc +_CET_ENDBR leaq (%rsp),%rax .cfi_def_cfa_register %rax pushq %rbx @@ -675,6 +669,7 @@ rsaz_1024_sqr_avx2: .align 64 rsaz_1024_mul_avx2: .cfi_startproc +_CET_ENDBR leaq (%rsp),%rax .cfi_def_cfa_register %rax pushq %rbx @@ -1231,6 +1226,7 @@ rsaz_1024_mul_avx2: .align 32 rsaz_1024_red2norm_avx2: .cfi_startproc +_CET_ENDBR subq $-128,%rsi xorq %rax,%rax movq -128(%rsi),%r8 @@ -1431,6 +1427,7 @@ rsaz_1024_red2norm_avx2: .align 32 rsaz_1024_norm2red_avx2: .cfi_startproc +_CET_ENDBR subq $-128,%rdi movq (%rsi),%r8 movl $0x1fffffff,%eax @@ -1591,6 +1588,7 @@ rsaz_1024_norm2red_avx2: .align 32 rsaz_1024_scatter5_avx2: .cfi_startproc +_CET_ENDBR vzeroupper vmovdqu .Lscatter_permd(%rip),%ymm5 shll $4,%edx @@ -1619,6 +1617,7 @@ rsaz_1024_scatter5_avx2: .align 32 rsaz_1024_gather5_avx2: .cfi_startproc +_CET_ENDBR vzeroupper movq %rsp,%r11 .cfi_def_cfa_register %r11 @@ -1750,10 +1749,6 @@ rsaz_1024_gather5_avx2: .align 64 .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsaz-avx2-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsaz-avx2-mac.mac.x86_64.S index 37a1097b..4f3f9bad 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsaz-avx2-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/rsaz-avx2-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text .globl _rsaz_1024_sqr_avx2 @@ -21,6 +14,7 @@ .p2align 6 _rsaz_1024_sqr_avx2: +_CET_ENDBR leaq (%rsp),%rax pushq %rbx @@ -675,6 +669,7 @@ L$sqr_1024_epilogue: .p2align 6 _rsaz_1024_mul_avx2: +_CET_ENDBR leaq (%rsp),%rax pushq %rbx @@ -1231,6 +1226,7 @@ L$mul_1024_epilogue: .p2align 5 _rsaz_1024_red2norm_avx2: +_CET_ENDBR subq $-128,%rsi xorq %rax,%rax movq -128(%rsi),%r8 @@ -1431,6 +1427,7 @@ _rsaz_1024_red2norm_avx2: .p2align 5 _rsaz_1024_norm2red_avx2: +_CET_ENDBR subq $-128,%rdi movq (%rsi),%r8 movl $0x1fffffff,%eax @@ -1591,6 +1588,7 @@ _rsaz_1024_norm2red_avx2: .p2align 5 _rsaz_1024_scatter5_avx2: +_CET_ENDBR vzeroupper vmovdqu L$scatter_permd(%rip),%ymm5 shll $4,%edx @@ -1619,6 +1617,7 @@ L$oop_scatter_1024: .p2align 5 _rsaz_1024_gather5_avx2: +_CET_ENDBR vzeroupper movq %rsp,%r11 @@ -1750,10 +1749,6 @@ L$inc: .p2align 6 .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/self_check/self_check.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/self_check/self_check.c index b9768432..26439fc5 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/self_check/self_check.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/self_check/self_check.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -248,11 +249,12 @@ static EC_KEY *self_test_ecdsa_key(void) { 0x93, 0x8b, 0x74, 0xf2, 0xbc, 0xc5, 0x30, 0x52, 0xb0, 0x77, }; - EC_KEY *ec_key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); + EC_KEY *ec_key = EC_KEY_new(); BIGNUM *qx = BN_bin2bn(kQx, sizeof(kQx), NULL); BIGNUM *qy = BN_bin2bn(kQy, sizeof(kQy), NULL); BIGNUM *d = BN_bin2bn(kD, sizeof(kD), NULL); if (ec_key == NULL || qx == NULL || qy == NULL || d == NULL || + !EC_KEY_set_group(ec_key, EC_group_p256()) || !EC_KEY_set_public_key_affine_coordinates(ec_key, qx, qy) || !EC_KEY_set_private_key(ec_key, d)) { EC_KEY_free(ec_key); @@ -410,7 +412,6 @@ err: static int boringssl_self_test_ecc(void) { int ret = 0; EC_KEY *ec_key = NULL; - EC_GROUP *ec_group = NULL; EC_POINT *ec_point_in = NULL; EC_POINT *ec_point_out = NULL; BIGNUM *ec_scalar = NULL; @@ -505,11 +506,7 @@ static int boringssl_self_test_ecc(void) { 0x7c, 0x41, 0x8f, 0xaf, 0x9c, 0x40, 0xaf, 0x2e, 0x4a, 0x0c, }; - ec_group = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1); - if (ec_group == NULL) { - fprintf(stderr, "Failed to create P-256 group.\n"); - goto err; - } + const EC_GROUP *ec_group = EC_group_p256(); ec_point_in = EC_POINT_new(ec_group); ec_point_out = EC_POINT_new(ec_group); ec_scalar = BN_new(); @@ -534,7 +531,6 @@ err: EC_KEY_free(ec_key); EC_POINT_free(ec_point_in); EC_POINT_free(ec_point_out); - EC_GROUP_free(ec_group); BN_free(ec_scalar); ECDSA_SIG_free(sig); @@ -917,11 +913,6 @@ static int boringssl_self_test_fast(void) { } // TLS KDF KAT - static const uint8_t kTLSSecret[32] = { - 0xab, 0xc3, 0x65, 0x7b, 0x09, 0x4c, 0x76, 0x28, 0xa0, 0xb2, 0x82, - 0x99, 0x6f, 0xe7, 0x5a, 0x75, 0xf4, 0x98, 0x4f, 0xd9, 0x4d, 0x4e, - 0xcc, 0x2f, 0xcf, 0x53, 0xa2, 0xc4, 0x69, 0xa3, 0xf7, 0x31, - }; static const char kTLSLabel[] = "FIPS self test"; static const uint8_t kTLSSeed1[16] = { 0x8f, 0x0d, 0xe8, 0xb6, 0x90, 0x8f, 0xb1, 0xd2, @@ -931,21 +922,119 @@ static int boringssl_self_test_fast(void) { 0x7d, 0x24, 0x1a, 0x9d, 0x3c, 0x59, 0xbf, 0x3c, 0x31, 0x1e, 0x2b, 0x21, 0x41, 0x8d, 0x32, 0x81, }; - static const uint8_t kTLSOutput[32] = { - 0xe2, 0x1d, 0xd6, 0xc2, 0x68, 0xc7, 0x57, 0x03, 0x2c, 0x2c, 0xeb, - 0xbb, 0xb8, 0xa9, 0x7d, 0xe9, 0xee, 0xe6, 0xc9, 0x47, 0x83, 0x0a, - 0xbd, 0x11, 0x60, 0x5d, 0xd5, 0x2c, 0x47, 0xb6, 0x05, 0x88, + + static const uint8_t kTLS10Secret[32] = { + 0xab, 0xc3, 0x65, 0x7b, 0x09, 0x4c, 0x76, 0x28, 0xa0, 0xb2, 0x82, + 0x99, 0x6f, 0xe7, 0x5a, 0x75, 0xf4, 0x98, 0x4f, 0xd9, 0x4d, 0x4e, + 0xcc, 0x2f, 0xcf, 0x53, 0xa2, 0xc4, 0x69, 0xa3, 0xf7, 0x31, }; - uint8_t tls_output[sizeof(kTLSOutput)]; - if (!CRYPTO_tls1_prf(EVP_sha256(), tls_output, sizeof(tls_output), kTLSSecret, - sizeof(kTLSSecret), kTLSLabel, sizeof(kTLSLabel), - kTLSSeed1, sizeof(kTLSSeed1), kTLSSeed2, - sizeof(kTLSSeed2)) || - !check_test(kTLSOutput, tls_output, sizeof(kTLSOutput), "TLS-KDF KAT")) { + static const uint8_t kTLS10Output[32] = { + 0x69, 0x7c, 0x4e, 0x2c, 0xee, 0x82, 0xb1, 0xd2, 0x8b, 0xac, 0x90, + 0x7a, 0xa1, 0x8a, 0x81, 0xfe, 0xc5, 0x58, 0x45, 0x57, 0x61, 0x2f, + 0x7a, 0x8d, 0x80, 0xfb, 0x44, 0xd8, 0x81, 0x60, 0xe5, 0xf8, + }; + uint8_t tls10_output[sizeof(kTLS10Output)]; + if (!CRYPTO_tls1_prf(EVP_md5_sha1(), tls10_output, sizeof(tls10_output), + kTLS10Secret, sizeof(kTLS10Secret), kTLSLabel, + sizeof(kTLSLabel), kTLSSeed1, sizeof(kTLSSeed1), + kTLSSeed2, sizeof(kTLSSeed2)) || + !check_test(kTLS10Output, tls10_output, sizeof(kTLS10Output), + "TLS10-KDF KAT")) { fprintf(stderr, "TLS KDF failed.\n"); goto err; } + static const uint8_t kTLS12Secret[32] = { + 0xc5, 0x43, 0x8e, 0xe2, 0x6f, 0xd4, 0xac, 0xbd, 0x25, 0x9f, 0xc9, + 0x18, 0x55, 0xdc, 0x69, 0xbf, 0x88, 0x4e, 0xe2, 0x93, 0x22, 0xfc, + 0xbf, 0xd2, 0x96, 0x6a, 0x46, 0x23, 0xd4, 0x2e, 0xc7, 0x81, + }; + static const uint8_t kTLS12Output[32] = { + 0xee, 0x4a, 0xcd, 0x3f, 0xa3, 0xd3, 0x55, 0x89, 0x9e, 0x6f, 0xf1, + 0x38, 0x46, 0x9d, 0x2b, 0x33, 0xaa, 0x7f, 0xc4, 0x7f, 0x51, 0x85, + 0x8a, 0xf3, 0x13, 0x84, 0xbf, 0x53, 0x6a, 0x65, 0x37, 0x51, + }; + uint8_t tls12_output[sizeof(kTLS12Output)]; + if (!CRYPTO_tls1_prf(EVP_sha256(), tls12_output, sizeof(tls12_output), + kTLS12Secret, sizeof(kTLS12Secret), kTLSLabel, + sizeof(kTLSLabel), kTLSSeed1, sizeof(kTLSSeed1), + kTLSSeed2, sizeof(kTLSSeed2)) || + !check_test(kTLS12Output, tls12_output, sizeof(kTLS12Output), + "TLS12-KDF KAT")) { + fprintf(stderr, "TLS KDF failed.\n"); + goto err; + } + + // TLS v1.3: derives a dummy client-early-traffic secret. + static const uint8_t kTLS13Secret[32] = { + 0x02, 0x4a, 0x0d, 0x80, 0xf3, 0x57, 0xf2, 0x49, 0x9a, 0x12, 0x44, + 0xda, 0xc2, 0x6d, 0xab, 0x66, 0xfc, 0x13, 0xed, 0x85, 0xfc, 0xa7, + 0x1d, 0xac, 0xe1, 0x46, 0x21, 0x11, 0x19, 0x52, 0x58, 0x74, + }; + static const uint8_t kTLS13Salt[16] = { + 0x54, 0x61, 0x11, 0x36, 0x75, 0x91, 0xf0, 0xf8, + 0x92, 0xec, 0x70, 0xbd, 0x78, 0x2a, 0xef, 0x61, + }; + static const uint8_t kTLS13Label[] = "c e traffic"; + static const uint8_t kTLS13ClientHelloHash[32] = { + 0x1d, 0xe8, 0x67, 0xed, 0x93, 0x6a, 0x73, 0x65, 0x9b, 0x05, 0xcf, + 0x8a, 0x22, 0x77, 0xb7, 0x37, 0x29, 0xf2, 0x44, 0x94, 0x81, 0x6a, + 0x83, 0x33, 0x7f, 0x09, 0xbb, 0x6c, 0xc2, 0x6f, 0x48, 0x9c, + }; + static const uint8_t kTLS13ExpandLabelOutput[32] = { + 0x62, 0x91, 0x52, 0x90, 0x2e, 0xc9, 0xcf, 0x9c, 0x5f, 0x1e, 0x0a, + 0xb7, 0x00, 0x33, 0x42, 0x24, 0xc4, 0xe3, 0xba, 0x01, 0x40, 0x32, + 0x06, 0xab, 0x09, 0x23, 0x8a, 0xdd, 0x01, 0xa4, 0x05, 0xcd, + }; + uint8_t tls13_extract_output[32]; + size_t tls13_extract_output_len; + uint8_t tls13_expand_label_output[32]; + if (!HKDF_extract(tls13_extract_output, &tls13_extract_output_len, + EVP_sha256(), kTLS13Secret, sizeof(kTLS13Secret), + kTLS13Salt, sizeof(kTLS13Salt)) || + tls13_extract_output_len != sizeof(tls13_extract_output) || + !CRYPTO_tls13_hkdf_expand_label( + tls13_expand_label_output, sizeof(tls13_expand_label_output), + EVP_sha256(), tls13_extract_output, sizeof(tls13_extract_output), + kTLS13Label, sizeof(kTLS13Label) - 1, kTLS13ClientHelloHash, + sizeof(kTLS13ClientHelloHash)) || + !check_test(kTLS13ExpandLabelOutput, tls13_expand_label_output, + sizeof(kTLS13ExpandLabelOutput), + "CRYPTO_tls13_hkdf_expand_label")) { + fprintf(stderr, "TLS13-KDF failed.\n"); + goto err; + } + + // HKDF + static const uint8_t kHKDFSecret[32] = { + 0x68, 0x67, 0x85, 0x04, 0xb9, 0xb3, 0xad, 0xd1, 0x7d, 0x59, 0x67, + 0xa1, 0xa7, 0xbd, 0x37, 0x99, 0x3f, 0xd8, 0xa3, 0x3c, 0xe7, 0x30, + 0x30, 0x71, 0xf3, 0x9c, 0x09, 0x6d, 0x16, 0x35, 0xb3, 0xc9, + }; + static const uint8_t kHKDFSalt[32] = { + 0x8a, 0xab, 0x18, 0xb4, 0x9b, 0x0a, 0x17, 0xf9, 0xe8, 0xe6, 0x97, + 0x1a, 0x3d, 0xff, 0xda, 0x9b, 0x26, 0x8b, 0x3d, 0x17, 0x78, 0x0a, + 0xb3, 0xea, 0x65, 0xdb, 0x2a, 0xc0, 0x29, 0x9c, 0xfa, 0x72, + }; + static const uint8_t kHKDFInfo[32] = { + 0xe5, 0x6f, 0xf9, 0xe1, 0x18, 0x5e, 0x64, 0x8c, 0x6c, 0x8f, 0xee, + 0xc6, 0x93, 0x5a, 0xc5, 0x14, 0x8c, 0xf3, 0xd9, 0x78, 0xd2, 0x3a, + 0x86, 0xdd, 0x01, 0xdf, 0xb9, 0xe9, 0x5e, 0xe5, 0x1a, 0x56, + }; + static const uint8_t kHKDFOutput[32] = { + 0xa6, 0x29, 0xb4, 0xd7, 0xf4, 0xc1, 0x16, 0x64, 0x71, 0x5e, 0xa4, + 0xa8, 0xe6, 0x60, 0x8c, 0xf3, 0xc1, 0xa5, 0x03, 0xe2, 0x22, 0xf9, + 0x89, 0xe2, 0x12, 0x18, 0xbe, 0xef, 0x16, 0x86, 0xe0, 0xec, + }; + uint8_t hkdf_output[sizeof(kHKDFOutput)]; + if (!HKDF(hkdf_output, sizeof(hkdf_output), EVP_sha256(), kHKDFSecret, + sizeof(kHKDFSecret), kHKDFSalt, sizeof(kHKDFSalt), kHKDFInfo, + sizeof(kHKDFInfo)) || + !check_test(kHKDFOutput, hkdf_output, sizeof(kHKDFOutput), "HKDF")) { + fprintf(stderr, "HKDF failed.\n"); + goto err; + } + ret = 1; err: diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/service_indicator/service_indicator.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/service_indicator/service_indicator.c index dab01cde..aff9b54e 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/service_indicator/service_indicator.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/service_indicator/service_indicator.c @@ -303,14 +303,11 @@ void HMAC_verify_service_indicator(const EVP_MD *evp_md) { } void TLSKDF_verify_service_indicator(const EVP_MD *md) { - // HMAC-MD5, HMAC-SHA1, and HMAC-MD5/HMAC-SHA1 (both used concurrently) are - // approved for use in the KDF in TLS 1.0/1.1. - // HMAC-SHA{256, 384, 512} are approved for use in the KDF in TLS 1.2. - // These Key Derivation functions are to be used in the context of the TLS - // protocol. + // HMAC-MD5/HMAC-SHA1 (both used concurrently) is approved for use in the KDF + // in TLS 1.0/1.1. HMAC-SHA{256, 384, 512} are approved for use in the KDF in + // TLS 1.2. These Key Derivation functions are to be used in the context of + // the TLS protocol. switch (EVP_MD_type(md)) { - case NID_md5: - case NID_sha1: case NID_md5_sha1: case NID_sha256: case NID_sha384: diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-586-linux.linux.x86.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-586-linux.linux.x86.S index 88112cfe..65355878 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-586-linux.linux.x86.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-586-linux.linux.x86.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) .text .globl sha1_block_data_order .hidden sha1_block_data_order @@ -3812,11 +3805,7 @@ _sha1_block_data_order_avx: .byte 102,111,114,109,32,102,111,114,32,120,56,54,44,32,67,82 .byte 89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112 .byte 114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 -#endif // !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv4-large-ios.ios.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv4-large-ios.ios.arm.S index 049752ed..6eed44c8 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv4-large-ios.ios.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv4-large-ios.ios.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__APPLE__) #include .text @@ -1517,11 +1509,7 @@ OPENSSL_armcap_P: .long 0 .private_extern _OPENSSL_armcap_P #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__APPLE__) #endif // defined(__arm__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv4-large-linux.linux.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv4-large-linux.linux.arm.S index 22e341c6..706826aa 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv4-large-linux.linux.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv4-large-linux.linux.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) #include .text @@ -1507,11 +1499,7 @@ sha1_block_data_order_armv8: .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv8-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv8-ios.ios.aarch64.S index aadc16c6..1a52d3c9 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv8-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv8-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) #include .text @@ -27,7 +19,7 @@ _sha1_block_data_order: // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. AARCH64_VALID_CALL_TARGET -#if __has_feature(hwaddress_sanitizer) && __clang_major__ >= 10 +#if defined(OPENSSL_HWASAN) && __clang_major__ >= 10 adrp x16,:pg_hi21_nc:_OPENSSL_armcap_P #else adrp x16,_OPENSSL_armcap_P@PAGE @@ -1234,11 +1226,7 @@ Lconst: .byte 83,72,65,49,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 2 .align 2 -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv8-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv8-linux.linux.aarch64.S index 91f59781..4de5977f 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv8-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-armv8-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) #include .text @@ -27,7 +19,7 @@ sha1_block_data_order: // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. AARCH64_VALID_CALL_TARGET -#if __has_feature(hwaddress_sanitizer) && __clang_major__ >= 10 +#if defined(OPENSSL_HWASAN) && __clang_major__ >= 10 adrp x16,:pg_hi21_nc:OPENSSL_armcap_P #else adrp x16,OPENSSL_armcap_P @@ -1234,11 +1226,7 @@ sha1_block_armv8: .byte 83,72,65,49,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 2 .align 2 -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-x86_64-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-x86_64-linux.linux.x86_64.S index 0103672e..57edb226 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-x86_64-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-x86_64-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .extern OPENSSL_ia32cap_P .hidden OPENSSL_ia32cap_P @@ -23,6 +16,7 @@ .align 16 sha1_block_data_order: .cfi_startproc +_CET_ENDBR leaq OPENSSL_ia32cap_P(%rip),%r10 movl 0(%r10),%r9d movl 4(%r10),%r8d @@ -5470,10 +5464,6 @@ K_XX_XX: .align 64 .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-x86_64-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-x86_64-mac.mac.x86_64.S index 427bbd2c..1d7c6c84 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-x86_64-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha1-x86_64-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text @@ -22,6 +15,7 @@ .p2align 4 _sha1_block_data_order: +_CET_ENDBR leaq _OPENSSL_ia32cap_P(%rip),%r10 movl 0(%r10),%r9d movl 4(%r10),%r8d @@ -5469,10 +5463,6 @@ K_XX_XX: .p2align 6 .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-586-linux.linux.x86.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-586-linux.linux.x86.S index 116125b0..1b2913b2 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-586-linux.linux.x86.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-586-linux.linux.x86.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) .text .globl sha256_block_data_order .hidden sha256_block_data_order @@ -5571,11 +5564,7 @@ sha256_block_data_order: popl %ebp ret .size sha256_block_data_order,.-.L_sha256_block_data_order_begin -#endif // !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv4-ios.ios.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv4-ios.ios.arm.S index 2bbef8af..2df9dcde 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv4-ios.ios.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv4-ios.ios.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__APPLE__) @ Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. @ @ Licensed under the OpenSSL license (the "License"). You may not use @@ -2845,11 +2837,7 @@ OPENSSL_armcap_P: .long 0 .private_extern _OPENSSL_armcap_P #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__APPLE__) #endif // defined(__arm__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv4-linux.linux.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv4-linux.linux.arm.S index b3271df1..3980623f 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv4-linux.linux.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv4-linux.linux.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) @ Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. @ @ Licensed under the OpenSSL license (the "License"). You may not use @@ -2835,11 +2827,7 @@ sha256_block_data_order_armv8: .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv8-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv8-ios.ios.aarch64.S index 645c7df6..58bb1be6 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv8-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv8-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) // Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. // // Licensed under the OpenSSL license (the "License"). You may not use @@ -69,7 +61,7 @@ _sha256_block_data_order: AARCH64_VALID_CALL_TARGET #ifndef __KERNEL__ -#if __has_feature(hwaddress_sanitizer) && __clang_major__ >= 10 +#if defined(OPENSSL_HWASAN) && __clang_major__ >= 10 adrp x16,:pg_hi21_nc:_OPENSSL_armcap_P #else adrp x16,_OPENSSL_armcap_P@PAGE @@ -1211,11 +1203,7 @@ Loop_hw: ret #endif -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv8-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv8-linux.linux.aarch64.S index ee6978a1..de32ec73 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv8-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-armv8-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) // Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. // // Licensed under the OpenSSL license (the "License"). You may not use @@ -69,7 +61,7 @@ sha256_block_data_order: AARCH64_VALID_CALL_TARGET #ifndef __KERNEL__ -#if __has_feature(hwaddress_sanitizer) && __clang_major__ >= 10 +#if defined(OPENSSL_HWASAN) && __clang_major__ >= 10 adrp x16,:pg_hi21_nc:OPENSSL_armcap_P #else adrp x16,OPENSSL_armcap_P @@ -1211,11 +1203,7 @@ sha256_block_armv8: ret .size sha256_block_armv8,.-sha256_block_armv8 #endif -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-x86_64-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-x86_64-linux.linux.x86_64.S index a8b7e2fc..b5e042ae 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-x86_64-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-x86_64-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .extern OPENSSL_ia32cap_P @@ -23,6 +16,7 @@ .align 16 sha256_block_data_order: .cfi_startproc +_CET_ENDBR leaq OPENSSL_ia32cap_P(%rip),%r11 movl 0(%r11),%r9d movl 4(%r11),%r10d @@ -4185,10 +4179,6 @@ sha256_block_data_order_avx: .cfi_endproc .size sha256_block_data_order_avx,.-sha256_block_data_order_avx #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-x86_64-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-x86_64-mac.mac.x86_64.S index 2edf4909..70feb0f6 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-x86_64-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha256-x86_64-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text @@ -22,6 +15,7 @@ .p2align 4 _sha256_block_data_order: +_CET_ENDBR leaq _OPENSSL_ia32cap_P(%rip),%r11 movl 0(%r11),%r9d movl 4(%r11),%r10d @@ -4183,10 +4177,6 @@ L$epilogue_avx: .byte 0xf3,0xc3 -#endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits #endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-586-linux.linux.x86.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-586-linux.linux.x86.S index 36090450..aa1ada92 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-586-linux.linux.x86.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-586-linux.linux.x86.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) .text .globl sha512_block_data_order .hidden sha512_block_data_order @@ -2841,11 +2834,7 @@ sha512_block_data_order: .byte 67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97 .byte 112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103 .byte 62,0 -#endif // !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv4-ios.ios.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv4-ios.ios.arm.S index 7ab1270b..5f136efb 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv4-ios.ios.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv4-ios.ios.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__APPLE__) @ Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. @ @ Licensed under the OpenSSL license (the "License"). You may not use @@ -1898,11 +1890,7 @@ OPENSSL_armcap_P: .long 0 .private_extern _OPENSSL_armcap_P #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__APPLE__) #endif // defined(__arm__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv4-linux.linux.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv4-linux.linux.arm.S index d3369587..0f84315d 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv4-linux.linux.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv4-linux.linux.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) @ Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. @ @ Licensed under the OpenSSL license (the "License"). You may not use @@ -1890,11 +1882,7 @@ sha512_block_data_order_neon: .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv8-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv8-ios.ios.aarch64.S index 5b5f7f98..bfcf21f0 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv8-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv8-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) // Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. // // Licensed under the OpenSSL license (the "License"). You may not use @@ -69,7 +61,7 @@ _sha512_block_data_order: AARCH64_VALID_CALL_TARGET #ifndef __KERNEL__ -#if __has_feature(hwaddress_sanitizer) && __clang_major__ >= 10 +#if defined(OPENSSL_HWASAN) && __clang_major__ >= 10 adrp x16,:pg_hi21_nc:_OPENSSL_armcap_P #else adrp x16,_OPENSSL_armcap_P@PAGE @@ -1613,11 +1605,7 @@ Loop_hw: ret #endif -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv8-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv8-linux.linux.aarch64.S index 3ce1b082..c5d4f251 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv8-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-armv8-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) // Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. // // Licensed under the OpenSSL license (the "License"). You may not use @@ -69,7 +61,7 @@ sha512_block_data_order: AARCH64_VALID_CALL_TARGET #ifndef __KERNEL__ -#if __has_feature(hwaddress_sanitizer) && __clang_major__ >= 10 +#if defined(OPENSSL_HWASAN) && __clang_major__ >= 10 adrp x16,:pg_hi21_nc:OPENSSL_armcap_P #else adrp x16,OPENSSL_armcap_P @@ -1613,11 +1605,7 @@ sha512_block_armv8: ret .size sha512_block_armv8,.-sha512_block_armv8 #endif -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-x86_64-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-x86_64-linux.linux.x86_64.S index 73b76eee..a2cf65b7 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-x86_64-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-x86_64-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .extern OPENSSL_ia32cap_P @@ -23,6 +16,7 @@ .align 16 sha512_block_data_order: .cfi_startproc +_CET_ENDBR leaq OPENSSL_ia32cap_P(%rip),%r11 movl 0(%r11),%r9d movl 4(%r11),%r10d @@ -2993,10 +2987,6 @@ sha512_block_data_order_avx: .cfi_endproc .size sha512_block_data_order_avx,.-sha512_block_data_order_avx #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-x86_64-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-x86_64-mac.mac.x86_64.S index ff07e1b3..c4beabc0 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-x86_64-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/sha512-x86_64-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text @@ -22,6 +15,7 @@ .p2align 4 _sha512_block_data_order: +_CET_ENDBR leaq _OPENSSL_ia32cap_P(%rip),%r11 movl 0(%r11),%r9d movl 4(%r11),%r10d @@ -2991,10 +2985,6 @@ L$epilogue_avx: .byte 0xf3,0xc3 -#endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits #endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/tls/internal.h b/Sources/CCryptoBoringSSL/crypto/fipsmodule/tls/internal.h index bcf0744a..46dadf88 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/tls/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/tls/internal.h @@ -31,6 +31,14 @@ OPENSSL_EXPORT int CRYPTO_tls1_prf(const EVP_MD *digest, const uint8_t *seed1, size_t seed1_len, const uint8_t *seed2, size_t seed2_len); +// CRYPTO_tls13_hkdf_expand_label computes the TLS 1.3 KDF function of the same +// name. See https://www.rfc-editor.org/rfc/rfc8446#section-7.1. +OPENSSL_EXPORT int CRYPTO_tls13_hkdf_expand_label( + uint8_t *out, size_t out_len, const EVP_MD *digest, // + const uint8_t *secret, size_t secret_len, // + const uint8_t *label, size_t label_len, // + const uint8_t *hash, size_t hash_len); + #if defined(__cplusplus) } diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/tls/kdf.c b/Sources/CCryptoBoringSSL/crypto/fipsmodule/tls/kdf.c index 386ea3c6..67c2ec7b 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/tls/kdf.c +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/tls/kdf.c @@ -52,7 +52,9 @@ #include +#include #include +#include #include #include @@ -176,3 +178,34 @@ end: } return ret; } + +int CRYPTO_tls13_hkdf_expand_label(uint8_t *out, size_t out_len, + const EVP_MD *digest, // + const uint8_t *secret, size_t secret_len, + const uint8_t *label, size_t label_len, + const uint8_t *hash, size_t hash_len) { + static const uint8_t kProtocolLabel[] = "tls13 "; + CBB cbb, child; + uint8_t *hkdf_label = NULL; + size_t hkdf_label_len; + + CBB_zero(&cbb); + if (!CBB_init(&cbb, 2 + 1 + sizeof(kProtocolLabel) - 1 + label_len + 1 + + hash_len) || + !CBB_add_u16(&cbb, out_len) || + !CBB_add_u8_length_prefixed(&cbb, &child) || + !CBB_add_bytes(&child, kProtocolLabel, sizeof(kProtocolLabel) - 1) || + !CBB_add_bytes(&child, label, label_len) || + !CBB_add_u8_length_prefixed(&cbb, &child) || + !CBB_add_bytes(&child, hash, hash_len) || + !CBB_finish(&cbb, &hkdf_label, &hkdf_label_len)) { + CBB_cleanup(&cbb); + return 0; + } + + const int ret = HKDF_expand(out, out_len, digest, secret, secret_len, + hkdf_label, hkdf_label_len); + OPENSSL_free(hkdf_label); + return ret; +} + diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv7-ios.ios.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv7-ios.ios.arm.S index 362a652e..d0f196ed 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv7-ios.ios.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv7-ios.ios.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__APPLE__) .syntax unified @@ -1264,11 +1256,7 @@ Lctr32_done: vldmia sp!, {d8,d9,d10,d11,d12,d13,d14,d15} ldmia sp!, {r7,r8,r9,r10,r11, pc} @ return -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__APPLE__) #endif // defined(__arm__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv7-linux.linux.arm.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv7-linux.linux.arm.S index f0f2dd42..42ae7354 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv7-linux.linux.arm.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv7-linux.linux.arm.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__ARMEL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) .syntax unified .arch armv7-a @@ -1232,11 +1224,7 @@ vpaes_ctr32_encrypt_blocks: vldmia sp!, {d8,d9,d10,d11,d12,d13,d14,d15} ldmia sp!, {r7,r8,r9,r10,r11, pc} @ return .size vpaes_ctr32_encrypt_blocks,.-vpaes_ctr32_encrypt_blocks -#endif // !OPENSSL_NO_ASM && defined(__ARMEL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv8-ios.ios.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv8-ios.ios.aarch64.S index 82d5f14f..8172671d 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv8-ios.ios.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv8-ios.ios.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) #include .section __TEXT,__const @@ -1231,11 +1223,7 @@ Lctr32_done: AARCH64_VALIDATE_LINK_REGISTER ret -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__APPLE__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) #endif // defined(__aarch64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv8-linux.linux.aarch64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv8-linux.linux.aarch64.S index b0f5fdca..6a7e2c27 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv8-linux.linux.aarch64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-armv8-linux.linux.aarch64.S @@ -3,17 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) #include .section .rodata @@ -1231,11 +1223,7 @@ vpaes_ctr32_encrypt_blocks: AARCH64_VALIDATE_LINK_REGISTER ret .size vpaes_ctr32_encrypt_blocks,.-vpaes_ctr32_encrypt_blocks -#endif // !OPENSSL_NO_ASM && defined(__AARCH64EL__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) #endif // defined(__aarch64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-x86-linux.linux.x86.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-x86-linux.linux.x86.S index db134b36..e1f6de82 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-x86-linux.linux.x86.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-x86-linux.linux.x86.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) .text #ifdef BORINGSSL_DISPATCH_TEST #endif @@ -712,11 +705,7 @@ vpaes_cbc_encrypt: popl %ebp ret .size vpaes_cbc_encrypt,.-.L_vpaes_cbc_encrypt_begin -#endif // !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-x86_64-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-x86_64-linux.linux.x86_64.S index 83aa0a95..efb5d95a 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-x86_64-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-x86_64-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text @@ -814,6 +807,7 @@ _vpaes_schedule_mangle: .align 16 vpaes_set_encrypt_key: .cfi_startproc +_CET_ENDBR #ifdef BORINGSSL_DISPATCH_TEST .extern BORINGSSL_function_hit .hidden BORINGSSL_function_hit @@ -839,6 +833,7 @@ vpaes_set_encrypt_key: .align 16 vpaes_set_decrypt_key: .cfi_startproc +_CET_ENDBR movl %esi,%eax shrl $5,%eax addl $5,%eax @@ -863,6 +858,7 @@ vpaes_set_decrypt_key: .align 16 vpaes_encrypt: .cfi_startproc +_CET_ENDBR #ifdef BORINGSSL_DISPATCH_TEST .extern BORINGSSL_function_hit .hidden BORINGSSL_function_hit @@ -882,6 +878,7 @@ vpaes_encrypt: .align 16 vpaes_decrypt: .cfi_startproc +_CET_ENDBR movdqu (%rdi),%xmm0 call _vpaes_preheat call _vpaes_decrypt_core @@ -895,6 +892,7 @@ vpaes_decrypt: .align 16 vpaes_cbc_encrypt: .cfi_startproc +_CET_ENDBR xchgq %rcx,%rdx subq $16,%rcx jc .Lcbc_abort @@ -938,6 +936,7 @@ vpaes_cbc_encrypt: .align 16 vpaes_ctr32_encrypt_blocks: .cfi_startproc +_CET_ENDBR xchgq %rcx,%rdx testq %rcx,%rcx @@ -1134,10 +1133,6 @@ _vpaes_consts: .size _vpaes_consts,.-_vpaes_consts .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-x86_64-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-x86_64-mac.mac.x86_64.S index e645b9aa..d619a06a 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-x86_64-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/vpaes-x86_64-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text @@ -814,6 +807,7 @@ L$schedule_mangle_both: .p2align 4 _vpaes_set_encrypt_key: +_CET_ENDBR #ifdef BORINGSSL_DISPATCH_TEST movb $1,_BORINGSSL_function_hit+5(%rip) @@ -838,6 +832,7 @@ _vpaes_set_encrypt_key: .p2align 4 _vpaes_set_decrypt_key: +_CET_ENDBR movl %esi,%eax shrl $5,%eax addl $5,%eax @@ -862,6 +857,7 @@ _vpaes_set_decrypt_key: .p2align 4 _vpaes_encrypt: +_CET_ENDBR #ifdef BORINGSSL_DISPATCH_TEST movb $1,_BORINGSSL_function_hit+4(%rip) @@ -880,6 +876,7 @@ _vpaes_encrypt: .p2align 4 _vpaes_decrypt: +_CET_ENDBR movdqu (%rdi),%xmm0 call _vpaes_preheat call _vpaes_decrypt_core @@ -893,6 +890,7 @@ _vpaes_decrypt: .p2align 4 _vpaes_cbc_encrypt: +_CET_ENDBR xchgq %rcx,%rdx subq $16,%rcx jc L$cbc_abort @@ -936,6 +934,7 @@ L$cbc_abort: .p2align 4 _vpaes_ctr32_encrypt_blocks: +_CET_ENDBR xchgq %rcx,%rdx testq %rcx,%rcx @@ -1132,10 +1131,6 @@ L$ctr_add_two: .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86-mont-linux.linux.x86.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86-mont-linux.linux.x86.S index 8d03e603..1da96a46 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86-mont-linux.linux.x86.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86-mont-linux.linux.x86.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) .text .globl bn_mul_mont .hidden bn_mul_mont @@ -488,11 +481,7 @@ bn_mul_mont: .byte 54,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121 .byte 32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46 .byte 111,114,103,62,0 -#endif // !defined(OPENSSL_NO_ASM) && defined(__i386__) && defined(__ELF__) -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont-linux.linux.x86_64.S index 2bc58430..2d39308e 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .extern OPENSSL_ia32cap_P @@ -24,6 +17,7 @@ .align 16 bn_mul_mont: .cfi_startproc +_CET_ENDBR movl %r9d,%r9d movq %rsp,%rax .cfi_def_cfa_register %rax @@ -1259,10 +1253,6 @@ bn_mulx4x_mont: .byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 16 #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont-mac.mac.x86_64.S index dc63d274..336a13da 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text @@ -23,6 +16,7 @@ .p2align 4 _bn_mul_mont: +_CET_ENDBR movl %r9d,%r9d movq %rsp,%rax @@ -1256,10 +1250,6 @@ L$mulx4x_epilogue: .byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .p2align 4 #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont5-linux.linux.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont5-linux.linux.x86_64.S index e1a5bd49..08850d86 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont5-linux.linux.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont5-linux.linux.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) .text .extern OPENSSL_ia32cap_P @@ -24,6 +17,7 @@ .align 64 bn_mul_mont_gather5: .cfi_startproc +_CET_ENDBR movl %r9d,%r9d movq %rsp,%rax .cfi_def_cfa_register %rax @@ -1102,6 +1096,7 @@ mul4x_internal: .align 32 bn_power5: .cfi_startproc +_CET_ENDBR movq %rsp,%rax .cfi_def_cfa_register %rax leaq OPENSSL_ia32cap_P(%rip),%r11 @@ -1241,6 +1236,7 @@ bn_power5: bn_sqr8x_internal: __bn_sqr8x_internal: .cfi_startproc +_CET_ENDBR @@ -2753,6 +2749,7 @@ bn_powerx5: bn_sqrx8x_internal: __bn_sqrx8x_internal: .cfi_startproc +_CET_ENDBR @@ -3425,6 +3422,7 @@ __bn_postx4x_internal: .align 16 bn_scatter5: .cfi_startproc +_CET_ENDBR cmpl $0,%esi jz .Lscatter_epilogue @@ -3456,6 +3454,7 @@ bn_scatter5: bn_gather5: .cfi_startproc .LSEH_begin_bn_gather5: +_CET_ENDBR .byte 0x4c,0x8d,0x14,0x24 .cfi_def_cfa_register %r10 @@ -3626,10 +3625,6 @@ bn_gather5: .byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,119,105,116,104,32,115,99,97,116,116,101,114,47,103,97,116,104,101,114,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont5-mac.mac.x86_64.S b/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont5-mac.mac.x86_64.S index 4f2c3faa..7aec4382 100644 --- a/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont5-mac.mac.x86_64.S +++ b/Sources/CCryptoBoringSSL/crypto/fipsmodule/x86_64-mont5-mac.mac.x86_64.S @@ -3,16 +3,9 @@ // This file is generated from a similarly-named Perl script in the BoringSSL // source tree. Do not edit by hand. -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__x86_64__) && !defined(OPENSSL_NO_ASM) && defined(__APPLE__) -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) .text @@ -23,6 +16,7 @@ .p2align 6 _bn_mul_mont_gather5: +_CET_ENDBR movl %r9d,%r9d movq %rsp,%rax @@ -1101,6 +1095,7 @@ L$inner4x: .p2align 5 _bn_power5: +_CET_ENDBR movq %rsp,%rax leaq _OPENSSL_ia32cap_P(%rip),%r11 @@ -1240,6 +1235,7 @@ L$power5_epilogue: _bn_sqr8x_internal: __bn_sqr8x_internal: +_CET_ENDBR @@ -2752,6 +2748,7 @@ L$powerx5_epilogue: _bn_sqrx8x_internal: __bn_sqrx8x_internal: +_CET_ENDBR @@ -3424,6 +3421,7 @@ L$sqrx4x_sub_entry: .p2align 4 _bn_scatter5: +_CET_ENDBR cmpl $0,%esi jz L$scatter_epilogue @@ -3455,6 +3453,7 @@ L$scatter_epilogue: _bn_gather5: L$SEH_begin_bn_gather5: +_CET_ENDBR .byte 0x4c,0x8d,0x14,0x24 @@ -3625,10 +3624,6 @@ L$inc: .byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,119,105,116,104,32,115,99,97,116,116,101,114,47,103,97,116,104,101,114,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .text #endif -#if defined(__ELF__) -// See https://www.airs.com/blog/archives/518. -.section .note.GNU-stack,"",%progbits -#endif #endif // defined(__x86_64__) && defined(__APPLE__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/hpke/hpke.c b/Sources/CCryptoBoringSSL/crypto/hpke/hpke.c index 8c9006ad..c43065a6 100644 --- a/Sources/CCryptoBoringSSL/crypto/hpke/hpke.c +++ b/Sources/CCryptoBoringSSL/crypto/hpke/hpke.c @@ -53,6 +53,17 @@ struct evp_hpke_kem_st { int (*decap)(const EVP_HPKE_KEY *key, uint8_t *out_shared_secret, size_t *out_shared_secret_len, const uint8_t *enc, size_t enc_len); + int (*auth_encap_with_seed)(const EVP_HPKE_KEY *key, + uint8_t *out_shared_secret, + size_t *out_shared_secret_len, uint8_t *out_enc, + size_t *out_enc_len, size_t max_enc, + const uint8_t *peer_public_key, + size_t peer_public_key_len, const uint8_t *seed, + size_t seed_len); + int (*auth_decap)(const EVP_HPKE_KEY *key, uint8_t *out_shared_secret, + size_t *out_shared_secret_len, const uint8_t *enc, + size_t enc_len, const uint8_t *peer_public_key, + size_t peer_public_key_len); }; struct evp_hpke_kdf_st { @@ -211,6 +222,76 @@ static int x25519_decap(const EVP_HPKE_KEY *key, uint8_t *out_shared_secret, return 1; } +static int x25519_auth_encap_with_seed( + const EVP_HPKE_KEY *key, uint8_t *out_shared_secret, + size_t *out_shared_secret_len, uint8_t *out_enc, size_t *out_enc_len, + size_t max_enc, const uint8_t *peer_public_key, size_t peer_public_key_len, + const uint8_t *seed, size_t seed_len) { + if (max_enc < X25519_PUBLIC_VALUE_LEN) { + OPENSSL_PUT_ERROR(EVP, EVP_R_INVALID_BUFFER_SIZE); + return 0; + } + if (seed_len != X25519_PRIVATE_KEY_LEN) { + OPENSSL_PUT_ERROR(EVP, EVP_R_DECODE_ERROR); + return 0; + } + X25519_public_from_private(out_enc, seed); + + uint8_t dh[2 * X25519_SHARED_KEY_LEN]; + if (peer_public_key_len != X25519_PUBLIC_VALUE_LEN || + !X25519(dh, seed, peer_public_key) || + !X25519(dh + X25519_SHARED_KEY_LEN, key->private_key, peer_public_key)) { + OPENSSL_PUT_ERROR(EVP, EVP_R_INVALID_PEER_KEY); + return 0; + } + + uint8_t kem_context[3 * X25519_PUBLIC_VALUE_LEN]; + OPENSSL_memcpy(kem_context, out_enc, X25519_PUBLIC_VALUE_LEN); + OPENSSL_memcpy(kem_context + X25519_PUBLIC_VALUE_LEN, peer_public_key, + X25519_PUBLIC_VALUE_LEN); + OPENSSL_memcpy(kem_context + 2 * X25519_PUBLIC_VALUE_LEN, key->public_key, + X25519_PUBLIC_VALUE_LEN); + if (!dhkem_extract_and_expand(key->kem->id, EVP_sha256(), out_shared_secret, + SHA256_DIGEST_LENGTH, dh, sizeof(dh), + kem_context, sizeof(kem_context))) { + return 0; + } + + *out_enc_len = X25519_PUBLIC_VALUE_LEN; + *out_shared_secret_len = SHA256_DIGEST_LENGTH; + return 1; +} + +static int x25519_auth_decap(const EVP_HPKE_KEY *key, + uint8_t *out_shared_secret, + size_t *out_shared_secret_len, const uint8_t *enc, + size_t enc_len, const uint8_t *peer_public_key, + size_t peer_public_key_len) { + uint8_t dh[2 * X25519_SHARED_KEY_LEN]; + if (enc_len != X25519_PUBLIC_VALUE_LEN || + peer_public_key_len != X25519_PUBLIC_VALUE_LEN || + !X25519(dh, key->private_key, enc) || + !X25519(dh + X25519_SHARED_KEY_LEN, key->private_key, peer_public_key)) { + OPENSSL_PUT_ERROR(EVP, EVP_R_INVALID_PEER_KEY); + return 0; + } + + uint8_t kem_context[3 * X25519_PUBLIC_VALUE_LEN]; + OPENSSL_memcpy(kem_context, enc, X25519_PUBLIC_VALUE_LEN); + OPENSSL_memcpy(kem_context + X25519_PUBLIC_VALUE_LEN, key->public_key, + X25519_PUBLIC_VALUE_LEN); + OPENSSL_memcpy(kem_context + 2 * X25519_PUBLIC_VALUE_LEN, peer_public_key, + X25519_PUBLIC_VALUE_LEN); + if (!dhkem_extract_and_expand(key->kem->id, EVP_sha256(), out_shared_secret, + SHA256_DIGEST_LENGTH, dh, sizeof(dh), + kem_context, sizeof(kem_context))) { + return 0; + } + + *out_shared_secret_len = SHA256_DIGEST_LENGTH; + return 1; +} + const EVP_HPKE_KEM *EVP_hpke_x25519_hkdf_sha256(void) { static const EVP_HPKE_KEM kKEM = { /*id=*/EVP_HPKE_DHKEM_X25519_HKDF_SHA256, @@ -222,6 +303,8 @@ const EVP_HPKE_KEM *EVP_hpke_x25519_hkdf_sha256(void) { x25519_generate_key, x25519_encap_with_seed, x25519_decap, + x25519_auth_encap_with_seed, + x25519_auth_decap, }; return &kKEM; } @@ -373,8 +456,10 @@ static int hpke_build_suite_id(const EVP_HPKE_CTX *ctx, } #define HPKE_MODE_BASE 0 +#define HPKE_MODE_AUTH 2 -static int hpke_key_schedule(EVP_HPKE_CTX *ctx, const uint8_t *shared_secret, +static int hpke_key_schedule(EVP_HPKE_CTX *ctx, uint8_t mode, + const uint8_t *shared_secret, size_t shared_secret_len, const uint8_t *info, size_t info_len) { uint8_t suite_id[HPKE_SUITE_ID_LEN]; @@ -407,7 +492,7 @@ static int hpke_key_schedule(EVP_HPKE_CTX *ctx, const uint8_t *shared_secret, size_t context_len; CBB context_cbb; CBB_init_fixed(&context_cbb, context, sizeof(context)); - if (!CBB_add_u8(&context_cbb, HPKE_MODE_BASE) || + if (!CBB_add_u8(&context_cbb, mode) || !CBB_add_bytes(&context_cbb, psk_id_hash, psk_id_hash_len) || !CBB_add_bytes(&context_cbb, info_hash, info_hash_len) || !CBB_finish(&context_cbb, NULL, &context_len)) { @@ -507,8 +592,8 @@ int EVP_HPKE_CTX_setup_sender_with_seed_for_testing( if (!kem->encap_with_seed(kem, shared_secret, &shared_secret_len, out_enc, out_enc_len, max_enc, peer_public_key, peer_public_key_len, seed, seed_len) || - !hpke_key_schedule(ctx, shared_secret, shared_secret_len, info, - info_len)) { + !hpke_key_schedule(ctx, HPKE_MODE_BASE, shared_secret, shared_secret_len, + info, info_len)) { EVP_HPKE_CTX_cleanup(ctx); return 0; } @@ -528,8 +613,79 @@ int EVP_HPKE_CTX_setup_recipient(EVP_HPKE_CTX *ctx, const EVP_HPKE_KEY *key, uint8_t shared_secret[MAX_SHARED_SECRET_LEN]; size_t shared_secret_len; if (!key->kem->decap(key, shared_secret, &shared_secret_len, enc, enc_len) || - !hpke_key_schedule(ctx, shared_secret, shared_secret_len, info, - info_len)) { + !hpke_key_schedule(ctx, HPKE_MODE_BASE, shared_secret, shared_secret_len, + info, info_len)) { + EVP_HPKE_CTX_cleanup(ctx); + return 0; + } + return 1; +} + + +int EVP_HPKE_CTX_setup_auth_sender( + EVP_HPKE_CTX *ctx, uint8_t *out_enc, size_t *out_enc_len, size_t max_enc, + const EVP_HPKE_KEY *key, const EVP_HPKE_KDF *kdf, const EVP_HPKE_AEAD *aead, + const uint8_t *peer_public_key, size_t peer_public_key_len, + const uint8_t *info, size_t info_len) { + uint8_t seed[MAX_SEED_LEN]; + RAND_bytes(seed, key->kem->seed_len); + return EVP_HPKE_CTX_setup_auth_sender_with_seed_for_testing( + ctx, out_enc, out_enc_len, max_enc, key, kdf, aead, peer_public_key, + peer_public_key_len, info, info_len, seed, key->kem->seed_len); +} + +int EVP_HPKE_CTX_setup_auth_sender_with_seed_for_testing( + EVP_HPKE_CTX *ctx, uint8_t *out_enc, size_t *out_enc_len, size_t max_enc, + const EVP_HPKE_KEY *key, const EVP_HPKE_KDF *kdf, const EVP_HPKE_AEAD *aead, + const uint8_t *peer_public_key, size_t peer_public_key_len, + const uint8_t *info, size_t info_len, const uint8_t *seed, + size_t seed_len) { + if (key->kem->auth_encap_with_seed == NULL) { + // Not all HPKE KEMs support AuthEncap. + OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); + return 0; + } + + EVP_HPKE_CTX_zero(ctx); + ctx->is_sender = 1; + ctx->kem = key->kem; + ctx->kdf = kdf; + ctx->aead = aead; + uint8_t shared_secret[MAX_SHARED_SECRET_LEN]; + size_t shared_secret_len; + if (!key->kem->auth_encap_with_seed( + key, shared_secret, &shared_secret_len, out_enc, out_enc_len, max_enc, + peer_public_key, peer_public_key_len, seed, seed_len) || + !hpke_key_schedule(ctx, HPKE_MODE_AUTH, shared_secret, shared_secret_len, + info, info_len)) { + EVP_HPKE_CTX_cleanup(ctx); + return 0; + } + return 1; +} + +int EVP_HPKE_CTX_setup_auth_recipient( + EVP_HPKE_CTX *ctx, const EVP_HPKE_KEY *key, const EVP_HPKE_KDF *kdf, + const EVP_HPKE_AEAD *aead, const uint8_t *enc, size_t enc_len, + const uint8_t *info, size_t info_len, const uint8_t *peer_public_key, + size_t peer_public_key_len) { + if (key->kem->auth_decap == NULL) { + // Not all HPKE KEMs support AuthDecap. + OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); + return 0; + } + + EVP_HPKE_CTX_zero(ctx); + ctx->is_sender = 0; + ctx->kem = key->kem; + ctx->kdf = kdf; + ctx->aead = aead; + uint8_t shared_secret[MAX_SHARED_SECRET_LEN]; + size_t shared_secret_len; + if (!key->kem->auth_decap(key, shared_secret, &shared_secret_len, enc, + enc_len, peer_public_key, peer_public_key_len) || + !hpke_key_schedule(ctx, HPKE_MODE_AUTH, shared_secret, shared_secret_len, + info, info_len)) { EVP_HPKE_CTX_cleanup(ctx); return 0; } diff --git a/Sources/CCryptoBoringSSL/crypto/hrss/asm/poly_rq_mul.S b/Sources/CCryptoBoringSSL/crypto/hrss/asm/poly_rq_mul.S index 50097779..37fddb62 100644 --- a/Sources/CCryptoBoringSSL/crypto/hrss/asm/poly_rq_mul.S +++ b/Sources/CCryptoBoringSSL/crypto/hrss/asm/poly_rq_mul.S @@ -14,11 +14,9 @@ // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_SMALL) && defined(__linux__) && defined(__x86_64__) +#include -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_SMALL) && defined(OPENSSL_LINUX) && defined(OPENSSL_X86_64) // This is the polynomial multiplication function from [HRSS], provided by kind // permission of the authors. @@ -305,6 +303,7 @@ mask_mod8192: .att_syntax prefix poly_Rq_mul: .cfi_startproc +_CET_ENDBR push %rbp .cfi_adjust_cfa_offset 8 .cfi_offset rbp, -16 @@ -8488,10 +8487,6 @@ ret .cfi_endproc .size poly_Rq_mul,.-poly_Rq_mul -#endif - -#if defined(__ELF__) -.section .note.GNU-stack,"",%progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CCryptoBoringSSL/crypto/internal.h b/Sources/CCryptoBoringSSL/crypto/internal.h index 055436a0..7f148e70 100644 --- a/Sources/CCryptoBoringSSL/crypto/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/internal.h @@ -155,6 +155,32 @@ #if defined(OPENSSL_THREADS) && !defined(OPENSSL_PTHREADS) && \ defined(OPENSSL_WINDOWS) #define OPENSSL_WINDOWS_THREADS +#endif + +// Determine the atomics implementation to use with C. +#if !defined(__cplusplus) +#if !defined(OPENSSL_C11_ATOMIC) && defined(OPENSSL_THREADS) && \ + !defined(__STDC_NO_ATOMICS__) && defined(__STDC_VERSION__) && \ + __STDC_VERSION__ >= 201112L +#define OPENSSL_C11_ATOMIC +#endif + +#if defined(OPENSSL_C11_ATOMIC) +#include +#endif + +// Older MSVC does not support C11 atomics, so we fallback to the Windows APIs. +// When both are available (e.g. clang-cl), we prefer the C11 ones. The Windows +// APIs don't allow some operations to be implemented as efficiently. This can +// be removed once we can rely on +// https://devblogs.microsoft.com/cppblog/c11-atomics-in-visual-studio-2022-version-17-5-preview-2/ +#if !defined(OPENSSL_C11_ATOMIC) && defined(OPENSSL_THREADS) && \ + defined(OPENSSL_WINDOWS) +#define OPENSSL_WINDOWS_ATOMIC +#endif +#endif // !__cplusplus + +#if defined(OPENSSL_WINDOWS_THREADS) || defined(OPENSSL_WINDOWS_ATOMIC) OPENSSL_MSVC_PRAGMA(warning(push, 3)) #include OPENSSL_MSVC_PRAGMA(warning(pop)) @@ -180,14 +206,17 @@ OPENSSL_EXPORT uint32_t *OPENSSL_get_armcap_pointer_for_test(void); #endif +// On non-MSVC 64-bit targets, we expect __uint128_t support. This includes +// clang-cl, which defines both __clang__ and _MSC_VER. #if (!defined(_MSC_VER) || defined(__clang__)) && defined(OPENSSL_64_BIT) #define BORINGSSL_HAS_UINT128 typedef __int128_t int128_t; typedef __uint128_t uint128_t; -// clang-cl supports __uint128_t but modulus and division don't work. -// https://crbug.com/787617. -#if !defined(_MSC_VER) || !defined(__clang__) +// __uint128_t division depends on intrinsics in the compiler runtime. Those +// intrinsics are missing in clang-cl (https://crbug.com/787617) and nanolibc. +// These may be bugs in the toolchain definition, but just disable it for now. +#if !defined(_MSC_VER) && !defined(OPENSSL_NANOLIBC) #define BORINGSSL_CAN_DIVIDE_UINT128 #endif #endif @@ -239,15 +268,15 @@ OPENSSL_INLINE void OPENSSL_reset_malloc_counter_for_testing(void) {} // Pointer utility functions. // buffers_alias returns one if |a| and |b| alias and zero otherwise. -static inline int buffers_alias(const uint8_t *a, size_t a_len, - const uint8_t *b, size_t b_len) { +static inline int buffers_alias(const void *a, size_t a_bytes, + const void *b, size_t b_bytes) { // Cast |a| and |b| to integers. In C, pointer comparisons between unrelated // objects are undefined whereas pointer to integer conversions are merely // implementation-defined. We assume the implementation defined it in a sane // way. uintptr_t a_u = (uintptr_t)a; uintptr_t b_u = (uintptr_t)b; - return a_u + a_len > b_u && b_u + b_len > a_u; + return a_u + a_bytes > b_u && b_u + b_bytes > a_u; } // align_pointer returns |ptr|, advanced to |alignment|. |alignment| must be a @@ -334,6 +363,9 @@ static inline uint64_t value_barrier_u64(uint64_t a) { return a; } +// |value_barrier_u8| could be defined as above, but compilers other than +// clang seem to still materialize 0x00..00MM instead of reusing 0x??..??MM. + // constant_time_msb_w returns the given value with the MSB copied to all the // other bits. static inline crypto_word_t constant_time_msb_w(crypto_word_t a) { @@ -450,16 +482,23 @@ static inline crypto_word_t constant_time_select_w(crypto_word_t mask, // to a cmov, it sometimes further transforms it into a branch, which we do // not want. // - // Adding barriers to both |mask| and |~mask| breaks the relationship between - // the two, which makes the compiler stick with bitmasks. - return (value_barrier_w(mask) & a) | (value_barrier_w(~mask) & b); + // Hiding the value of the mask from the compiler evades this transformation. + mask = value_barrier_w(mask); + return (mask & a) | (~mask & b); } // constant_time_select_8 acts like |constant_time_select| but operates on // 8-bit values. -static inline uint8_t constant_time_select_8(uint8_t mask, uint8_t a, +static inline uint8_t constant_time_select_8(crypto_word_t mask, uint8_t a, uint8_t b) { - return (uint8_t)(constant_time_select_w(mask, a, b)); + // |mask| is a word instead of |uint8_t| to avoid materializing 0x000..0MM + // Making both |mask| and its value barrier |uint8_t| would allow the compiler + // to materialize 0x????..?MM instead, but only clang is that clever. + // However, vectorization of bitwise operations seems to work better on + // |uint8_t| than a mix of |uint64_t| and |uint8_t|, so |m| is cast to + // |uint8_t| after the value barrier but before the bitwise operations. + uint8_t m = value_barrier_w(mask); + return (m & a) | (~m & b); } // constant_time_select_int acts like |constant_time_select| but operates on @@ -469,6 +508,34 @@ static inline int constant_time_select_int(crypto_word_t mask, int a, int b) { (crypto_word_t)(b))); } +// constant_time_conditional_memcpy copies |n| bytes from |src| to |dst| if +// |mask| is 0xff..ff and does nothing if |mask| is 0. The |n|-byte memory +// ranges at |dst| and |src| must not overlap, as when calling |memcpy|. +static inline void constant_time_conditional_memcpy(void *dst, const void *src, + const size_t n, + const crypto_word_t mask) { + assert(!buffers_alias(dst, n, src, n)); + uint8_t *out = (uint8_t *)dst; + const uint8_t *in = (const uint8_t *)src; + for (size_t i = 0; i < n; i++) { + out[i] = constant_time_select_8(mask, in[i], out[i]); + } +} + +// constant_time_conditional_memxor xors |n| bytes from |src| to |dst| if +// |mask| is 0xff..ff and does nothing if |mask| is 0. The |n|-byte memory +// ranges at |dst| and |src| must not overlap, as when calling |memcpy|. +static inline void constant_time_conditional_memxor(void *dst, const void *src, + const size_t n, + const crypto_word_t mask) { + assert(!buffers_alias(dst, n, src, n)); + uint8_t *out = (uint8_t *)dst; + const uint8_t *in = (const uint8_t *)src; + for (size_t i = 0; i < n; i++) { + out[i] ^= value_barrier_w(mask) & in[i]; + } +} + #if defined(BORINGSSL_CONSTANT_TIME_VALIDATION) // CONSTTIME_SECRET takes a pointer and a number of bytes and marks that region @@ -539,15 +606,117 @@ typedef pthread_once_t CRYPTO_once_t; OPENSSL_EXPORT void CRYPTO_once(CRYPTO_once_t *once, void (*init)(void)); -// Reference counting. +// Atomics. +// +// The following functions provide an API analogous to from C11 +// and abstract between a few variations on atomics we need to support. + +#if defined(__cplusplus) + +// In C++, we can't easily detect whether C will use |OPENSSL_C11_ATOMIC| or +// |OPENSSL_WINDOWS_ATOMIC|. Instead, we define a layout-compatible type without +// the corresponding functions. When we can rely on C11 atomics in MSVC, that +// will no longer be a concern. +typedef uint32_t CRYPTO_atomic_u32; + +#elif defined(OPENSSL_C11_ATOMIC) + +typedef _Atomic uint32_t CRYPTO_atomic_u32; + +// This should be const, but the |OPENSSL_WINDOWS_ATOMIC| implementation is not +// const due to Windows limitations. When we can rely on C11 atomics, make this +// const-correct. +OPENSSL_INLINE uint32_t CRYPTO_atomic_load_u32(CRYPTO_atomic_u32 *val) { + return atomic_load(val); +} + +OPENSSL_INLINE int CRYPTO_atomic_compare_exchange_weak_u32( + CRYPTO_atomic_u32 *val, uint32_t *expected, uint32_t desired) { + return atomic_compare_exchange_weak(val, expected, desired); +} + +OPENSSL_INLINE void CRYPTO_atomic_store_u32(CRYPTO_atomic_u32 *val, + uint32_t desired) { + atomic_store(val, desired); +} + +#elif defined(OPENSSL_WINDOWS_ATOMIC) + +typedef LONG CRYPTO_atomic_u32; + +OPENSSL_INLINE uint32_t CRYPTO_atomic_load_u32(volatile CRYPTO_atomic_u32 *val) { + // This is not ideal because it still writes to a cacheline. MSVC is not able + // to optimize this to a true atomic read, and Windows does not provide an + // InterlockedLoad function. + // + // The Windows documentation [1] does say "Simple reads and writes to + // properly-aligned 32-bit variables are atomic operations", but this is not + // phrased in terms of the C11 and C++11 memory models, and indeed a read or + // write seems to produce slightly different code on MSVC than a sequentially + // consistent std::atomic::load in C++. Moreover, it is unclear if non-MSVC + // compilers on Windows provide the same guarantees. Thus we avoid relying on + // this and instead still use an interlocked function. This is still + // preferable a global mutex, and eventually this code will be replaced by + // [2]. Additionally, on clang-cl, we'll use the |OPENSSL_C11_ATOMIC| path. + // + // [1] https://learn.microsoft.com/en-us/windows/win32/sync/interlocked-variable-access + // [2] https://devblogs.microsoft.com/cppblog/c11-atomics-in-visual-studio-2022-version-17-5-preview-2/ + return (uint32_t)InterlockedCompareExchange(val, 0, 0); +} + +OPENSSL_INLINE int CRYPTO_atomic_compare_exchange_weak_u32( + volatile CRYPTO_atomic_u32 *val, uint32_t *expected32, uint32_t desired) { + LONG expected = (LONG)*expected32; + LONG actual = InterlockedCompareExchange(val, (LONG)desired, expected); + *expected32 = (uint32_t)actual; + return actual == expected; +} + +OPENSSL_INLINE void CRYPTO_atomic_store_u32(volatile CRYPTO_atomic_u32 *val, + uint32_t desired) { + InterlockedExchange(val, (LONG)desired); +} + +#elif !defined(OPENSSL_THREADS) + +typedef uint32_t CRYPTO_atomic_u32; + +OPENSSL_INLINE uint32_t CRYPTO_atomic_load_u32(CRYPTO_atomic_u32 *val) { + return *val; +} + +OPENSSL_INLINE int CRYPTO_atomic_compare_exchange_weak_u32( + CRYPTO_atomic_u32 *val, uint32_t *expected, uint32_t desired) { + if (*val != *expected) { + *expected = *val; + return 0; + } + *val = desired; + return 1; +} + +OPENSSL_INLINE void CRYPTO_atomic_store_u32(CRYPTO_atomic_u32 *val, + uint32_t desired) { + *val = desired; +} + +#else + +// Require some atomics implementation. Contact BoringSSL maintainers if you +// have a platform with fails this check. +#error "Thread-compatible configurations require atomics" -// Automatically enable C11 atomics if implemented. -#if !defined(OPENSSL_C11_ATOMIC) && defined(OPENSSL_THREADS) && \ - !defined(__STDC_NO_ATOMICS__) && defined(__STDC_VERSION__) && \ - __STDC_VERSION__ >= 201112L -#define OPENSSL_C11_ATOMIC #endif +// See the comment in the |__cplusplus| section above. +static_assert(sizeof(CRYPTO_atomic_u32) == sizeof(uint32_t), + "CRYPTO_atomic_u32 does not match uint32_t size"); +static_assert(alignof(CRYPTO_atomic_u32) == alignof(uint32_t), + "CRYPTO_atomic_u32 does not match uint32_t alignment"); + + +// Reference counting. + // CRYPTO_REFCOUNT_MAX is the value at which the reference count saturates. #define CRYPTO_REFCOUNT_MAX 0xffffffff @@ -569,37 +738,24 @@ OPENSSL_EXPORT int CRYPTO_refcount_dec_and_test_zero(CRYPTO_refcount_t *count); // Locks. -// -// Two types of locks are defined: |CRYPTO_MUTEX|, which can be used in -// structures as normal, and |struct CRYPTO_STATIC_MUTEX|, which can be used as -// a global lock. A global lock must be initialised to the value -// |CRYPTO_STATIC_MUTEX_INIT|. -// -// |CRYPTO_MUTEX| can appear in public structures and so is defined in -// thread.h as a structure large enough to fit the real type. The global lock is -// a different type so it may be initialized with platform initializer macros. #if !defined(OPENSSL_THREADS) -struct CRYPTO_STATIC_MUTEX { +typedef struct crypto_mutex_st { char padding; // Empty structs have different sizes in C and C++. -}; -#define CRYPTO_STATIC_MUTEX_INIT { 0 } +} CRYPTO_MUTEX; +#define CRYPTO_MUTEX_INIT { 0 } #elif defined(OPENSSL_WINDOWS_THREADS) -struct CRYPTO_STATIC_MUTEX { - SRWLOCK lock; -}; -#define CRYPTO_STATIC_MUTEX_INIT { SRWLOCK_INIT } +typedef SRWLOCK CRYPTO_MUTEX; +#define CRYPTO_MUTEX_INIT SRWLOCK_INIT #elif defined(OPENSSL_PTHREADS) -struct CRYPTO_STATIC_MUTEX { - pthread_rwlock_t lock; -}; -#define CRYPTO_STATIC_MUTEX_INIT { PTHREAD_RWLOCK_INITIALIZER } +typedef pthread_rwlock_t CRYPTO_MUTEX; +#define CRYPTO_MUTEX_INIT PTHREAD_RWLOCK_INITIALIZER #else #error "Unknown threading library" #endif // CRYPTO_MUTEX_init initialises |lock|. If |lock| is a static variable, use a -// |CRYPTO_STATIC_MUTEX|. +// |CRYPTO_MUTEX_INIT|. OPENSSL_EXPORT void CRYPTO_MUTEX_init(CRYPTO_MUTEX *lock); // CRYPTO_MUTEX_lock_read locks |lock| such that other threads may also have a @@ -619,28 +775,6 @@ OPENSSL_EXPORT void CRYPTO_MUTEX_unlock_write(CRYPTO_MUTEX *lock); // CRYPTO_MUTEX_cleanup releases all resources held by |lock|. OPENSSL_EXPORT void CRYPTO_MUTEX_cleanup(CRYPTO_MUTEX *lock); -// CRYPTO_STATIC_MUTEX_lock_read locks |lock| such that other threads may also -// have a read lock, but none may have a write lock. The |lock| variable does -// not need to be initialised by any function, but must have been statically -// initialised with |CRYPTO_STATIC_MUTEX_INIT|. -OPENSSL_EXPORT void CRYPTO_STATIC_MUTEX_lock_read( - struct CRYPTO_STATIC_MUTEX *lock); - -// CRYPTO_STATIC_MUTEX_lock_write locks |lock| such that no other thread has -// any type of lock on it. The |lock| variable does not need to be initialised -// by any function, but must have been statically initialised with -// |CRYPTO_STATIC_MUTEX_INIT|. -OPENSSL_EXPORT void CRYPTO_STATIC_MUTEX_lock_write( - struct CRYPTO_STATIC_MUTEX *lock); - -// CRYPTO_STATIC_MUTEX_unlock_read unlocks |lock| for reading. -OPENSSL_EXPORT void CRYPTO_STATIC_MUTEX_unlock_read( - struct CRYPTO_STATIC_MUTEX *lock); - -// CRYPTO_STATIC_MUTEX_unlock_write unlocks |lock| for writing. -OPENSSL_EXPORT void CRYPTO_STATIC_MUTEX_unlock_write( - struct CRYPTO_STATIC_MUTEX *lock); - #if defined(__cplusplus) extern "C++" { @@ -722,22 +856,25 @@ OPENSSL_EXPORT int CRYPTO_set_thread_local( typedef struct crypto_ex_data_func_st CRYPTO_EX_DATA_FUNCS; -DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) - // CRYPTO_EX_DATA_CLASS tracks the ex_indices registered for a type which // supports ex_data. It should defined as a static global within the module // which defines that type. typedef struct { - struct CRYPTO_STATIC_MUTEX lock; - STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth; + CRYPTO_MUTEX lock; + // funcs is a linked list of |CRYPTO_EX_DATA_FUNCS| structures. It may be + // traversed without serialization only up to |num_funcs|. last points to the + // final entry of |funcs|, or NULL if empty. + CRYPTO_EX_DATA_FUNCS *funcs, *last; + // num_funcs is the number of entries in |funcs|. + CRYPTO_atomic_u32 num_funcs; // num_reserved is one if the ex_data index zero is reserved for legacy // |TYPE_get_app_data| functions. uint8_t num_reserved; } CRYPTO_EX_DATA_CLASS; -#define CRYPTO_EX_DATA_CLASS_INIT {CRYPTO_STATIC_MUTEX_INIT, NULL, 0} +#define CRYPTO_EX_DATA_CLASS_INIT {CRYPTO_MUTEX_INIT, NULL, NULL, 0, 0} #define CRYPTO_EX_DATA_CLASS_INIT_WITH_APP_DATA \ - {CRYPTO_STATIC_MUTEX_INIT, NULL, 1} + {CRYPTO_MUTEX_INIT, NULL, NULL, 0, 1} // CRYPTO_get_ex_new_index allocates a new index for |ex_data_class| and writes // it to |*out_index|. Each class of object should provide a wrapper function @@ -1216,9 +1353,15 @@ OPENSSL_INLINE int CRYPTO_is_ADX_capable(void) { #if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64) -#if defined(OPENSSL_APPLE) && defined(OPENSSL_ARM) -// We do not detect any features at runtime for Apple's 32-bit ARM platforms. On -// 64-bit ARM, we detect some post-ARMv8.0 features. +extern uint32_t OPENSSL_armcap_P; + +// We do not detect any features at runtime on several 32-bit Arm platforms. +// Apple platforms and OpenBSD require NEON and moved to 64-bit to pick up Armv8 +// extensions. Android baremetal does not aim to support 32-bit Arm at all, but +// it simplifies things to make it build. +#if defined(OPENSSL_ARM) && !defined(OPENSSL_STATIC_ARMCAP) && \ + (defined(OPENSSL_APPLE) || defined(OPENSSL_OPENBSD) || \ + defined(ANDROID_BAREMETAL)) #define OPENSSL_STATIC_ARMCAP #endif diff --git a/Sources/CCryptoBoringSSL/crypto/kyber/kyber.c b/Sources/CCryptoBoringSSL/crypto/kyber/kyber.c index ef2d58da..d8ea6bef 100644 --- a/Sources/CCryptoBoringSSL/crypto/kyber/kyber.c +++ b/Sources/CCryptoBoringSSL/crypto/kyber/kyber.c @@ -132,7 +132,7 @@ static uint16_t reduce_once(uint16_t x) { static uint16_t reduce(uint32_t x) { assert(x < kPrime + 2u * kPrime * kPrime); uint64_t product = (uint64_t)x * kBarrettMultiplier; - uint32_t quotient = product >> kBarrettShift; + uint32_t quotient = (uint32_t)(product >> kBarrettShift); uint32_t remainder = x - quotient * kPrime; return reduce_once(remainder); } @@ -230,7 +230,7 @@ static void scalar_sub(scalar *lhs, const scalar *rhs) { static void scalar_mult(scalar *out, const scalar *lhs, const scalar *rhs) { for (int i = 0; i < DEGREE / 2; i++) { uint32_t real_real = (uint32_t)lhs->c[2 * i] * rhs->c[2 * i]; - uint32_t img_img = (uint32_t)rhs->c[2 * i + 1] * lhs->c[2 * i + 1]; + uint32_t img_img = (uint32_t)lhs->c[2 * i + 1] * rhs->c[2 * i + 1]; uint32_t real_img = (uint32_t)lhs->c[2 * i] * rhs->c[2 * i + 1]; uint32_t img_real = (uint32_t)lhs->c[2 * i + 1] * rhs->c[2 * i]; out->c[2 * i] = @@ -283,16 +283,23 @@ static void scalar_inner_product(scalar *out, const vector *lhs, // operates on public inputs. static void scalar_from_keccak_vartime(scalar *out, struct BORINGSSL_keccak_st *keccak_ctx) { - uint8_t bytes[3]; - for (int i = 0; i < DEGREE;) { - BORINGSSL_keccak_squeeze(keccak_ctx, bytes, sizeof(bytes)); - uint16_t d1 = bytes[0] + 256 * (bytes[1] % 16); - uint16_t d2 = bytes[1] / 16 + 16 * bytes[2]; - if (d1 < kPrime) { - out->c[i++] = d1; - } - if (d2 < kPrime && i < DEGREE) { - out->c[i++] = d2; + assert(keccak_ctx->offset == 0); + assert(keccak_ctx->rate_bytes == 168); + static_assert(168 % 3 == 0, "block and coefficient boundaries do not align"); + + int done = 0; + while (done < DEGREE) { + uint8_t block[168]; + BORINGSSL_keccak_squeeze(keccak_ctx, block, sizeof(block)); + for (size_t i = 0; i < sizeof(block) && done < DEGREE; i += 3) { + uint16_t d1 = block[i] + 256 * (block[i + 1] % 16); + uint16_t d2 = block[i + 1] / 16 + 16 * block[i + 2]; + if (d1 < kPrime) { + out->c[done++] = d1; + } + if (d2 < kPrime && done < DEGREE) { + out->c[done++] = d2; + } } } } @@ -484,9 +491,10 @@ static int vector_decode(vector *out, const uint8_t *in, int bits) { // remainder (for rounding) and the quotient (as the result), we cannot use // |reduce| here, but need to do the Barrett reduction directly. static uint16_t compress(uint16_t x, int bits) { - uint32_t product = (uint32_t)x << bits; - uint32_t quotient = ((uint64_t)product * kBarrettMultiplier) >> kBarrettShift; - uint32_t remainder = product - quotient * kPrime; + uint32_t shifted = (uint32_t)x << bits; + uint64_t product = (uint64_t)shifted * kBarrettMultiplier; + uint32_t quotient = (uint32_t)(product >> kBarrettShift); + uint32_t remainder = shifted - quotient * kPrime; // Adjust the quotient to round correctly: // 0 <= remainder <= kHalfPrime round to 0 diff --git a/Sources/CCryptoBoringSSL/crypto/mem.c b/Sources/CCryptoBoringSSL/crypto/mem.c index e9d41a8b..6c722341 100644 --- a/Sources/CCryptoBoringSSL/crypto/mem.c +++ b/Sources/CCryptoBoringSSL/crypto/mem.c @@ -159,21 +159,20 @@ static const uint8_t kBoringSSLBinaryTag[18] = { }; #if defined(BORINGSSL_MALLOC_FAILURE_TESTING) -static struct CRYPTO_STATIC_MUTEX malloc_failure_lock = - CRYPTO_STATIC_MUTEX_INIT; +static CRYPTO_MUTEX malloc_failure_lock = CRYPTO_MUTEX_INIT; static uint64_t current_malloc_count = 0; static uint64_t malloc_number_to_fail = 0; static int malloc_failure_enabled = 0, break_on_malloc_fail = 0, any_malloc_failed = 0; static void malloc_exit_handler(void) { - CRYPTO_STATIC_MUTEX_lock_read(&malloc_failure_lock); + CRYPTO_MUTEX_lock_read(&malloc_failure_lock); if (any_malloc_failed) { // Signal to the test driver that some allocation failed, so it knows to // increment the counter and continue. _exit(88); } - CRYPTO_STATIC_MUTEX_unlock_read(&malloc_failure_lock); + CRYPTO_MUTEX_unlock_read(&malloc_failure_lock); } static void init_malloc_failure(void) { @@ -200,11 +199,11 @@ static int should_fail_allocation() { // We lock just so multi-threaded tests are still correct, but we won't test // every malloc exhaustively. - CRYPTO_STATIC_MUTEX_lock_write(&malloc_failure_lock); + CRYPTO_MUTEX_lock_write(&malloc_failure_lock); int should_fail = current_malloc_count == malloc_number_to_fail; current_malloc_count++; any_malloc_failed = any_malloc_failed || should_fail; - CRYPTO_STATIC_MUTEX_unlock_write(&malloc_failure_lock); + CRYPTO_MUTEX_unlock_write(&malloc_failure_lock); if (should_fail && break_on_malloc_fail) { raise(SIGTRAP); @@ -216,9 +215,9 @@ static int should_fail_allocation() { } void OPENSSL_reset_malloc_counter_for_testing(void) { - CRYPTO_STATIC_MUTEX_lock_write(&malloc_failure_lock); + CRYPTO_MUTEX_lock_write(&malloc_failure_lock); current_malloc_count = 0; - CRYPTO_STATIC_MUTEX_unlock_write(&malloc_failure_lock); + CRYPTO_MUTEX_unlock_write(&malloc_failure_lock); } #else diff --git a/Sources/CCryptoBoringSSL/crypto/obj/obj.c b/Sources/CCryptoBoringSSL/crypto/obj/obj.c index 4168c21f..156b3c20 100644 --- a/Sources/CCryptoBoringSSL/crypto/obj/obj.c +++ b/Sources/CCryptoBoringSSL/crypto/obj/obj.c @@ -77,24 +77,20 @@ DEFINE_LHASH_OF(ASN1_OBJECT) -static struct CRYPTO_STATIC_MUTEX global_added_lock = CRYPTO_STATIC_MUTEX_INIT; +static CRYPTO_MUTEX global_added_lock = CRYPTO_MUTEX_INIT; // These globals are protected by |global_added_lock|. static LHASH_OF(ASN1_OBJECT) *global_added_by_data = NULL; static LHASH_OF(ASN1_OBJECT) *global_added_by_nid = NULL; static LHASH_OF(ASN1_OBJECT) *global_added_by_short_name = NULL; static LHASH_OF(ASN1_OBJECT) *global_added_by_long_name = NULL; -static struct CRYPTO_STATIC_MUTEX global_next_nid_lock = - CRYPTO_STATIC_MUTEX_INIT; +static CRYPTO_MUTEX global_next_nid_lock = CRYPTO_MUTEX_INIT; static unsigned global_next_nid = NUM_NID; static int obj_next_nid(void) { - int ret; - - CRYPTO_STATIC_MUTEX_lock_write(&global_next_nid_lock); - ret = global_next_nid++; - CRYPTO_STATIC_MUTEX_unlock_write(&global_next_nid_lock); - + CRYPTO_MUTEX_lock_write(&global_next_nid_lock); + int ret = global_next_nid++; + CRYPTO_MUTEX_unlock_write(&global_next_nid_lock); return ret; } @@ -213,17 +209,17 @@ int OBJ_obj2nid(const ASN1_OBJECT *obj) { return obj->nid; } - CRYPTO_STATIC_MUTEX_lock_read(&global_added_lock); + CRYPTO_MUTEX_lock_read(&global_added_lock); if (global_added_by_data != NULL) { ASN1_OBJECT *match; match = lh_ASN1_OBJECT_retrieve(global_added_by_data, obj); if (match != NULL) { - CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock); + CRYPTO_MUTEX_unlock_read(&global_added_lock); return match->nid; } } - CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock); + CRYPTO_MUTEX_unlock_read(&global_added_lock); const uint16_t *nid_ptr = bsearch(obj, kNIDsInOIDOrder, OPENSSL_ARRAY_SIZE(kNIDsInOIDOrder), @@ -259,18 +255,18 @@ static int short_name_cmp(const void *key, const void *element) { } int OBJ_sn2nid(const char *short_name) { - CRYPTO_STATIC_MUTEX_lock_read(&global_added_lock); + CRYPTO_MUTEX_lock_read(&global_added_lock); if (global_added_by_short_name != NULL) { ASN1_OBJECT *match, template; template.sn = short_name; match = lh_ASN1_OBJECT_retrieve(global_added_by_short_name, &template); if (match != NULL) { - CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock); + CRYPTO_MUTEX_unlock_read(&global_added_lock); return match->nid; } } - CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock); + CRYPTO_MUTEX_unlock_read(&global_added_lock); const uint16_t *nid_ptr = bsearch(short_name, kNIDsInShortNameOrder, @@ -294,18 +290,18 @@ static int long_name_cmp(const void *key, const void *element) { } int OBJ_ln2nid(const char *long_name) { - CRYPTO_STATIC_MUTEX_lock_read(&global_added_lock); + CRYPTO_MUTEX_lock_read(&global_added_lock); if (global_added_by_long_name != NULL) { ASN1_OBJECT *match, template; template.ln = long_name; match = lh_ASN1_OBJECT_retrieve(global_added_by_long_name, &template); if (match != NULL) { - CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock); + CRYPTO_MUTEX_unlock_read(&global_added_lock); return match->nid; } } - CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock); + CRYPTO_MUTEX_unlock_read(&global_added_lock); const uint16_t *nid_ptr = bsearch( long_name, kNIDsInLongNameOrder, OPENSSL_ARRAY_SIZE(kNIDsInLongNameOrder), @@ -349,18 +345,18 @@ ASN1_OBJECT *OBJ_nid2obj(int nid) { return (ASN1_OBJECT *)&kObjects[nid]; } - CRYPTO_STATIC_MUTEX_lock_read(&global_added_lock); + CRYPTO_MUTEX_lock_read(&global_added_lock); if (global_added_by_nid != NULL) { ASN1_OBJECT *match, template; template.nid = nid; match = lh_ASN1_OBJECT_retrieve(global_added_by_nid, &template); if (match != NULL) { - CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock); + CRYPTO_MUTEX_unlock_read(&global_added_lock); return match; } } - CRYPTO_STATIC_MUTEX_unlock_read(&global_added_lock); + CRYPTO_MUTEX_unlock_read(&global_added_lock); err: OPENSSL_PUT_ERROR(OBJ, OBJ_R_UNKNOWN_NID); @@ -508,7 +504,7 @@ static int obj_add_object(ASN1_OBJECT *obj) { obj->flags &= ~(ASN1_OBJECT_FLAG_DYNAMIC | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS | ASN1_OBJECT_FLAG_DYNAMIC_DATA); - CRYPTO_STATIC_MUTEX_lock_write(&global_added_lock); + CRYPTO_MUTEX_lock_write(&global_added_lock); if (global_added_by_nid == NULL) { global_added_by_nid = lh_ASN1_OBJECT_new(hash_nid, cmp_nid); } @@ -548,7 +544,7 @@ static int obj_add_object(ASN1_OBJECT *obj) { } err: - CRYPTO_STATIC_MUTEX_unlock_write(&global_added_lock); + CRYPTO_MUTEX_unlock_write(&global_added_lock); return ok; } diff --git a/Sources/CCryptoBoringSSL/crypto/obj/obj_dat.h b/Sources/CCryptoBoringSSL/crypto/obj/obj_dat.h index d879233a..654b3c08 100644 --- a/Sources/CCryptoBoringSSL/crypto/obj/obj_dat.h +++ b/Sources/CCryptoBoringSSL/crypto/obj/obj_dat.h @@ -57,7 +57,7 @@ /* This file is generated by crypto/obj/objects.go. */ -#define NUM_NID 967 +#define NUM_NID 965 static const uint8_t kObjectData[] = { /* NID_rsadsi */ @@ -8777,14 +8777,13 @@ static const ASN1_OBJECT kObjects[NUM_NID] = { {"AuthPSK", "auth-psk", NID_auth_psk, 0, NULL, 0}, {"KxANY", "kx-any", NID_kx_any, 0, NULL, 0}, {"AuthANY", "auth-any", NID_auth_any, 0, NULL, 0}, - {"CECPQ2", "CECPQ2", NID_CECPQ2, 0, NULL, 0}, + {NULL, NULL, NID_undef, 0, NULL, 0}, {"ED448", "ED448", NID_ED448, 3, &kObjectData[6181], 0}, {"X448", "X448", NID_X448, 3, &kObjectData[6184], 0}, {"SHA512-256", "sha512-256", NID_sha512_256, 9, &kObjectData[6187], 0}, {"HKDF", "hkdf", NID_hkdf, 0, NULL, 0}, - {"X25519Kyber768", "X25519Kyber768", NID_X25519Kyber768, 0, NULL, 0}, - {"P256Kyber768", "P256Kyber768", NID_P256Kyber768, 0, NULL, 0}, - {"P384Kyber768", "P384Kyber768", NID_P384Kyber768, 0, NULL, 0}, + {"X25519Kyber768Draft00", "X25519Kyber768Draft00", + NID_X25519Kyber768Draft00, 0, NULL, 0}, }; static const uint16_t kNIDsInShortNameOrder[] = { @@ -8846,7 +8845,6 @@ static const uint16_t kNIDsInShortNameOrder[] = { 110 /* CAST5-CFB */, 109 /* CAST5-ECB */, 111 /* CAST5-OFB */, - 959 /* CECPQ2 */, 894 /* CMAC */, 13 /* CN */, 141 /* CRLReason */, @@ -8918,8 +8916,6 @@ static const uint16_t kNIDsInShortNameOrder[] = { 18 /* OU */, 749 /* Oakley-EC2N-3 */, 750 /* Oakley-EC2N-4 */, - 965 /* P256Kyber768 */, - 966 /* P384Kyber768 */, 9 /* PBE-MD2-DES */, 168 /* PBE-MD2-RC2-64 */, 10 /* PBE-MD5-DES */, @@ -8986,7 +8982,7 @@ static const uint16_t kNIDsInShortNameOrder[] = { 458 /* UID */, 0 /* UNDEF */, 948 /* X25519 */, - 964 /* X25519Kyber768 */, + 964 /* X25519Kyber768Draft00 */, 961 /* X448 */, 11 /* X500 */, 378 /* X500algorithms */, @@ -9758,7 +9754,6 @@ static const uint16_t kNIDsInLongNameOrder[] = { 285 /* Biometric Info */, 179 /* CA Issuers */, 785 /* CA Repository */, - 959 /* CECPQ2 */, 131 /* Code Signing */, 783 /* Diffie-Hellman based MAC */, 382 /* Directory */, @@ -9834,8 +9829,6 @@ static const uint16_t kNIDsInLongNameOrder[] = { 366 /* OCSP Nonce */, 371 /* OCSP Service Locator */, 180 /* OCSP Signing */, - 965 /* P256Kyber768 */, - 966 /* P384Kyber768 */, 161 /* PBES2 */, 69 /* PBKDF2 */, 162 /* PBMAC1 */, @@ -9860,7 +9853,7 @@ static const uint16_t kNIDsInLongNameOrder[] = { 133 /* Time Stamping */, 375 /* Trust Root */, 948 /* X25519 */, - 964 /* X25519Kyber768 */, + 964 /* X25519Kyber768Draft00 */, 961 /* X448 */, 12 /* X509 */, 402 /* X509v3 AC Targeting */, diff --git a/Sources/CCryptoBoringSSL/crypto/pkcs8/internal.h b/Sources/CCryptoBoringSSL/crypto/pkcs8/internal.h index 1592a290..853e830f 100644 --- a/Sources/CCryptoBoringSSL/crypto/pkcs8/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/pkcs8/internal.h @@ -87,13 +87,13 @@ int pkcs8_pbe_decrypt(uint8_t **out, size_t *out_len, CBS *algorithm, // key material to |out| and returns one. Otherwise, it returns zero. |id| // should be one of the |PKCS12_*_ID| values. int pkcs12_key_gen(const char *pass, size_t pass_len, const uint8_t *salt, - size_t salt_len, uint8_t id, unsigned iterations, + size_t salt_len, uint8_t id, uint32_t iterations, size_t out_len, uint8_t *out, const EVP_MD *md); // pkcs12_pbe_encrypt_init configures |ctx| for encrypting with a PBES1 scheme // defined in PKCS#12. It writes the corresponding AlgorithmIdentifier to |out|. int pkcs12_pbe_encrypt_init(CBB *out, EVP_CIPHER_CTX *ctx, int alg, - unsigned iterations, const char *pass, + uint32_t iterations, const char *pass, size_t pass_len, const uint8_t *salt, size_t salt_len); @@ -121,7 +121,7 @@ int PKCS5_pbe2_decrypt_init(const struct pbe_suite *suite, EVP_CIPHER_CTX *ctx, // as defined in RFC 2998, with the specified parameters. It writes the // corresponding AlgorithmIdentifier to |out|. int PKCS5_pbe2_encrypt_init(CBB *out, EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, unsigned iterations, + const EVP_CIPHER *cipher, uint32_t iterations, const char *pass, size_t pass_len, const uint8_t *salt, size_t salt_len); diff --git a/Sources/CCryptoBoringSSL/crypto/pkcs8/p5_pbev2.c b/Sources/CCryptoBoringSSL/crypto/pkcs8/p5_pbev2.c index c2a3f0c8..9a505e19 100644 --- a/Sources/CCryptoBoringSSL/crypto/pkcs8/p5_pbev2.c +++ b/Sources/CCryptoBoringSSL/crypto/pkcs8/p5_pbev2.c @@ -144,7 +144,7 @@ static int add_cipher_oid(CBB *out, int nid) { } static int pkcs5_pbe2_cipher_init(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const EVP_MD *pbkdf2_md, unsigned iterations, + const EVP_MD *pbkdf2_md, uint32_t iterations, const char *pass, size_t pass_len, const uint8_t *salt, size_t salt_len, const uint8_t *iv, size_t iv_len, int enc) { @@ -162,7 +162,7 @@ static int pkcs5_pbe2_cipher_init(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, } int PKCS5_pbe2_encrypt_init(CBB *out, EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, unsigned iterations, + const EVP_CIPHER *cipher, uint32_t iterations, const char *pass, size_t pass_len, const uint8_t *salt, size_t salt_len) { int cipher_nid = EVP_CIPHER_nid(cipher); @@ -310,7 +310,7 @@ int PKCS5_pbe2_decrypt_init(const struct pbe_suite *suite, EVP_CIPHER_CTX *ctx, return 0; } - return pkcs5_pbe2_cipher_init(ctx, cipher, md, (unsigned)iterations, pass, + return pkcs5_pbe2_cipher_init(ctx, cipher, md, (uint32_t)iterations, pass, pass_len, CBS_data(&salt), CBS_len(&salt), CBS_data(&iv), CBS_len(&iv), 0 /* decrypt */); } diff --git a/Sources/CCryptoBoringSSL/crypto/pkcs8/pkcs8.c b/Sources/CCryptoBoringSSL/crypto/pkcs8/pkcs8.c index 1c93b828..08a1f216 100644 --- a/Sources/CCryptoBoringSSL/crypto/pkcs8/pkcs8.c +++ b/Sources/CCryptoBoringSSL/crypto/pkcs8/pkcs8.c @@ -106,7 +106,7 @@ err: } int pkcs12_key_gen(const char *pass, size_t pass_len, const uint8_t *salt, - size_t salt_len, uint8_t id, unsigned iterations, + size_t salt_len, uint8_t id, uint32_t iterations, size_t out_len, uint8_t *out, const EVP_MD *md) { // See https://tools.ietf.org/html/rfc7292#appendix-B. Quoted parts of the // specification have errata applied and other typos fixed. @@ -182,7 +182,7 @@ int pkcs12_key_gen(const char *pass, size_t pass_len, const uint8_t *salt, !EVP_DigestFinal_ex(&ctx, A, &A_len)) { goto err; } - for (unsigned iter = 1; iter < iterations; iter++) { + for (uint32_t iter = 1; iter < iterations; iter++) { if (!EVP_DigestInit_ex(&ctx, md, NULL) || !EVP_DigestUpdate(&ctx, A, A_len) || !EVP_DigestFinal_ex(&ctx, A, &A_len)) { @@ -229,7 +229,7 @@ err: } static int pkcs12_pbe_cipher_init(const struct pbe_suite *suite, - EVP_CIPHER_CTX *ctx, unsigned iterations, + EVP_CIPHER_CTX *ctx, uint32_t iterations, const char *pass, size_t pass_len, const uint8_t *salt, size_t salt_len, int is_encrypt) { @@ -271,7 +271,7 @@ static int pkcs12_pbe_decrypt_init(const struct pbe_suite *suite, return 0; } - return pkcs12_pbe_cipher_init(suite, ctx, (unsigned)iterations, pass, + return pkcs12_pbe_cipher_init(suite, ctx, (uint32_t)iterations, pass, pass_len, CBS_data(&salt), CBS_len(&salt), 0 /* decrypt */); } @@ -329,7 +329,7 @@ static const struct pbe_suite *get_pkcs12_pbe_suite(int pbe_nid) { } int pkcs12_pbe_encrypt_init(CBB *out, EVP_CIPHER_CTX *ctx, int alg, - unsigned iterations, const char *pass, + uint32_t iterations, const char *pass, size_t pass_len, const uint8_t *salt, size_t salt_len) { const struct pbe_suite *suite = get_pkcs12_pbe_suite(alg); @@ -489,10 +489,10 @@ int PKCS8_marshal_encrypted_private_key(CBB *out, int pbe_nid, // it. See 5693a30813a031d3921a016a870420e7eb93ec90 in OpenSSL. int alg_ok; if (pbe_nid == -1) { - alg_ok = PKCS5_pbe2_encrypt_init(&epki, &ctx, cipher, (unsigned)iterations, + alg_ok = PKCS5_pbe2_encrypt_init(&epki, &ctx, cipher, (uint32_t)iterations, pass, pass_len, salt, salt_len); } else { - alg_ok = pkcs12_pbe_encrypt_init(&epki, &ctx, pbe_nid, (unsigned)iterations, + alg_ok = pkcs12_pbe_encrypt_init(&epki, &ctx, pbe_nid, (uint32_t)iterations, pass, pass_len, salt, salt_len); } if (!alg_ok) { diff --git a/Sources/CCryptoBoringSSL/crypto/pkcs8/pkcs8_x509.c b/Sources/CCryptoBoringSSL/crypto/pkcs8/pkcs8_x509.c index 72b4cf8b..274d3576 100644 --- a/Sources/CCryptoBoringSSL/crypto/pkcs8/pkcs8_x509.c +++ b/Sources/CCryptoBoringSSL/crypto/pkcs8/pkcs8_x509.c @@ -87,6 +87,7 @@ int pkcs12_iterations_acceptable(uint64_t iterations) { static const uint64_t kIterationsLimit = 100 * 1000000; #endif + assert(kIterationsLimit <= UINT32_MAX); return 0 < iterations && iterations <= kIterationsLimit; } @@ -554,7 +555,7 @@ err: static int pkcs12_check_mac(int *out_mac_ok, const char *password, size_t password_len, const CBS *salt, - unsigned iterations, const EVP_MD *md, + uint32_t iterations, const EVP_MD *md, const CBS *authsafes, const CBS *expected_mac) { int ret = 0; uint8_t hmac_key[EVP_MAX_MD_SIZE]; @@ -676,13 +677,15 @@ int PKCS12_get_key_and_certs(EVP_PKEY **out_key, STACK_OF(X509) *out_certs, } // The iteration count is optional and the default is one. - uint64_t iterations = 1; + uint32_t iterations = 1; if (CBS_len(&mac_data) > 0) { - if (!CBS_get_asn1_uint64(&mac_data, &iterations) || - !pkcs12_iterations_acceptable(iterations)) { + uint64_t iterations_u64; + if (!CBS_get_asn1_uint64(&mac_data, &iterations_u64) || + !pkcs12_iterations_acceptable(iterations_u64)) { OPENSSL_PUT_ERROR(PKCS8, PKCS8_R_BAD_PKCS12_DATA); goto err; } + iterations = (uint32_t)iterations_u64; } int mac_ok; @@ -1056,7 +1059,7 @@ static int add_cert_safe_contents(CBB *cbb, X509 *cert, } static int add_encrypted_data(CBB *out, int pbe_nid, const char *password, - size_t password_len, unsigned iterations, + size_t password_len, uint32_t iterations, const uint8_t *in, size_t in_len) { uint8_t salt[PKCS5_SALT_LEN]; if (!RAND_bytes(salt, sizeof(salt))) { diff --git a/Sources/CCryptoBoringSSL/crypto/poly1305/poly1305_arm_asm.S b/Sources/CCryptoBoringSSL/crypto/poly1305/poly1305_arm_asm.S index 8f05a70a..ff4f09cf 100644 --- a/Sources/CCryptoBoringSSL/crypto/poly1305/poly1305_arm_asm.S +++ b/Sources/CCryptoBoringSSL/crypto/poly1305/poly1305_arm_asm.S @@ -1,16 +1,8 @@ #define BORINGSSL_PREFIX CCryptoBoringSSL #if defined(__arm__) && defined(__linux__) -#if defined(__has_feature) -#if __has_feature(memory_sanitizer) && !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif +#include -#if defined(__ARMEL__) && !defined(OPENSSL_NO_ASM) && defined(__ELF__) - -#if defined(BORINGSSL_PREFIX) -#include -#endif +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) # This implementation was taken from the public domain, neon2 version in # SUPERCOP by D. J. Bernstein and Peter Schwabe. @@ -2024,11 +2016,7 @@ vst1.8 d4,[r0,: 64] add sp,sp,#0 bx lr -#endif /* __ARMEL__ && !OPENSSL_NO_ASM && __ELF__ */ - -#if defined(__ELF__) -.section .note.GNU-stack,"",%progbits -#endif +#endif /* !OPENSSL_NO_ASM && OPENSSL_ARM && __ELF__ */ #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/Sources/CCryptoBoringSSL/crypto/pool/internal.h b/Sources/CCryptoBoringSSL/crypto/pool/internal.h index dab6b35e..654d300b 100644 --- a/Sources/CCryptoBoringSSL/crypto/pool/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/pool/internal.h @@ -18,6 +18,7 @@ #include #include +#include "../internal.h" #include "../lhash/internal.h" diff --git a/Sources/CCryptoBoringSSL/crypto/rand_extra/deterministic.c b/Sources/CCryptoBoringSSL/crypto/rand_extra/deterministic.c index 49df7bab..96b9b336 100644 --- a/Sources/CCryptoBoringSSL/crypto/rand_extra/deterministic.c +++ b/Sources/CCryptoBoringSSL/crypto/rand_extra/deterministic.c @@ -14,14 +14,15 @@ #include -#if defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) +#include "../fipsmodule/rand/internal.h" + +#if defined(OPENSSL_RAND_DETERMINISTIC) #include #include #include "../internal.h" -#include "../fipsmodule/rand/internal.h" // g_num_calls is the number of calls to |CRYPTO_sysrand| that have occurred. @@ -30,16 +31,16 @@ // multi-threaded program, replace this with a thread-local. (A mutex would not // be deterministic.) static uint64_t g_num_calls = 0; -static struct CRYPTO_STATIC_MUTEX g_num_calls_lock = CRYPTO_STATIC_MUTEX_INIT; +static CRYPTO_MUTEX g_num_calls_lock = CRYPTO_MUTEX_INIT; void RAND_reset_for_fuzzing(void) { g_num_calls = 0; } void CRYPTO_sysrand(uint8_t *out, size_t requested) { static const uint8_t kZeroKey[32]; - CRYPTO_STATIC_MUTEX_lock_write(&g_num_calls_lock); + CRYPTO_MUTEX_lock_write(&g_num_calls_lock); uint64_t num_calls = g_num_calls++; - CRYPTO_STATIC_MUTEX_unlock_write(&g_num_calls_lock); + CRYPTO_MUTEX_unlock_write(&g_num_calls_lock); uint8_t nonce[12]; OPENSSL_memset(nonce, 0, sizeof(nonce)); @@ -53,4 +54,4 @@ void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) { CRYPTO_sysrand(out, requested); } -#endif // BORINGSSL_UNSAFE_DETERMINISTIC_MODE +#endif // OPENSSL_RAND_DETERMINISTIC diff --git a/Sources/CCryptoBoringSSL/crypto/rand_extra/forkunsafe.c b/Sources/CCryptoBoringSSL/crypto/rand_extra/forkunsafe.c index 22af9823..51cb3db0 100644 --- a/Sources/CCryptoBoringSSL/crypto/rand_extra/forkunsafe.c +++ b/Sources/CCryptoBoringSSL/crypto/rand_extra/forkunsafe.c @@ -17,13 +17,12 @@ #include #include "../fipsmodule/rand/internal.h" +#include "../internal.h" -// g_buffering_enabled is true if fork-unsafe buffering has been enabled. -static int g_buffering_enabled = 0; - -// g_lock protects |g_buffering_enabled|. -static struct CRYPTO_STATIC_MUTEX g_lock = CRYPTO_STATIC_MUTEX_INIT; +// g_buffering_enabled is one if fork-unsafe buffering has been enabled and zero +// otherwise. +static CRYPTO_atomic_u32 g_buffering_enabled = 0; #if !defined(OPENSSL_WINDOWS) void RAND_enable_fork_unsafe_buffering(int fd) { @@ -32,15 +31,10 @@ void RAND_enable_fork_unsafe_buffering(int fd) { abort(); } - CRYPTO_STATIC_MUTEX_lock_write(&g_lock); - g_buffering_enabled = 1; - CRYPTO_STATIC_MUTEX_unlock_write(&g_lock); + CRYPTO_atomic_store_u32(&g_buffering_enabled, 1); } #endif int rand_fork_unsafe_buffering_enabled(void) { - CRYPTO_STATIC_MUTEX_lock_read(&g_lock); - const int ret = g_buffering_enabled; - CRYPTO_STATIC_MUTEX_unlock_read(&g_lock); - return ret; + return CRYPTO_atomic_load_u32(&g_buffering_enabled) != 0; } diff --git a/Sources/CCryptoBoringSSL/crypto/rand_extra/getentropy.c b/Sources/CCryptoBoringSSL/crypto/rand_extra/getentropy.c new file mode 100644 index 00000000..ccab73e1 --- /dev/null +++ b/Sources/CCryptoBoringSSL/crypto/rand_extra/getentropy.c @@ -0,0 +1,52 @@ +/* Copyright (c) 2023, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#if !defined(_DEFAULT_SOURCE) +#define _DEFAULT_SOURCE // Needed for getentropy on musl and glibc +#endif + +#include + +#include "../fipsmodule/rand/internal.h" + +#if defined(OPENSSL_RAND_GETENTROPY) + +#include +#include +#include + +#if defined(OPENSSL_MACOS) || defined(OPENSSL_FUCHSIA) +#include +#endif + +// CRYPTO_sysrand puts |requested| random bytes into |out|. +void CRYPTO_sysrand(uint8_t *out, size_t requested) { + while (requested > 0) { + // |getentropy| can only request 256 bytes at a time. + size_t todo = requested <= 256 ? requested : 256; + if (getentropy(out, todo) != 0) { + perror("getentropy() failed"); + abort(); + } + + out += todo; + requested -= todo; + } +} + +void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) { + CRYPTO_sysrand(out, requested); +} + +#endif // OPENSSL_RAND_GETENTROPY diff --git a/Sources/CCryptoBoringSSL/crypto/rand_extra/fuchsia.c b/Sources/CCryptoBoringSSL/crypto/rand_extra/ios.c similarity index 79% rename from Sources/CCryptoBoringSSL/crypto/rand_extra/fuchsia.c rename to Sources/CCryptoBoringSSL/crypto/rand_extra/ios.c index 613dc329..ca3b7127 100644 --- a/Sources/CCryptoBoringSSL/crypto/rand_extra/fuchsia.c +++ b/Sources/CCryptoBoringSSL/crypto/rand_extra/ios.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2017, Google Inc. +/* Copyright (c) 2023, Google Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -14,21 +14,21 @@ #include -#if defined(OPENSSL_FUCHSIA) && !defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) - -#include -#include - -#include - #include "../fipsmodule/rand/internal.h" +#if defined(OPENSSL_RAND_IOS) +#include + +#include + void CRYPTO_sysrand(uint8_t *out, size_t requested) { - zx_cprng_draw(out, requested); + if (CCRandomGenerateBytes(out, requested) != kCCSuccess) { + abort(); + } } void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) { CRYPTO_sysrand(out, requested); } -#endif // OPENSSL_FUCHSIA && !BORINGSSL_UNSAFE_DETERMINISTIC_MODE +#endif // OPENSSL_RAND_IOS diff --git a/Sources/CCryptoBoringSSL/crypto/rand_extra/trusty.c b/Sources/CCryptoBoringSSL/crypto/rand_extra/trusty.c new file mode 100644 index 00000000..88be7cbc --- /dev/null +++ b/Sources/CCryptoBoringSSL/crypto/rand_extra/trusty.c @@ -0,0 +1,38 @@ +/* Copyright (c) 2023, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#include + +#include "../fipsmodule/rand/internal.h" + +#if defined(OPENSSL_RAND_TRUSTY) +#include +#include + +#include +#include + +#include + +void CRYPTO_sysrand(uint8_t *out, size_t requested) { + if (trusty_rng_hw_rand(out, requested) != NO_ERROR) { + abort(); + } +} + +void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) { + CRYPTO_sysrand(out, requested); +} + +#endif // OPENSSL_RAND_TRUSTY diff --git a/Sources/CCryptoBoringSSL/crypto/rand_extra/windows.c b/Sources/CCryptoBoringSSL/crypto/rand_extra/windows.c index 670dc6fd..d7517af4 100644 --- a/Sources/CCryptoBoringSSL/crypto/rand_extra/windows.c +++ b/Sources/CCryptoBoringSSL/crypto/rand_extra/windows.c @@ -14,7 +14,9 @@ #include -#if defined(OPENSSL_WINDOWS) && !defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) +#include "../fipsmodule/rand/internal.h" + +#if defined(OPENSSL_RAND_WINDOWS) #include #include @@ -27,19 +29,14 @@ OPENSSL_MSVC_PRAGMA(warning(push, 3)) !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) #include OPENSSL_MSVC_PRAGMA(comment(lib, "bcrypt.lib")) -#else -// #define needed to link in RtlGenRandom(), a.k.a. SystemFunction036. See the -// "Community Additions" comment on MSDN here: -// http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx -#define SystemFunction036 NTAPI SystemFunction036 -#include -#undef SystemFunction036 #endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP OPENSSL_MSVC_PRAGMA(warning(pop)) -#include "../fipsmodule/rand/internal.h" +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ + !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +void CRYPTO_init_sysrand(void) {} void CRYPTO_sysrand(uint8_t *out, size_t requested) { while (requested > 0) { @@ -47,27 +44,52 @@ void CRYPTO_sysrand(uint8_t *out, size_t requested) { if (requested < output_bytes_this_pass) { output_bytes_this_pass = (ULONG)requested; } - // On non-UWP configurations, use RtlGenRandom instead of BCryptGenRandom - // to avoid accessing resources that may be unavailable inside the - // Chromium sandbox. See https://crbug.com/boringssl/307 -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ - !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) if (!BCRYPT_SUCCESS(BCryptGenRandom( /*hAlgorithm=*/NULL, out, output_bytes_this_pass, BCRYPT_USE_SYSTEM_PREFERRED_RNG))) { -#else - if (RtlGenRandom(out, output_bytes_this_pass) == FALSE) { -#endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP abort(); } requested -= output_bytes_this_pass; out += output_bytes_this_pass; } - return; } +#else + +// See: https://learn.microsoft.com/en-us/windows/win32/seccng/processprng +typedef BOOL (WINAPI *ProcessPrngFunction)(PBYTE pbData, SIZE_T cbData); +static ProcessPrngFunction g_processprng_fn = NULL; + +static void init_processprng(void) { + HMODULE hmod = LoadLibraryW(L"bcryptprimitives"); + if (hmod == NULL) { + abort(); + } + g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng"); + if (g_processprng_fn == NULL) { + abort(); + } +} + +void CRYPTO_init_sysrand(void) { + static CRYPTO_once_t once = CRYPTO_ONCE_INIT; + CRYPTO_once(&once, init_processprng); +} + +void CRYPTO_sysrand(uint8_t *out, size_t requested) { + CRYPTO_init_sysrand(); + // On non-UWP configurations, use ProcessPrng instead of BCryptGenRandom + // to avoid accessing resources that may be unavailable inside the + // Chromium sandbox. See https://crbug.com/74242 + if (!g_processprng_fn(out, requested)) { + abort(); + } +} + +#endif // WINAPI_PARTITION_APP && !WINAPI_PARTITION_DESKTOP + void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) { CRYPTO_sysrand(out, requested); } -#endif // OPENSSL_WINDOWS && !BORINGSSL_UNSAFE_DETERMINISTIC_MODE +#endif // OPENSSL_RAND_WINDOWS diff --git a/Sources/CCryptoBoringSSL/crypto/refcount_c11.c b/Sources/CCryptoBoringSSL/crypto/refcount.c similarity index 65% rename from Sources/CCryptoBoringSSL/crypto/refcount_c11.c rename to Sources/CCryptoBoringSSL/crypto/refcount.c index a1781c66..d2a886d0 100644 --- a/Sources/CCryptoBoringSSL/crypto/refcount_c11.c +++ b/Sources/CCryptoBoringSSL/crypto/refcount.c @@ -14,39 +14,34 @@ #include "internal.h" - -#if defined(OPENSSL_C11_ATOMIC) - #include -#include -#include #include // See comment above the typedef of CRYPTO_refcount_t about these tests. -static_assert(alignof(CRYPTO_refcount_t) == alignof(_Atomic CRYPTO_refcount_t), - "_Atomic alters the needed alignment of a reference count"); -static_assert(sizeof(CRYPTO_refcount_t) == sizeof(_Atomic CRYPTO_refcount_t), - "_Atomic alters the size of a reference count"); +static_assert(alignof(CRYPTO_refcount_t) == alignof(CRYPTO_atomic_u32), + "CRYPTO_refcount_t does not match CRYPTO_atomic_u32 alignment"); +static_assert(sizeof(CRYPTO_refcount_t) == sizeof(CRYPTO_atomic_u32), + "CRYPTO_refcount_t does not match CRYPTO_atomic_u32 size"); static_assert((CRYPTO_refcount_t)-1 == CRYPTO_REFCOUNT_MAX, "CRYPTO_REFCOUNT_MAX is incorrect"); void CRYPTO_refcount_inc(CRYPTO_refcount_t *in_count) { - _Atomic CRYPTO_refcount_t *count = (_Atomic CRYPTO_refcount_t *) in_count; - uint32_t expected = atomic_load(count); + CRYPTO_atomic_u32 *count = (CRYPTO_atomic_u32 *)in_count; + uint32_t expected = CRYPTO_atomic_load_u32(count); while (expected != CRYPTO_REFCOUNT_MAX) { uint32_t new_value = expected + 1; - if (atomic_compare_exchange_weak(count, &expected, new_value)) { + if (CRYPTO_atomic_compare_exchange_weak_u32(count, &expected, new_value)) { break; } } } int CRYPTO_refcount_dec_and_test_zero(CRYPTO_refcount_t *in_count) { - _Atomic CRYPTO_refcount_t *count = (_Atomic CRYPTO_refcount_t *)in_count; - uint32_t expected = atomic_load(count); + CRYPTO_atomic_u32 *count = (CRYPTO_atomic_u32 *)in_count; + uint32_t expected = CRYPTO_atomic_load_u32(count); for (;;) { if (expected == 0) { @@ -55,11 +50,10 @@ int CRYPTO_refcount_dec_and_test_zero(CRYPTO_refcount_t *in_count) { return 0; } else { const uint32_t new_value = expected - 1; - if (atomic_compare_exchange_weak(count, &expected, new_value)) { + if (CRYPTO_atomic_compare_exchange_weak_u32(count, &expected, + new_value)) { return new_value == 0; } } } } - -#endif // OPENSSL_C11_ATOMIC diff --git a/Sources/CCryptoBoringSSL/crypto/refcount_lock.c b/Sources/CCryptoBoringSSL/crypto/refcount_lock.c deleted file mode 100644 index 173267e3..00000000 --- a/Sources/CCryptoBoringSSL/crypto/refcount_lock.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2015, Google Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#include "internal.h" - -#include -#include - - -#if !defined(OPENSSL_C11_ATOMIC) - -static_assert((CRYPTO_refcount_t)-1 == CRYPTO_REFCOUNT_MAX, - "CRYPTO_REFCOUNT_MAX is incorrect"); - -static struct CRYPTO_STATIC_MUTEX g_refcount_lock = CRYPTO_STATIC_MUTEX_INIT; - -void CRYPTO_refcount_inc(CRYPTO_refcount_t *count) { - CRYPTO_STATIC_MUTEX_lock_write(&g_refcount_lock); - if (*count < CRYPTO_REFCOUNT_MAX) { - (*count)++; - } - CRYPTO_STATIC_MUTEX_unlock_write(&g_refcount_lock); -} - -int CRYPTO_refcount_dec_and_test_zero(CRYPTO_refcount_t *count) { - int ret; - - CRYPTO_STATIC_MUTEX_lock_write(&g_refcount_lock); - if (*count == 0) { - abort(); - } - if (*count < CRYPTO_REFCOUNT_MAX) { - (*count)--; - } - ret = (*count == 0); - CRYPTO_STATIC_MUTEX_unlock_write(&g_refcount_lock); - - return ret; -} - -#endif // OPENSSL_C11_ATOMIC diff --git a/Sources/CCryptoBoringSSL/crypto/rsa_extra/rsa_crypt.c b/Sources/CCryptoBoringSSL/crypto/rsa_extra/rsa_crypt.c index ab27f671..ebae0c37 100644 --- a/Sources/CCryptoBoringSSL/crypto/rsa_extra/rsa_crypt.c +++ b/Sources/CCryptoBoringSSL/crypto/rsa_extra/rsa_crypt.c @@ -376,6 +376,11 @@ int RSA_private_encrypt(size_t flen, const uint8_t *from, uint8_t *to, RSA *rsa, int RSA_encrypt(RSA *rsa, size_t *out_len, uint8_t *out, size_t max_out, const uint8_t *in, size_t in_len, int padding) { + if (rsa->n == NULL || rsa->e == NULL) { + OPENSSL_PUT_ERROR(RSA, RSA_R_VALUE_MISSING); + return 0; + } + if (!rsa_check_public_key(rsa)) { return 0; } diff --git a/Sources/CCryptoBoringSSL/crypto/stack/stack.c b/Sources/CCryptoBoringSSL/crypto/stack/stack.c index b4320567..e0e20ebf 100644 --- a/Sources/CCryptoBoringSSL/crypto/stack/stack.c +++ b/Sources/CCryptoBoringSSL/crypto/stack/stack.c @@ -57,22 +57,38 @@ #include #include +#include +#include #include #include "../internal.h" +struct stack_st { + // num contains the number of valid pointers in |data|. + size_t num; + void **data; + // sorted is non-zero if the values pointed to by |data| are in ascending + // order, based on |comp|. + int sorted; + // num_alloc contains the number of pointers allocated in the buffer pointed + // to by |data|, which may be larger than |num|. + size_t num_alloc; + // comp is an optional comparison function. + OPENSSL_sk_cmp_func comp; +}; + // kMinSize is the number of pointers that will be initially allocated in a new // stack. static const size_t kMinSize = 4; -_STACK *sk_new(OPENSSL_sk_cmp_func comp) { - _STACK *ret = OPENSSL_malloc(sizeof(_STACK)); +OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_cmp_func comp) { + OPENSSL_STACK *ret = OPENSSL_malloc(sizeof(OPENSSL_STACK)); if (ret == NULL) { return NULL; } - OPENSSL_memset(ret, 0, sizeof(_STACK)); + OPENSSL_memset(ret, 0, sizeof(OPENSSL_STACK)); ret->data = OPENSSL_malloc(sizeof(void *) * kMinSize); if (ret->data == NULL) { @@ -91,16 +107,16 @@ err: return NULL; } -_STACK *sk_new_null(void) { return sk_new(NULL); } +OPENSSL_STACK *OPENSSL_sk_new_null(void) { return OPENSSL_sk_new(NULL); } -size_t sk_num(const _STACK *sk) { +size_t OPENSSL_sk_num(const OPENSSL_STACK *sk) { if (sk == NULL) { return 0; } return sk->num; } -void sk_zero(_STACK *sk) { +void OPENSSL_sk_zero(OPENSSL_STACK *sk) { if (sk == NULL || sk->num == 0) { return; } @@ -109,21 +125,21 @@ void sk_zero(_STACK *sk) { sk->sorted = 0; } -void *sk_value(const _STACK *sk, size_t i) { +void *OPENSSL_sk_value(const OPENSSL_STACK *sk, size_t i) { if (!sk || i >= sk->num) { return NULL; } return sk->data[i]; } -void *sk_set(_STACK *sk, size_t i, void *value) { +void *OPENSSL_sk_set(OPENSSL_STACK *sk, size_t i, void *value) { if (!sk || i >= sk->num) { return NULL; } return sk->data[i] = value; } -void sk_free(_STACK *sk) { +void OPENSSL_sk_free(OPENSSL_STACK *sk) { if (sk == NULL) { return; } @@ -131,8 +147,9 @@ void sk_free(_STACK *sk) { OPENSSL_free(sk); } -void sk_pop_free_ex(_STACK *sk, OPENSSL_sk_call_free_func call_free_func, - OPENSSL_sk_free_func free_func) { +void OPENSSL_sk_pop_free_ex(OPENSSL_STACK *sk, + OPENSSL_sk_call_free_func call_free_func, + OPENSSL_sk_free_func free_func) { if (sk == NULL) { return; } @@ -142,7 +159,7 @@ void sk_pop_free_ex(_STACK *sk, OPENSSL_sk_call_free_func call_free_func, call_free_func(free_func, sk->data[i]); } } - sk_free(sk); + OPENSSL_sk_free(sk); } // Historically, |sk_pop_free| called the function as |OPENSSL_sk_free_func| @@ -152,15 +169,20 @@ static void call_free_func_legacy(OPENSSL_sk_free_func func, void *ptr) { func(ptr); } -void sk_pop_free(_STACK *sk, OPENSSL_sk_free_func free_func) { - sk_pop_free_ex(sk, call_free_func_legacy, free_func); +void sk_pop_free(OPENSSL_STACK *sk, OPENSSL_sk_free_func free_func) { + OPENSSL_sk_pop_free_ex(sk, call_free_func_legacy, free_func); } -size_t sk_insert(_STACK *sk, void *p, size_t where) { +size_t OPENSSL_sk_insert(OPENSSL_STACK *sk, void *p, size_t where) { if (sk == NULL) { return 0; } + if (sk->num >= INT_MAX) { + OPENSSL_PUT_ERROR(CRYPTO, ERR_R_OVERFLOW); + return 0; + } + if (sk->num_alloc <= sk->num + 1) { // Attempt to double the size of the array. size_t new_alloc = sk->num_alloc << 1; @@ -201,7 +223,7 @@ size_t sk_insert(_STACK *sk, void *p, size_t where) { return sk->num; } -void *sk_delete(_STACK *sk, size_t where) { +void *OPENSSL_sk_delete(OPENSSL_STACK *sk, size_t where) { void *ret; if (!sk || where >= sk->num) { @@ -219,22 +241,23 @@ void *sk_delete(_STACK *sk, size_t where) { return ret; } -void *sk_delete_ptr(_STACK *sk, const void *p) { +void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *sk, const void *p) { if (sk == NULL) { return NULL; } for (size_t i = 0; i < sk->num; i++) { if (sk->data[i] == p) { - return sk_delete(sk, i); + return OPENSSL_sk_delete(sk, i); } } return NULL; } -void sk_delete_if(_STACK *sk, OPENSSL_sk_call_delete_if_func call_func, - OPENSSL_sk_delete_if_func func, void *data) { +void OPENSSL_sk_delete_if(OPENSSL_STACK *sk, + OPENSSL_sk_call_delete_if_func call_func, + OPENSSL_sk_delete_if_func func, void *data) { if (sk == NULL) { return; } @@ -249,8 +272,8 @@ void sk_delete_if(_STACK *sk, OPENSSL_sk_call_delete_if_func call_func, sk->num = new_num; } -int sk_find(const _STACK *sk, size_t *out_index, const void *p, - OPENSSL_sk_call_cmp_func call_cmp_func) { +int OPENSSL_sk_find(const OPENSSL_STACK *sk, size_t *out_index, const void *p, + OPENSSL_sk_call_cmp_func call_cmp_func) { if (sk == NULL) { return 0; } @@ -272,10 +295,9 @@ int sk_find(const _STACK *sk, size_t *out_index, const void *p, return 0; } - if (!sk_is_sorted(sk)) { + if (!OPENSSL_sk_is_sorted(sk)) { for (size_t i = 0; i < sk->num; i++) { - const void *elem = sk->data[i]; - if (call_cmp_func(sk->comp, &p, &elem) == 0) { + if (call_cmp_func(sk->comp, p, sk->data[i]) == 0) { if (out_index) { *out_index = i; } @@ -294,8 +316,7 @@ int sk_find(const _STACK *sk, size_t *out_index, const void *p, // Bias |mid| towards |lo|. See the |r == 0| case below. size_t mid = lo + (hi - lo - 1) / 2; assert(lo <= mid && mid < hi); - const void *elem = sk->data[mid]; - int r = call_cmp_func(sk->comp, &p, &elem); + int r = call_cmp_func(sk->comp, p, sk->data[mid]); if (r > 0) { lo = mid + 1; // |mid| is too low. } else if (r < 0) { @@ -320,38 +341,40 @@ int sk_find(const _STACK *sk, size_t *out_index, const void *p, return 0; // Not found. } -void *sk_shift(_STACK *sk) { +void *OPENSSL_sk_shift(OPENSSL_STACK *sk) { if (sk == NULL) { return NULL; } if (sk->num == 0) { return NULL; } - return sk_delete(sk, 0); + return OPENSSL_sk_delete(sk, 0); } -size_t sk_push(_STACK *sk, void *p) { return (sk_insert(sk, p, sk->num)); } +size_t OPENSSL_sk_push(OPENSSL_STACK *sk, void *p) { + return OPENSSL_sk_insert(sk, p, sk->num); +} -void *sk_pop(_STACK *sk) { +void *OPENSSL_sk_pop(OPENSSL_STACK *sk) { if (sk == NULL) { return NULL; } if (sk->num == 0) { return NULL; } - return sk_delete(sk, sk->num - 1); + return OPENSSL_sk_delete(sk, sk->num - 1); } -_STACK *sk_dup(const _STACK *sk) { +OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *sk) { if (sk == NULL) { return NULL; } - _STACK *ret = OPENSSL_malloc(sizeof(_STACK)); + OPENSSL_STACK *ret = OPENSSL_malloc(sizeof(OPENSSL_STACK)); if (ret == NULL) { return NULL; } - OPENSSL_memset(ret, 0, sizeof(_STACK)); + OPENSSL_memset(ret, 0, sizeof(OPENSSL_STACK)); ret->data = OPENSSL_malloc(sizeof(void *) * sk->num_alloc); if (ret->data == NULL) { @@ -366,52 +389,88 @@ _STACK *sk_dup(const _STACK *sk) { return ret; err: - sk_free(ret); + OPENSSL_sk_free(ret); return NULL; } -#if defined(_MSC_VER) -struct sort_compare_ctx { - OPENSSL_sk_call_cmp_func call_cmp_func; - OPENSSL_sk_cmp_func cmp_func; -}; - -static int sort_compare(void *ctx_v, const void *a, const void *b) { - struct sort_compare_ctx *ctx = ctx_v; - return ctx->call_cmp_func(ctx->cmp_func, a, b); +static size_t parent_idx(size_t idx) { + assert(idx > 0); + return (idx - 1) / 2; } -#endif -void sk_sort(_STACK *sk, OPENSSL_sk_call_cmp_func call_cmp_func) { +static size_t left_idx(size_t idx) { + // The largest possible index is |PTRDIFF_MAX|, not |SIZE_MAX|. If + // |ptrdiff_t|, a signed type, is the same size as |size_t|, this cannot + // overflow. + assert(idx <= PTRDIFF_MAX); + static_assert(PTRDIFF_MAX <= (SIZE_MAX - 1) / 2, "2 * idx + 1 may oveflow"); + return 2 * idx + 1; +} + +// down_heap fixes the subtree rooted at |i|. |i|'s children must each satisfy +// the heap property. Only the first |num| elements of |sk| are considered. +static void down_heap(OPENSSL_STACK *sk, OPENSSL_sk_call_cmp_func call_cmp_func, + size_t i, size_t num) { + assert(i < num && num <= sk->num); + for (;;) { + size_t left = left_idx(i); + if (left >= num) { + break; // No left child. + } + + // Swap |i| with the largest of its children. + size_t next = i; + if (call_cmp_func(sk->comp, sk->data[next], sk->data[left]) < 0) { + next = left; + } + size_t right = left + 1; // Cannot overflow because |left < num|. + if (right < num && + call_cmp_func(sk->comp, sk->data[next], sk->data[right]) < 0) { + next = right; + } + + if (i == next) { + break; // |i| is already larger than its children. + } + + void *tmp = sk->data[i]; + sk->data[i] = sk->data[next]; + sk->data[next] = tmp; + i = next; + } +} + +void OPENSSL_sk_sort(OPENSSL_STACK *sk, + OPENSSL_sk_call_cmp_func call_cmp_func) { if (sk == NULL || sk->comp == NULL || sk->sorted) { return; } if (sk->num >= 2) { -#if defined(_MSC_VER) - // MSVC's |qsort_s| is different from the C11 one. - // https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/qsort-s?view=msvc-170 - struct sort_compare_ctx ctx = {call_cmp_func, sk->comp}; - qsort_s(sk->data, sk->num, sizeof(void *), sort_compare, &ctx); -#else - // sk->comp is a function that takes pointers to pointers to elements, but - // qsort take a comparison function that just takes pointers to elements. - // However, since we're passing an array of pointers to qsort, we can just - // cast the comparison function and everything works. - // - // TODO(davidben): This is undefined behavior, but the call is in libc so, - // e.g., CFI does not notice. |qsort| is missing a void* parameter in its - // callback, while no one defines |qsort_r| or |qsort_s| consistently. See + // |qsort| lacks a context parameter in the comparison function for us to + // pass in |call_cmp_func| and |sk->comp|. While we could cast |sk->comp| to + // the expected type, it is undefined behavior in C can trip sanitizers. + // |qsort_r| and |qsort_s| avoid this, but using them is impractical. See // https://stackoverflow.com/a/39561369 - int (*comp_func)(const void *, const void *) = - (int (*)(const void *, const void *))(sk->comp); - qsort(sk->data, sk->num, sizeof(void *), comp_func); -#endif + // + // Use our own heap sort instead. This is not performance-sensitive, so we + // optimize for simplicity and size. First, build a max-heap in place. + for (size_t i = parent_idx(sk->num - 1); i < sk->num; i--) { + down_heap(sk, call_cmp_func, i, sk->num); + } + + // Iteratively remove the maximum element to populate the result in reverse. + for (size_t i = sk->num - 1; i > 0; i--) { + void *tmp = sk->data[0]; + sk->data[0] = sk->data[i]; + sk->data[i] = tmp; + down_heap(sk, call_cmp_func, 0, i); + } } sk->sorted = 1; } -int sk_is_sorted(const _STACK *sk) { +int OPENSSL_sk_is_sorted(const OPENSSL_STACK *sk) { if (!sk) { return 1; } @@ -419,7 +478,8 @@ int sk_is_sorted(const _STACK *sk) { return sk->sorted || (sk->comp != NULL && sk->num < 2); } -OPENSSL_sk_cmp_func sk_set_cmp_func(_STACK *sk, OPENSSL_sk_cmp_func comp) { +OPENSSL_sk_cmp_func OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk, + OPENSSL_sk_cmp_func comp) { OPENSSL_sk_cmp_func old = sk->comp; if (sk->comp != comp) { @@ -430,11 +490,12 @@ OPENSSL_sk_cmp_func sk_set_cmp_func(_STACK *sk, OPENSSL_sk_cmp_func comp) { return old; } -_STACK *sk_deep_copy(const _STACK *sk, OPENSSL_sk_call_copy_func call_copy_func, - OPENSSL_sk_copy_func copy_func, - OPENSSL_sk_call_free_func call_free_func, - OPENSSL_sk_free_func free_func) { - _STACK *ret = sk_dup(sk); +OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *sk, + OPENSSL_sk_call_copy_func call_copy_func, + OPENSSL_sk_copy_func copy_func, + OPENSSL_sk_call_free_func call_free_func, + OPENSSL_sk_free_func free_func) { + OPENSSL_STACK *ret = OPENSSL_sk_dup(sk); if (ret == NULL) { return NULL; } @@ -450,10 +511,29 @@ _STACK *sk_deep_copy(const _STACK *sk, OPENSSL_sk_call_copy_func call_copy_func, call_free_func(free_func, ret->data[j]); } } - sk_free(ret); + OPENSSL_sk_free(ret); return NULL; } } return ret; } + +OPENSSL_STACK *sk_new_null(void) { return OPENSSL_sk_new_null(); } + +size_t sk_num(const OPENSSL_STACK *sk) { return OPENSSL_sk_num(sk); } + +void *sk_value(const OPENSSL_STACK *sk, size_t i) { + return OPENSSL_sk_value(sk, i); +} + +void sk_free(OPENSSL_STACK *sk) { OPENSSL_sk_free(sk); } + +size_t sk_push(OPENSSL_STACK *sk, void *p) { return OPENSSL_sk_push(sk, p); } + +void *sk_pop(OPENSSL_STACK *sk) { return OPENSSL_sk_pop(sk); } + +void sk_pop_free_ex(OPENSSL_STACK *sk, OPENSSL_sk_call_free_func call_free_func, + OPENSSL_sk_free_func free_func) { + OPENSSL_sk_pop_free_ex(sk, call_free_func, free_func); +} diff --git a/Sources/CCryptoBoringSSL/crypto/thread_none.c b/Sources/CCryptoBoringSSL/crypto/thread_none.c index 4f07b9d9..e6f7d427 100644 --- a/Sources/CCryptoBoringSSL/crypto/thread_none.c +++ b/Sources/CCryptoBoringSSL/crypto/thread_none.c @@ -28,14 +28,6 @@ void CRYPTO_MUTEX_unlock_write(CRYPTO_MUTEX *lock) {} void CRYPTO_MUTEX_cleanup(CRYPTO_MUTEX *lock) {} -void CRYPTO_STATIC_MUTEX_lock_read(struct CRYPTO_STATIC_MUTEX *lock) {} - -void CRYPTO_STATIC_MUTEX_lock_write(struct CRYPTO_STATIC_MUTEX *lock) {} - -void CRYPTO_STATIC_MUTEX_unlock_read(struct CRYPTO_STATIC_MUTEX *lock) {} - -void CRYPTO_STATIC_MUTEX_unlock_write(struct CRYPTO_STATIC_MUTEX *lock) {} - void CRYPTO_once(CRYPTO_once_t *once, void (*init)(void)) { if (*once) { return; diff --git a/Sources/CCryptoBoringSSL/crypto/thread_pthread.c b/Sources/CCryptoBoringSSL/crypto/thread_pthread.c index 82cbbfe5..a40fbc00 100644 --- a/Sources/CCryptoBoringSSL/crypto/thread_pthread.c +++ b/Sources/CCryptoBoringSSL/crypto/thread_pthread.c @@ -23,67 +23,38 @@ #include #include -static_assert(sizeof(CRYPTO_MUTEX) >= sizeof(pthread_rwlock_t), - "CRYPTO_MUTEX is too small"); -static_assert(alignof(CRYPTO_MUTEX) >= alignof(pthread_rwlock_t), - "CRYPTO_MUTEX has insufficient alignment"); - void CRYPTO_MUTEX_init(CRYPTO_MUTEX *lock) { - if (pthread_rwlock_init((pthread_rwlock_t *) lock, NULL) != 0) { + if (pthread_rwlock_init(lock, NULL) != 0) { abort(); } } void CRYPTO_MUTEX_lock_read(CRYPTO_MUTEX *lock) { - if (pthread_rwlock_rdlock((pthread_rwlock_t *) lock) != 0) { + if (pthread_rwlock_rdlock(lock) != 0) { abort(); } } void CRYPTO_MUTEX_lock_write(CRYPTO_MUTEX *lock) { - if (pthread_rwlock_wrlock((pthread_rwlock_t *) lock) != 0) { + if (pthread_rwlock_wrlock(lock) != 0) { abort(); } } void CRYPTO_MUTEX_unlock_read(CRYPTO_MUTEX *lock) { - if (pthread_rwlock_unlock((pthread_rwlock_t *) lock) != 0) { + if (pthread_rwlock_unlock(lock) != 0) { abort(); } } void CRYPTO_MUTEX_unlock_write(CRYPTO_MUTEX *lock) { - if (pthread_rwlock_unlock((pthread_rwlock_t *) lock) != 0) { + if (pthread_rwlock_unlock(lock) != 0) { abort(); } } void CRYPTO_MUTEX_cleanup(CRYPTO_MUTEX *lock) { - pthread_rwlock_destroy((pthread_rwlock_t *) lock); -} - -void CRYPTO_STATIC_MUTEX_lock_read(struct CRYPTO_STATIC_MUTEX *lock) { - if (pthread_rwlock_rdlock(&lock->lock) != 0) { - abort(); - } -} - -void CRYPTO_STATIC_MUTEX_lock_write(struct CRYPTO_STATIC_MUTEX *lock) { - if (pthread_rwlock_wrlock(&lock->lock) != 0) { - abort(); - } -} - -void CRYPTO_STATIC_MUTEX_unlock_read(struct CRYPTO_STATIC_MUTEX *lock) { - if (pthread_rwlock_unlock(&lock->lock) != 0) { - abort(); - } -} - -void CRYPTO_STATIC_MUTEX_unlock_write(struct CRYPTO_STATIC_MUTEX *lock) { - if (pthread_rwlock_unlock(&lock->lock) != 0) { - abort(); - } + pthread_rwlock_destroy(lock); } void CRYPTO_once(CRYPTO_once_t *once, void (*init)(void)) { diff --git a/Sources/CCryptoBoringSSL/crypto/thread_win.c b/Sources/CCryptoBoringSSL/crypto/thread_win.c index 57e4f9be..6daa8144 100644 --- a/Sources/CCryptoBoringSSL/crypto/thread_win.c +++ b/Sources/CCryptoBoringSSL/crypto/thread_win.c @@ -26,11 +26,6 @@ OPENSSL_MSVC_PRAGMA(warning(pop)) #include #include -static_assert(sizeof(CRYPTO_MUTEX) >= sizeof(SRWLOCK), - "CRYPTO_MUTEX is too small"); -static_assert(alignof(CRYPTO_MUTEX) >= alignof(SRWLOCK), - "CRYPTO_MUTEX has insufficient alignment"); - static BOOL CALLBACK call_once_init(INIT_ONCE *once, void *arg, void **out) { void (**init)(void) = (void (**)(void))arg; (**init)(); @@ -44,45 +39,29 @@ void CRYPTO_once(CRYPTO_once_t *once, void (*init)(void)) { } void CRYPTO_MUTEX_init(CRYPTO_MUTEX *lock) { - InitializeSRWLock((SRWLOCK *) lock); + InitializeSRWLock(lock); } void CRYPTO_MUTEX_lock_read(CRYPTO_MUTEX *lock) { - AcquireSRWLockShared((SRWLOCK *) lock); + AcquireSRWLockShared(lock); } void CRYPTO_MUTEX_lock_write(CRYPTO_MUTEX *lock) { - AcquireSRWLockExclusive((SRWLOCK *) lock); + AcquireSRWLockExclusive(lock); } void CRYPTO_MUTEX_unlock_read(CRYPTO_MUTEX *lock) { - ReleaseSRWLockShared((SRWLOCK *) lock); + ReleaseSRWLockShared(lock); } void CRYPTO_MUTEX_unlock_write(CRYPTO_MUTEX *lock) { - ReleaseSRWLockExclusive((SRWLOCK *) lock); + ReleaseSRWLockExclusive(lock); } void CRYPTO_MUTEX_cleanup(CRYPTO_MUTEX *lock) { // SRWLOCKs require no cleanup. } -void CRYPTO_STATIC_MUTEX_lock_read(struct CRYPTO_STATIC_MUTEX *lock) { - AcquireSRWLockShared(&lock->lock); -} - -void CRYPTO_STATIC_MUTEX_lock_write(struct CRYPTO_STATIC_MUTEX *lock) { - AcquireSRWLockExclusive(&lock->lock); -} - -void CRYPTO_STATIC_MUTEX_unlock_read(struct CRYPTO_STATIC_MUTEX *lock) { - ReleaseSRWLockShared(&lock->lock); -} - -void CRYPTO_STATIC_MUTEX_unlock_write(struct CRYPTO_STATIC_MUTEX *lock) { - ReleaseSRWLockExclusive(&lock->lock); -} - static SRWLOCK g_destructors_lock = SRWLOCK_INIT; static thread_local_destructor_t g_destructors[NUM_OPENSSL_THREAD_LOCALS]; diff --git a/Sources/CCryptoBoringSSL/crypto/trust_token/internal.h b/Sources/CCryptoBoringSSL/crypto/trust_token/internal.h index 3831ebe9..afdee0a2 100644 --- a/Sources/CCryptoBoringSSL/crypto/trust_token/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/trust_token/internal.h @@ -239,6 +239,10 @@ STACK_OF(TRUST_TOKEN_PRETOKEN) *voprf_pst1_blind(CBB *cbb, size_t count, int voprf_pst1_sign(const TRUST_TOKEN_ISSUER_KEY *key, CBB *cbb, CBS *cbs, size_t num_requested, size_t num_to_issue, uint8_t private_metadata); +OPENSSL_EXPORT int voprf_pst1_sign_with_proof_scalar_for_testing( + const TRUST_TOKEN_ISSUER_KEY *key, CBB *cbb, CBS *cbs, size_t num_requested, + size_t num_to_issue, uint8_t private_metadata, + const uint8_t *proof_scalar_buf, size_t proof_scalar_len); STACK_OF(TRUST_TOKEN) *voprf_pst1_unblind( const TRUST_TOKEN_CLIENT_KEY *key, const STACK_OF(TRUST_TOKEN_PRETOKEN) *pretokens, CBS *cbs, size_t count, diff --git a/Sources/CCryptoBoringSSL/crypto/trust_token/pmbtoken.c b/Sources/CCryptoBoringSSL/crypto/trust_token/pmbtoken.c index c2a7aea9..df48fd76 100644 --- a/Sources/CCryptoBoringSSL/crypto/trust_token/pmbtoken.c +++ b/Sources/CCryptoBoringSSL/crypto/trust_token/pmbtoken.c @@ -30,9 +30,9 @@ #include "internal.h" -typedef int (*hash_t_func_t)(const EC_GROUP *group, EC_RAW_POINT *out, +typedef int (*hash_t_func_t)(const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t t[TRUST_TOKEN_NONCE_SIZE]); -typedef int (*hash_s_func_t)(const EC_GROUP *group, EC_RAW_POINT *out, +typedef int (*hash_s_func_t)(const EC_GROUP *group, EC_JACOBIAN *out, const EC_AFFINE *t, const uint8_t s[TRUST_TOKEN_NONCE_SIZE]); typedef int (*hash_c_func_t)(const EC_GROUP *group, EC_SCALAR *out, @@ -44,7 +44,7 @@ typedef struct { const EC_GROUP *group; EC_PRECOMP g_precomp; EC_PRECOMP h_precomp; - EC_RAW_POINT h; + EC_JACOBIAN h; // hash_t implements the H_t operation in PMBTokens. It returns one on success // and zero on error. hash_t_func_t hash_t; @@ -62,17 +62,13 @@ typedef struct { static const uint8_t kDefaultAdditionalData[32] = {0}; -static int pmbtoken_init_method(PMBTOKEN_METHOD *method, int curve_nid, +static int pmbtoken_init_method(PMBTOKEN_METHOD *method, const EC_GROUP *group, const uint8_t *h_bytes, size_t h_len, hash_t_func_t hash_t, hash_s_func_t hash_s, hash_c_func_t hash_c, hash_to_scalar_func_t hash_to_scalar, int prefix_point) { - method->group = EC_GROUP_new_by_curve_name(curve_nid); - if (method->group == NULL) { - return 0; - } - + method->group = group; method->hash_t = hash_t; method->hash_s = hash_s; method->hash_c = hash_c; @@ -86,7 +82,7 @@ static int pmbtoken_init_method(PMBTOKEN_METHOD *method, int curve_nid, ec_affine_to_jacobian(method->group, &method->h, &h); if (!ec_init_precomp(method->group, &method->g_precomp, - &method->group->generator->raw) || + &method->group->generator.raw) || !ec_init_precomp(method->group, &method->h_precomp, &method->h)) { return 0; } @@ -160,7 +156,7 @@ static int cbs_get_prefixed_point(CBS *cbs, const EC_GROUP *group, return 0; } } else { - size_t plen = 1 + 2 * BN_num_bytes(&group->field); + size_t plen = ec_point_byte_len(group, POINT_CONVERSION_UNCOMPRESSED); if (!CBS_get_bytes(cbs, &child, plen)) { return 0; } @@ -173,11 +169,11 @@ static int cbs_get_prefixed_point(CBS *cbs, const EC_GROUP *group, return 1; } -static int mul_public_3(const EC_GROUP *group, EC_RAW_POINT *out, - const EC_RAW_POINT *p0, const EC_SCALAR *scalar0, - const EC_RAW_POINT *p1, const EC_SCALAR *scalar1, - const EC_RAW_POINT *p2, const EC_SCALAR *scalar2) { - EC_RAW_POINT points[3] = {*p0, *p1, *p2}; +static int mul_public_3(const EC_GROUP *group, EC_JACOBIAN *out, + const EC_JACOBIAN *p0, const EC_SCALAR *scalar0, + const EC_JACOBIAN *p1, const EC_SCALAR *scalar1, + const EC_JACOBIAN *p2, const EC_SCALAR *scalar2) { + EC_JACOBIAN points[3] = {*p0, *p1, *p2}; EC_SCALAR scalars[3] = {*scalar0, *scalar1, *scalar2}; return ec_point_mul_scalar_public_batch(group, out, /*g_scalar=*/NULL, points, scalars, 3); @@ -189,7 +185,7 @@ static int pmbtoken_compute_keys(const PMBTOKEN_METHOD *method, const EC_SCALAR *x1, const EC_SCALAR *y1, const EC_SCALAR *xs, const EC_SCALAR *ys) { const EC_GROUP *group = method->group; - EC_RAW_POINT pub[3]; + EC_JACOBIAN pub[3]; if (!ec_point_mul_scalar_precomp(group, &pub[0], &method->g_precomp, x0, &method->h_precomp, y0, NULL, NULL) || !ec_point_mul_scalar_precomp(group, &pub[1], &method->g_precomp, @@ -201,7 +197,7 @@ static int pmbtoken_compute_keys(const PMBTOKEN_METHOD *method, } const EC_SCALAR *scalars[] = {x0, y0, x1, y1, xs, ys}; - size_t scalar_len = BN_num_bytes(&group->order); + size_t scalar_len = BN_num_bytes(EC_GROUP_get0_order(group)); for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(scalars); i++) { uint8_t *buf; if (!CBB_add_space(out_private, &buf, scalar_len)) { @@ -290,7 +286,7 @@ static int pmbtoken_issuer_key_from_bytes(const PMBTOKEN_METHOD *method, const EC_GROUP *group = method->group; CBS cbs, tmp; CBS_init(&cbs, in, len); - size_t scalar_len = BN_num_bytes(&group->order); + size_t scalar_len = BN_num_bytes(EC_GROUP_get0_order(group)); EC_SCALAR *scalars[] = {&key->x0, &key->y0, &key->x1, &key->y1, &key->xs, &key->ys}; for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(scalars); i++) { @@ -303,7 +299,7 @@ static int pmbtoken_issuer_key_from_bytes(const PMBTOKEN_METHOD *method, } // Recompute the public key. - EC_RAW_POINT pub[3]; + EC_JACOBIAN pub[3]; EC_AFFINE pub_affine[3]; if (!ec_point_mul_scalar_precomp(group, &pub[0], &method->g_precomp, &key->x0, &method->h_precomp, &key->y0, NULL, NULL) || @@ -367,7 +363,7 @@ static STACK_OF(TRUST_TOKEN_PRETOKEN) *pmbtoken_blind( ec_scalar_from_montgomery(group, &pretoken->r, &pretoken->r); ec_scalar_from_montgomery(group, &rinv, &rinv); - EC_RAW_POINT T, Tp; + EC_JACOBIAN T, Tp; if (!method->hash_t(group, &T, pretoken->t) || !ec_point_mul_scalar(group, &Tp, &T, &rinv) || !ec_jacobian_to_affine(group, &pretoken->Tp, &Tp)) { @@ -390,7 +386,7 @@ err: static int scalar_to_cbb(CBB *out, const EC_GROUP *group, const EC_SCALAR *scalar) { uint8_t *buf; - size_t scalar_len = BN_num_bytes(&group->order); + size_t scalar_len = BN_num_bytes(EC_GROUP_get0_order(group)); if (!CBB_add_space(out, &buf, scalar_len)) { return 0; } @@ -399,7 +395,7 @@ static int scalar_to_cbb(CBB *out, const EC_GROUP *group, } static int scalar_from_cbs(CBS *cbs, const EC_GROUP *group, EC_SCALAR *out) { - size_t scalar_len = BN_num_bytes(&group->order); + size_t scalar_len = BN_num_bytes(EC_GROUP_get0_order(group)); CBS tmp; if (!CBS_get_bytes(cbs, &tmp, scalar_len)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE); @@ -516,8 +512,8 @@ err: static int dleq_generate(const PMBTOKEN_METHOD *method, CBB *cbb, const TRUST_TOKEN_ISSUER_KEY *priv, - const EC_RAW_POINT *T, const EC_RAW_POINT *S, - const EC_RAW_POINT *W, const EC_RAW_POINT *Ws, + const EC_JACOBIAN *T, const EC_JACOBIAN *S, + const EC_JACOBIAN *W, const EC_JACOBIAN *Ws, uint8_t private_metadata) { const EC_GROUP *group = method->group; @@ -537,7 +533,7 @@ static int dleq_generate(const PMBTOKEN_METHOD *method, CBB *cbb, idx_Ko1, num_idx, }; - EC_RAW_POINT jacobians[num_idx]; + EC_JACOBIAN jacobians[num_idx]; // Setup the DLEQ proof. EC_SCALAR ks0, ks1; @@ -675,11 +671,11 @@ static int dleq_generate(const PMBTOKEN_METHOD *method, CBB *cbb, } static int dleq_verify(const PMBTOKEN_METHOD *method, CBS *cbs, - const TRUST_TOKEN_CLIENT_KEY *pub, const EC_RAW_POINT *T, - const EC_RAW_POINT *S, const EC_RAW_POINT *W, - const EC_RAW_POINT *Ws) { + const TRUST_TOKEN_CLIENT_KEY *pub, const EC_JACOBIAN *T, + const EC_JACOBIAN *S, const EC_JACOBIAN *W, + const EC_JACOBIAN *Ws) { const EC_GROUP *group = method->group; - const EC_RAW_POINT *g = &group->generator->raw; + const EC_JACOBIAN *g = &group->generator.raw; // We verify a DLEQ proof for the validity token and a DLEQOR2 proof for the // private metadata token. To allow amortizing Jacobian-to-affine conversions, @@ -699,7 +695,7 @@ static int dleq_verify(const PMBTOKEN_METHOD *method, CBS *cbs, idx_K11, num_idx, }; - EC_RAW_POINT jacobians[num_idx]; + EC_JACOBIAN jacobians[num_idx]; // Decode the DLEQ proof. EC_SCALAR cs, us, vs; @@ -711,7 +707,7 @@ static int dleq_verify(const PMBTOKEN_METHOD *method, CBS *cbs, } // Ks = us*(G;T) + vs*(H;S) - cs*(pubs;Ws) - EC_RAW_POINT pubs; + EC_JACOBIAN pubs; ec_affine_to_jacobian(group, &pubs, &pub->pubs); EC_SCALAR minus_cs; ec_scalar_neg(group, &minus_cs, &cs); @@ -734,7 +730,7 @@ static int dleq_verify(const PMBTOKEN_METHOD *method, CBS *cbs, return 0; } - EC_RAW_POINT pub0, pub1; + EC_JACOBIAN pub0, pub1; ec_affine_to_jacobian(group, &pub0, &pub->pub0); ec_affine_to_jacobian(group, &pub1, &pub->pub1); EC_SCALAR minus_c0, minus_c1; @@ -803,17 +799,17 @@ static int pmbtoken_sign(const PMBTOKEN_METHOD *method, return 0; } - if (num_to_issue > ((size_t)-1) / sizeof(EC_RAW_POINT) || + if (num_to_issue > ((size_t)-1) / sizeof(EC_JACOBIAN) || num_to_issue > ((size_t)-1) / sizeof(EC_SCALAR)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_OVERFLOW); return 0; } int ret = 0; - EC_RAW_POINT *Tps = OPENSSL_malloc(num_to_issue * sizeof(EC_RAW_POINT)); - EC_RAW_POINT *Sps = OPENSSL_malloc(num_to_issue * sizeof(EC_RAW_POINT)); - EC_RAW_POINT *Wps = OPENSSL_malloc(num_to_issue * sizeof(EC_RAW_POINT)); - EC_RAW_POINT *Wsps = OPENSSL_malloc(num_to_issue * sizeof(EC_RAW_POINT)); + EC_JACOBIAN *Tps = OPENSSL_malloc(num_to_issue * sizeof(EC_JACOBIAN)); + EC_JACOBIAN *Sps = OPENSSL_malloc(num_to_issue * sizeof(EC_JACOBIAN)); + EC_JACOBIAN *Wps = OPENSSL_malloc(num_to_issue * sizeof(EC_JACOBIAN)); + EC_JACOBIAN *Wsps = OPENSSL_malloc(num_to_issue * sizeof(EC_JACOBIAN)); EC_SCALAR *es = OPENSSL_malloc(num_to_issue * sizeof(EC_SCALAR)); CBB batch_cbb; CBB_zero(&batch_cbb); @@ -831,7 +827,7 @@ static int pmbtoken_sign(const PMBTOKEN_METHOD *method, for (size_t i = 0; i < num_to_issue; i++) { EC_AFFINE Tp_affine; - EC_RAW_POINT Tp; + EC_JACOBIAN Tp; if (!cbs_get_prefixed_point(cbs, group, &Tp_affine, method->prefix_point)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE); goto err; @@ -846,7 +842,7 @@ static int pmbtoken_sign(const PMBTOKEN_METHOD *method, uint8_t s[TRUST_TOKEN_NONCE_SIZE]; RAND_bytes(s, TRUST_TOKEN_NONCE_SIZE); // The |jacobians| and |affines| contain Sp, Wp, and Wsp. - EC_RAW_POINT jacobians[3]; + EC_JACOBIAN jacobians[3]; EC_AFFINE affines[3]; if (!method->hash_s(group, &jacobians[0], &Tp_affine, s) || !ec_point_mul_scalar_batch(group, &jacobians[1], &Tp, &xb, @@ -887,7 +883,7 @@ static int pmbtoken_sign(const PMBTOKEN_METHOD *method, } } - EC_RAW_POINT Tp_batch, Sp_batch, Wp_batch, Wsp_batch; + EC_JACOBIAN Tp_batch, Sp_batch, Wp_batch, Wsp_batch; if (!ec_point_mul_scalar_public_batch(group, &Tp_batch, /*g_scalar=*/NULL, Tps, es, num_to_issue) || @@ -912,7 +908,7 @@ static int pmbtoken_sign(const PMBTOKEN_METHOD *method, } // Skip over any unused requests. - size_t point_len = 1 + 2 * BN_num_bytes(&group->field); + size_t point_len = ec_point_byte_len(group, POINT_CONVERSION_UNCOMPRESSED); size_t token_len = point_len; if (method->prefix_point) { token_len += 2; @@ -944,7 +940,7 @@ static STACK_OF(TRUST_TOKEN) *pmbtoken_unblind( return NULL; } - if (count > ((size_t)-1) / sizeof(EC_RAW_POINT) || + if (count > ((size_t)-1) / sizeof(EC_JACOBIAN) || count > ((size_t)-1) / sizeof(EC_SCALAR)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_OVERFLOW); return NULL; @@ -952,10 +948,10 @@ static STACK_OF(TRUST_TOKEN) *pmbtoken_unblind( int ok = 0; STACK_OF(TRUST_TOKEN) *ret = sk_TRUST_TOKEN_new_null(); - EC_RAW_POINT *Tps = OPENSSL_malloc(count * sizeof(EC_RAW_POINT)); - EC_RAW_POINT *Sps = OPENSSL_malloc(count * sizeof(EC_RAW_POINT)); - EC_RAW_POINT *Wps = OPENSSL_malloc(count * sizeof(EC_RAW_POINT)); - EC_RAW_POINT *Wsps = OPENSSL_malloc(count * sizeof(EC_RAW_POINT)); + EC_JACOBIAN *Tps = OPENSSL_malloc(count * sizeof(EC_JACOBIAN)); + EC_JACOBIAN *Sps = OPENSSL_malloc(count * sizeof(EC_JACOBIAN)); + EC_JACOBIAN *Wps = OPENSSL_malloc(count * sizeof(EC_JACOBIAN)); + EC_JACOBIAN *Wsps = OPENSSL_malloc(count * sizeof(EC_JACOBIAN)); EC_SCALAR *es = OPENSSL_malloc(count * sizeof(EC_SCALAR)); CBB batch_cbb; CBB_zero(&batch_cbb); @@ -1003,7 +999,7 @@ static STACK_OF(TRUST_TOKEN) *pmbtoken_unblind( } // Unblind the token. - EC_RAW_POINT jacobians[3]; + EC_JACOBIAN jacobians[3]; EC_AFFINE affines[3]; if (!ec_point_mul_scalar(group, &jacobians[0], &Sps[i], &pretoken->r) || !ec_point_mul_scalar(group, &jacobians[1], &Wps[i], &pretoken->r) || @@ -1015,7 +1011,7 @@ static STACK_OF(TRUST_TOKEN) *pmbtoken_unblind( // Serialize the token. Include |key_id| to avoid an extra copy in the layer // above. CBB token_cbb; - size_t point_len = 1 + 2 * BN_num_bytes(&group->field); + size_t point_len = ec_point_byte_len(group, POINT_CONVERSION_UNCOMPRESSED); if (!CBB_init(&token_cbb, 4 + TRUST_TOKEN_NONCE_SIZE + 3 * (2 + point_len)) || !CBB_add_u32(&token_cbb, key_id) || @@ -1050,7 +1046,7 @@ static STACK_OF(TRUST_TOKEN) *pmbtoken_unblind( } } - EC_RAW_POINT Tp_batch, Sp_batch, Wp_batch, Wsp_batch; + EC_JACOBIAN Tp_batch, Sp_batch, Wp_batch, Wsp_batch; if (!ec_point_mul_scalar_public_batch(group, &Tp_batch, /*g_scalar=*/NULL, Tps, es, count) || !ec_point_mul_scalar_public_batch(group, &Sp_batch, @@ -1116,14 +1112,14 @@ static int pmbtoken_read(const PMBTOKEN_METHOD *method, OPENSSL_memcpy(out_nonce, CBS_data(&salt), CBS_len(&salt)); } - EC_RAW_POINT T; + EC_JACOBIAN T; if (!method->hash_t(group, &T, out_nonce)) { return 0; } // We perform three multiplications with S and T. This is enough that it is // worth using |ec_point_mul_scalar_precomp|. - EC_RAW_POINT S_jacobian; + EC_JACOBIAN S_jacobian; EC_PRECOMP S_precomp, T_precomp; ec_affine_to_jacobian(group, &S_jacobian, &S); if (!ec_init_precomp(group, &S_precomp, &S_jacobian) || @@ -1131,7 +1127,7 @@ static int pmbtoken_read(const PMBTOKEN_METHOD *method, return 0; } - EC_RAW_POINT Ws_calculated; + EC_JACOBIAN Ws_calculated; // Check the validity of the token. if (!ec_point_mul_scalar_precomp(group, &Ws_calculated, &T_precomp, &key->xs, &S_precomp, &key->ys, NULL, NULL) || @@ -1140,7 +1136,7 @@ static int pmbtoken_read(const PMBTOKEN_METHOD *method, return 0; } - EC_RAW_POINT W0, W1; + EC_JACOBIAN W0, W1; if (!ec_point_mul_scalar_precomp(group, &W0, &T_precomp, &key->x0, &S_precomp, &key->y0, NULL, NULL) || !ec_point_mul_scalar_precomp(group, &W1, &T_precomp, &key->x1, &S_precomp, @@ -1164,14 +1160,14 @@ static int pmbtoken_read(const PMBTOKEN_METHOD *method, // PMBTokens experiment v1. -static int pmbtoken_exp1_hash_t(const EC_GROUP *group, EC_RAW_POINT *out, +static int pmbtoken_exp1_hash_t(const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t t[TRUST_TOKEN_NONCE_SIZE]) { const uint8_t kHashTLabel[] = "PMBTokens Experiment V1 HashT"; return ec_hash_to_curve_p384_xmd_sha512_sswu_draft07( group, out, kHashTLabel, sizeof(kHashTLabel), t, TRUST_TOKEN_NONCE_SIZE); } -static int pmbtoken_exp1_hash_s(const EC_GROUP *group, EC_RAW_POINT *out, +static int pmbtoken_exp1_hash_s(const EC_GROUP *group, EC_JACOBIAN *out, const EC_AFFINE *t, const uint8_t s[TRUST_TOKEN_NONCE_SIZE]) { const uint8_t kHashSLabel[] = "PMBTokens Experiment V1 HashS"; @@ -1230,7 +1226,7 @@ static void pmbtoken_exp1_init_method_impl(void) { }; pmbtoken_exp1_ok = pmbtoken_init_method( - &pmbtoken_exp1_method, NID_secp384r1, kH, sizeof(kH), + &pmbtoken_exp1_method, EC_group_p384(), kH, sizeof(kH), pmbtoken_exp1_hash_t, pmbtoken_exp1_hash_s, pmbtoken_exp1_hash_c, pmbtoken_exp1_hash_to_scalar, 1); } @@ -1337,14 +1333,14 @@ int pmbtoken_exp1_get_h_for_testing(uint8_t out[97]) { // PMBTokens experiment v2. -static int pmbtoken_exp2_hash_t(const EC_GROUP *group, EC_RAW_POINT *out, +static int pmbtoken_exp2_hash_t(const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t t[TRUST_TOKEN_NONCE_SIZE]) { const uint8_t kHashTLabel[] = "PMBTokens Experiment V2 HashT"; return ec_hash_to_curve_p384_xmd_sha512_sswu_draft07( group, out, kHashTLabel, sizeof(kHashTLabel), t, TRUST_TOKEN_NONCE_SIZE); } -static int pmbtoken_exp2_hash_s(const EC_GROUP *group, EC_RAW_POINT *out, +static int pmbtoken_exp2_hash_s(const EC_GROUP *group, EC_JACOBIAN *out, const EC_AFFINE *t, const uint8_t s[TRUST_TOKEN_NONCE_SIZE]) { const uint8_t kHashSLabel[] = "PMBTokens Experiment V2 HashS"; @@ -1403,7 +1399,7 @@ static void pmbtoken_exp2_init_method_impl(void) { }; pmbtoken_exp2_ok = pmbtoken_init_method( - &pmbtoken_exp2_method, NID_secp384r1, kH, sizeof(kH), + &pmbtoken_exp2_method, EC_group_p384(), kH, sizeof(kH), pmbtoken_exp2_hash_t, pmbtoken_exp2_hash_s, pmbtoken_exp2_hash_c, pmbtoken_exp2_hash_to_scalar, 0); } @@ -1511,14 +1507,14 @@ int pmbtoken_exp2_get_h_for_testing(uint8_t out[97]) { // PMBTokens PST v1. -static int pmbtoken_pst1_hash_t(const EC_GROUP *group, EC_RAW_POINT *out, +static int pmbtoken_pst1_hash_t(const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t t[TRUST_TOKEN_NONCE_SIZE]) { const uint8_t kHashTLabel[] = "PMBTokens PST V1 HashT"; return ec_hash_to_curve_p384_xmd_sha384_sswu( group, out, kHashTLabel, sizeof(kHashTLabel), t, TRUST_TOKEN_NONCE_SIZE); } -static int pmbtoken_pst1_hash_s(const EC_GROUP *group, EC_RAW_POINT *out, +static int pmbtoken_pst1_hash_s(const EC_GROUP *group, EC_JACOBIAN *out, const EC_AFFINE *t, const uint8_t s[TRUST_TOKEN_NONCE_SIZE]) { const uint8_t kHashSLabel[] = "PMBTokens PST V1 HashS"; @@ -1577,7 +1573,7 @@ static void pmbtoken_pst1_init_method_impl(void) { }; pmbtoken_pst1_ok = pmbtoken_init_method( - &pmbtoken_pst1_method, NID_secp384r1, kH, sizeof(kH), + &pmbtoken_pst1_method, EC_group_p384(), kH, sizeof(kH), pmbtoken_pst1_hash_t, pmbtoken_pst1_hash_s, pmbtoken_pst1_hash_c, pmbtoken_pst1_hash_to_scalar, 0); } diff --git a/Sources/CCryptoBoringSSL/crypto/trust_token/voprf.c b/Sources/CCryptoBoringSSL/crypto/trust_token/voprf.c index e6299075..29717ccf 100644 --- a/Sources/CCryptoBoringSSL/crypto/trust_token/voprf.c +++ b/Sources/CCryptoBoringSSL/crypto/trust_token/voprf.c @@ -29,13 +29,13 @@ #include "internal.h" -typedef int (*hash_to_group_func_t)(const EC_GROUP *group, EC_RAW_POINT *out, +typedef int (*hash_to_group_func_t)(const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t t[TRUST_TOKEN_NONCE_SIZE]); typedef int (*hash_to_scalar_func_t)(const EC_GROUP *group, EC_SCALAR *out, uint8_t *buf, size_t len); typedef struct { - const EC_GROUP *group; + const EC_GROUP *(*group_func)(void); // hash_to_group implements the HashToGroup operation for VOPRFs. It returns // one on success and zero on error. @@ -47,37 +47,29 @@ typedef struct { static const uint8_t kDefaultAdditionalData[32] = {0}; -static int voprf_init_method(VOPRF_METHOD *method, int curve_nid, - hash_to_group_func_t hash_to_group, - hash_to_scalar_func_t hash_to_scalar) { - method->group = EC_GROUP_new_by_curve_name(curve_nid); - if (method->group == NULL) { - return 0; - } - - method->hash_to_group = hash_to_group; - method->hash_to_scalar = hash_to_scalar; - - return 1; -} - static int cbb_add_point(CBB *out, const EC_GROUP *group, const EC_AFFINE *point) { - size_t len = ec_point_byte_len(group, POINT_CONVERSION_UNCOMPRESSED); - if (len == 0) { - return 0; - } - uint8_t *p; + size_t len = ec_point_byte_len(group, POINT_CONVERSION_UNCOMPRESSED); return CBB_add_space(out, &p, len) && ec_point_to_bytes(group, point, POINT_CONVERSION_UNCOMPRESSED, p, len) == len && CBB_flush(out); } +static int cbb_serialize_point(CBB *out, const EC_GROUP *group, + const EC_AFFINE *point) { + uint8_t *p; + size_t len = ec_point_byte_len(group, POINT_CONVERSION_COMPRESSED); + return CBB_add_u16(out, len) && CBB_add_space(out, &p, len) && + ec_point_to_bytes(group, point, POINT_CONVERSION_COMPRESSED, p, len) == + len && + CBB_flush(out); +} + static int cbs_get_point(CBS *cbs, const EC_GROUP *group, EC_AFFINE *out) { CBS child; - size_t plen = 1 + 2 * BN_num_bytes(&group->field); + size_t plen = ec_point_byte_len(group, POINT_CONVERSION_UNCOMPRESSED); if (!CBS_get_bytes(cbs, &child, plen) || !ec_point_from_uncompressed(group, out, CBS_data(&child), CBS_len(&child))) { @@ -89,7 +81,7 @@ static int cbs_get_point(CBS *cbs, const EC_GROUP *group, EC_AFFINE *out) { static int scalar_to_cbb(CBB *out, const EC_GROUP *group, const EC_SCALAR *scalar) { uint8_t *buf; - size_t scalar_len = BN_num_bytes(&group->order); + size_t scalar_len = BN_num_bytes(EC_GROUP_get0_order(group)); if (!CBB_add_space(out, &buf, scalar_len)) { return 0; } @@ -98,7 +90,7 @@ static int scalar_to_cbb(CBB *out, const EC_GROUP *group, } static int scalar_from_cbs(CBS *cbs, const EC_GROUP *group, EC_SCALAR *out) { - size_t scalar_len = BN_num_bytes(&group->order); + size_t scalar_len = BN_num_bytes(EC_GROUP_get0_order(group)); CBS tmp; if (!CBS_get_bytes(cbs, &tmp, scalar_len)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE); @@ -111,8 +103,8 @@ static int scalar_from_cbs(CBS *cbs, const EC_GROUP *group, EC_SCALAR *out) { static int voprf_calculate_key(const VOPRF_METHOD *method, CBB *out_private, CBB *out_public, const EC_SCALAR *priv) { - const EC_GROUP *group = method->group; - EC_RAW_POINT pub; + const EC_GROUP *group = method->group_func(); + EC_JACOBIAN pub; EC_AFFINE pub_affine; if (!ec_point_mul_scalar_base(group, &pub, priv) || !ec_jacobian_to_affine(group, &pub_affine, &pub)) { @@ -133,7 +125,8 @@ static int voprf_calculate_key(const VOPRF_METHOD *method, CBB *out_private, static int voprf_generate_key(const VOPRF_METHOD *method, CBB *out_private, CBB *out_public) { EC_SCALAR priv; - if (!ec_random_nonzero_scalar(method->group, &priv, kDefaultAdditionalData)) { + if (!ec_random_nonzero_scalar(method->group_func(), &priv, + kDefaultAdditionalData)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_KEYGEN_FAILURE); return 0; } @@ -156,7 +149,7 @@ static int voprf_derive_key_from_secret(const VOPRF_METHOD *method, !CBB_add_bytes(&cbb, kKeygenLabel, sizeof(kKeygenLabel)) || !CBB_add_bytes(&cbb, secret, secret_len) || !CBB_finish(&cbb, &buf, &len) || - !method->hash_to_scalar(method->group, &priv, buf, len)) { + !method->hash_to_scalar(method->group_func(), &priv, buf, len)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_KEYGEN_FAILURE); goto err; } @@ -172,7 +165,7 @@ err: static int voprf_client_key_from_bytes(const VOPRF_METHOD *method, TRUST_TOKEN_CLIENT_KEY *key, const uint8_t *in, size_t len) { - const EC_GROUP *group = method->group; + const EC_GROUP *group = method->group_func(); if (!ec_point_from_uncompressed(group, &key->pubs, in, len)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE); return 0; @@ -184,14 +177,14 @@ static int voprf_client_key_from_bytes(const VOPRF_METHOD *method, static int voprf_issuer_key_from_bytes(const VOPRF_METHOD *method, TRUST_TOKEN_ISSUER_KEY *key, const uint8_t *in, size_t len) { - const EC_GROUP *group = method->group; + const EC_GROUP *group = method->group_func(); if (!ec_scalar_from_bytes(group, &key->xs, in, len)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE); return 0; } // Recompute the public key. - EC_RAW_POINT pub; + EC_JACOBIAN pub; if (!ec_point_mul_scalar_base(group, &pub, &key->xs) || !ec_jacobian_to_affine(group, &key->pubs, &pub)) { return 0; @@ -207,7 +200,7 @@ static STACK_OF(TRUST_TOKEN_PRETOKEN) *voprf_blind(const VOPRF_METHOD *method, size_t msg_len) { SHA512_CTX hash_ctx; - const EC_GROUP *group = method->group; + const EC_GROUP *group = method->group_func(); STACK_OF(TRUST_TOKEN_PRETOKEN) *pretokens = sk_TRUST_TOKEN_PRETOKEN_new_null(); if (pretokens == NULL) { @@ -249,7 +242,7 @@ static STACK_OF(TRUST_TOKEN_PRETOKEN) *voprf_blind(const VOPRF_METHOD *method, ec_scalar_from_montgomery(group, &pretoken->r, &pretoken->r); // Tp is the blinded token in the VOPRF protocol. - EC_RAW_POINT P, Tp; + EC_JACOBIAN P, Tp; if (!method->hash_to_group(group, &P, pretoken->t) || !ec_point_mul_scalar(group, &Tp, &P, &r) || !ec_jacobian_to_affine(group, &pretoken->Tp, &Tp)) { @@ -274,6 +267,7 @@ static int hash_to_scalar_dleq(const VOPRF_METHOD *method, EC_SCALAR *out, const EC_AFFINE *K1) { static const uint8_t kDLEQLabel[] = "DLEQ"; + const EC_GROUP *group = method->group_func(); int ok = 0; CBB cbb; CBB_zero(&cbb); @@ -281,13 +275,13 @@ static int hash_to_scalar_dleq(const VOPRF_METHOD *method, EC_SCALAR *out, size_t len; if (!CBB_init(&cbb, 0) || !CBB_add_bytes(&cbb, kDLEQLabel, sizeof(kDLEQLabel)) || - !cbb_add_point(&cbb, method->group, X) || - !cbb_add_point(&cbb, method->group, T) || - !cbb_add_point(&cbb, method->group, W) || - !cbb_add_point(&cbb, method->group, K0) || - !cbb_add_point(&cbb, method->group, K1) || + !cbb_add_point(&cbb, group, X) || + !cbb_add_point(&cbb, group, T) || + !cbb_add_point(&cbb, group, W) || + !cbb_add_point(&cbb, group, K0) || + !cbb_add_point(&cbb, group, K1) || !CBB_finish(&cbb, &buf, &len) || - !method->hash_to_scalar(method->group, out, buf, len)) { + !method->hash_to_scalar(group, out, buf, len)) { goto err; } @@ -299,6 +293,31 @@ err: return ok; } +static int hash_to_scalar_challenge(const VOPRF_METHOD *method, EC_SCALAR *out, + const EC_AFFINE *Bm, const EC_AFFINE *a0, + const EC_AFFINE *a1, const EC_AFFINE *a2, + const EC_AFFINE *a3) { + static const uint8_t kChallengeLabel[] = "Challenge"; + + const EC_GROUP *group = method->group_func(); + CBB cbb; + uint8_t transcript[5 * EC_MAX_COMPRESSED + 2 + sizeof(kChallengeLabel) - 1]; + size_t len; + if (!CBB_init_fixed(&cbb, transcript, sizeof(transcript)) || + !cbb_serialize_point(&cbb, group, Bm) || + !cbb_serialize_point(&cbb, group, a0) || + !cbb_serialize_point(&cbb, group, a1) || + !cbb_serialize_point(&cbb, group, a2) || + !cbb_serialize_point(&cbb, group, a3) || + !CBB_add_bytes(&cbb, kChallengeLabel, sizeof(kChallengeLabel) - 1) || + !CBB_finish(&cbb, NULL, &len) || + !method->hash_to_scalar(group, out, transcript, len)) { + return 0; + } + + return 1; +} + static int hash_to_scalar_batch(const VOPRF_METHOD *method, EC_SCALAR *out, const CBB *points, size_t index) { static const uint8_t kDLEQBatchLabel[] = "DLEQ BATCH"; @@ -318,7 +337,7 @@ static int hash_to_scalar_batch(const VOPRF_METHOD *method, EC_SCALAR *out, !CBB_add_bytes(&cbb, CBB_data(points), CBB_len(points)) || !CBB_add_u16(&cbb, (uint16_t)index) || !CBB_finish(&cbb, &buf, &len) || - !method->hash_to_scalar(method->group, out, buf, len)) { + !method->hash_to_scalar(method->group_func(), out, buf, len)) { goto err; } @@ -332,8 +351,8 @@ err: static int dleq_generate(const VOPRF_METHOD *method, CBB *cbb, const TRUST_TOKEN_ISSUER_KEY *priv, - const EC_RAW_POINT *T, const EC_RAW_POINT *W) { - const EC_GROUP *group = method->group; + const EC_JACOBIAN *T, const EC_JACOBIAN *W) { + const EC_GROUP *group = method->group_func(); enum { idx_T, @@ -342,7 +361,7 @@ static int dleq_generate(const VOPRF_METHOD *method, CBB *cbb, idx_k1, num_idx, }; - EC_RAW_POINT jacobians[num_idx]; + EC_JACOBIAN jacobians[num_idx]; // Setup the DLEQ proof. EC_SCALAR r; @@ -387,19 +406,19 @@ static int dleq_generate(const VOPRF_METHOD *method, CBB *cbb, return 1; } -static int mul_public_2(const EC_GROUP *group, EC_RAW_POINT *out, - const EC_RAW_POINT *p0, const EC_SCALAR *scalar0, - const EC_RAW_POINT *p1, const EC_SCALAR *scalar1) { - EC_RAW_POINT points[2] = {*p0, *p1}; +static int mul_public_2(const EC_GROUP *group, EC_JACOBIAN *out, + const EC_JACOBIAN *p0, const EC_SCALAR *scalar0, + const EC_JACOBIAN *p1, const EC_SCALAR *scalar1) { + EC_JACOBIAN points[2] = {*p0, *p1}; EC_SCALAR scalars[2] = {*scalar0, *scalar1}; return ec_point_mul_scalar_public_batch(group, out, /*g_scalar=*/NULL, points, scalars, 2); } static int dleq_verify(const VOPRF_METHOD *method, CBS *cbs, - const TRUST_TOKEN_CLIENT_KEY *pub, const EC_RAW_POINT *T, - const EC_RAW_POINT *W) { - const EC_GROUP *group = method->group; + const TRUST_TOKEN_CLIENT_KEY *pub, const EC_JACOBIAN *T, + const EC_JACOBIAN *W) { + const EC_GROUP *group = method->group_func(); enum { @@ -409,7 +428,7 @@ static int dleq_verify(const VOPRF_METHOD *method, CBS *cbs, idx_k1, num_idx, }; - EC_RAW_POINT jacobians[num_idx]; + EC_JACOBIAN jacobians[num_idx]; // Decode the DLEQ proof. EC_SCALAR c, u; @@ -420,7 +439,7 @@ static int dleq_verify(const VOPRF_METHOD *method, CBS *cbs, } // k0;k1 = u*(G;T) - c*(pub;W) - EC_RAW_POINT pubs; + EC_JACOBIAN pubs; ec_affine_to_jacobian(group, &pubs, &pub->pubs); EC_SCALAR minus_c; ec_scalar_neg(group, &minus_c, &c); @@ -455,24 +474,24 @@ static int dleq_verify(const VOPRF_METHOD *method, CBS *cbs, return 1; } -static int voprf_sign(const VOPRF_METHOD *method, - const TRUST_TOKEN_ISSUER_KEY *key, CBB *cbb, CBS *cbs, - size_t num_requested, size_t num_to_issue) { - const EC_GROUP *group = method->group; +static int voprf_sign_tt(const VOPRF_METHOD *method, + const TRUST_TOKEN_ISSUER_KEY *key, CBB *cbb, CBS *cbs, + size_t num_requested, size_t num_to_issue) { + const EC_GROUP *group = method->group_func(); if (num_requested < num_to_issue) { OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_INTERNAL_ERROR); return 0; } - if (num_to_issue > ((size_t)-1) / sizeof(EC_RAW_POINT) || + if (num_to_issue > ((size_t)-1) / sizeof(EC_JACOBIAN) || num_to_issue > ((size_t)-1) / sizeof(EC_SCALAR)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_OVERFLOW); return 0; } int ret = 0; - EC_RAW_POINT *BTs = OPENSSL_malloc(num_to_issue * sizeof(EC_RAW_POINT)); - EC_RAW_POINT *Zs = OPENSSL_malloc(num_to_issue * sizeof(EC_RAW_POINT)); + EC_JACOBIAN *BTs = OPENSSL_malloc(num_to_issue * sizeof(EC_JACOBIAN)); + EC_JACOBIAN *Zs = OPENSSL_malloc(num_to_issue * sizeof(EC_JACOBIAN)); EC_SCALAR *es = OPENSSL_malloc(num_to_issue * sizeof(EC_SCALAR)); CBB batch_cbb; CBB_zero(&batch_cbb); @@ -480,13 +499,13 @@ static int voprf_sign(const VOPRF_METHOD *method, !Zs || !es || !CBB_init(&batch_cbb, 0) || - !cbb_add_point(&batch_cbb, method->group, &key->pubs)) { + !cbb_add_point(&batch_cbb, group, &key->pubs)) { goto err; } for (size_t i = 0; i < num_to_issue; i++) { EC_AFFINE BT_affine, Z_affine; - EC_RAW_POINT BT, Z; + EC_JACOBIAN BT, Z; if (!cbs_get_point(cbs, group, &BT_affine)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE); goto err; @@ -519,7 +538,7 @@ static int voprf_sign(const VOPRF_METHOD *method, } } - EC_RAW_POINT BT_batch, Z_batch; + EC_JACOBIAN BT_batch, Z_batch; if (!ec_point_mul_scalar_public_batch(group, &BT_batch, /*g_scalar=*/NULL, BTs, es, num_to_issue) || @@ -537,7 +556,7 @@ static int voprf_sign(const VOPRF_METHOD *method, } // Skip over any unused requests. - size_t point_len = 1 + 2 * BN_num_bytes(&group->field); + size_t point_len = ec_point_byte_len(group, POINT_CONVERSION_UNCOMPRESSED); if (!CBS_skip(cbs, point_len * (num_requested - num_to_issue))) { OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE); goto err; @@ -553,17 +572,17 @@ err: return ret; } -static STACK_OF(TRUST_TOKEN) *voprf_unblind( +static STACK_OF(TRUST_TOKEN) *voprf_unblind_tt( const VOPRF_METHOD *method, const TRUST_TOKEN_CLIENT_KEY *key, const STACK_OF(TRUST_TOKEN_PRETOKEN) *pretokens, CBS *cbs, size_t count, uint32_t key_id) { - const EC_GROUP *group = method->group; + const EC_GROUP *group = method->group_func(); if (count > sk_TRUST_TOKEN_PRETOKEN_num(pretokens)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE); return NULL; } - if (count > ((size_t)-1) / sizeof(EC_RAW_POINT) || + if (count > ((size_t)-1) / sizeof(EC_JACOBIAN) || count > ((size_t)-1) / sizeof(EC_SCALAR)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_OVERFLOW); return NULL; @@ -571,8 +590,8 @@ static STACK_OF(TRUST_TOKEN) *voprf_unblind( int ok = 0; STACK_OF(TRUST_TOKEN) *ret = sk_TRUST_TOKEN_new_null(); - EC_RAW_POINT *BTs = OPENSSL_malloc(count * sizeof(EC_RAW_POINT)); - EC_RAW_POINT *Zs = OPENSSL_malloc(count * sizeof(EC_RAW_POINT)); + EC_JACOBIAN *BTs = OPENSSL_malloc(count * sizeof(EC_JACOBIAN)); + EC_JACOBIAN *Zs = OPENSSL_malloc(count * sizeof(EC_JACOBIAN)); EC_SCALAR *es = OPENSSL_malloc(count * sizeof(EC_SCALAR)); CBB batch_cbb; CBB_zero(&batch_cbb); @@ -581,7 +600,7 @@ static STACK_OF(TRUST_TOKEN) *voprf_unblind( Zs == NULL || es == NULL || !CBB_init(&batch_cbb, 0) || - !cbb_add_point(&batch_cbb, method->group, &key->pubs)) { + !cbb_add_point(&batch_cbb, group, &key->pubs)) { goto err; } @@ -605,7 +624,7 @@ static STACK_OF(TRUST_TOKEN) *voprf_unblind( // Unblind the token. // pretoken->r is rinv. - EC_RAW_POINT N; + EC_JACOBIAN N; EC_AFFINE N_affine; if (!ec_point_mul_scalar(group, &N, &Zs[i], &pretoken->r) || !ec_jacobian_to_affine(group, &N_affine, &N)) { @@ -615,7 +634,7 @@ static STACK_OF(TRUST_TOKEN) *voprf_unblind( // Serialize the token. Include |key_id| to avoid an extra copy in the layer // above. CBB token_cbb; - size_t point_len = 1 + 2 * BN_num_bytes(&group->field); + size_t point_len = ec_point_byte_len(group, POINT_CONVERSION_UNCOMPRESSED); if (!CBB_init(&token_cbb, 4 + TRUST_TOKEN_NONCE_SIZE + (2 + point_len)) || !CBB_add_u32(&token_cbb, key_id) || !CBB_add_bytes(&token_cbb, pretoken->salt, TRUST_TOKEN_NONCE_SIZE) || @@ -644,7 +663,7 @@ static STACK_OF(TRUST_TOKEN) *voprf_unblind( } } - EC_RAW_POINT BT_batch, Z_batch; + EC_JACOBIAN BT_batch, Z_batch; if (!ec_point_mul_scalar_public_batch(group, &BT_batch, /*g_scalar=*/NULL, BTs, es, count) || !ec_point_mul_scalar_public_batch(group, &Z_batch, @@ -673,12 +692,403 @@ err: return ret; } +static void sha384_update_u16(SHA512_CTX *ctx, uint16_t v) { + uint8_t buf[2] = {v >> 8, v & 0xff}; + SHA384_Update(ctx, buf, 2); +} + +static void sha384_update_point_with_length( + SHA512_CTX *ctx, const EC_GROUP *group, const EC_AFFINE *point) { + uint8_t buf[EC_MAX_COMPRESSED]; + size_t len = ec_point_to_bytes(group, point, POINT_CONVERSION_COMPRESSED, + buf, sizeof(buf)); + assert(len > 0); + sha384_update_u16(ctx, (uint16_t)len); + SHA384_Update(ctx, buf, len); +} + +static int compute_composite_seed(const VOPRF_METHOD *method, + uint8_t out[SHA384_DIGEST_LENGTH], + const EC_AFFINE *pub) { + const EC_GROUP *group = method->group_func(); + static const uint8_t kSeedDST[] = "Seed-OPRFV1-\x01-P384-SHA384"; + + SHA512_CTX hash_ctx; + SHA384_Init(&hash_ctx); + sha384_update_point_with_length(&hash_ctx, group, pub); + sha384_update_u16(&hash_ctx, sizeof(kSeedDST) - 1); + SHA384_Update(&hash_ctx, kSeedDST, sizeof(kSeedDST) - 1); + SHA384_Final(out, &hash_ctx); + + return 1; +} + +static int compute_composite_element(const VOPRF_METHOD *method, + uint8_t seed[SHA384_DIGEST_LENGTH], + EC_SCALAR *di, size_t index, + const EC_AFFINE *C, const EC_AFFINE *D) { + static const uint8_t kCompositeLabel[] = "Composite"; + const EC_GROUP *group = method->group_func(); + + if (index > UINT16_MAX) { + return 0; + } + + CBB cbb; + uint8_t transcript[2 + SHA384_DIGEST_LENGTH + 2 + 2 * EC_MAX_COMPRESSED + + sizeof(kCompositeLabel) - 1]; + size_t len; + if (!CBB_init_fixed(&cbb, transcript, sizeof(transcript)) || + !CBB_add_u16(&cbb, SHA384_DIGEST_LENGTH) || + !CBB_add_bytes(&cbb, seed, SHA384_DIGEST_LENGTH) || + !CBB_add_u16(&cbb, index) || + !cbb_serialize_point(&cbb, group, C) || + !cbb_serialize_point(&cbb, group, D) || + !CBB_add_bytes(&cbb, kCompositeLabel, + sizeof(kCompositeLabel) - 1) || + !CBB_finish(&cbb, NULL, &len) || + !method->hash_to_scalar(group, di, transcript, len)) { + return 0; + } + + return 1; +} + +static int generate_proof(const VOPRF_METHOD *method, CBB *cbb, + const TRUST_TOKEN_ISSUER_KEY *priv, + const EC_SCALAR *r, const EC_JACOBIAN *M, + const EC_JACOBIAN *Z) { + const EC_GROUP *group = method->group_func(); + + enum { + idx_M, + idx_Z, + idx_t2, + idx_t3, + num_idx, + }; + EC_JACOBIAN jacobians[num_idx]; + + if (!ec_point_mul_scalar_base(group, &jacobians[idx_t2], r) || + !ec_point_mul_scalar(group, &jacobians[idx_t3], M, r)) { + return 0; + } + + + EC_AFFINE affines[num_idx]; + jacobians[idx_M] = *M; + jacobians[idx_Z] = *Z; + if (!ec_jacobian_to_affine_batch(group, affines, jacobians, num_idx)) { + return 0; + } + + EC_SCALAR c; + if (!hash_to_scalar_challenge(method, &c, &priv->pubs, &affines[idx_M], + &affines[idx_Z], &affines[idx_t2], + &affines[idx_t3])) { + return 0; + } + + EC_SCALAR c_mont; + ec_scalar_to_montgomery(group, &c_mont, &c); + + // s = r - c*xs + EC_SCALAR s; + ec_scalar_mul_montgomery(group, &s, &priv->xs, &c_mont); + ec_scalar_sub(group, &s, r, &s); + + // Store DLEQ proof in transcript. + if (!scalar_to_cbb(cbb, group, &c) || + !scalar_to_cbb(cbb, group, &s)) { + return 0; + } + + return 1; +} + +static int verify_proof(const VOPRF_METHOD *method, CBS *cbs, + const TRUST_TOKEN_CLIENT_KEY *pub, + const EC_JACOBIAN *M, const EC_JACOBIAN *Z) { + const EC_GROUP *group = method->group_func(); + + enum { + idx_M, + idx_Z, + idx_t2, + idx_t3, + num_idx, + }; + EC_JACOBIAN jacobians[num_idx]; + + EC_SCALAR c, s; + if (!scalar_from_cbs(cbs, group, &c) || + !scalar_from_cbs(cbs, group, &s)) { + OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE); + return 0; + } + + EC_JACOBIAN pubs; + ec_affine_to_jacobian(group, &pubs, &pub->pubs); + if (!ec_point_mul_scalar_public(group, &jacobians[idx_t2], &s, &pubs, + &c) || + !mul_public_2(group, &jacobians[idx_t3], M, &s, Z, &c)) { + return 0; + } + + EC_AFFINE affines[num_idx]; + jacobians[idx_M] = *M; + jacobians[idx_Z] = *Z; + if (!ec_jacobian_to_affine_batch(group, affines, jacobians, num_idx)) { + return 0; + } + + EC_SCALAR expected_c; + if (!hash_to_scalar_challenge(method, &expected_c, &pub->pubs, + &affines[idx_M], &affines[idx_Z], + &affines[idx_t2], &affines[idx_t3])) { + return 0; + } + + // c == expected_c + if (!ec_scalar_equal_vartime(group, &c, &expected_c)) { + OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_INVALID_PROOF); + return 0; + } + + return 1; +} + +static int voprf_sign_impl(const VOPRF_METHOD *method, + const TRUST_TOKEN_ISSUER_KEY *key, CBB *cbb, + CBS *cbs, size_t num_requested, size_t num_to_issue, + const EC_SCALAR *proof_scalar) { + const EC_GROUP *group = method->group_func(); + if (num_requested < num_to_issue) { + OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_INTERNAL_ERROR); + return 0; + } + + if (num_to_issue > ((size_t)-1) / sizeof(EC_JACOBIAN) || + num_to_issue > ((size_t)-1) / sizeof(EC_SCALAR)) { + OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_OVERFLOW); + return 0; + } + + int ret = 0; + EC_JACOBIAN *BTs = OPENSSL_malloc(num_to_issue * sizeof(EC_JACOBIAN)); + EC_JACOBIAN *Zs = OPENSSL_malloc(num_to_issue * sizeof(EC_JACOBIAN)); + EC_SCALAR *dis = OPENSSL_malloc(num_to_issue * sizeof(EC_SCALAR)); + if (!BTs || !Zs || !dis) { + goto err; + } + + uint8_t seed[SHA384_DIGEST_LENGTH]; + if (!compute_composite_seed(method, seed, &key->pubs)) { + goto err; + } + + // This implements the BlindEvaluateBatch as defined in section 4 of + // draft-robert-privacypass-batched-tokens-01, based on the constructions + // in draft-irtf-cfrg-voprf-21. To optimize the computation of the proof, + // the computation of di is done during the token signing and passed into + // the proof generation. + for (size_t i = 0; i < num_to_issue; i++) { + EC_AFFINE BT_affine, Z_affine; + EC_JACOBIAN BT, Z; + if (!cbs_get_point(cbs, group, &BT_affine)) { + OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE); + goto err; + } + ec_affine_to_jacobian(group, &BT, &BT_affine); + if (!ec_point_mul_scalar(group, &Z, &BT, &key->xs) || + !ec_jacobian_to_affine(group, &Z_affine, &Z) || + !cbb_add_point(cbb, group, &Z_affine)) { + goto err; + } + BTs[i] = BT; + Zs[i] = Z; + if (!compute_composite_element(method, seed, &dis[i], i, &BT_affine, + &Z_affine)) { + goto err; + } + + if (!CBB_flush(cbb)) { + goto err; + } + } + + EC_JACOBIAN M, Z; + if (!ec_point_mul_scalar_public_batch(group, &M, + /*g_scalar=*/NULL, BTs, dis, + num_to_issue) || + !ec_point_mul_scalar(group, &Z, &M, &key->xs)) { + goto err; + } + + CBB proof; + if (!CBB_add_u16_length_prefixed(cbb, &proof) || + !generate_proof(method, &proof, key, proof_scalar, &M, &Z) || + !CBB_flush(cbb)) { + goto err; + } + + // Skip over any unused requests. + size_t point_len = ec_point_byte_len(group, POINT_CONVERSION_UNCOMPRESSED); + if (!CBS_skip(cbs, point_len * (num_requested - num_to_issue))) { + OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE); + goto err; + } + + ret = 1; + +err: + OPENSSL_free(BTs); + OPENSSL_free(Zs); + OPENSSL_free(dis); + return ret; +} + +static int voprf_sign(const VOPRF_METHOD *method, + const TRUST_TOKEN_ISSUER_KEY *key, CBB *cbb, CBS *cbs, + size_t num_requested, size_t num_to_issue) { + EC_SCALAR proof_scalar; + if (!ec_random_nonzero_scalar(method->group_func(), &proof_scalar, + kDefaultAdditionalData)) { + return 0; + } + + return voprf_sign_impl(method, key, cbb, cbs, num_requested, num_to_issue, + &proof_scalar); +} + +static int voprf_sign_with_proof_scalar_for_testing( + const VOPRF_METHOD *method, const TRUST_TOKEN_ISSUER_KEY *key, CBB *cbb, + CBS *cbs, size_t num_requested, size_t num_to_issue, + const uint8_t *proof_scalar_buf, size_t proof_scalar_len) { + EC_SCALAR proof_scalar; + if (!ec_scalar_from_bytes(method->group_func(), &proof_scalar, + proof_scalar_buf, proof_scalar_len)) { + return 0; + } + return voprf_sign_impl(method, key, cbb, cbs, num_requested, num_to_issue, + &proof_scalar); +} + +static STACK_OF(TRUST_TOKEN) *voprf_unblind( + const VOPRF_METHOD *method, const TRUST_TOKEN_CLIENT_KEY *key, + const STACK_OF(TRUST_TOKEN_PRETOKEN) *pretokens, CBS *cbs, size_t count, + uint32_t key_id) { + const EC_GROUP *group = method->group_func(); + if (count > sk_TRUST_TOKEN_PRETOKEN_num(pretokens)) { + OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE); + return NULL; + } + + if (count > ((size_t)-1) / sizeof(EC_JACOBIAN) || + count > ((size_t)-1) / sizeof(EC_SCALAR)) { + OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_OVERFLOW); + return NULL; + } + + int ok = 0; + STACK_OF(TRUST_TOKEN) *ret = sk_TRUST_TOKEN_new_null(); + EC_JACOBIAN *BTs = OPENSSL_malloc(count * sizeof(EC_JACOBIAN)); + EC_JACOBIAN *Zs = OPENSSL_malloc(count * sizeof(EC_JACOBIAN)); + EC_SCALAR *dis = OPENSSL_malloc(count * sizeof(EC_SCALAR)); + if (ret == NULL || !BTs || !Zs || !dis) { + goto err; + } + + uint8_t seed[SHA384_DIGEST_LENGTH]; + if (!compute_composite_seed(method, seed, &key->pubs)) { + goto err; + } + + for (size_t i = 0; i < count; i++) { + const TRUST_TOKEN_PRETOKEN *pretoken = + sk_TRUST_TOKEN_PRETOKEN_value(pretokens, i); + + EC_AFFINE Z_affine; + if (!cbs_get_point(cbs, group, &Z_affine)) { + OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_DECODE_FAILURE); + goto err; + } + + ec_affine_to_jacobian(group, &BTs[i], &pretoken->Tp); + ec_affine_to_jacobian(group, &Zs[i], &Z_affine); + if (!compute_composite_element(method, seed, &dis[i], i, &pretoken->Tp, + &Z_affine)) { + goto err; + } + + // Unblind the token. + // pretoken->r is rinv. + EC_JACOBIAN N; + EC_AFFINE N_affine; + if (!ec_point_mul_scalar(group, &N, &Zs[i], &pretoken->r) || + !ec_jacobian_to_affine(group, &N_affine, &N)) { + goto err; + } + + // Serialize the token. Include |key_id| to avoid an extra copy in the layer + // above. + CBB token_cbb; + size_t point_len = ec_point_byte_len(group, POINT_CONVERSION_UNCOMPRESSED); + if (!CBB_init(&token_cbb, 4 + TRUST_TOKEN_NONCE_SIZE + (2 + point_len)) || + !CBB_add_u32(&token_cbb, key_id) || + !CBB_add_bytes(&token_cbb, pretoken->salt, TRUST_TOKEN_NONCE_SIZE) || + !cbb_add_point(&token_cbb, group, &N_affine) || + !CBB_flush(&token_cbb)) { + CBB_cleanup(&token_cbb); + goto err; + } + + TRUST_TOKEN *token = + TRUST_TOKEN_new(CBB_data(&token_cbb), CBB_len(&token_cbb)); + CBB_cleanup(&token_cbb); + if (token == NULL || + !sk_TRUST_TOKEN_push(ret, token)) { + TRUST_TOKEN_free(token); + goto err; + } + } + + EC_JACOBIAN M, Z; + if (!ec_point_mul_scalar_public_batch(group, &M, + /*g_scalar=*/NULL, BTs, dis, + count) || + !ec_point_mul_scalar_public_batch(group, &Z, + /*g_scalar=*/NULL, Zs, dis, + count)) { + goto err; + } + + CBS proof; + if (!CBS_get_u16_length_prefixed(cbs, &proof) || + !verify_proof(method, &proof, key, &M, &Z) || + CBS_len(&proof) != 0) { + goto err; + } + + ok = 1; + +err: + OPENSSL_free(BTs); + OPENSSL_free(Zs); + OPENSSL_free(dis); + if (!ok) { + sk_TRUST_TOKEN_pop_free(ret, TRUST_TOKEN_free); + ret = NULL; + } + return ret; +} + static int voprf_read(const VOPRF_METHOD *method, const TRUST_TOKEN_ISSUER_KEY *key, uint8_t out_nonce[TRUST_TOKEN_NONCE_SIZE], const uint8_t *token, size_t token_len, int include_message, const uint8_t *msg, size_t msg_len) { - const EC_GROUP *group = method->group; + const EC_GROUP *group = method->group_func(); CBS cbs, salt; CBS_init(&cbs, token, token_len); EC_AFFINE Ws; @@ -701,12 +1111,12 @@ static int voprf_read(const VOPRF_METHOD *method, } - EC_RAW_POINT T; + EC_JACOBIAN T; if (!method->hash_to_group(group, &T, out_nonce)) { return 0; } - EC_RAW_POINT Ws_calculated; + EC_JACOBIAN Ws_calculated; if (!ec_point_mul_scalar(group, &Ws_calculated, &T, &key->xs) || !ec_affine_jacobian_equal(group, &Ws, &Ws_calculated)) { OPENSSL_PUT_ERROR(TRUST_TOKEN, TRUST_TOKEN_R_BAD_VALIDITY_CHECK); @@ -719,7 +1129,7 @@ static int voprf_read(const VOPRF_METHOD *method, // VOPRF experiment v2. -static int voprf_exp2_hash_to_group(const EC_GROUP *group, EC_RAW_POINT *out, +static int voprf_exp2_hash_to_group(const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t t[TRUST_TOKEN_NONCE_SIZE]) { const uint8_t kHashTLabel[] = "TrustToken VOPRF Experiment V2 HashToGroup"; return ec_hash_to_curve_p384_xmd_sha512_sswu_draft07( @@ -733,57 +1143,27 @@ static int voprf_exp2_hash_to_scalar(const EC_GROUP *group, EC_SCALAR *out, group, out, kHashCLabel, sizeof(kHashCLabel), buf, len); } -static int voprf_exp2_ok = 0; -static VOPRF_METHOD voprf_exp2_method; -static CRYPTO_once_t voprf_exp2_method_once = CRYPTO_ONCE_INIT; - -static void voprf_exp2_init_method_impl(void) { - voprf_exp2_ok = - voprf_init_method(&voprf_exp2_method, NID_secp384r1, - voprf_exp2_hash_to_group, voprf_exp2_hash_to_scalar); -} - -static int voprf_exp2_init_method(void) { - CRYPTO_once(&voprf_exp2_method_once, voprf_exp2_init_method_impl); - if (!voprf_exp2_ok) { - OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_INTERNAL_ERROR); - return 0; - } - return 1; -} +static VOPRF_METHOD voprf_exp2_method = { + EC_group_p384, voprf_exp2_hash_to_group, voprf_exp2_hash_to_scalar}; int voprf_exp2_generate_key(CBB *out_private, CBB *out_public) { - if (!voprf_exp2_init_method()) { - return 0; - } - return voprf_generate_key(&voprf_exp2_method, out_private, out_public); } int voprf_exp2_derive_key_from_secret(CBB *out_private, CBB *out_public, const uint8_t *secret, size_t secret_len) { - if (!voprf_exp2_init_method()) { - return 0; - } - return voprf_derive_key_from_secret(&voprf_exp2_method, out_private, out_public, secret, secret_len); } int voprf_exp2_client_key_from_bytes(TRUST_TOKEN_CLIENT_KEY *key, const uint8_t *in, size_t len) { - if (!voprf_exp2_init_method()) { - return 0; - } return voprf_client_key_from_bytes(&voprf_exp2_method, key, in, len); } int voprf_exp2_issuer_key_from_bytes(TRUST_TOKEN_ISSUER_KEY *key, const uint8_t *in, size_t len) { - if (!voprf_exp2_init_method()) { - return 0; - } return voprf_issuer_key_from_bytes(&voprf_exp2_method, key, in, len); } @@ -791,9 +1171,6 @@ STACK_OF(TRUST_TOKEN_PRETOKEN) *voprf_exp2_blind(CBB *cbb, size_t count, int include_message, const uint8_t *msg, size_t msg_len) { - if (!voprf_exp2_init_method()) { - return NULL; - } return voprf_blind(&voprf_exp2_method, cbb, count, include_message, msg, msg_len); } @@ -801,21 +1178,19 @@ STACK_OF(TRUST_TOKEN_PRETOKEN) *voprf_exp2_blind(CBB *cbb, size_t count, int voprf_exp2_sign(const TRUST_TOKEN_ISSUER_KEY *key, CBB *cbb, CBS *cbs, size_t num_requested, size_t num_to_issue, uint8_t private_metadata) { - if (!voprf_exp2_init_method() || private_metadata != 0) { + if (private_metadata != 0) { return 0; } - return voprf_sign(&voprf_exp2_method, key, cbb, cbs, num_requested, - num_to_issue); + return voprf_sign_tt(&voprf_exp2_method, key, cbb, cbs, num_requested, + num_to_issue); } STACK_OF(TRUST_TOKEN) *voprf_exp2_unblind( const TRUST_TOKEN_CLIENT_KEY *key, const STACK_OF(TRUST_TOKEN_PRETOKEN) *pretokens, CBS *cbs, size_t count, uint32_t key_id) { - if (!voprf_exp2_init_method()) { - return NULL; - } - return voprf_unblind(&voprf_exp2_method, key, pretokens, cbs, count, key_id); + return voprf_unblind_tt(&voprf_exp2_method, key, pretokens, cbs, count, + key_id); } int voprf_exp2_read(const TRUST_TOKEN_ISSUER_KEY *key, @@ -823,80 +1198,48 @@ int voprf_exp2_read(const TRUST_TOKEN_ISSUER_KEY *key, uint8_t *out_private_metadata, const uint8_t *token, size_t token_len, int include_message, const uint8_t *msg, size_t msg_len) { - if (!voprf_exp2_init_method()) { - return 0; - } return voprf_read(&voprf_exp2_method, key, out_nonce, token, token_len, include_message, msg, msg_len); } // VOPRF PST v1. -static int voprf_pst1_hash_to_group(const EC_GROUP *group, EC_RAW_POINT *out, +static int voprf_pst1_hash_to_group(const EC_GROUP *group, EC_JACOBIAN *out, const uint8_t t[TRUST_TOKEN_NONCE_SIZE]) { - const uint8_t kHashTLabel[] = "TrustToken VOPRF PST V1 HashToGroup"; - return ec_hash_to_curve_p384_xmd_sha384_sswu( - group, out, kHashTLabel, sizeof(kHashTLabel), t, TRUST_TOKEN_NONCE_SIZE); + const uint8_t kHashTLabel[] = "HashToGroup-OPRFV1-\x01-P384-SHA384"; + return ec_hash_to_curve_p384_xmd_sha384_sswu(group, out, kHashTLabel, + sizeof(kHashTLabel) - 1, t, + TRUST_TOKEN_NONCE_SIZE); } static int voprf_pst1_hash_to_scalar(const EC_GROUP *group, EC_SCALAR *out, uint8_t *buf, size_t len) { - const uint8_t kHashCLabel[] = "TrustToken VOPRF PST V1 HashToScalar"; - return ec_hash_to_scalar_p384_xmd_sha384( - group, out, kHashCLabel, sizeof(kHashCLabel), buf, len); + const uint8_t kHashCLabel[] = "HashToScalar-OPRFV1-\x01-P384-SHA384"; + return ec_hash_to_scalar_p384_xmd_sha384(group, out, kHashCLabel, + sizeof(kHashCLabel) - 1, buf, len); } -static int voprf_pst1_ok = 0; -static VOPRF_METHOD voprf_pst1_method; -static CRYPTO_once_t voprf_pst1_method_once = CRYPTO_ONCE_INIT; - -static void voprf_pst1_init_method_impl(void) { - voprf_pst1_ok = - voprf_init_method(&voprf_pst1_method, NID_secp384r1, - voprf_pst1_hash_to_group, voprf_pst1_hash_to_scalar); -} - -static int voprf_pst1_init_method(void) { - CRYPTO_once(&voprf_pst1_method_once, voprf_pst1_init_method_impl); - if (!voprf_pst1_ok) { - OPENSSL_PUT_ERROR(TRUST_TOKEN, ERR_R_INTERNAL_ERROR); - return 0; - } - return 1; -} +static VOPRF_METHOD voprf_pst1_method = { + EC_group_p384, voprf_pst1_hash_to_group, voprf_pst1_hash_to_scalar}; int voprf_pst1_generate_key(CBB *out_private, CBB *out_public) { - if (!voprf_pst1_init_method()) { - return 0; - } - return voprf_generate_key(&voprf_pst1_method, out_private, out_public); } int voprf_pst1_derive_key_from_secret(CBB *out_private, CBB *out_public, const uint8_t *secret, size_t secret_len) { - if (!voprf_pst1_init_method()) { - return 0; - } - return voprf_derive_key_from_secret(&voprf_pst1_method, out_private, out_public, secret, secret_len); } int voprf_pst1_client_key_from_bytes(TRUST_TOKEN_CLIENT_KEY *key, const uint8_t *in, size_t len) { - if (!voprf_pst1_init_method()) { - return 0; - } return voprf_client_key_from_bytes(&voprf_pst1_method, key, in, len); } int voprf_pst1_issuer_key_from_bytes(TRUST_TOKEN_ISSUER_KEY *key, const uint8_t *in, size_t len) { - if (!voprf_pst1_init_method()) { - return 0; - } return voprf_issuer_key_from_bytes(&voprf_pst1_method, key, in, len); } @@ -904,9 +1247,6 @@ STACK_OF(TRUST_TOKEN_PRETOKEN) *voprf_pst1_blind(CBB *cbb, size_t count, int include_message, const uint8_t *msg, size_t msg_len) { - if (!voprf_pst1_init_method()) { - return NULL; - } return voprf_blind(&voprf_pst1_method, cbb, count, include_message, msg, msg_len); } @@ -914,20 +1254,30 @@ STACK_OF(TRUST_TOKEN_PRETOKEN) *voprf_pst1_blind(CBB *cbb, size_t count, int voprf_pst1_sign(const TRUST_TOKEN_ISSUER_KEY *key, CBB *cbb, CBS *cbs, size_t num_requested, size_t num_to_issue, uint8_t private_metadata) { - if (!voprf_pst1_init_method() || private_metadata != 0) { + if (private_metadata != 0) { return 0; } return voprf_sign(&voprf_pst1_method, key, cbb, cbs, num_requested, num_to_issue); } + +int voprf_pst1_sign_with_proof_scalar_for_testing( + const TRUST_TOKEN_ISSUER_KEY *key, CBB *cbb, CBS *cbs, size_t num_requested, + size_t num_to_issue, uint8_t private_metadata, + const uint8_t *proof_scalar_buf, size_t proof_scalar_len) { + if (private_metadata != 0) { + return 0; + } + return voprf_sign_with_proof_scalar_for_testing( + &voprf_pst1_method, key, cbb, cbs, num_requested, num_to_issue, + proof_scalar_buf, proof_scalar_len); +} + STACK_OF(TRUST_TOKEN) *voprf_pst1_unblind( const TRUST_TOKEN_CLIENT_KEY *key, const STACK_OF(TRUST_TOKEN_PRETOKEN) *pretokens, CBS *cbs, size_t count, uint32_t key_id) { - if (!voprf_pst1_init_method()) { - return NULL; - } return voprf_unblind(&voprf_pst1_method, key, pretokens, cbs, count, key_id); } @@ -936,9 +1286,6 @@ int voprf_pst1_read(const TRUST_TOKEN_ISSUER_KEY *key, uint8_t *out_private_metadata, const uint8_t *token, size_t token_len, int include_message, const uint8_t *msg, size_t msg_len) { - if (!voprf_pst1_init_method()) { - return 0; - } return voprf_read(&voprf_pst1_method, key, out_nonce, token, token_len, include_message, msg, msg_len); } diff --git a/Sources/CCryptoBoringSSL/crypto/x509/a_sign.c b/Sources/CCryptoBoringSSL/crypto/x509/a_sign.c index 424be555..2bb6770e 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/a_sign.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/a_sign.c @@ -126,7 +126,7 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, out = NULL; signature->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); signature->flags |= ASN1_STRING_FLAG_BITS_LEFT; - ret = 1; + ret = (int)out_len; err: EVP_MD_CTX_cleanup(ctx); diff --git a/Sources/CCryptoBoringSSL/crypto/x509/by_dir.c b/Sources/CCryptoBoringSSL/crypto/x509/by_dir.c index 0f518e55..6bd894f4 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/by_dir.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/by_dir.c @@ -64,8 +64,6 @@ #include #include -#if !defined(OPENSSL_TRUSTY) - #include "../internal.h" #include "internal.h" @@ -81,7 +79,6 @@ typedef struct lookup_dir_entry_st { } BY_DIR_ENTRY; typedef struct lookup_dir_st { - BUF_MEM *buffer; STACK_OF(BY_DIR_ENTRY) *dirs; } BY_DIR; @@ -141,10 +138,6 @@ static int new_dir(X509_LOOKUP *lu) { if ((a = (BY_DIR *)OPENSSL_malloc(sizeof(BY_DIR))) == NULL) { return 0; } - if ((a->buffer = BUF_MEM_new()) == NULL) { - OPENSSL_free(a); - return 0; - } a->dirs = NULL; lu->method_data = a; return 1; @@ -175,7 +168,6 @@ static void free_dir(X509_LOOKUP *lu) { BY_DIR *a = lu->method_data; if (a != NULL) { sk_BY_DIR_ENTRY_pop_free(a->dirs, by_dir_entry_free); - BUF_MEM_free(a->buffer); OPENSSL_free(a); } } @@ -238,7 +230,7 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type) { // g_ent_hashes_lock protects the |hashes| member of all |BY_DIR_ENTRY| // objects. -static struct CRYPTO_STATIC_MUTEX g_ent_hashes_lock = CRYPTO_STATIC_MUTEX_INIT; +static CRYPTO_MUTEX g_ent_hashes_lock = CRYPTO_MUTEX_INIT; static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, X509_OBJECT *ret) { @@ -304,7 +296,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, } if (type == X509_LU_CRL && ent->hashes) { htmp.hash = h; - CRYPTO_STATIC_MUTEX_lock_read(&g_ent_hashes_lock); + CRYPTO_MUTEX_lock_read(&g_ent_hashes_lock); if (sk_BY_DIR_HASH_find(ent->hashes, &idx, &htmp)) { hent = sk_BY_DIR_HASH_value(ent->hashes, idx); k = hent->suffix; @@ -312,14 +304,13 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, hent = NULL; k = 0; } - CRYPTO_STATIC_MUTEX_unlock_read(&g_ent_hashes_lock); + CRYPTO_MUTEX_unlock_read(&g_ent_hashes_lock); } else { k = 0; hent = NULL; } for (;;) { - BIO_snprintf(b->data, b->max, "%s/%08lx.%s%d", ent->dir, h, postfix, - k); + snprintf(b->data, b->max, "%s/%08lx.%s%d", ent->dir, h, postfix, k); #ifndef OPENSSL_NO_POSIX_IO #if defined(_WIN32) && !defined(stat) #define stat _stat @@ -357,7 +348,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, // If a CRL, update the last file suffix added for this if (type == X509_LU_CRL) { - CRYPTO_STATIC_MUTEX_lock_write(&g_ent_hashes_lock); + CRYPTO_MUTEX_lock_write(&g_ent_hashes_lock); // Look for entry again in case another thread added an entry // first. if (!hent) { @@ -370,14 +361,14 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, if (!hent) { hent = OPENSSL_malloc(sizeof(BY_DIR_HASH)); if (hent == NULL) { - CRYPTO_STATIC_MUTEX_unlock_write(&g_ent_hashes_lock); + CRYPTO_MUTEX_unlock_write(&g_ent_hashes_lock); ok = 0; goto finish; } hent->hash = h; hent->suffix = k; if (!sk_BY_DIR_HASH_push(ent->hashes, hent)) { - CRYPTO_STATIC_MUTEX_unlock_write(&g_ent_hashes_lock); + CRYPTO_MUTEX_unlock_write(&g_ent_hashes_lock); OPENSSL_free(hent); ok = 0; goto finish; @@ -387,7 +378,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, hent->suffix = k; } - CRYPTO_STATIC_MUTEX_unlock_write(&g_ent_hashes_lock); + CRYPTO_MUTEX_unlock_write(&g_ent_hashes_lock); } if (tmp != NULL) { @@ -409,5 +400,3 @@ finish: BUF_MEM_free(b); return ok; } - -#endif // OPENSSL_TRUSTY diff --git a/Sources/CCryptoBoringSSL/crypto/x509/by_file.c b/Sources/CCryptoBoringSSL/crypto/x509/by_file.c index 3dd356b2..cbf7bf7e 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/by_file.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/by_file.c @@ -62,7 +62,6 @@ #include "internal.h" -#ifndef OPENSSL_NO_STDIO static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret); @@ -278,5 +277,3 @@ err: sk_X509_INFO_pop_free(inf, X509_INFO_free); return count; } - -#endif // OPENSSL_NO_STDIO diff --git a/Sources/CCryptoBoringSSL/crypto/x509/internal.h b/Sources/CCryptoBoringSSL/crypto/x509/internal.h index fff035c1..6d8589b7 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/internal.h +++ b/Sources/CCryptoBoringSSL/crypto/x509/internal.h @@ -64,6 +64,7 @@ #include #include "../asn1/internal.h" +#include "../internal.h" #if defined(__cplusplus) extern "C" { @@ -274,7 +275,6 @@ struct x509_lookup_method_st { // function is then called to actually check the cert chain. struct x509_store_st { // The following is a cache of trusted certs - int cache; // if true, stash any hits STACK_OF(X509_OBJECT) *objs; // Cache of all objects CRYPTO_MUTEX objs_lock; diff --git a/Sources/CCryptoBoringSSL/crypto/x509/name_print.c b/Sources/CCryptoBoringSSL/crypto/x509/name_print.c index 121a05e6..4a5169eb 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/name_print.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/name_print.c @@ -56,6 +56,7 @@ #include +#include #include #include @@ -84,8 +85,7 @@ static int do_indent(BIO *out, int indent) { static int do_name_ex(BIO *out, const X509_NAME *n, int indent, unsigned long flags) { - int i, prev = -1, orflags, cnt; - int fn_opt, fn_nid; + int prev = -1, orflags; char objtmp[80]; const char *objbuf; int outlen, len; @@ -142,10 +142,8 @@ static int do_name_ex(BIO *out, const X509_NAME *n, int indent, sep_eq_len = 1; } - fn_opt = flags & XN_FLAG_FN_MASK; - - cnt = X509_NAME_entry_count(n); - for (i = 0; i < cnt; i++) { + int cnt = X509_NAME_entry_count(n); + for (int i = 0; i < cnt; i++) { const X509_NAME_ENTRY *ent; if (flags & XN_FLAG_DN_REV) { ent = X509_NAME_get_entry(n, cnt - i - 1); @@ -172,40 +170,20 @@ static int do_name_ex(BIO *out, const X509_NAME *n, int indent, prev = X509_NAME_ENTRY_set(ent); const ASN1_OBJECT *fn = X509_NAME_ENTRY_get_object(ent); const ASN1_STRING *val = X509_NAME_ENTRY_get_data(ent); - fn_nid = OBJ_obj2nid(fn); - if (fn_opt != XN_FLAG_FN_NONE) { - int objlen, fld_len; - if ((fn_opt == XN_FLAG_FN_OID) || (fn_nid == NID_undef)) { - OBJ_obj2txt(objtmp, sizeof objtmp, fn, 1); - fld_len = 0; // XXX: what should this be? - objbuf = objtmp; - } else { - if (fn_opt == XN_FLAG_FN_SN) { - fld_len = FN_WIDTH_SN; - objbuf = OBJ_nid2sn(fn_nid); - } else if (fn_opt == XN_FLAG_FN_LN) { - fld_len = FN_WIDTH_LN; - objbuf = OBJ_nid2ln(fn_nid); - } else { - fld_len = 0; // XXX: what should this be? - objbuf = ""; - } - } - objlen = strlen(objbuf); - if (!maybe_write(out, objbuf, objlen)) { - return -1; - } - if ((objlen < fld_len) && (flags & XN_FLAG_FN_ALIGN)) { - if (!do_indent(out, fld_len - objlen)) { - return -1; - } - outlen += fld_len - objlen; - } - if (!maybe_write(out, sep_eq, sep_eq_len)) { - return -1; - } - outlen += objlen + sep_eq_len; + assert((flags & XN_FLAG_FN_MASK) == XN_FLAG_FN_SN); + int fn_nid = OBJ_obj2nid(fn); + if (fn_nid == NID_undef) { + OBJ_obj2txt(objtmp, sizeof(objtmp), fn, 1); + objbuf = objtmp; + } else { + objbuf = OBJ_nid2sn(fn_nid); } + int objlen = strlen(objbuf); + if (!maybe_write(out, objbuf, objlen) || + !maybe_write(out, sep_eq, sep_eq_len)) { + return -1; + } + outlen += objlen + sep_eq_len; // If the field name is unknown then fix up the DER dump flag. We // might want to limit this further so it will DER dump on anything // other than a few 'standard' fields. diff --git a/Sources/CCryptoBoringSSL/crypto/x509/t_x509.c b/Sources/CCryptoBoringSSL/crypto/x509/t_x509.c index ff915a35..3093967f 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/t_x509.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/t_x509.c @@ -91,14 +91,8 @@ int X509_print(BIO *bp, X509 *x) { int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag) { - long l; - int ret = 0, i; - char *m = NULL, mlch = ' '; + char mlch = ' '; int nmindent = 0; - X509_CINF *ci; - EVP_PKEY *pkey = NULL; - const char *neg; - if ((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { mlch = '\n'; nmindent = 12; @@ -108,26 +102,26 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, nmindent = 16; } - ci = x->cert_info; + const X509_CINF *ci = x->cert_info; if (!(cflag & X509_FLAG_NO_HEADER)) { if (BIO_write(bp, "Certificate:\n", 13) <= 0) { - goto err; + return 0; } if (BIO_write(bp, " Data:\n", 10) <= 0) { - goto err; + return 0; } } if (!(cflag & X509_FLAG_NO_VERSION)) { - l = X509_get_version(x); + long l = X509_get_version(x); assert(X509_VERSION_1 <= l && l <= X509_VERSION_3); if (BIO_printf(bp, "%8sVersion: %ld (0x%lx)\n", "", l + 1, (unsigned long)l) <= 0) { - goto err; + return 0; } } if (!(cflag & X509_FLAG_NO_SERIAL)) { if (BIO_write(bp, " Serial Number:", 22) <= 0) { - goto err; + return 0; } const ASN1_INTEGER *serial = X509_get0_serialNumber(x); @@ -136,19 +130,20 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, assert(serial->type != V_ASN1_NEG_INTEGER); if (BIO_printf(bp, " %" PRIu64 " (0x%" PRIx64 ")\n", serial_u64, serial_u64) <= 0) { - goto err; + return 0; } } else { ERR_clear_error(); // Clear |ASN1_INTEGER_get_uint64|'s error. - neg = (serial->type == V_ASN1_NEG_INTEGER) ? " (Negative)" : ""; + const char *neg = + (serial->type == V_ASN1_NEG_INTEGER) ? " (Negative)" : ""; if (BIO_printf(bp, "\n%12s%s", "", neg) <= 0) { - goto err; + return 0; } - for (i = 0; i < serial->length; i++) { + for (int i = 0; i < serial->length; i++) { if (BIO_printf(bp, "%02x%c", serial->data[i], ((i + 1 == serial->length) ? '\n' : ':')) <= 0) { - goto err; + return 0; } } } @@ -156,69 +151,69 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, if (!(cflag & X509_FLAG_NO_SIGNAME)) { if (X509_signature_print(bp, ci->signature, NULL) <= 0) { - goto err; + return 0; } } if (!(cflag & X509_FLAG_NO_ISSUER)) { if (BIO_printf(bp, " Issuer:%c", mlch) <= 0) { - goto err; + return 0; } if (X509_NAME_print_ex(bp, X509_get_issuer_name(x), nmindent, nmflags) < 0) { - goto err; + return 0; } if (BIO_write(bp, "\n", 1) <= 0) { - goto err; + return 0; } } if (!(cflag & X509_FLAG_NO_VALIDITY)) { if (BIO_write(bp, " Validity\n", 17) <= 0) { - goto err; + return 0; } if (BIO_write(bp, " Not Before: ", 24) <= 0) { - goto err; + return 0; } if (!ASN1_TIME_print(bp, X509_get_notBefore(x))) { - goto err; + return 0; } if (BIO_write(bp, "\n Not After : ", 25) <= 0) { - goto err; + return 0; } if (!ASN1_TIME_print(bp, X509_get_notAfter(x))) { - goto err; + return 0; } if (BIO_write(bp, "\n", 1) <= 0) { - goto err; + return 0; } } if (!(cflag & X509_FLAG_NO_SUBJECT)) { if (BIO_printf(bp, " Subject:%c", mlch) <= 0) { - goto err; + return 0; } if (X509_NAME_print_ex(bp, X509_get_subject_name(x), nmindent, nmflags) < 0) { - goto err; + return 0; } if (BIO_write(bp, "\n", 1) <= 0) { - goto err; + return 0; } } if (!(cflag & X509_FLAG_NO_PUBKEY)) { if (BIO_write(bp, " Subject Public Key Info:\n", 33) <= 0) { - goto err; + return 0; } if (BIO_printf(bp, "%12sPublic Key Algorithm: ", "") <= 0) { - goto err; + return 0; } if (i2a_ASN1_OBJECT(bp, ci->key->algor->algorithm) <= 0) { - goto err; + return 0; } if (BIO_puts(bp, "\n") <= 0) { - goto err; + return 0; } - pkey = X509_get_pubkey(x); + EVP_PKEY *pkey = X509_get_pubkey(x); if (pkey == NULL) { BIO_printf(bp, "%12sUnable to load Public Key\n", ""); ERR_print_errors(bp); @@ -231,18 +226,18 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, if (!(cflag & X509_FLAG_NO_IDS)) { if (ci->issuerUID) { if (BIO_printf(bp, "%8sIssuer Unique ID: ", "") <= 0) { - goto err; + return 0; } if (!X509_signature_dump(bp, ci->issuerUID, 12)) { - goto err; + return 0; } } if (ci->subjectUID) { if (BIO_printf(bp, "%8sSubject Unique ID: ", "") <= 0) { - goto err; + return 0; } if (!X509_signature_dump(bp, ci->subjectUID, 12)) { - goto err; + return 0; } } } @@ -253,20 +248,16 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, if (!(cflag & X509_FLAG_NO_SIGDUMP)) { if (X509_signature_print(bp, x->sig_alg, x->signature) <= 0) { - goto err; + return 0; } } if (!(cflag & X509_FLAG_NO_AUX)) { if (!X509_CERT_AUX_print(bp, x->aux, 0)) { - goto err; + return 0; } } - ret = 1; -err: - if (m != NULL) { - OPENSSL_free(m); - } - return ret; + + return 1; } int X509_signature_print(BIO *bp, const X509_ALGOR *sigalg, diff --git a/Sources/CCryptoBoringSSL/crypto/x509/x509_att.c b/Sources/CCryptoBoringSSL/crypto/x509/x509_att.c index fc1e46f7..db8c51a0 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/x509_att.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/x509_att.c @@ -56,153 +56,13 @@ #include #include -#include #include -#include #include #include "../asn1/internal.h" #include "internal.h" -int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x) { - return sk_X509_ATTRIBUTE_num(x); -} - -int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, - int lastpos) { - const ASN1_OBJECT *obj = OBJ_nid2obj(nid); - if (obj == NULL) { - return -1; - } - return X509at_get_attr_by_OBJ(x, obj, lastpos); -} - -int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, - const ASN1_OBJECT *obj, int lastpos) { - int n; - X509_ATTRIBUTE *ex; - - if (sk == NULL) { - return -1; - } - lastpos++; - if (lastpos < 0) { - lastpos = 0; - } - n = sk_X509_ATTRIBUTE_num(sk); - for (; lastpos < n; lastpos++) { - ex = sk_X509_ATTRIBUTE_value(sk, lastpos); - if (OBJ_cmp(ex->object, obj) == 0) { - return lastpos; - } - } - return -1; -} - -X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc) { - if (x == NULL || loc < 0 || sk_X509_ATTRIBUTE_num(x) <= (size_t)loc) { - return NULL; - } else { - return sk_X509_ATTRIBUTE_value(x, loc); - } -} - -X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc) { - X509_ATTRIBUTE *ret; - - if (x == NULL || loc < 0 || sk_X509_ATTRIBUTE_num(x) <= (size_t)loc) { - return NULL; - } - ret = sk_X509_ATTRIBUTE_delete(x, loc); - return ret; -} - -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, - X509_ATTRIBUTE *attr) { - X509_ATTRIBUTE *new_attr = NULL; - STACK_OF(X509_ATTRIBUTE) *sk = NULL; - - if (x == NULL) { - OPENSSL_PUT_ERROR(X509, ERR_R_PASSED_NULL_PARAMETER); - goto err; - } - - if (*x == NULL) { - if ((sk = sk_X509_ATTRIBUTE_new_null()) == NULL) { - goto err; - } - } else { - sk = *x; - } - - if ((new_attr = X509_ATTRIBUTE_dup(attr)) == NULL) { - goto err; - } - if (!sk_X509_ATTRIBUTE_push(sk, new_attr)) { - goto err; - } - if (*x == NULL) { - *x = sk; - } - return sk; -err: - if (new_attr != NULL) { - X509_ATTRIBUTE_free(new_attr); - } - if (sk != NULL) { - sk_X509_ATTRIBUTE_free(sk); - } - return NULL; -} - -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x, - const ASN1_OBJECT *obj, - int type, - const unsigned char *bytes, - int len) { - X509_ATTRIBUTE *attr; - STACK_OF(X509_ATTRIBUTE) *ret; - attr = X509_ATTRIBUTE_create_by_OBJ(NULL, obj, type, bytes, len); - if (!attr) { - return 0; - } - ret = X509at_add1_attr(x, attr); - X509_ATTRIBUTE_free(attr); - return ret; -} - -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x, - int nid, int type, - const unsigned char *bytes, - int len) { - X509_ATTRIBUTE *attr; - STACK_OF(X509_ATTRIBUTE) *ret; - attr = X509_ATTRIBUTE_create_by_NID(NULL, nid, type, bytes, len); - if (!attr) { - return 0; - } - ret = X509at_add1_attr(x, attr); - X509_ATTRIBUTE_free(attr); - return ret; -} - -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, - const char *attrname, - int type, - const unsigned char *bytes, - int len) { - X509_ATTRIBUTE *attr; - STACK_OF(X509_ATTRIBUTE) *ret; - attr = X509_ATTRIBUTE_create_by_txt(NULL, attrname, type, bytes, len); - if (!attr) { - return 0; - } - ret = X509at_add1_attr(x, attr); - X509_ATTRIBUTE_free(attr); - return ret; -} - X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, int attrtype, const void *data, int len) { @@ -329,7 +189,7 @@ err: } int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr) { - return sk_ASN1_TYPE_num(attr->set); + return (int)sk_ASN1_TYPE_num(attr->set); } ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr) { diff --git a/Sources/CCryptoBoringSSL/crypto/x509/x509_d2.c b/Sources/CCryptoBoringSSL/crypto/x509/x509_d2.c index d7b55efc..29882628 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/x509_d2.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/x509_d2.c @@ -57,7 +57,7 @@ #include #include -#ifndef OPENSSL_NO_STDIO + int X509_STORE_set_default_paths(X509_STORE *ctx) { X509_LOOKUP *lookup; @@ -106,5 +106,3 @@ int X509_STORE_load_locations(X509_STORE *ctx, const char *file, } return 1; } - -#endif diff --git a/Sources/CCryptoBoringSSL/crypto/x509/x509_lu.c b/Sources/CCryptoBoringSSL/crypto/x509/x509_lu.c index 33346f6a..2e359277 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/x509_lu.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/x509_lu.c @@ -173,7 +173,6 @@ X509_STORE *X509_STORE_new(void) { if (ret->objs == NULL) { goto err; } - ret->cache = 1; ret->get_cert_methods = sk_X509_LOOKUP_new_null(); if (ret->get_cert_methods == NULL) { goto err; @@ -423,9 +422,8 @@ static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type, } if (pnmatch != NULL) { - int tidx; *pnmatch = 1; - for (tidx = idx + 1; tidx < (int)sk_X509_OBJECT_num(h); tidx++) { + for (size_t tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) { const X509_OBJECT *tobj = sk_X509_OBJECT_value(h, tidx); if (x509_object_cmp(tobj, &stmp)) { break; @@ -434,7 +432,7 @@ static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type, } } - return idx; + return (int)idx; } int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, int type, diff --git a/Sources/CCryptoBoringSSL/crypto/x509/x509_req.c b/Sources/CCryptoBoringSSL/crypto/x509/x509_req.c index c21c3fb8..d1c843b7 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/x509_req.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/x509_req.c @@ -160,62 +160,111 @@ int X509_REQ_add_extensions(X509_REQ *req, return X509_REQ_add_extensions_nid(req, exts, NID_ext_req); } -// Request attribute functions - int X509_REQ_get_attr_count(const X509_REQ *req) { - return X509at_get_attr_count(req->req_info->attributes); + return (int)sk_X509_ATTRIBUTE_num(req->req_info->attributes); } int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos) { - return X509at_get_attr_by_NID(req->req_info->attributes, nid, lastpos); + const ASN1_OBJECT *obj = OBJ_nid2obj(nid); + if (obj == NULL) { + return -1; + } + return X509_REQ_get_attr_by_OBJ(req, obj, lastpos); } int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj, int lastpos) { - return X509at_get_attr_by_OBJ(req->req_info->attributes, obj, lastpos); + if (req->req_info->attributes == NULL) { + return -1; + } + lastpos++; + if (lastpos < 0) { + lastpos = 0; + } + int n = (int)sk_X509_ATTRIBUTE_num(req->req_info->attributes); + for (; lastpos < n; lastpos++) { + const X509_ATTRIBUTE *attr = + sk_X509_ATTRIBUTE_value(req->req_info->attributes, lastpos); + if (OBJ_cmp(attr->object, obj) == 0) { + return lastpos; + } + } + return -1; } X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc) { - return X509at_get_attr(req->req_info->attributes, loc); + if (req->req_info->attributes == NULL || loc < 0 || + sk_X509_ATTRIBUTE_num(req->req_info->attributes) <= (size_t)loc) { + return NULL; + } + return sk_X509_ATTRIBUTE_value(req->req_info->attributes, loc); } X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc) { - return X509at_delete_attr(req->req_info->attributes, loc); + if (req->req_info->attributes == NULL || loc < 0 || + sk_X509_ATTRIBUTE_num(req->req_info->attributes) <= (size_t)loc) { + return NULL; + } + return sk_X509_ATTRIBUTE_delete(req->req_info->attributes, loc); } -int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr) { - if (X509at_add1_attr(&req->req_info->attributes, attr)) { - return 1; +static int X509_REQ_add0_attr(X509_REQ *req, X509_ATTRIBUTE *attr) { + if (req->req_info->attributes == NULL) { + req->req_info->attributes = sk_X509_ATTRIBUTE_new_null(); } - return 0; + if (req->req_info->attributes == NULL || + !sk_X509_ATTRIBUTE_push(req->req_info->attributes, attr)) { + return 0; + } + + return 1; +} + +int X509_REQ_add1_attr(X509_REQ *req, const X509_ATTRIBUTE *attr) { + X509_ATTRIBUTE *new_attr = X509_ATTRIBUTE_dup(attr); + if (new_attr == NULL || !X509_REQ_add0_attr(req, new_attr)) { + X509_ATTRIBUTE_free(new_attr); + return 0; + } + + return 1; } int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, const ASN1_OBJECT *obj, int attrtype, const unsigned char *data, int len) { - if (X509at_add1_attr_by_OBJ(&req->req_info->attributes, obj, attrtype, data, - len)) { - return 1; + X509_ATTRIBUTE *attr = + X509_ATTRIBUTE_create_by_OBJ(NULL, obj, attrtype, data, len); + if (attr == NULL || !X509_REQ_add0_attr(req, attr)) { + X509_ATTRIBUTE_free(attr); + return 0; } - return 0; + + return 1; } int X509_REQ_add1_attr_by_NID(X509_REQ *req, int nid, int attrtype, const unsigned char *data, int len) { - if (X509at_add1_attr_by_NID(&req->req_info->attributes, nid, attrtype, data, - len)) { - return 1; + X509_ATTRIBUTE *attr = + X509_ATTRIBUTE_create_by_NID(NULL, nid, attrtype, data, len); + if (attr == NULL || !X509_REQ_add0_attr(req, attr)) { + X509_ATTRIBUTE_free(attr); + return 0; } - return 0; + + return 1; } int X509_REQ_add1_attr_by_txt(X509_REQ *req, const char *attrname, int attrtype, const unsigned char *data, int len) { - if (X509at_add1_attr_by_txt(&req->req_info->attributes, attrname, attrtype, - data, len)) { - return 1; + X509_ATTRIBUTE *attr = + X509_ATTRIBUTE_create_by_txt(NULL, attrname, attrtype, data, len); + if (attr == NULL || !X509_REQ_add0_attr(req, attr)) { + X509_ATTRIBUTE_free(attr); + return 0; } - return 0; + + return 1; } void X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig, diff --git a/Sources/CCryptoBoringSSL/crypto/x509/x509_trs.c b/Sources/CCryptoBoringSSL/crypto/x509/x509_trs.c index bb52f61a..d43f85d6 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/x509_trs.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/x509_trs.c @@ -168,7 +168,7 @@ int X509_TRUST_set(int *t, int trust) { } int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), - char *name, int arg1, void *arg2) { + const char *name, int arg1, void *arg2) { int idx; X509_TRUST *trtmp; char *name_dup; diff --git a/Sources/CCryptoBoringSSL/crypto/x509/x509_v3.c b/Sources/CCryptoBoringSSL/crypto/x509/x509_v3.c index 2db91b55..7502ba1c 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/x509_v3.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/x509_v3.c @@ -69,7 +69,7 @@ int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x) { if (x == NULL) { return 0; } - return (sk_X509_EXTENSION_num(x)); + return (int)sk_X509_EXTENSION_num(x); } int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, int nid, @@ -83,9 +83,6 @@ int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, int nid, int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *sk, const ASN1_OBJECT *obj, int lastpos) { - int n; - X509_EXTENSION *ex; - if (sk == NULL) { return -1; } @@ -93,9 +90,9 @@ int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *sk, if (lastpos < 0) { lastpos = 0; } - n = sk_X509_EXTENSION_num(sk); + int n = (int)sk_X509_EXTENSION_num(sk); for (; lastpos < n; lastpos++) { - ex = sk_X509_EXTENSION_value(sk, lastpos); + const X509_EXTENSION *ex = sk_X509_EXTENSION_value(sk, lastpos); if (OBJ_cmp(ex->object, obj) == 0) { return lastpos; } @@ -115,7 +112,7 @@ int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *sk, int crit, } crit = !!crit; - int n = sk_X509_EXTENSION_num(sk); + int n = (int)sk_X509_EXTENSION_num(sk); for (; lastpos < n; lastpos++) { const X509_EXTENSION *ex = sk_X509_EXTENSION_value(sk, lastpos); if (X509_EXTENSION_get_critical(ex) == crit) { @@ -146,13 +143,12 @@ X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc) { STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, const X509_EXTENSION *ex, int loc) { X509_EXTENSION *new_ex = NULL; - int n; STACK_OF(X509_EXTENSION) *sk = NULL; int free_sk = 0; if (x == NULL) { OPENSSL_PUT_ERROR(X509, ERR_R_PASSED_NULL_PARAMETER); - goto err2; + goto err; } if (*x == NULL) { @@ -164,7 +160,7 @@ STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, sk = *x; } - n = sk_X509_EXTENSION_num(sk); + int n = (int)sk_X509_EXTENSION_num(sk); if (loc > n) { loc = n; } else if (loc < 0) { @@ -172,7 +168,7 @@ STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, } if ((new_ex = X509_EXTENSION_dup(ex)) == NULL) { - goto err2; + goto err; } if (!sk_X509_EXTENSION_insert(sk, new_ex, loc)) { goto err; @@ -181,8 +177,8 @@ STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, *x = sk; } return sk; + err: -err2: X509_EXTENSION_free(new_ex); if (free_sk) { sk_X509_EXTENSION_free(sk); diff --git a/Sources/CCryptoBoringSSL/crypto/x509/x509_vfy.c b/Sources/CCryptoBoringSSL/crypto/x509/x509_vfy.c index ad9391ac..9e0a9d9a 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/x509_vfy.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/x509_vfy.c @@ -217,7 +217,7 @@ int X509_verify_cert(X509_STORE_CTX *ctx) { goto end; } - num = sk_X509_num(ctx->chain); + num = (int)sk_X509_num(ctx->chain); x = sk_X509_value(ctx->chain, num - 1); depth = param->depth; @@ -284,7 +284,7 @@ int X509_verify_cert(X509_STORE_CTX *ctx) { do { // Examine last certificate in chain and see if it is self signed. - i = sk_X509_num(ctx->chain); + i = (int)sk_X509_num(ctx->chain); x = sk_X509_value(ctx->chain, i - 1); int is_self_signed; @@ -396,7 +396,7 @@ int X509_verify_cert(X509_STORE_CTX *ctx) { X509_free(xtmp); num--; } - ctx->last_untrusted = sk_X509_num(ctx->chain); + ctx->last_untrusted = (int)sk_X509_num(ctx->chain); retry = 1; break; } @@ -628,7 +628,7 @@ static int check_name_constraints(X509_STORE_CTX *ctx) { int i, j, rv; int has_name_constraints = 0; // Check name constraints for all certificates - for (i = sk_X509_num(ctx->chain) - 1; i >= 0; i--) { + for (i = (int)sk_X509_num(ctx->chain) - 1; i >= 0; i--) { X509 *x = sk_X509_value(ctx->chain, i); // Ignore self issued certs unless last in chain if (i && (x->ex_flags & EXFLAG_SI)) { @@ -638,7 +638,7 @@ static int check_name_constraints(X509_STORE_CTX *ctx) { // including trust anchor. Trust anchor not strictly speaking needed // but if it includes constraints it is to be assumed it expects them // to be obeyed. - for (j = sk_X509_num(ctx->chain) - 1; j > i; j--) { + for (j = (int)sk_X509_num(ctx->chain) - 1; j > i; j--) { NAME_CONSTRAINTS *nc = sk_X509_value(ctx->chain, j)->nc; if (nc) { has_name_constraints = 1; @@ -748,11 +748,10 @@ static int check_id(X509_STORE_CTX *ctx) { } static int check_trust(X509_STORE_CTX *ctx) { - size_t i; int ok; X509 *x = NULL; // Check all trusted certificates in chain - for (i = ctx->last_untrusted; i < sk_X509_num(ctx->chain); i++) { + for (size_t i = ctx->last_untrusted; i < sk_X509_num(ctx->chain); i++) { x = sk_X509_value(ctx->chain, i); ok = X509_check_trust(x, ctx->param->trust, 0); // If explicitly trusted return trusted @@ -762,7 +761,7 @@ static int check_trust(X509_STORE_CTX *ctx) { // If explicitly rejected notify callback and reject if not // overridden. if (ok == X509_TRUST_REJECTED) { - ctx->error_depth = i; + ctx->error_depth = (int)i; ctx->current_cert = x; ctx->error = X509_V_ERR_CERT_REJECTED; ok = ctx->verify_cb(0, ctx); @@ -794,12 +793,12 @@ static int check_trust(X509_STORE_CTX *ctx) { } static int check_revocation(X509_STORE_CTX *ctx) { - int i, last, ok; if (!(ctx->param->flags & X509_V_FLAG_CRL_CHECK)) { return 1; } + int last; if (ctx->param->flags & X509_V_FLAG_CRL_CHECK_ALL) { - last = sk_X509_num(ctx->chain) - 1; + last = (int)sk_X509_num(ctx->chain) - 1; } else { // If checking CRL paths this isn't the EE certificate if (ctx->parent) { @@ -807,9 +806,9 @@ static int check_revocation(X509_STORE_CTX *ctx) { } last = 0; } - for (i = 0; i <= last; i++) { + for (int i = 0; i <= last; i++) { ctx->error_depth = i; - ok = check_cert(ctx); + int ok = check_cert(ctx); if (!ok) { return ok; } @@ -1478,9 +1477,9 @@ done: static int check_crl(X509_STORE_CTX *ctx, X509_CRL *crl) { X509 *issuer = NULL; EVP_PKEY *ikey = NULL; - int ok = 0, chnum, cnum; - cnum = ctx->error_depth; - chnum = sk_X509_num(ctx->chain) - 1; + int ok = 0; + int cnum = ctx->error_depth; + int chnum = (int)sk_X509_num(ctx->chain) - 1; // if we have an alternative CRL issuer cert use that if (ctx->current_issuer) { issuer = ctx->current_issuer; @@ -1691,11 +1690,11 @@ static int check_cert_time(X509_STORE_CTX *ctx, X509 *x) { } static int internal_verify(X509_STORE_CTX *ctx) { - int ok = 0, n; + int ok = 0; X509 *xs, *xi; EVP_PKEY *pkey = NULL; - n = sk_X509_num(ctx->chain); + int n = (int)sk_X509_num(ctx->chain); ctx->error_depth = n - 1; n--; xi = sk_X509_value(ctx->chain, n); @@ -1776,7 +1775,7 @@ int X509_cmp_current_time(const ASN1_TIME *ctm) { return X509_cmp_time_posix(ctm, time(NULL)); } -int X509_cmp_time(const ASN1_TIME *ctm, time_t *cmp_time) { +int X509_cmp_time(const ASN1_TIME *ctm, const time_t *cmp_time) { int64_t compare_time = (cmp_time == NULL) ? time(NULL) : *cmp_time; return X509_cmp_time_posix(ctm, compare_time); } @@ -1794,12 +1793,12 @@ ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long offset_sec) { return X509_time_adj(s, offset_sec, NULL); } -ASN1_TIME *X509_time_adj(ASN1_TIME *s, long offset_sec, time_t *in_tm) { +ASN1_TIME *X509_time_adj(ASN1_TIME *s, long offset_sec, const time_t *in_tm) { return X509_time_adj_ex(s, 0, offset_sec, in_tm); } ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s, int offset_day, long offset_sec, - time_t *in_tm) { + const time_t *in_tm) { int64_t t = 0; if (in_tm) { diff --git a/Sources/CCryptoBoringSSL/crypto/x509/x509name.c b/Sources/CCryptoBoringSSL/crypto/x509/x509name.c index 20924791..5beca8e5 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/x509name.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/x509name.c @@ -99,7 +99,7 @@ int X509_NAME_entry_count(const X509_NAME *name) { if (name == NULL) { return 0; } - return (sk_X509_NAME_ENTRY_num(name->entries)); + return (int)sk_X509_NAME_ENTRY_num(name->entries); } int X509_NAME_get_index_by_NID(const X509_NAME *name, int nid, int lastpos) { @@ -109,26 +109,22 @@ int X509_NAME_get_index_by_NID(const X509_NAME *name, int nid, int lastpos) { if (obj == NULL) { return -2; } - return (X509_NAME_get_index_by_OBJ(name, obj, lastpos)); + return X509_NAME_get_index_by_OBJ(name, obj, lastpos); } // NOTE: you should be passsing -1, not 0 as lastpos int X509_NAME_get_index_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj, int lastpos) { - int n; - X509_NAME_ENTRY *ne; - STACK_OF(X509_NAME_ENTRY) *sk; - if (name == NULL) { return -1; } if (lastpos < 0) { lastpos = -1; } - sk = name->entries; - n = sk_X509_NAME_ENTRY_num(sk); + const STACK_OF(X509_NAME_ENTRY) *sk = name->entries; + int n = (int)sk_X509_NAME_ENTRY_num(sk); for (lastpos++; lastpos < n; lastpos++) { - ne = sk_X509_NAME_ENTRY_value(sk, lastpos); + const X509_NAME_ENTRY *ne = sk_X509_NAME_ENTRY_value(sk, lastpos); if (OBJ_cmp(ne->object, obj) == 0) { return lastpos; } @@ -153,9 +149,9 @@ X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc) { STACK_OF(X509_NAME_ENTRY) *sk = name->entries; X509_NAME_ENTRY *ret = sk_X509_NAME_ENTRY_delete(sk, loc); - int n = sk_X509_NAME_ENTRY_num(sk); + size_t n = sk_X509_NAME_ENTRY_num(sk); name->modified = 1; - if (loc == n) { + if ((size_t)loc == n) { return ret; } @@ -170,7 +166,7 @@ X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc) { // If we removed a singleton RDN, update the RDN indices so they are // consecutive again. if (set_prev + 1 < set_next) { - for (int i = loc; i < n; i++) { + for (size_t i = loc; i < n; i++) { sk_X509_NAME_ENTRY_value(sk, i)->set--; } } @@ -178,8 +174,8 @@ X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc) { } int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, - int type, const unsigned char *bytes, int len, - int loc, int set) { + int type, const unsigned char *bytes, + ossl_ssize_t len, int loc, int set) { X509_NAME_ENTRY *ne = X509_NAME_ENTRY_create_by_OBJ(NULL, obj, type, bytes, len); if (!ne) { @@ -191,8 +187,8 @@ int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, } int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, - const unsigned char *bytes, int len, int loc, - int set) { + const unsigned char *bytes, ossl_ssize_t len, + int loc, int set) { X509_NAME_ENTRY *ne = X509_NAME_ENTRY_create_by_NID(NULL, nid, type, bytes, len); if (!ne) { @@ -204,8 +200,8 @@ int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, } int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, - const unsigned char *bytes, int len, int loc, - int set) { + const unsigned char *bytes, ossl_ssize_t len, + int loc, int set) { X509_NAME_ENTRY *ne = X509_NAME_ENTRY_create_by_txt(NULL, field, type, bytes, len); if (!ne) { @@ -221,14 +217,14 @@ int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *entry, int loc, int set) { X509_NAME_ENTRY *new_name = NULL; - int n, i, inc; + int i, inc; STACK_OF(X509_NAME_ENTRY) *sk; if (name == NULL) { return 0; } sk = name->entries; - n = sk_X509_NAME_ENTRY_num(sk); + int n = (int)sk_X509_NAME_ENTRY_num(sk); if (loc > n) { loc = n; } else if (loc < 0) { @@ -266,7 +262,7 @@ int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *entry, int loc, goto err; } if (inc) { - n = sk_X509_NAME_ENTRY_num(sk); + n = (int)sk_X509_NAME_ENTRY_num(sk); for (i = loc + 1; i < n; i++) { sk_X509_NAME_ENTRY_value(sk, i)->set += 1; } @@ -282,7 +278,7 @@ err: X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, const char *field, int type, const unsigned char *bytes, - int len) { + ossl_ssize_t len) { ASN1_OBJECT *obj; X509_NAME_ENTRY *nentry; @@ -300,7 +296,7 @@ X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, int type, const unsigned char *bytes, - int len) { + ossl_ssize_t len) { const ASN1_OBJECT *obj = OBJ_nid2obj(nid); if (obj == NULL) { OPENSSL_PUT_ERROR(X509, X509_R_UNKNOWN_NID); @@ -312,7 +308,7 @@ X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, const ASN1_OBJECT *obj, int type, const unsigned char *bytes, - int len) { + ossl_ssize_t len) { X509_NAME_ENTRY *ret; if ((ne == NULL) || (*ne == NULL)) { @@ -352,9 +348,7 @@ int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj) { } int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, - const unsigned char *bytes, int len) { - int i; - + const unsigned char *bytes, ossl_ssize_t len) { if ((ne == NULL) || ((bytes == NULL) && (len != 0))) { return 0; } @@ -367,8 +361,7 @@ int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, if (len < 0) { len = strlen((const char *)bytes); } - i = ASN1_STRING_set(ne->value, bytes, len); - if (!i) { + if (!ASN1_STRING_set(ne->value, bytes, len)) { return 0; } if (type != V_ASN1_UNDEF) { diff --git a/Sources/CCryptoBoringSSL/crypto/x509/x_crl.c b/Sources/CCryptoBoringSSL/crypto/x509/x_crl.c index 049c750f..4c160f32 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/x_crl.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/x_crl.c @@ -430,7 +430,7 @@ static int crl_revoked_issuer_match(X509_CRL *crl, X509_NAME *nm, return 0; } -static struct CRYPTO_STATIC_MUTEX g_crl_sort_lock = CRYPTO_STATIC_MUTEX_INIT; +static CRYPTO_MUTEX g_crl_sort_lock = CRYPTO_MUTEX_INIT; static int crl_lookup(X509_CRL *crl, X509_REVOKED **ret, ASN1_INTEGER *serial, X509_NAME *issuer) { @@ -443,16 +443,16 @@ static int crl_lookup(X509_CRL *crl, X509_REVOKED **ret, ASN1_INTEGER *serial, // Sort revoked into serial number order if not already sorted. Do this // under a lock to avoid race condition. - CRYPTO_STATIC_MUTEX_lock_read(&g_crl_sort_lock); + CRYPTO_MUTEX_lock_read(&g_crl_sort_lock); const int is_sorted = sk_X509_REVOKED_is_sorted(crl->crl->revoked); - CRYPTO_STATIC_MUTEX_unlock_read(&g_crl_sort_lock); + CRYPTO_MUTEX_unlock_read(&g_crl_sort_lock); if (!is_sorted) { - CRYPTO_STATIC_MUTEX_lock_write(&g_crl_sort_lock); + CRYPTO_MUTEX_lock_write(&g_crl_sort_lock); if (!sk_X509_REVOKED_is_sorted(crl->crl->revoked)) { sk_X509_REVOKED_sort(crl->crl->revoked); } - CRYPTO_STATIC_MUTEX_unlock_write(&g_crl_sort_lock); + CRYPTO_MUTEX_unlock_write(&g_crl_sort_lock); } if (!sk_X509_REVOKED_find(crl->crl->revoked, &idx, &rtmp)) { diff --git a/Sources/CCryptoBoringSSL/crypto/x509/x_name.c b/Sources/CCryptoBoringSSL/crypto/x509/x_name.c index a1d874b0..9b30b43e 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/x_name.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/x_name.c @@ -230,7 +230,7 @@ static int x509_name_ex_d2i(ASN1_VALUE **val, const unsigned char **in, entries = sk_STACK_OF_X509_NAME_ENTRY_value(intname, i); for (j = 0; j < sk_X509_NAME_ENTRY_num(entries); j++) { entry = sk_X509_NAME_ENTRY_value(entries, j); - entry->set = i; + entry->set = (int)i; if (!sk_X509_NAME_ENTRY_push(nm->entries, entry)) { goto err; } diff --git a/Sources/CCryptoBoringSSL/crypto/x509/x_pubkey.c b/Sources/CCryptoBoringSSL/crypto/x509/x_pubkey.c index c05a89f7..9a97587a 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509/x_pubkey.c +++ b/Sources/CCryptoBoringSSL/crypto/x509/x_pubkey.c @@ -128,7 +128,7 @@ error: // |X509_PUBKEY| objects. Really |X509_PUBKEY| should have a |CRYPTO_once_t| // inside it for this, but |CRYPTO_once_t| is private and |X509_PUBKEY| is // not. -static struct CRYPTO_STATIC_MUTEX g_pubkey_lock = CRYPTO_STATIC_MUTEX_INIT; +static CRYPTO_MUTEX g_pubkey_lock = CRYPTO_MUTEX_INIT; EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key) { EVP_PKEY *ret = NULL; @@ -138,13 +138,13 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key) { goto error; } - CRYPTO_STATIC_MUTEX_lock_read(&g_pubkey_lock); + CRYPTO_MUTEX_lock_read(&g_pubkey_lock); if (key->pkey != NULL) { - CRYPTO_STATIC_MUTEX_unlock_read(&g_pubkey_lock); + CRYPTO_MUTEX_unlock_read(&g_pubkey_lock); EVP_PKEY_up_ref(key->pkey); return key->pkey; } - CRYPTO_STATIC_MUTEX_unlock_read(&g_pubkey_lock); + CRYPTO_MUTEX_unlock_read(&g_pubkey_lock); // Re-encode the |X509_PUBKEY| to DER and parse it. int spki_len = i2d_X509_PUBKEY(key, &spki); @@ -160,14 +160,14 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key) { } // Check to see if another thread set key->pkey first - CRYPTO_STATIC_MUTEX_lock_write(&g_pubkey_lock); + CRYPTO_MUTEX_lock_write(&g_pubkey_lock); if (key->pkey) { - CRYPTO_STATIC_MUTEX_unlock_write(&g_pubkey_lock); + CRYPTO_MUTEX_unlock_write(&g_pubkey_lock); EVP_PKEY_free(ret); ret = key->pkey; } else { key->pkey = ret; - CRYPTO_STATIC_MUTEX_unlock_write(&g_pubkey_lock); + CRYPTO_MUTEX_unlock_write(&g_pubkey_lock); } OPENSSL_free(spki); diff --git a/Sources/CCryptoBoringSSL/crypto/x509v3/v3_alt.c b/Sources/CCryptoBoringSSL/crypto/x509v3/v3_alt.c index 930e1534..582cbf97 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509v3/v3_alt.c +++ b/Sources/CCryptoBoringSSL/crypto/x509v3/v3_alt.c @@ -173,13 +173,12 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(const X509V3_EXT_METHOD *method, case GEN_IPADD: p = gen->d.ip->data; if (gen->d.ip->length == 4) { - BIO_snprintf(oline, sizeof(oline), "%d.%d.%d.%d", p[0], p[1], p[2], - p[3]); + snprintf(oline, sizeof(oline), "%d.%d.%d.%d", p[0], p[1], p[2], p[3]); } else if (gen->d.ip->length == 16) { oline[0] = 0; for (i = 0; i < 8; i++) { uint16_t v = ((uint16_t)p[0] << 8) | p[1]; - BIO_snprintf(htmp, sizeof(htmp), "%X", v); + snprintf(htmp, sizeof(htmp), "%X", v); p += 2; OPENSSL_strlcat(oline, htmp, sizeof(oline)); if (i != 7) { diff --git a/Sources/CCryptoBoringSSL/crypto/x509v3/v3_conf.c b/Sources/CCryptoBoringSSL/crypto/x509v3/v3_conf.c index 3b78794d..799d3ca6 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509v3/v3_conf.c +++ b/Sources/CCryptoBoringSSL/crypto/x509v3/v3_conf.c @@ -192,35 +192,17 @@ static X509_EXTENSION *do_ext_nconf(const CONF *conf, const X509V3_CTX *ctx, } ext = do_ext_i2d(method, ext_nid, crit, ext_struc); - if (method->it) { - ASN1_item_free(ext_struc, ASN1_ITEM_ptr(method->it)); - } else { - method->ext_free(ext_struc); - } + ASN1_item_free(ext_struc, ASN1_ITEM_ptr(method->it)); return ext; } static X509_EXTENSION *do_ext_i2d(const X509V3_EXT_METHOD *method, int ext_nid, int crit, void *ext_struc) { // Convert the extension's internal representation to DER. - unsigned char *ext_der; - int ext_len; - if (method->it) { - ext_der = NULL; - ext_len = ASN1_item_i2d(ext_struc, &ext_der, ASN1_ITEM_ptr(method->it)); - if (ext_len < 0) { - return NULL; - } - } else { - // TODO(davidben): Remove support for the "old-style" ASN.1 callbacks. Every - // |X509V3_EXT_METHOD|, both inside and outside the library, has an - // |ASN1_ITEM|, and this codepath is missing handling. - ext_len = method->i2d(ext_struc, NULL); - if (!(ext_der = OPENSSL_malloc(ext_len))) { - return NULL; - } - unsigned char *p = ext_der; - method->i2d(ext_struc, &p); + unsigned char *ext_der = NULL; + int ext_len = ASN1_item_i2d(ext_struc, &ext_der, ASN1_ITEM_ptr(method->it)); + if (ext_len < 0) { + return NULL; } ASN1_OCTET_STRING *ext_oct = ASN1_OCTET_STRING_new(); diff --git a/Sources/CCryptoBoringSSL/crypto/x509v3/v3_lib.c b/Sources/CCryptoBoringSSL/crypto/x509v3/v3_lib.c index 6d5fdeb8..160026f6 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509v3/v3_lib.c +++ b/Sources/CCryptoBoringSSL/crypto/x509v3/v3_lib.c @@ -57,6 +57,7 @@ */ /* X509 v3 extension utilities */ +#include #include #include @@ -70,21 +71,20 @@ #include "ext_dat.h" static STACK_OF(X509V3_EXT_METHOD) *ext_list = NULL; -static void ext_list_free(X509V3_EXT_METHOD *ext); - static int ext_stack_cmp(const X509V3_EXT_METHOD *const *a, const X509V3_EXT_METHOD *const *b) { return ((*a)->ext_nid - (*b)->ext_nid); } int X509V3_EXT_add(X509V3_EXT_METHOD *ext) { + // We only support |ASN1_ITEM|-based extensions. + assert(ext->it != NULL); + // TODO(davidben): This should be locked. Also check for duplicates. if (!ext_list && !(ext_list = sk_X509V3_EXT_METHOD_new(ext_stack_cmp))) { - ext_list_free(ext); return 0; } if (!sk_X509V3_EXT_METHOD_push(ext_list, ext)) { - ext_list_free(ext); return 0; } sk_X509V3_EXT_METHOD_sort(ext_list); @@ -136,28 +136,12 @@ int X509V3_EXT_free(int nid, void *ext_data) { return 0; } - if (ext_method->it != NULL) { - ASN1_item_free(ext_data, ASN1_ITEM_ptr(ext_method->it)); - } else if (ext_method->ext_free != NULL) { - ext_method->ext_free(ext_data); - } else { - OPENSSL_PUT_ERROR(X509V3, X509V3_R_CANNOT_FIND_FREE_FUNCTION); - return 0; - } - - return 1; -} - -int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist) { - for (; extlist->ext_nid != -1; extlist++) { - if (!X509V3_EXT_add(extlist)) { - return 0; - } - } + ASN1_item_free(ext_data, ASN1_ITEM_ptr(ext_method->it)); return 1; } int X509V3_EXT_add_alias(int nid_to, int nid_from) { +OPENSSL_BEGIN_ALLOW_DEPRECATED const X509V3_EXT_METHOD *ext; X509V3_EXT_METHOD *tmpext; @@ -171,19 +155,12 @@ int X509V3_EXT_add_alias(int nid_to, int nid_from) { } *tmpext = *ext; tmpext->ext_nid = nid_to; - tmpext->ext_flags |= X509V3_EXT_DYNAMIC; - return X509V3_EXT_add(tmpext); -} - -void X509V3_EXT_cleanup(void) { - sk_X509V3_EXT_METHOD_pop_free(ext_list, ext_list_free); - ext_list = NULL; -} - -static void ext_list_free(X509V3_EXT_METHOD *ext) { - if (ext->ext_flags & X509V3_EXT_DYNAMIC) { - OPENSSL_free(ext); + if (!X509V3_EXT_add(tmpext)) { + OPENSSL_free(tmpext); + return 0; } + return 1; +OPENSSL_END_ALLOW_DEPRECATED } // Legacy function: we don't need to add standard extensions any more because @@ -201,23 +178,14 @@ void *X509V3_EXT_d2i(const X509_EXTENSION *ext) { return NULL; } p = ext->value->data; - void *ret; - if (method->it) { - ret = - ASN1_item_d2i(NULL, &p, ext->value->length, ASN1_ITEM_ptr(method->it)); - } else { - ret = method->d2i(NULL, &p, ext->value->length); - } + void *ret = + ASN1_item_d2i(NULL, &p, ext->value->length, ASN1_ITEM_ptr(method->it)); if (ret == NULL) { return NULL; } // Check for trailing data. if (p != ext->value->data + ext->value->length) { - if (method->it) { - ASN1_item_free(ret, ASN1_ITEM_ptr(method->it)); - } else { - method->ext_free(ret); - } + ASN1_item_free(ret, ASN1_ITEM_ptr(method->it)); OPENSSL_PUT_ERROR(X509V3, X509V3_R_TRAILING_DATA_IN_EXTENSION); return NULL; } @@ -227,7 +195,6 @@ void *X509V3_EXT_d2i(const X509_EXTENSION *ext) { void *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *extensions, int nid, int *out_critical, int *out_idx) { int lastpos; - size_t i; X509_EXTENSION *ex, *found_ex = NULL; if (!extensions) { if (out_idx) { @@ -246,13 +213,13 @@ void *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *extensions, int nid, if (lastpos < 0) { lastpos = 0; } - for (i = lastpos; i < sk_X509_EXTENSION_num(extensions); i++) { + for (size_t i = lastpos; i < sk_X509_EXTENSION_num(extensions); i++) { ex = sk_X509_EXTENSION_value(extensions, i); if (OBJ_obj2nid(ex->object) == nid) { if (out_idx) { // TODO(https://crbug.com/boringssl/379): Consistently reject // duplicate extensions. - *out_idx = i; + *out_idx = (int)i; found_ex = ex; break; } else if (found_ex) { diff --git a/Sources/CCryptoBoringSSL/crypto/x509v3/v3_prn.c b/Sources/CCryptoBoringSSL/crypto/x509v3/v3_prn.c index f0afc692..170ac55e 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509v3/v3_prn.c +++ b/Sources/CCryptoBoringSSL/crypto/x509v3/v3_prn.c @@ -105,59 +105,47 @@ void X509V3_EXT_val_prn(BIO *out, const STACK_OF(CONF_VALUE) *val, int indent, int X509V3_EXT_print(BIO *out, const X509_EXTENSION *ext, unsigned long flag, int indent) { - void *ext_str = NULL; - char *value = NULL; - const X509V3_EXT_METHOD *method; - STACK_OF(CONF_VALUE) *nval = NULL; - int ok = 1; - - if (!(method = X509V3_EXT_get(ext))) { + const X509V3_EXT_METHOD *method = X509V3_EXT_get(ext); + if (method == NULL) { return unknown_ext_print(out, ext, flag, indent, 0); } const ASN1_STRING *ext_data = X509_EXTENSION_get_data(ext); const unsigned char *p = ASN1_STRING_get0_data(ext_data); - if (method->it) { - ext_str = ASN1_item_d2i(NULL, &p, ASN1_STRING_length(ext_data), - ASN1_ITEM_ptr(method->it)); - } else { - ext_str = method->d2i(NULL, &p, ASN1_STRING_length(ext_data)); - } - + void *ext_str = ASN1_item_d2i(NULL, &p, ASN1_STRING_length(ext_data), + ASN1_ITEM_ptr(method->it)); if (!ext_str) { return unknown_ext_print(out, ext, flag, indent, 1); } + char *value = NULL; + STACK_OF(CONF_VALUE) *nval = NULL; + int ok = 0; if (method->i2s) { if (!(value = method->i2s(method, ext_str))) { - ok = 0; goto err; } BIO_printf(out, "%*s%s", indent, "", value); } else if (method->i2v) { if (!(nval = method->i2v(method, ext_str, NULL))) { - ok = 0; goto err; } X509V3_EXT_val_prn(out, nval, indent, method->ext_flags & X509V3_EXT_MULTILINE); } else if (method->i2r) { if (!method->i2r(method, ext_str, out, indent)) { - ok = 0; + goto err; } } else { - ok = 0; + OPENSSL_PUT_ERROR(X509V3, X509V3_R_OPERATION_NOT_DEFINED); + goto err; } + ok = 1; + err: sk_CONF_VALUE_pop_free(nval, X509V3_conf_free); - if (value) { - OPENSSL_free(value); - } - if (method->it) { - ASN1_item_free(ext_str, ASN1_ITEM_ptr(method->it)); - } else { - method->ext_free(ext_str); - } + OPENSSL_free(value); + ASN1_item_free(ext_str, ASN1_ITEM_ptr(method->it)); return ok; } diff --git a/Sources/CCryptoBoringSSL/crypto/x509v3/v3_purp.c b/Sources/CCryptoBoringSSL/crypto/x509v3/v3_purp.c index 7feeb67f..ce95d076 100644 --- a/Sources/CCryptoBoringSSL/crypto/x509v3/v3_purp.c +++ b/Sources/CCryptoBoringSSL/crypto/x509v3/v3_purp.c @@ -177,10 +177,9 @@ X509_PURPOSE *X509_PURPOSE_get0(int idx) { return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT); } -int X509_PURPOSE_get_by_sname(char *sname) { - int i; +int X509_PURPOSE_get_by_sname(const char *sname) { X509_PURPOSE *xptmp; - for (i = 0; i < X509_PURPOSE_get_count(); i++) { + for (int i = 0; i < X509_PURPOSE_get_count(); i++) { xptmp = X509_PURPOSE_get0(i); if (!strcmp(xptmp->sname, sname)) { return i; @@ -209,8 +208,7 @@ int X509_PURPOSE_get_by_id(int purpose) { int X509_PURPOSE_add(int id, int trust, int flags, int (*ck)(const X509_PURPOSE *, const X509 *, int), - char *name, char *sname, void *arg) { - int idx; + const char *name, const char *sname, void *arg) { X509_PURPOSE *ptmp; char *name_dup, *sname_dup; @@ -219,7 +217,7 @@ int X509_PURPOSE_add(int id, int trust, int flags, // This will always be set for application modified trust entries flags |= X509_PURPOSE_DYNAMIC_NAME; // Get existing entry if any - idx = X509_PURPOSE_get_by_id(id); + int idx = X509_PURPOSE_get_by_id(id); // Need a new entry if (idx == -1) { if (!(ptmp = OPENSSL_malloc(sizeof(X509_PURPOSE)))) { diff --git a/Sources/CCryptoBoringSSL/hash.txt b/Sources/CCryptoBoringSSL/hash.txt index 9766498e..f3dfc4a2 100644 --- a/Sources/CCryptoBoringSSL/hash.txt +++ b/Sources/CCryptoBoringSSL/hash.txt @@ -1 +1 @@ -This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision abfd5ebc87ddca0fab9fca067c9d7edbc355eae8 +This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 7ae2b910c13017b63f1a8bd6c8decfce692869b0 diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_aead.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_aead.h index c29f6d0b..5ae9a4dd 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_aead.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_aead.h @@ -138,12 +138,10 @@ OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_128_ctr_hmac_sha256(void); // authentication. See |EVP_aead_aes_128_ctr_hmac_sha256| for details. OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_256_ctr_hmac_sha256(void); -// EVP_aead_aes_128_gcm_siv is AES-128 in GCM-SIV mode. See -// https://tools.ietf.org/html/draft-irtf-cfrg-gcmsiv-02 +// EVP_aead_aes_128_gcm_siv is AES-128 in GCM-SIV mode. See RFC 8452. OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_128_gcm_siv(void); -// EVP_aead_aes_256_gcm_siv is AES-256 in GCM-SIV mode. See -// https://tools.ietf.org/html/draft-irtf-cfrg-gcmsiv-02 +// EVP_aead_aes_256_gcm_siv is AES-256 in GCM-SIV mode. See RFC 8452. OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_256_gcm_siv(void); // EVP_aead_aes_128_gcm_randnonce is AES-128 in Galois Counter Mode with @@ -212,7 +210,7 @@ OPENSSL_EXPORT size_t EVP_AEAD_max_tag_len(const EVP_AEAD *aead); // AEAD operations. union evp_aead_ctx_st_state { - uint8_t opaque[580]; + uint8_t opaque[564]; uint64_t alignment; }; @@ -402,14 +400,14 @@ OPENSSL_EXPORT const EVP_AEAD *EVP_AEAD_CTX_aead(const EVP_AEAD_CTX *ctx); OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_128_cbc_sha1_tls(void); OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_128_cbc_sha1_tls_implicit_iv(void); +OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_128_cbc_sha256_tls(void); + OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_256_cbc_sha1_tls(void); OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_256_cbc_sha1_tls_implicit_iv(void); OPENSSL_EXPORT const EVP_AEAD *EVP_aead_des_ede3_cbc_sha1_tls(void); OPENSSL_EXPORT const EVP_AEAD *EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv(void); -OPENSSL_EXPORT const EVP_AEAD *EVP_aead_null_sha1_tls(void); - // EVP_aead_aes_128_gcm_tls12 is AES-128 in Galois Counter Mode using the TLS // 1.2 nonce construction. OPENSSL_EXPORT const EVP_AEAD *EVP_aead_aes_128_gcm_tls12(void); diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_arm_arch.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_arm_arch.h index 7215f62e..016c9d32 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_arm_arch.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_arm_arch.h @@ -53,12 +53,13 @@ #ifndef OPENSSL_HEADER_ARM_ARCH_H #define OPENSSL_HEADER_ARM_ARCH_H +#include "CCryptoBoringSSL_target.h" + // arm_arch.h contains symbols used by ARM assembly, and the C code that calls // it. It is included as a public header to simplify the build, but is not // intended for external use. -#if defined(__ARMEL__) || defined(_M_ARM) || defined(__AARCH64EL__) || \ - defined(_M_ARM64) +#if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64) // ARMV7_NEON is true when a NEON unit is present in the current CPU. #define ARMV7_NEON (1 << 0) @@ -97,124 +98,8 @@ // will be included. #define __ARM_MAX_ARCH__ 8 -// Support macros for -// - Armv8.3-A Pointer Authentication and -// - Armv8.5-A Branch Target Identification -// features which require emitting a .note.gnu.property section with the -// appropriate architecture-dependent feature bits set. -// -// |AARCH64_SIGN_LINK_REGISTER| and |AARCH64_VALIDATE_LINK_REGISTER| expand to -// PACIxSP and AUTIxSP, respectively. |AARCH64_SIGN_LINK_REGISTER| should be -// used immediately before saving the LR register (x30) to the stack. -// |AARCH64_VALIDATE_LINK_REGISTER| should be used immediately after restoring -// it. Note |AARCH64_SIGN_LINK_REGISTER|'s modifications to LR must be undone -// with |AARCH64_VALIDATE_LINK_REGISTER| before RET. The SP register must also -// have the same value at the two points. For example: -// -// .global f -// f: -// AARCH64_SIGN_LINK_REGISTER -// stp x29, x30, [sp, #-96]! -// mov x29, sp -// ... -// ldp x29, x30, [sp], #96 -// AARCH64_VALIDATE_LINK_REGISTER -// ret -// -// |AARCH64_VALID_CALL_TARGET| expands to BTI 'c'. Either it, or -// |AARCH64_SIGN_LINK_REGISTER|, must be used at every point that may be an -// indirect call target. In particular, all symbols exported from a file must -// begin with one of these macros. For example, a leaf function that does not -// save LR can instead use |AARCH64_VALID_CALL_TARGET|: -// -// .globl return_zero -// return_zero: -// AARCH64_VALID_CALL_TARGET -// mov x0, #0 -// ret -// -// A non-leaf function which does not immediately save LR may need both macros -// because |AARCH64_SIGN_LINK_REGISTER| appears late. For example, the function -// may jump to an alternate implementation before setting up the stack: -// -// .globl with_early_jump -// with_early_jump: -// AARCH64_VALID_CALL_TARGET -// cmp x0, #128 -// b.lt .Lwith_early_jump_128 -// AARCH64_SIGN_LINK_REGISTER -// stp x29, x30, [sp, #-96]! -// mov x29, sp -// ... -// ldp x29, x30, [sp], #96 -// AARCH64_VALIDATE_LINK_REGISTER -// ret -// -// .Lwith_early_jump_128: -// ... -// ret -// -// These annotations are only required with indirect calls. Private symbols that -// are only the target of direct calls do not require annotations. Also note -// that |AARCH64_VALID_CALL_TARGET| is only valid for indirect calls (BLR), not -// indirect jumps (BR). Indirect jumps in assembly are currently not supported -// and would require a macro for BTI 'j'. -// -// Although not necessary, it is safe to use these macros in 32-bit ARM -// assembly. This may be used to simplify dual 32-bit and 64-bit files. -// -// References: -// - "ELF for the Arm® 64-bit Architecture" -// https://github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst -// - "Providing protection for complex software" -// https://developer.arm.com/architectures/learn-the-architecture/providing-protection-for-complex-software - -#if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1 -#define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has Branch Target Identification -#define AARCH64_VALID_CALL_TARGET hint #34 // BTI 'c' -#else -#define GNU_PROPERTY_AARCH64_BTI 0 // No Branch Target Identification -#define AARCH64_VALID_CALL_TARGET -#endif - -#if defined(__ARM_FEATURE_PAC_DEFAULT) && \ - (__ARM_FEATURE_PAC_DEFAULT & 1) == 1 // Signed with A-key -#define GNU_PROPERTY_AARCH64_POINTER_AUTH \ - (1 << 1) // Has Pointer Authentication -#define AARCH64_SIGN_LINK_REGISTER hint #25 // PACIASP -#define AARCH64_VALIDATE_LINK_REGISTER hint #29 // AUTIASP -#elif defined(__ARM_FEATURE_PAC_DEFAULT) && \ - (__ARM_FEATURE_PAC_DEFAULT & 2) == 2 // Signed with B-key -#define GNU_PROPERTY_AARCH64_POINTER_AUTH \ - (1 << 1) // Has Pointer Authentication -#define AARCH64_SIGN_LINK_REGISTER hint #27 // PACIBSP -#define AARCH64_VALIDATE_LINK_REGISTER hint #31 // AUTIBSP -#else -#define GNU_PROPERTY_AARCH64_POINTER_AUTH 0 // No Pointer Authentication -#if GNU_PROPERTY_AARCH64_BTI != 0 -#define AARCH64_SIGN_LINK_REGISTER AARCH64_VALID_CALL_TARGET -#else -#define AARCH64_SIGN_LINK_REGISTER -#endif -#define AARCH64_VALIDATE_LINK_REGISTER -#endif - -#if GNU_PROPERTY_AARCH64_POINTER_AUTH != 0 || GNU_PROPERTY_AARCH64_BTI != 0 -.pushsection .note.gnu.property, "a"; -.balign 8; -.long 4; -.long 0x10; -.long 0x5; -.asciz "GNU"; -.long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */ -.long 4; -.long (GNU_PROPERTY_AARCH64_POINTER_AUTH | GNU_PROPERTY_AARCH64_BTI); -.long 0; -.popsection; -#endif - #endif // __ASSEMBLER__ -#endif // __ARMEL__ || _M_ARM || __AARCH64EL__ || _M_ARM64 +#endif // ARM || AARCH64 #endif // OPENSSL_HEADER_ARM_ARCH_H diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_asm_base.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_asm_base.h new file mode 100644 index 00000000..836d127a --- /dev/null +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_asm_base.h @@ -0,0 +1,207 @@ +/* Copyright (c) 2023, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef OPENSSL_HEADER_ASM_BASE_H +#define OPENSSL_HEADER_ASM_BASE_H + +#include "CCryptoBoringSSL_target.h" + + +// This header contains symbols and common sections used by assembly files. It +// is included as a public header to simplify the build, but is not intended for +// external use. +// +// Every assembly file must include this header. Some linker features require +// all object files to be tagged with some section metadata. This header file, +// when included in assembly, adds that metadata. It also makes defines like +// |OPENSSL_X86_64| available and includes the prefixing macros. +// +// Including this header in an assembly file imples: +// +// - The file does not require an executable stack. +// +// - The file, on aarch64, uses the macros defined below to be compatible with +// BTI and PAC. +// +// - The file, on x86_64, requires the program to be compatible with Intel IBT +// and SHSTK + +#if defined(__ASSEMBLER__) + +#if defined(BORINGSSL_PREFIX) +#include "CCryptoBoringSSL_boringssl_prefix_symbols_asm.h" +#endif + +#if defined(__ELF__) +// Every ELF object file, even empty ones, should disable executable stacks. See +// https://www.airs.com/blog/archives/518. +.pushsection .note.GNU-stack, "", %progbits +.popsection +#endif + +#if defined(__CET__) && defined(OPENSSL_X86_64) +// Clang and GCC define __CET__ and provide when they support Intel's +// Indirect Branch Tracking. +// https://lpc.events/event/7/contributions/729/attachments/496/903/CET-LPC-2020.pdf +// +// cet.h defines _CET_ENDBR which is used to mark function entry points for IBT. +// and adds the assembly marker. The value of _CET_ENDBR is made dependant on if +// '-fcf-protection' is passed to the compiler. _CET_ENDBR is only required when +// the function is the target of an indirect jump, but BoringSSL chooses to mark +// all assembly entry points because it is easier, and allows BoringSSL's ABI +// tester to call the assembly entry points via an indirect jump. +#include +#else +#define _CET_ENDBR +#endif + +#if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64) + +// We require the ARM assembler provide |__ARM_ARCH| from Arm C Language +// Extensions (ACLE). This is supported in GCC 4.8+ and Clang 3.2+. MSVC does +// not implement ACLE, but we require Clang's assembler on Windows. +#if !defined(__ARM_ARCH) +#error "ARM assembler must define __ARM_ARCH" +#endif + +// __ARM_ARCH__ is used by OpenSSL assembly to determine the minimum target ARM +// version. +// +// TODO(davidben): Switch the assembly to use |__ARM_ARCH| directly. +#define __ARM_ARCH__ __ARM_ARCH + +// Even when building for 32-bit ARM, support for aarch64 crypto instructions +// will be included. +#define __ARM_MAX_ARCH__ 8 + +// Support macros for +// - Armv8.3-A Pointer Authentication and +// - Armv8.5-A Branch Target Identification +// features which require emitting a .note.gnu.property section with the +// appropriate architecture-dependent feature bits set. +// +// |AARCH64_SIGN_LINK_REGISTER| and |AARCH64_VALIDATE_LINK_REGISTER| expand to +// PACIxSP and AUTIxSP, respectively. |AARCH64_SIGN_LINK_REGISTER| should be +// used immediately before saving the LR register (x30) to the stack. +// |AARCH64_VALIDATE_LINK_REGISTER| should be used immediately after restoring +// it. Note |AARCH64_SIGN_LINK_REGISTER|'s modifications to LR must be undone +// with |AARCH64_VALIDATE_LINK_REGISTER| before RET. The SP register must also +// have the same value at the two points. For example: +// +// .global f +// f: +// AARCH64_SIGN_LINK_REGISTER +// stp x29, x30, [sp, #-96]! +// mov x29, sp +// ... +// ldp x29, x30, [sp], #96 +// AARCH64_VALIDATE_LINK_REGISTER +// ret +// +// |AARCH64_VALID_CALL_TARGET| expands to BTI 'c'. Either it, or +// |AARCH64_SIGN_LINK_REGISTER|, must be used at every point that may be an +// indirect call target. In particular, all symbols exported from a file must +// begin with one of these macros. For example, a leaf function that does not +// save LR can instead use |AARCH64_VALID_CALL_TARGET|: +// +// .globl return_zero +// return_zero: +// AARCH64_VALID_CALL_TARGET +// mov x0, #0 +// ret +// +// A non-leaf function which does not immediately save LR may need both macros +// because |AARCH64_SIGN_LINK_REGISTER| appears late. For example, the function +// may jump to an alternate implementation before setting up the stack: +// +// .globl with_early_jump +// with_early_jump: +// AARCH64_VALID_CALL_TARGET +// cmp x0, #128 +// b.lt .Lwith_early_jump_128 +// AARCH64_SIGN_LINK_REGISTER +// stp x29, x30, [sp, #-96]! +// mov x29, sp +// ... +// ldp x29, x30, [sp], #96 +// AARCH64_VALIDATE_LINK_REGISTER +// ret +// +// .Lwith_early_jump_128: +// ... +// ret +// +// These annotations are only required with indirect calls. Private symbols that +// are only the target of direct calls do not require annotations. Also note +// that |AARCH64_VALID_CALL_TARGET| is only valid for indirect calls (BLR), not +// indirect jumps (BR). Indirect jumps in assembly are currently not supported +// and would require a macro for BTI 'j'. +// +// Although not necessary, it is safe to use these macros in 32-bit ARM +// assembly. This may be used to simplify dual 32-bit and 64-bit files. +// +// References: +// - "ELF for the Arm® 64-bit Architecture" +// https://github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst +// - "Providing protection for complex software" +// https://developer.arm.com/architectures/learn-the-architecture/providing-protection-for-complex-software + +#if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1 +#define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has Branch Target Identification +#define AARCH64_VALID_CALL_TARGET hint #34 // BTI 'c' +#else +#define GNU_PROPERTY_AARCH64_BTI 0 // No Branch Target Identification +#define AARCH64_VALID_CALL_TARGET +#endif + +#if defined(__ARM_FEATURE_PAC_DEFAULT) && \ + (__ARM_FEATURE_PAC_DEFAULT & 1) == 1 // Signed with A-key +#define GNU_PROPERTY_AARCH64_POINTER_AUTH \ + (1 << 1) // Has Pointer Authentication +#define AARCH64_SIGN_LINK_REGISTER hint #25 // PACIASP +#define AARCH64_VALIDATE_LINK_REGISTER hint #29 // AUTIASP +#elif defined(__ARM_FEATURE_PAC_DEFAULT) && \ + (__ARM_FEATURE_PAC_DEFAULT & 2) == 2 // Signed with B-key +#define GNU_PROPERTY_AARCH64_POINTER_AUTH \ + (1 << 1) // Has Pointer Authentication +#define AARCH64_SIGN_LINK_REGISTER hint #27 // PACIBSP +#define AARCH64_VALIDATE_LINK_REGISTER hint #31 // AUTIBSP +#else +#define GNU_PROPERTY_AARCH64_POINTER_AUTH 0 // No Pointer Authentication +#if GNU_PROPERTY_AARCH64_BTI != 0 +#define AARCH64_SIGN_LINK_REGISTER AARCH64_VALID_CALL_TARGET +#else +#define AARCH64_SIGN_LINK_REGISTER +#endif +#define AARCH64_VALIDATE_LINK_REGISTER +#endif + +#if GNU_PROPERTY_AARCH64_POINTER_AUTH != 0 || GNU_PROPERTY_AARCH64_BTI != 0 +.pushsection .note.gnu.property, "a"; +.balign 8; +.long 4; +.long 0x10; +.long 0x5; +.asciz "GNU"; +.long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */ +.long 4; +.long (GNU_PROPERTY_AARCH64_POINTER_AUTH | GNU_PROPERTY_AARCH64_BTI); +.long 0; +.popsection; +#endif +#endif // ARM || AARCH64 + +#endif // __ASSEMBLER__ + +#endif // OPENSSL_HEADER_ASM_BASE_H diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_asn1.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_asn1.h index 3aaed9d4..8a7517e7 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_asn1.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_asn1.h @@ -740,15 +740,17 @@ OPENSSL_EXPORT int ASN1_STRING_to_UTF8(unsigned char **out, // the result. If |out| is NULL, it returns the selected output type without // constructing an |ASN1_STRING|. On error, this function returns -1. OPENSSL_EXPORT int ASN1_mbstring_copy(ASN1_STRING **out, const uint8_t *in, - int len, int inform, unsigned long mask); + ossl_ssize_t len, int inform, + unsigned long mask); // ASN1_mbstring_ncopy behaves like |ASN1_mbstring_copy| but returns an error if // the input is less than |minsize| or greater than |maxsize| codepoints long. A // |maxsize| value of zero is ignored. Note the sizes are measured in // codepoints, not output bytes. OPENSSL_EXPORT int ASN1_mbstring_ncopy(ASN1_STRING **out, const uint8_t *in, - int len, int inform, unsigned long mask, - long minsize, long maxsize); + ossl_ssize_t len, int inform, + unsigned long mask, ossl_ssize_t minsize, + ossl_ssize_t maxsize); // ASN1_STRING_set_by_NID behaves like |ASN1_mbstring_ncopy|, but determines // |mask|, |minsize|, and |maxsize| based on |nid|. When |nid| is a recognized @@ -774,7 +776,7 @@ OPENSSL_EXPORT int ASN1_mbstring_ncopy(ASN1_STRING **out, const uint8_t *in, // to call |ASN1_mbstring_ncopy| directly instead. OPENSSL_EXPORT ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, const unsigned char *in, - int len, int inform, + ossl_ssize_t len, int inform, int nid); // STABLE_NO_MASK causes |ASN1_STRING_TABLE_add| to allow types other than @@ -1353,6 +1355,11 @@ OPENSSL_EXPORT ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime( // GeneralizedTime. If |str| is neither, it returns zero. OPENSSL_EXPORT int ASN1_TIME_set_string(ASN1_TIME *s, const char *str); +// ASN1_TIME_set_string_X509 behaves like |ASN1_TIME_set_string| except it +// additionally converts GeneralizedTime to UTCTime if it is in the range where +// UTCTime is used. See RFC 5280, section 4.1.2.5. +OPENSSL_EXPORT int ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str); + // ASN1_TIME_to_time_t converts |t| to a time_t value in |out|. On // success, one is returned. On failure zero is returned. This function // will fail if the time can not be represented in a time_t. diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_base.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_base.h index 892d9b81..ad2a2b8d 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_base.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_base.h @@ -82,6 +82,7 @@ // opensslconf.h. #include "CCryptoBoringSSL_is_boringssl.h" #include "CCryptoBoringSSL_opensslconf.h" +#include "CCryptoBoringSSL_target.h" // IWYU pragma: export #if defined(BORINGSSL_PREFIX) #include "CCryptoBoringSSL_boringssl_prefix_symbols.h" @@ -92,48 +93,7 @@ extern "C" { #endif -#if defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) -#define OPENSSL_64_BIT -#define OPENSSL_X86_64 -#elif defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86) -#define OPENSSL_32_BIT -#define OPENSSL_X86 -#elif defined(__AARCH64EL__) || defined(_M_ARM64) -#define OPENSSL_64_BIT -#define OPENSSL_AARCH64 -#elif defined(__ARMEL__) || defined(_M_ARM) -#define OPENSSL_32_BIT -#define OPENSSL_ARM -#elif defined(__MIPSEL__) && !defined(__LP64__) -#define OPENSSL_32_BIT -#define OPENSSL_MIPS -#elif defined(__MIPSEL__) && defined(__LP64__) -#define OPENSSL_64_BIT -#define OPENSSL_MIPS64 -#elif defined(__riscv) && __SIZEOF_POINTER__ == 8 -#define OPENSSL_64_BIT -#define OPENSSL_RISCV64 -#elif defined(__riscv) && __SIZEOF_POINTER__ == 4 -#define OPENSSL_32_BIT -#elif defined(__pnacl__) -#define OPENSSL_32_BIT -#define OPENSSL_PNACL -#elif defined(__wasm__) -#define OPENSSL_32_BIT -#elif defined(__asmjs__) -#define OPENSSL_32_BIT -#elif defined(__myriad2__) -#define OPENSSL_32_BIT -#else -// Note BoringSSL only supports standard 32-bit and 64-bit two's-complement, -// little-endian architectures. Functions will not produce the correct answer -// on other systems. Run the crypto_test binary, notably -// crypto/compiler_test.cc, before adding a new architecture. -#error "Unknown target CPU" -#endif - #if defined(__APPLE__) -#define OPENSSL_APPLE // Note |TARGET_OS_MAC| is set for all Apple OS variants. |TARGET_OS_OSX| // targets macOS specifically. #if defined(TARGET_OS_OSX) && TARGET_OS_OSX @@ -144,51 +104,6 @@ extern "C" { #endif #endif -#if defined(_WIN32) -#define OPENSSL_WINDOWS -#endif - -// Trusty isn't Linux but currently defines __linux__. As a workaround, we -// exclude it here. -// TODO(b/169780122): Remove this workaround once Trusty no longer defines it. -#if defined(__linux__) && !defined(__TRUSTY__) -#define OPENSSL_LINUX -#endif - -#if defined(__Fuchsia__) -#define OPENSSL_FUCHSIA -#endif - -#if defined(__TRUSTY__) -#define OPENSSL_TRUSTY -#define OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED -#endif - -#if defined(__ANDROID_API__) -#define OPENSSL_ANDROID -#endif - -#if defined(__FreeBSD__) -#define OPENSSL_FREEBSD -#endif - -// BoringSSL requires platform's locking APIs to make internal global state -// thread-safe, including the PRNG. On some single-threaded embedded platforms, -// locking APIs may not exist, so this dependency may be disabled with the -// following build flag. -// -// IMPORTANT: Doing so means the consumer promises the library will never be -// used in any multi-threaded context. It causes BoringSSL to be globally -// thread-unsafe. Setting it inappropriately will subtly and unpredictably -// corrupt memory and leak secret keys. -// -// Do not set this flag on any platform where threads are possible. BoringSSL -// maintainers will not provide support for any consumers that do so. Changes -// which break such unsupported configurations will not be reverted. -#if !defined(OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED) -#define OPENSSL_THREADS -#endif - #define OPENSSL_IS_BORINGSSL #define OPENSSL_VERSION_NUMBER 0x1010107f #define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER @@ -201,7 +116,7 @@ extern "C" { // A consumer may use this symbol in the preprocessor to temporarily build // against multiple revisions of BoringSSL at the same time. It is not // recommended to do so for longer than is necessary. -#define BORINGSSL_API_VERSION 19 +#define BORINGSSL_API_VERSION 26 #if defined(BORINGSSL_SHARED_LIBRARY) @@ -229,6 +144,33 @@ extern "C" { #endif // defined(BORINGSSL_SHARED_LIBRARY) +#if defined(_MSC_VER) + +// OPENSSL_DEPRECATED is used to mark a function as deprecated. Use +// of any functions so marked in caller code will produce a warning. +// OPENSSL_BEGIN_ALLOW_DEPRECATED and OPENSSL_END_ALLOW_DEPRECATED +// can be used to suppress the warning in regions of caller code. +#define OPENSSL_DEPRECATED __declspec(deprecated) +#define OPENSSL_BEGIN_ALLOW_DEPRECATED \ + __pragma(warning(push)) __pragma(warning(disable : 4996)) +#define OPENSSL_END_ALLOW_DEPRECATED __pragma(warning(pop)) + +#elif defined(__GNUC__) || defined(__clang__) + +#define OPENSSL_DEPRECATED __attribute__((__deprecated__)) +#define OPENSSL_BEGIN_ALLOW_DEPRECATED \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#define OPENSSL_END_ALLOW_DEPRECATED _Pragma("GCC diagnostic pop") + +#else + +#define OPENSSL_DEPRECATED +#define OPENSSL_BEGIN_ALLOW_DEPRECATED +#define OPENSSL_END_ALLOW_DEPRECATED + +#endif + #if defined(__GNUC__) || defined(__clang__) // MinGW has two different printf implementations. Ensure the format macro @@ -288,31 +230,6 @@ extern "C" { #define OPENSSL_INLINE static inline OPENSSL_UNUSED #endif -#if defined(BORINGSSL_UNSAFE_FUZZER_MODE) && \ - !defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) -#define BORINGSSL_UNSAFE_DETERMINISTIC_MODE -#endif - -#if defined(__has_feature) -#if __has_feature(address_sanitizer) -#define OPENSSL_ASAN -#endif -#if __has_feature(thread_sanitizer) -#define OPENSSL_TSAN -#endif -#if __has_feature(memory_sanitizer) -#define OPENSSL_MSAN -#define OPENSSL_ASM_INCOMPATIBLE -#endif -#endif - -#if defined(OPENSSL_ASM_INCOMPATIBLE) -#undef OPENSSL_ASM_INCOMPATIBLE -#if !defined(OPENSSL_NO_ASM) -#define OPENSSL_NO_ASM -#endif -#endif // OPENSSL_ASM_INCOMPATIBLE - #if defined(__cplusplus) // enums can be predeclared, but only in C++ and only if given an explicit type. // C doesn't support setting an explicit type for enums thus a #define is used diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_bio.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_bio.h index fbed4fff..dc30eb2f 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_bio.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_bio.h @@ -431,12 +431,14 @@ OPENSSL_EXPORT int BIO_set_mem_eof_return(BIO *bio, int eof_value); // |BIO_reset| attempts to seek the file pointer to the start of file using // |lseek|. +#if !defined(OPENSSL_NO_POSIX_IO) // BIO_s_fd returns a |BIO_METHOD| for file descriptor fds. OPENSSL_EXPORT const BIO_METHOD *BIO_s_fd(void); // BIO_new_fd creates a new file descriptor BIO wrapping |fd|. If |close_flag| // is non-zero, then |fd| will be closed when the BIO is. OPENSSL_EXPORT BIO *BIO_new_fd(int fd, int close_flag); +#endif // BIO_set_fd sets the file descriptor of |bio| to |fd|. If |close_flag| is // non-zero then |fd| will be closed when |bio| is. It returns one on success @@ -540,12 +542,14 @@ OPENSSL_EXPORT long BIO_seek(BIO *bio, long offset); // TODO(davidben): Add separate APIs and fix the internals to use |SOCKET|s // around rather than rely on int casts. +#if !defined(OPENSSL_NO_SOCK) OPENSSL_EXPORT const BIO_METHOD *BIO_s_socket(void); // BIO_new_socket allocates and initialises a fresh BIO which will read and // write to the socket |fd|. If |close_flag| is |BIO_CLOSE| then closing the // BIO will close |fd|. It returns the fresh |BIO| or NULL on error. OPENSSL_EXPORT BIO *BIO_new_socket(int fd, int close_flag); +#endif // !OPENSSL_NO_SOCK // Connect BIOs. @@ -553,6 +557,7 @@ OPENSSL_EXPORT BIO *BIO_new_socket(int fd, int close_flag); // A connection BIO creates a network connection and transfers data over the // resulting socket. +#if !defined(OPENSSL_NO_SOCK) OPENSSL_EXPORT const BIO_METHOD *BIO_s_connect(void); // BIO_new_connect returns a BIO that connects to the given hostname and port. @@ -580,12 +585,17 @@ OPENSSL_EXPORT int BIO_set_conn_port(BIO *bio, const char *port_str); OPENSSL_EXPORT int BIO_set_conn_int_port(BIO *bio, const int *port); // BIO_set_nbio sets whether |bio| will use non-blocking I/O operations. It -// returns one on success and zero otherwise. +// returns one on success and zero otherwise. This only works for connect BIOs +// and must be called before |bio| is connected to take effect. +// +// For socket and fd BIOs, callers must configure blocking vs. non-blocking I/O +// using the underlying platform APIs. OPENSSL_EXPORT int BIO_set_nbio(BIO *bio, int on); // BIO_do_connect connects |bio| if it has not been connected yet. It returns // one on success and <= 0 otherwise. OPENSSL_EXPORT int BIO_do_connect(BIO *bio); +#endif // !OPENSSL_NO_SOCK // Datagram BIOs. @@ -873,7 +883,6 @@ struct bio_st { #define BIO_C_GET_FILE_PTR 107 #define BIO_C_SET_FILENAME 108 #define BIO_C_SET_SSL 109 -#define BIO_C_GET_SSL 110 #define BIO_C_SET_MD 111 #define BIO_C_GET_MD 112 #define BIO_C_GET_CIPHER_STATUS 113 @@ -887,9 +896,6 @@ struct bio_st { #define BIO_C_GET_PROXY_PARAM 121 #define BIO_C_SET_BUFF_READ_DATA 122 // data to read first #define BIO_C_GET_ACCEPT 124 -#define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 -#define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 -#define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 #define BIO_C_FILE_SEEK 128 #define BIO_C_GET_CIPHER_CTX 129 #define BIO_C_SET_BUF_MEM_EOF_RETURN 130 // return end of input value diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_blake2.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_blake2.h index 73fd60a7..5c06d081 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_blake2.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_blake2.h @@ -28,10 +28,7 @@ extern "C" { struct blake2b_state_st { uint64_t h[8]; uint64_t t_low, t_high; - union { - uint8_t bytes[BLAKE2B_CBLOCK]; - uint64_t words[16]; - } block; + uint8_t block[BLAKE2B_CBLOCK]; size_t block_used; }; diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_bn.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_bn.h index e0ea016b..9a9d5a50 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_bn.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_bn.h @@ -161,14 +161,12 @@ extern "C" { typedef uint64_t BN_ULONG; #define BN_BITS2 64 #define BN_DEC_FMT1 "%" PRIu64 -#define BN_DEC_FMT2 "%019" PRIu64 #define BN_HEX_FMT1 "%" PRIx64 #define BN_HEX_FMT2 "%016" PRIx64 #elif defined(OPENSSL_32_BIT) typedef uint32_t BN_ULONG; #define BN_BITS2 32 #define BN_DEC_FMT1 "%" PRIu32 -#define BN_DEC_FMT2 "%09" PRIu32 #define BN_HEX_FMT1 "%" PRIx32 #define BN_HEX_FMT2 "%08" PRIx32 #else diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_boringssl_prefix_symbols.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_boringssl_prefix_symbols.h index fc9b7eb0..7ebe2eb1 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_boringssl_prefix_symbols.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_boringssl_prefix_symbols.h @@ -142,6 +142,7 @@ #define ASN1_TIME_set BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ASN1_TIME_set) #define ASN1_TIME_set_posix BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ASN1_TIME_set_posix) #define ASN1_TIME_set_string BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ASN1_TIME_set_string) +#define ASN1_TIME_set_string_X509 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ASN1_TIME_set_string_X509) #define ASN1_TIME_to_generalizedtime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ASN1_TIME_to_generalizedtime) #define ASN1_TIME_to_posix BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ASN1_TIME_to_posix) #define ASN1_TIME_to_time_t BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ASN1_TIME_to_time_t) @@ -577,10 +578,6 @@ #define CRYPTO_POLYVAL_finish BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_POLYVAL_finish) #define CRYPTO_POLYVAL_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_POLYVAL_init) #define CRYPTO_POLYVAL_update_blocks BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_POLYVAL_update_blocks) -#define CRYPTO_STATIC_MUTEX_lock_read BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_STATIC_MUTEX_lock_read) -#define CRYPTO_STATIC_MUTEX_lock_write BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_STATIC_MUTEX_lock_write) -#define CRYPTO_STATIC_MUTEX_unlock_read BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_STATIC_MUTEX_unlock_read) -#define CRYPTO_STATIC_MUTEX_unlock_write BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_STATIC_MUTEX_unlock_write) #define CRYPTO_THREADID_current BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_THREADID_current) #define CRYPTO_THREADID_set_callback BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_THREADID_set_callback) #define CRYPTO_THREADID_set_numeric BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_THREADID_set_numeric) @@ -654,6 +651,7 @@ #define CRYPTO_sysrand BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_sysrand) #define CRYPTO_sysrand_for_seed BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_sysrand_for_seed) #define CRYPTO_sysrand_if_available BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_sysrand_if_available) +#define CRYPTO_tls13_hkdf_expand_label BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_tls13_hkdf_expand_label) #define CRYPTO_tls1_prf BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CRYPTO_tls1_prf) #define CTR_DRBG_clear BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CTR_DRBG_clear) #define CTR_DRBG_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, CTR_DRBG_free) @@ -855,6 +853,10 @@ #define EC_curve_nid2nist BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_curve_nid2nist) #define EC_curve_nist2nid BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_curve_nist2nid) #define EC_get_builtin_curves BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_get_builtin_curves) +#define EC_group_p224 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_group_p224) +#define EC_group_p256 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_group_p256) +#define EC_group_p384 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_group_p384) +#define EC_group_p521 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_group_p521) #define EC_hash_to_curve_p256_xmd_sha256_sswu BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_hash_to_curve_p256_xmd_sha256_sswu) #define EC_hash_to_curve_p384_xmd_sha384_sswu BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EC_hash_to_curve_p384_xmd_sha384_sswu) #define ED25519_keypair BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ED25519_keypair) @@ -1008,6 +1010,9 @@ #define EVP_HPKE_CTX_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_CTX_new) #define EVP_HPKE_CTX_open BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_CTX_open) #define EVP_HPKE_CTX_seal BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_CTX_seal) +#define EVP_HPKE_CTX_setup_auth_recipient BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_auth_recipient) +#define EVP_HPKE_CTX_setup_auth_sender BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_auth_sender) +#define EVP_HPKE_CTX_setup_auth_sender_with_seed_for_testing BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_auth_sender_with_seed_for_testing) #define EVP_HPKE_CTX_setup_recipient BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_recipient) #define EVP_HPKE_CTX_setup_sender BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_sender) #define EVP_HPKE_CTX_setup_sender_with_seed_for_testing BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_sender_with_seed_for_testing) @@ -1153,6 +1158,7 @@ #define EVP_add_digest BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_add_digest) #define EVP_aead_aes_128_cbc_sha1_tls BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aead_aes_128_cbc_sha1_tls) #define EVP_aead_aes_128_cbc_sha1_tls_implicit_iv BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aead_aes_128_cbc_sha1_tls_implicit_iv) +#define EVP_aead_aes_128_cbc_sha256_tls BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aead_aes_128_cbc_sha256_tls) #define EVP_aead_aes_128_ccm_bluetooth BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aead_aes_128_ccm_bluetooth) #define EVP_aead_aes_128_ccm_bluetooth_8 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aead_aes_128_ccm_bluetooth_8) #define EVP_aead_aes_128_ccm_matter BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aead_aes_128_ccm_matter) @@ -1174,7 +1180,6 @@ #define EVP_aead_chacha20_poly1305 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aead_chacha20_poly1305) #define EVP_aead_des_ede3_cbc_sha1_tls BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aead_des_ede3_cbc_sha1_tls) #define EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv) -#define EVP_aead_null_sha1_tls BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aead_null_sha1_tls) #define EVP_aead_xchacha20_poly1305 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aead_xchacha20_poly1305) #define EVP_aes_128_cbc BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aes_128_cbc) #define EVP_aes_128_ctr BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_aes_128_ctr) @@ -1228,6 +1233,7 @@ #define EVP_sha1_final_with_secret_suffix BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_sha1_final_with_secret_suffix) #define EVP_sha224 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_sha224) #define EVP_sha256 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_sha256) +#define EVP_sha256_final_with_secret_suffix BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_sha256_final_with_secret_suffix) #define EVP_sha384 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_sha384) #define EVP_sha512 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_sha512) #define EVP_sha512_256 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, EVP_sha512_256) @@ -1359,7 +1365,6 @@ #define OPENSSL_add_all_algorithms_conf BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_add_all_algorithms_conf) #define OPENSSL_armcap_P BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_armcap_P) #define OPENSSL_asprintf BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_asprintf) -#define OPENSSL_built_in_curves BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_built_in_curves) #define OPENSSL_cleanse BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_cleanse) #define OPENSSL_cleanup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_cleanup) #define OPENSSL_clear_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_clear_free) @@ -1396,6 +1401,27 @@ #define OPENSSL_realloc BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_realloc) #define OPENSSL_secure_clear_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_secure_clear_free) #define OPENSSL_secure_malloc BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_secure_malloc) +#define OPENSSL_sk_deep_copy BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_deep_copy) +#define OPENSSL_sk_delete BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_delete) +#define OPENSSL_sk_delete_if BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_delete_if) +#define OPENSSL_sk_delete_ptr BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_delete_ptr) +#define OPENSSL_sk_dup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_dup) +#define OPENSSL_sk_find BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_find) +#define OPENSSL_sk_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_free) +#define OPENSSL_sk_insert BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_insert) +#define OPENSSL_sk_is_sorted BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_is_sorted) +#define OPENSSL_sk_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_new) +#define OPENSSL_sk_new_null BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_new_null) +#define OPENSSL_sk_num BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_num) +#define OPENSSL_sk_pop BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_pop) +#define OPENSSL_sk_pop_free_ex BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_pop_free_ex) +#define OPENSSL_sk_push BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_push) +#define OPENSSL_sk_set BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_set) +#define OPENSSL_sk_set_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_set_cmp_func) +#define OPENSSL_sk_shift BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_shift) +#define OPENSSL_sk_sort BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_sort) +#define OPENSSL_sk_value BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_value) +#define OPENSSL_sk_zero BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_sk_zero) #define OPENSSL_strcasecmp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_strcasecmp) #define OPENSSL_strdup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_strdup) #define OPENSSL_strhash BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, OPENSSL_strhash) @@ -1612,6 +1638,13 @@ #define RSA_marshal_public_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_marshal_public_key) #define RSA_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_new) #define RSA_new_method BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_new_method) +#define RSA_new_method_no_e BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_new_method_no_e) +#define RSA_new_private_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_new_private_key) +#define RSA_new_private_key_large_e BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_new_private_key_large_e) +#define RSA_new_private_key_no_crt BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_new_private_key_no_crt) +#define RSA_new_private_key_no_e BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_new_private_key_no_e) +#define RSA_new_public_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_new_public_key) +#define RSA_new_public_key_large_e BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_new_public_key_large_e) #define RSA_padding_add_PKCS1_OAEP_mgf1 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_padding_add_PKCS1_OAEP_mgf1) #define RSA_padding_add_PKCS1_PSS_mgf1 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_padding_add_PKCS1_PSS_mgf1) #define RSA_padding_add_PKCS1_type_1 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, RSA_padding_add_PKCS1_type_1) @@ -1716,10 +1749,8 @@ #define X509V3_EXT_REQ_add_nconf BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509V3_EXT_REQ_add_nconf) #define X509V3_EXT_add BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509V3_EXT_add) #define X509V3_EXT_add_alias BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509V3_EXT_add_alias) -#define X509V3_EXT_add_list BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509V3_EXT_add_list) #define X509V3_EXT_add_nconf BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509V3_EXT_add_nconf) #define X509V3_EXT_add_nconf_sk BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509V3_EXT_add_nconf_sk) -#define X509V3_EXT_cleanup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509V3_EXT_cleanup) #define X509V3_EXT_d2i BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509V3_EXT_d2i) #define X509V3_EXT_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509V3_EXT_free) #define X509V3_EXT_get BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509V3_EXT_get) @@ -2205,15 +2236,6 @@ #define X509_verify BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_verify) #define X509_verify_cert BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_verify_cert) #define X509_verify_cert_error_string BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509_verify_cert_error_string) -#define X509at_add1_attr BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509at_add1_attr) -#define X509at_add1_attr_by_NID BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509at_add1_attr_by_NID) -#define X509at_add1_attr_by_OBJ BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509at_add1_attr_by_OBJ) -#define X509at_add1_attr_by_txt BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509at_add1_attr_by_txt) -#define X509at_delete_attr BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509at_delete_attr) -#define X509at_get_attr BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509at_get_attr) -#define X509at_get_attr_by_NID BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509at_get_attr_by_NID) -#define X509at_get_attr_by_OBJ BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509at_get_attr_by_OBJ) -#define X509at_get_attr_count BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509at_get_attr_count) #define X509v3_add_ext BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509v3_add_ext) #define X509v3_delete_ext BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509v3_delete_ext) #define X509v3_get_ext BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, X509v3_get_ext) @@ -2279,7 +2301,7 @@ #define asn1_type_value_as_pointer BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, asn1_type_value_as_pointer) #define asn1_utctime_to_tm BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, asn1_utctime_to_tm) #define beeu_mod_inverse_vartime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, beeu_mod_inverse_vartime) -#define bio_fd_should_retry BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bio_fd_should_retry) +#define bio_errno_should_retry BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bio_errno_should_retry) #define bn_abs_sub_consttime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_abs_sub_consttime) #define bn_add_words BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_add_words) #define bn_assert_fits_in_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_assert_fits_in_bytes) @@ -2302,7 +2324,6 @@ #define bn_minimal_width BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_minimal_width) #define bn_mod_add_consttime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_add_consttime) #define bn_mod_add_words BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_add_words) -#define bn_mod_exp_base_2_consttime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_exp_base_2_consttime) #define bn_mod_exp_mont_small BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_exp_mont_small) #define bn_mod_inverse0_prime_mont_small BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_inverse0_prime_mont_small) #define bn_mod_inverse_consttime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_inverse_consttime) @@ -2314,6 +2335,9 @@ #define bn_mod_sub_consttime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_sub_consttime) #define bn_mod_sub_words BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_sub_words) #define bn_mod_u16_consttime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mod_u16_consttime) +#define bn_mont_ctx_cleanup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mont_ctx_cleanup) +#define bn_mont_ctx_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mont_ctx_init) +#define bn_mont_ctx_set_RR_consttime BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mont_ctx_set_RR_consttime) #define bn_mont_n0 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mont_n0) #define bn_mul_add_words BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mul_add_words) #define bn_mul_comba4 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, bn_mul_comba4) @@ -2498,9 +2522,6 @@ #define ec_GFp_mont_felem_reduce BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_felem_reduce) #define ec_GFp_mont_felem_sqr BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_felem_sqr) #define ec_GFp_mont_felem_to_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_felem_to_bytes) -#define ec_GFp_mont_group_finish BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_group_finish) -#define ec_GFp_mont_group_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_group_init) -#define ec_GFp_mont_group_set_curve BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_group_set_curve) #define ec_GFp_mont_init_precomp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_init_precomp) #define ec_GFp_mont_mul BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_mul) #define ec_GFp_mont_mul_base BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_mont_mul_base) @@ -2511,9 +2532,7 @@ #define ec_GFp_simple_cmp_x_coordinate BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_cmp_x_coordinate) #define ec_GFp_simple_felem_from_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_felem_from_bytes) #define ec_GFp_simple_felem_to_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_felem_to_bytes) -#define ec_GFp_simple_group_finish BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_group_finish) #define ec_GFp_simple_group_get_curve BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_group_get_curve) -#define ec_GFp_simple_group_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_group_init) #define ec_GFp_simple_group_set_curve BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_group_set_curve) #define ec_GFp_simple_invert BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_invert) #define ec_GFp_simple_is_at_infinity BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_GFp_simple_is_at_infinity) @@ -2535,13 +2554,13 @@ #define ec_felem_from_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_from_bytes) #define ec_felem_neg BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_neg) #define ec_felem_non_zero_mask BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_non_zero_mask) +#define ec_felem_one BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_one) #define ec_felem_select BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_select) #define ec_felem_sub BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_sub) #define ec_felem_to_bignum BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_to_bignum) #define ec_felem_to_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_felem_to_bytes) #define ec_get_x_coordinate_as_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_get_x_coordinate_as_bytes) #define ec_get_x_coordinate_as_scalar BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_get_x_coordinate_as_scalar) -#define ec_group_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_group_new) #define ec_hash_to_curve_p256_xmd_sha256_sswu BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_hash_to_curve_p256_xmd_sha256_sswu) #define ec_hash_to_curve_p384_xmd_sha384_sswu BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_hash_to_curve_p384_xmd_sha384_sswu) #define ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ec_hash_to_curve_p384_xmd_sha512_sswu_draft07) @@ -2601,6 +2620,8 @@ #define ecp_nistz256_sub BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ecp_nistz256_sub) #define ed25519_asn1_meth BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ed25519_asn1_meth) #define ed25519_pkey_meth BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ed25519_pkey_meth) +#define fiat_curve25519_adx_mul BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, fiat_curve25519_adx_mul) +#define fiat_curve25519_adx_square BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, fiat_curve25519_adx_square) #define gcm_ghash_avx BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, gcm_ghash_avx) #define gcm_ghash_clmul BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, gcm_ghash_clmul) #define gcm_ghash_neon BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, gcm_ghash_neon) @@ -2759,6 +2780,7 @@ #define i2t_ASN1_OBJECT BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, i2t_ASN1_OBJECT) #define i2v_GENERAL_NAME BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, i2v_GENERAL_NAME) #define i2v_GENERAL_NAMES BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, i2v_GENERAL_NAMES) +#define k25519Precomp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, k25519Precomp) #define kBoringSSLRSASqrtTwo BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, kBoringSSLRSASqrtTwo) #define kBoringSSLRSASqrtTwoLen BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, kBoringSSLRSASqrtTwoLen) #define kOpenSSLReasonStringData BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, kOpenSSLReasonStringData) @@ -2807,6 +2829,7 @@ #define rsa_default_private_transform BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, rsa_default_private_transform) #define rsa_default_sign_raw BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, rsa_default_sign_raw) #define rsa_default_size BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, rsa_default_size) +#define rsa_invalidate_key BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, rsa_invalidate_key) #define rsa_pkey_meth BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, rsa_pkey_meth) #define rsa_private_transform BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, rsa_private_transform) #define rsa_private_transform_no_self_test BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, rsa_private_transform_no_self_test) @@ -2824,28 +2847,14 @@ #define sha1_block_data_order BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha1_block_data_order) #define sha256_block_data_order BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha256_block_data_order) #define sha512_block_data_order BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sha512_block_data_order) -#define sk_deep_copy BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_deep_copy) -#define sk_delete BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_delete) -#define sk_delete_if BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_delete_if) -#define sk_delete_ptr BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_delete_ptr) -#define sk_dup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_dup) -#define sk_find BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_find) #define sk_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_free) -#define sk_insert BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_insert) -#define sk_is_sorted BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_is_sorted) -#define sk_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_new) #define sk_new_null BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_new_null) #define sk_num BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_num) #define sk_pop BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_pop) #define sk_pop_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_pop_free) #define sk_pop_free_ex BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_pop_free_ex) #define sk_push BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_push) -#define sk_set BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_set) -#define sk_set_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_set_cmp_func) -#define sk_shift BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_shift) -#define sk_sort BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_sort) #define sk_value BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_value) -#define sk_zero BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_zero) #define v2i_GENERAL_NAME BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, v2i_GENERAL_NAME) #define v2i_GENERAL_NAMES BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, v2i_GENERAL_NAMES) #define v2i_GENERAL_NAME_ex BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, v2i_GENERAL_NAME_ex) @@ -2888,6 +2897,7 @@ #define voprf_pst1_issuer_key_from_bytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, voprf_pst1_issuer_key_from_bytes) #define voprf_pst1_read BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, voprf_pst1_read) #define voprf_pst1_sign BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, voprf_pst1_sign) +#define voprf_pst1_sign_with_proof_scalar_for_testing BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, voprf_pst1_sign_with_proof_scalar_for_testing) #define voprf_pst1_unblind BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, voprf_pst1_unblind) #define vpaes_cbc_encrypt BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, vpaes_cbc_encrypt) #define vpaes_ctr32_encrypt_blocks BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, vpaes_ctr32_encrypt_blocks) @@ -2903,11 +2913,13 @@ #define x25519_ge_p3_to_cached BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_ge_p3_to_cached) #define x25519_ge_scalarmult BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_ge_scalarmult) #define x25519_ge_scalarmult_base BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_ge_scalarmult_base) +#define x25519_ge_scalarmult_base_adx BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_ge_scalarmult_base_adx) #define x25519_ge_scalarmult_small_precomp BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_ge_scalarmult_small_precomp) #define x25519_ge_sub BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_ge_sub) #define x25519_ge_tobytes BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_ge_tobytes) #define x25519_pkey_meth BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_pkey_meth) #define x25519_sc_reduce BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_sc_reduce) +#define x25519_scalar_mult_adx BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x25519_scalar_mult_adx) #define x509V3_add_value_asn1_string BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x509V3_add_value_asn1_string) #define x509_digest_sign_algorithm BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x509_digest_sign_algorithm) #define x509_digest_verify_init BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, x509_digest_verify_init) diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_boringssl_prefix_symbols_asm.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_boringssl_prefix_symbols_asm.h index 9cba0e73..e8e9de67 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_boringssl_prefix_symbols_asm.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_boringssl_prefix_symbols_asm.h @@ -147,6 +147,7 @@ #define _ASN1_TIME_set BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ASN1_TIME_set) #define _ASN1_TIME_set_posix BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ASN1_TIME_set_posix) #define _ASN1_TIME_set_string BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ASN1_TIME_set_string) +#define _ASN1_TIME_set_string_X509 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ASN1_TIME_set_string_X509) #define _ASN1_TIME_to_generalizedtime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ASN1_TIME_to_generalizedtime) #define _ASN1_TIME_to_posix BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ASN1_TIME_to_posix) #define _ASN1_TIME_to_time_t BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ASN1_TIME_to_time_t) @@ -582,10 +583,6 @@ #define _CRYPTO_POLYVAL_finish BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_POLYVAL_finish) #define _CRYPTO_POLYVAL_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_POLYVAL_init) #define _CRYPTO_POLYVAL_update_blocks BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_POLYVAL_update_blocks) -#define _CRYPTO_STATIC_MUTEX_lock_read BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_STATIC_MUTEX_lock_read) -#define _CRYPTO_STATIC_MUTEX_lock_write BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_STATIC_MUTEX_lock_write) -#define _CRYPTO_STATIC_MUTEX_unlock_read BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_STATIC_MUTEX_unlock_read) -#define _CRYPTO_STATIC_MUTEX_unlock_write BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_STATIC_MUTEX_unlock_write) #define _CRYPTO_THREADID_current BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_THREADID_current) #define _CRYPTO_THREADID_set_callback BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_THREADID_set_callback) #define _CRYPTO_THREADID_set_numeric BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_THREADID_set_numeric) @@ -659,6 +656,7 @@ #define _CRYPTO_sysrand BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_sysrand) #define _CRYPTO_sysrand_for_seed BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_sysrand_for_seed) #define _CRYPTO_sysrand_if_available BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_sysrand_if_available) +#define _CRYPTO_tls13_hkdf_expand_label BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_tls13_hkdf_expand_label) #define _CRYPTO_tls1_prf BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CRYPTO_tls1_prf) #define _CTR_DRBG_clear BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CTR_DRBG_clear) #define _CTR_DRBG_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, CTR_DRBG_free) @@ -860,6 +858,10 @@ #define _EC_curve_nid2nist BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_curve_nid2nist) #define _EC_curve_nist2nid BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_curve_nist2nid) #define _EC_get_builtin_curves BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_get_builtin_curves) +#define _EC_group_p224 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_group_p224) +#define _EC_group_p256 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_group_p256) +#define _EC_group_p384 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_group_p384) +#define _EC_group_p521 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_group_p521) #define _EC_hash_to_curve_p256_xmd_sha256_sswu BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_hash_to_curve_p256_xmd_sha256_sswu) #define _EC_hash_to_curve_p384_xmd_sha384_sswu BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EC_hash_to_curve_p384_xmd_sha384_sswu) #define _ED25519_keypair BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ED25519_keypair) @@ -1013,6 +1015,9 @@ #define _EVP_HPKE_CTX_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_CTX_new) #define _EVP_HPKE_CTX_open BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_CTX_open) #define _EVP_HPKE_CTX_seal BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_CTX_seal) +#define _EVP_HPKE_CTX_setup_auth_recipient BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_auth_recipient) +#define _EVP_HPKE_CTX_setup_auth_sender BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_auth_sender) +#define _EVP_HPKE_CTX_setup_auth_sender_with_seed_for_testing BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_auth_sender_with_seed_for_testing) #define _EVP_HPKE_CTX_setup_recipient BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_recipient) #define _EVP_HPKE_CTX_setup_sender BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_sender) #define _EVP_HPKE_CTX_setup_sender_with_seed_for_testing BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_HPKE_CTX_setup_sender_with_seed_for_testing) @@ -1158,6 +1163,7 @@ #define _EVP_add_digest BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_add_digest) #define _EVP_aead_aes_128_cbc_sha1_tls BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aead_aes_128_cbc_sha1_tls) #define _EVP_aead_aes_128_cbc_sha1_tls_implicit_iv BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aead_aes_128_cbc_sha1_tls_implicit_iv) +#define _EVP_aead_aes_128_cbc_sha256_tls BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aead_aes_128_cbc_sha256_tls) #define _EVP_aead_aes_128_ccm_bluetooth BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aead_aes_128_ccm_bluetooth) #define _EVP_aead_aes_128_ccm_bluetooth_8 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aead_aes_128_ccm_bluetooth_8) #define _EVP_aead_aes_128_ccm_matter BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aead_aes_128_ccm_matter) @@ -1179,7 +1185,6 @@ #define _EVP_aead_chacha20_poly1305 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aead_chacha20_poly1305) #define _EVP_aead_des_ede3_cbc_sha1_tls BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aead_des_ede3_cbc_sha1_tls) #define _EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv) -#define _EVP_aead_null_sha1_tls BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aead_null_sha1_tls) #define _EVP_aead_xchacha20_poly1305 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aead_xchacha20_poly1305) #define _EVP_aes_128_cbc BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aes_128_cbc) #define _EVP_aes_128_ctr BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_aes_128_ctr) @@ -1233,6 +1238,7 @@ #define _EVP_sha1_final_with_secret_suffix BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_sha1_final_with_secret_suffix) #define _EVP_sha224 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_sha224) #define _EVP_sha256 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_sha256) +#define _EVP_sha256_final_with_secret_suffix BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_sha256_final_with_secret_suffix) #define _EVP_sha384 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_sha384) #define _EVP_sha512 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_sha512) #define _EVP_sha512_256 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, EVP_sha512_256) @@ -1364,7 +1370,6 @@ #define _OPENSSL_add_all_algorithms_conf BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_add_all_algorithms_conf) #define _OPENSSL_armcap_P BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_armcap_P) #define _OPENSSL_asprintf BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_asprintf) -#define _OPENSSL_built_in_curves BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_built_in_curves) #define _OPENSSL_cleanse BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_cleanse) #define _OPENSSL_cleanup BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_cleanup) #define _OPENSSL_clear_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_clear_free) @@ -1401,6 +1406,27 @@ #define _OPENSSL_realloc BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_realloc) #define _OPENSSL_secure_clear_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_secure_clear_free) #define _OPENSSL_secure_malloc BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_secure_malloc) +#define _OPENSSL_sk_deep_copy BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_deep_copy) +#define _OPENSSL_sk_delete BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_delete) +#define _OPENSSL_sk_delete_if BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_delete_if) +#define _OPENSSL_sk_delete_ptr BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_delete_ptr) +#define _OPENSSL_sk_dup BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_dup) +#define _OPENSSL_sk_find BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_find) +#define _OPENSSL_sk_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_free) +#define _OPENSSL_sk_insert BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_insert) +#define _OPENSSL_sk_is_sorted BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_is_sorted) +#define _OPENSSL_sk_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_new) +#define _OPENSSL_sk_new_null BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_new_null) +#define _OPENSSL_sk_num BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_num) +#define _OPENSSL_sk_pop BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_pop) +#define _OPENSSL_sk_pop_free_ex BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_pop_free_ex) +#define _OPENSSL_sk_push BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_push) +#define _OPENSSL_sk_set BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_set) +#define _OPENSSL_sk_set_cmp_func BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_set_cmp_func) +#define _OPENSSL_sk_shift BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_shift) +#define _OPENSSL_sk_sort BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_sort) +#define _OPENSSL_sk_value BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_value) +#define _OPENSSL_sk_zero BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_sk_zero) #define _OPENSSL_strcasecmp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_strcasecmp) #define _OPENSSL_strdup BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_strdup) #define _OPENSSL_strhash BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, OPENSSL_strhash) @@ -1617,6 +1643,13 @@ #define _RSA_marshal_public_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_marshal_public_key) #define _RSA_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_new) #define _RSA_new_method BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_new_method) +#define _RSA_new_method_no_e BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_new_method_no_e) +#define _RSA_new_private_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_new_private_key) +#define _RSA_new_private_key_large_e BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_new_private_key_large_e) +#define _RSA_new_private_key_no_crt BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_new_private_key_no_crt) +#define _RSA_new_private_key_no_e BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_new_private_key_no_e) +#define _RSA_new_public_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_new_public_key) +#define _RSA_new_public_key_large_e BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_new_public_key_large_e) #define _RSA_padding_add_PKCS1_OAEP_mgf1 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_padding_add_PKCS1_OAEP_mgf1) #define _RSA_padding_add_PKCS1_PSS_mgf1 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_padding_add_PKCS1_PSS_mgf1) #define _RSA_padding_add_PKCS1_type_1 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, RSA_padding_add_PKCS1_type_1) @@ -1721,10 +1754,8 @@ #define _X509V3_EXT_REQ_add_nconf BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509V3_EXT_REQ_add_nconf) #define _X509V3_EXT_add BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509V3_EXT_add) #define _X509V3_EXT_add_alias BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509V3_EXT_add_alias) -#define _X509V3_EXT_add_list BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509V3_EXT_add_list) #define _X509V3_EXT_add_nconf BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509V3_EXT_add_nconf) #define _X509V3_EXT_add_nconf_sk BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509V3_EXT_add_nconf_sk) -#define _X509V3_EXT_cleanup BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509V3_EXT_cleanup) #define _X509V3_EXT_d2i BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509V3_EXT_d2i) #define _X509V3_EXT_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509V3_EXT_free) #define _X509V3_EXT_get BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509V3_EXT_get) @@ -2210,15 +2241,6 @@ #define _X509_verify BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_verify) #define _X509_verify_cert BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_verify_cert) #define _X509_verify_cert_error_string BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509_verify_cert_error_string) -#define _X509at_add1_attr BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509at_add1_attr) -#define _X509at_add1_attr_by_NID BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509at_add1_attr_by_NID) -#define _X509at_add1_attr_by_OBJ BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509at_add1_attr_by_OBJ) -#define _X509at_add1_attr_by_txt BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509at_add1_attr_by_txt) -#define _X509at_delete_attr BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509at_delete_attr) -#define _X509at_get_attr BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509at_get_attr) -#define _X509at_get_attr_by_NID BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509at_get_attr_by_NID) -#define _X509at_get_attr_by_OBJ BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509at_get_attr_by_OBJ) -#define _X509at_get_attr_count BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509at_get_attr_count) #define _X509v3_add_ext BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509v3_add_ext) #define _X509v3_delete_ext BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509v3_delete_ext) #define _X509v3_get_ext BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, X509v3_get_ext) @@ -2284,7 +2306,7 @@ #define _asn1_type_value_as_pointer BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, asn1_type_value_as_pointer) #define _asn1_utctime_to_tm BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, asn1_utctime_to_tm) #define _beeu_mod_inverse_vartime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, beeu_mod_inverse_vartime) -#define _bio_fd_should_retry BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bio_fd_should_retry) +#define _bio_errno_should_retry BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bio_errno_should_retry) #define _bn_abs_sub_consttime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_abs_sub_consttime) #define _bn_add_words BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_add_words) #define _bn_assert_fits_in_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_assert_fits_in_bytes) @@ -2307,7 +2329,6 @@ #define _bn_minimal_width BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_minimal_width) #define _bn_mod_add_consttime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_add_consttime) #define _bn_mod_add_words BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_add_words) -#define _bn_mod_exp_base_2_consttime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_exp_base_2_consttime) #define _bn_mod_exp_mont_small BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_exp_mont_small) #define _bn_mod_inverse0_prime_mont_small BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_inverse0_prime_mont_small) #define _bn_mod_inverse_consttime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_inverse_consttime) @@ -2319,6 +2340,9 @@ #define _bn_mod_sub_consttime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_sub_consttime) #define _bn_mod_sub_words BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_sub_words) #define _bn_mod_u16_consttime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mod_u16_consttime) +#define _bn_mont_ctx_cleanup BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mont_ctx_cleanup) +#define _bn_mont_ctx_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mont_ctx_init) +#define _bn_mont_ctx_set_RR_consttime BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mont_ctx_set_RR_consttime) #define _bn_mont_n0 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mont_n0) #define _bn_mul_add_words BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mul_add_words) #define _bn_mul_comba4 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, bn_mul_comba4) @@ -2503,9 +2527,6 @@ #define _ec_GFp_mont_felem_reduce BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_felem_reduce) #define _ec_GFp_mont_felem_sqr BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_felem_sqr) #define _ec_GFp_mont_felem_to_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_felem_to_bytes) -#define _ec_GFp_mont_group_finish BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_group_finish) -#define _ec_GFp_mont_group_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_group_init) -#define _ec_GFp_mont_group_set_curve BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_group_set_curve) #define _ec_GFp_mont_init_precomp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_init_precomp) #define _ec_GFp_mont_mul BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_mul) #define _ec_GFp_mont_mul_base BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_mont_mul_base) @@ -2516,9 +2537,7 @@ #define _ec_GFp_simple_cmp_x_coordinate BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_cmp_x_coordinate) #define _ec_GFp_simple_felem_from_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_felem_from_bytes) #define _ec_GFp_simple_felem_to_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_felem_to_bytes) -#define _ec_GFp_simple_group_finish BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_group_finish) #define _ec_GFp_simple_group_get_curve BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_group_get_curve) -#define _ec_GFp_simple_group_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_group_init) #define _ec_GFp_simple_group_set_curve BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_group_set_curve) #define _ec_GFp_simple_invert BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_invert) #define _ec_GFp_simple_is_at_infinity BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_GFp_simple_is_at_infinity) @@ -2540,13 +2559,13 @@ #define _ec_felem_from_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_from_bytes) #define _ec_felem_neg BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_neg) #define _ec_felem_non_zero_mask BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_non_zero_mask) +#define _ec_felem_one BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_one) #define _ec_felem_select BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_select) #define _ec_felem_sub BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_sub) #define _ec_felem_to_bignum BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_to_bignum) #define _ec_felem_to_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_felem_to_bytes) #define _ec_get_x_coordinate_as_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_get_x_coordinate_as_bytes) #define _ec_get_x_coordinate_as_scalar BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_get_x_coordinate_as_scalar) -#define _ec_group_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_group_new) #define _ec_hash_to_curve_p256_xmd_sha256_sswu BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_hash_to_curve_p256_xmd_sha256_sswu) #define _ec_hash_to_curve_p384_xmd_sha384_sswu BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_hash_to_curve_p384_xmd_sha384_sswu) #define _ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ec_hash_to_curve_p384_xmd_sha512_sswu_draft07) @@ -2606,6 +2625,8 @@ #define _ecp_nistz256_sub BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ecp_nistz256_sub) #define _ed25519_asn1_meth BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ed25519_asn1_meth) #define _ed25519_pkey_meth BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, ed25519_pkey_meth) +#define _fiat_curve25519_adx_mul BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, fiat_curve25519_adx_mul) +#define _fiat_curve25519_adx_square BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, fiat_curve25519_adx_square) #define _gcm_ghash_avx BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, gcm_ghash_avx) #define _gcm_ghash_clmul BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, gcm_ghash_clmul) #define _gcm_ghash_neon BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, gcm_ghash_neon) @@ -2764,6 +2785,7 @@ #define _i2t_ASN1_OBJECT BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, i2t_ASN1_OBJECT) #define _i2v_GENERAL_NAME BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, i2v_GENERAL_NAME) #define _i2v_GENERAL_NAMES BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, i2v_GENERAL_NAMES) +#define _k25519Precomp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, k25519Precomp) #define _kBoringSSLRSASqrtTwo BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, kBoringSSLRSASqrtTwo) #define _kBoringSSLRSASqrtTwoLen BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, kBoringSSLRSASqrtTwoLen) #define _kOpenSSLReasonStringData BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, kOpenSSLReasonStringData) @@ -2812,6 +2834,7 @@ #define _rsa_default_private_transform BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, rsa_default_private_transform) #define _rsa_default_sign_raw BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, rsa_default_sign_raw) #define _rsa_default_size BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, rsa_default_size) +#define _rsa_invalidate_key BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, rsa_invalidate_key) #define _rsa_pkey_meth BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, rsa_pkey_meth) #define _rsa_private_transform BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, rsa_private_transform) #define _rsa_private_transform_no_self_test BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, rsa_private_transform_no_self_test) @@ -2829,28 +2852,14 @@ #define _sha1_block_data_order BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha1_block_data_order) #define _sha256_block_data_order BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha256_block_data_order) #define _sha512_block_data_order BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sha512_block_data_order) -#define _sk_deep_copy BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_deep_copy) -#define _sk_delete BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_delete) -#define _sk_delete_if BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_delete_if) -#define _sk_delete_ptr BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_delete_ptr) -#define _sk_dup BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_dup) -#define _sk_find BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_find) #define _sk_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_free) -#define _sk_insert BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_insert) -#define _sk_is_sorted BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_is_sorted) -#define _sk_new BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_new) #define _sk_new_null BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_new_null) #define _sk_num BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_num) #define _sk_pop BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_pop) #define _sk_pop_free BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_pop_free) #define _sk_pop_free_ex BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_pop_free_ex) #define _sk_push BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_push) -#define _sk_set BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_set) -#define _sk_set_cmp_func BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_set_cmp_func) -#define _sk_shift BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_shift) -#define _sk_sort BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_sort) #define _sk_value BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_value) -#define _sk_zero BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, sk_zero) #define _v2i_GENERAL_NAME BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, v2i_GENERAL_NAME) #define _v2i_GENERAL_NAMES BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, v2i_GENERAL_NAMES) #define _v2i_GENERAL_NAME_ex BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, v2i_GENERAL_NAME_ex) @@ -2893,6 +2902,7 @@ #define _voprf_pst1_issuer_key_from_bytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, voprf_pst1_issuer_key_from_bytes) #define _voprf_pst1_read BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, voprf_pst1_read) #define _voprf_pst1_sign BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, voprf_pst1_sign) +#define _voprf_pst1_sign_with_proof_scalar_for_testing BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, voprf_pst1_sign_with_proof_scalar_for_testing) #define _voprf_pst1_unblind BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, voprf_pst1_unblind) #define _vpaes_cbc_encrypt BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, vpaes_cbc_encrypt) #define _vpaes_ctr32_encrypt_blocks BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, vpaes_ctr32_encrypt_blocks) @@ -2908,11 +2918,13 @@ #define _x25519_ge_p3_to_cached BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_ge_p3_to_cached) #define _x25519_ge_scalarmult BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_ge_scalarmult) #define _x25519_ge_scalarmult_base BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_ge_scalarmult_base) +#define _x25519_ge_scalarmult_base_adx BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_ge_scalarmult_base_adx) #define _x25519_ge_scalarmult_small_precomp BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_ge_scalarmult_small_precomp) #define _x25519_ge_sub BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_ge_sub) #define _x25519_ge_tobytes BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_ge_tobytes) #define _x25519_pkey_meth BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_pkey_meth) #define _x25519_sc_reduce BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_sc_reduce) +#define _x25519_scalar_mult_adx BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x25519_scalar_mult_adx) #define _x509V3_add_value_asn1_string BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x509V3_add_value_asn1_string) #define _x509_digest_sign_algorithm BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x509_digest_sign_algorithm) #define _x509_digest_verify_init BORINGSSL_ADD_PREFIX_MAC_ASM(BORINGSSL_PREFIX, x509_digest_verify_init) diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_chacha.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_chacha.h index dd377e5a..59f4a872 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_chacha.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_chacha.h @@ -29,6 +29,12 @@ extern "C" { // CRYPTO_chacha_20 encrypts |in_len| bytes from |in| with the given key and // nonce and writes the result to |out|. If |in| and |out| alias, they must be // equal. The initial block counter is specified by |counter|. +// +// This function implements a 32-bit block counter as in RFC 8439. On overflow, +// the counter wraps. Reusing a key, nonce, and block counter combination is not +// secure, so wrapping is usually a bug in the caller. While it is possible to +// wrap without reuse with a large initial block counter, this is not +// recommended and may not be portable to other ChaCha20 implementations. OPENSSL_EXPORT void CRYPTO_chacha_20(uint8_t *out, const uint8_t *in, size_t in_len, const uint8_t key[32], const uint8_t nonce[12], uint32_t counter); diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_conf.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_conf.h index a0b0467d..aac159d9 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_conf.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_conf.h @@ -77,7 +77,10 @@ extern "C" { // [section_name] // key2=value2 // -// Config files are represented by a |CONF|. +// Config files are represented by a |CONF|. Use of this module is strongly +// discouraged. It is a remnant of the OpenSSL command-line tool. Parsing an +// untrusted input as a config file risks string injection and denial of service +// vulnerabilities. struct conf_value_st { char *section; @@ -166,5 +169,6 @@ BSSL_NAMESPACE_END #define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 104 #define CONF_R_VARIABLE_HAS_NO_VALUE 105 #define CONF_R_VARIABLE_EXPANSION_TOO_LONG 106 +#define CONF_R_VARIABLE_EXPANSION_NOT_SUPPORTED 107 #endif // OPENSSL_HEADER_THREAD_H diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_dsa.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_dsa.h index c8455067..077aaef1 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_dsa.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_dsa.h @@ -62,9 +62,7 @@ #include "CCryptoBoringSSL_base.h" -#include "CCryptoBoringSSL_engine.h" #include "CCryptoBoringSSL_ex_data.h" -#include "CCryptoBoringSSL_thread.h" #if defined(__cplusplus) extern "C" { @@ -398,25 +396,6 @@ OPENSSL_EXPORT DSA *DSA_generate_parameters(int bits, unsigned char *seed, void *cb_arg); -struct dsa_st { - long version; - BIGNUM *p; - BIGNUM *q; // == 20 - BIGNUM *g; - - BIGNUM *pub_key; // y public key - BIGNUM *priv_key; // x private key - - int flags; - // Normally used to cache montgomery values - CRYPTO_MUTEX method_mont_lock; - BN_MONT_CTX *method_mont_p; - BN_MONT_CTX *method_mont_q; - CRYPTO_refcount_t references; - CRYPTO_EX_DATA ex_data; -}; - - #if defined(__cplusplus) } // extern C diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_ec.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_ec.h index 8a569e8a..4c30c350 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_ec.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_ec.h @@ -101,8 +101,24 @@ typedef enum { // Elliptic curve groups. -// EC_GROUP_new_by_curve_name returns a fresh EC_GROUP object for the elliptic -// curve specified by |nid|, or NULL on unsupported NID or allocation failure. +// EC_group_p224 returns an |EC_GROUP| for P-224, also known as secp224r1. +OPENSSL_EXPORT const EC_GROUP *EC_group_p224(void); + +// EC_group_p256 returns an |EC_GROUP| for P-256, also known as secp256r1 or +// prime256v1. +OPENSSL_EXPORT const EC_GROUP *EC_group_p256(void); + +// EC_group_p384 returns an |EC_GROUP| for P-384, also known as secp384r1. +OPENSSL_EXPORT const EC_GROUP *EC_group_p384(void); + +// EC_group_p521 returns an |EC_GROUP| for P-521, also known as secp521r1. +OPENSSL_EXPORT const EC_GROUP *EC_group_p521(void); + +// EC_GROUP_new_by_curve_name returns the |EC_GROUP| object for the elliptic +// curve specified by |nid|, or NULL on unsupported NID. For OpenSSL +// compatibility, this function returns a non-const pointer which may be passed +// to |EC_GROUP_free|. However, the resulting object is actually static and +// calling |EC_GROUP_free| is optional. // // The supported NIDs are: // NID_secp224r1 (P-224), @@ -110,6 +126,9 @@ typedef enum { // NID_secp384r1 (P-384), // NID_secp521r1 (P-521) // +// Calling this function causes all four curves to be linked into the binary. +// Prefer calling |EC_group_*| to allow the static linker to drop unused curves. +// // If in doubt, use |NID_X9_62_prime256v1|, or see the curve25519.h header for // more modern primitives. OPENSSL_EXPORT EC_GROUP *EC_GROUP_new_by_curve_name(int nid); diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_ec_key.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_ec_key.h index ece63ac1..94ba5a4d 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_ec_key.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_ec_key.h @@ -259,8 +259,15 @@ OPENSSL_EXPORT int EC_KEY_marshal_private_key(CBB *cbb, const EC_KEY *key, unsigned enc_flags); // EC_KEY_parse_curve_name parses a DER-encoded OBJECT IDENTIFIER as a curve -// name from |cbs| and advances |cbs|. It returns a newly-allocated |EC_GROUP| -// or NULL on error. +// name from |cbs| and advances |cbs|. It returns the decoded |EC_GROUP| or NULL +// on error. +// +// This function returns a non-const pointer which may be passed to +// |EC_GROUP_free|. However, the resulting object is actually static and calling +// |EC_GROUP_free| is optional. +// +// TODO(davidben): Make this return a const pointer, if it does not break too +// many callers. OPENSSL_EXPORT EC_GROUP *EC_KEY_parse_curve_name(CBS *cbs); // EC_KEY_marshal_curve_name marshals |group| as a DER-encoded OBJECT IDENTIFIER @@ -269,10 +276,16 @@ OPENSSL_EXPORT EC_GROUP *EC_KEY_parse_curve_name(CBS *cbs); OPENSSL_EXPORT int EC_KEY_marshal_curve_name(CBB *cbb, const EC_GROUP *group); // EC_KEY_parse_parameters parses a DER-encoded ECParameters structure (RFC -// 5480) from |cbs| and advances |cbs|. It returns a newly-allocated |EC_GROUP| -// or NULL on error. It supports the namedCurve and specifiedCurve options, but -// use of specifiedCurve is deprecated. Use |EC_KEY_parse_curve_name| -// instead. +// 5480) from |cbs| and advances |cbs|. It returns the resulting |EC_GROUP| or +// NULL on error. It supports the namedCurve and specifiedCurve options, but use +// of specifiedCurve is deprecated. Use |EC_KEY_parse_curve_name| instead. +// +// This function returns a non-const pointer which may be passed to +// |EC_GROUP_free|. However, the resulting object is actually static and calling +// |EC_GROUP_free| is optional. +// +// TODO(davidben): Make this return a const pointer, if it does not break too +// many callers. OPENSSL_EXPORT EC_GROUP *EC_KEY_parse_parameters(CBS *cbs); diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_evp.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_evp.h index d56d9810..8244d2e1 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_evp.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_evp.h @@ -180,11 +180,6 @@ OPENSSL_EXPORT EC_KEY *EVP_PKEY_get1_EC_KEY(const EVP_PKEY *pkey); #define EVP_PKEY_X25519 NID_X25519 #define EVP_PKEY_HKDF NID_hkdf -// EVP_PKEY_assign sets the underlying key of |pkey| to |key|, which must be of -// the given type. It returns one if successful or zero if the |type| argument -// is not one of the |EVP_PKEY_*| values or if |key| is NULL. -OPENSSL_EXPORT int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key); - // EVP_PKEY_set_type sets the type of |pkey| to |type|. It returns one if // successful or zero if the |type| argument is not one of the |EVP_PKEY_*| // values. If |pkey| is NULL, it simply reports whether the type is known. @@ -239,9 +234,9 @@ OPENSSL_EXPORT int EVP_marshal_private_key(CBB *cbb, const EVP_PKEY *key); // Raw keys // // Some keys types support a "raw" serialization. Currently the only supported -// raw format is Ed25519, where the public key and private key formats are those -// specified in RFC 8032. Note the RFC 8032 private key format is the 32-byte -// prefix of |ED25519_sign|'s 64-byte private key. +// raw formats are X25519 and Ed25519, where the formats are those specified in +// RFC 7748 and RFC 8032, respectively. Note the RFC 8032 private key format is +// the 32-byte prefix of |ED25519_sign|'s 64-byte private key. // EVP_PKEY_new_raw_private_key returns a newly allocated |EVP_PKEY| wrapping a // private key of the specified type. It returns one on success and zero on @@ -480,7 +475,7 @@ OPENSSL_EXPORT int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, // returns one on success and zero on allocation failure or if iterations is 0. OPENSSL_EXPORT int PKCS5_PBKDF2_HMAC(const char *password, size_t password_len, const uint8_t *salt, size_t salt_len, - unsigned iterations, const EVP_MD *digest, + uint32_t iterations, const EVP_MD *digest, size_t key_len, uint8_t *out_key); // PKCS5_PBKDF2_HMAC_SHA1 is the same as PKCS5_PBKDF2_HMAC, but with |digest| @@ -488,7 +483,7 @@ OPENSSL_EXPORT int PKCS5_PBKDF2_HMAC(const char *password, size_t password_len, OPENSSL_EXPORT int PKCS5_PBKDF2_HMAC_SHA1(const char *password, size_t password_len, const uint8_t *salt, size_t salt_len, - unsigned iterations, size_t key_len, + uint32_t iterations, size_t key_len, uint8_t *out_key); // EVP_PBE_scrypt expands |password| into a secret key of length |key_len| using @@ -1032,6 +1027,15 @@ OPENSSL_EXPORT int EVP_PKEY_CTX_set_dsa_paramgen_bits(EVP_PKEY_CTX *ctx, OPENSSL_EXPORT int EVP_PKEY_CTX_set_dsa_paramgen_q_bits(EVP_PKEY_CTX *ctx, int qbits); +// EVP_PKEY_assign sets the underlying key of |pkey| to |key|, which must be of +// the given type. If successful, it returns one. If the |type| argument +// is not one of |EVP_PKEY_RSA|, |EVP_PKEY_DSA|, or |EVP_PKEY_EC| values or if +// |key| is NULL, it returns zero. This function may not be used with other +// |EVP_PKEY_*| types. +// +// Use the |EVP_PKEY_assign_*| functions instead. +OPENSSL_EXPORT int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key); + // Preprocessor compatibility section (hidden). // diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_hpke.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_hpke.h index 71b318d9..bd38cd98 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_hpke.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_hpke.h @@ -249,6 +249,34 @@ OPENSSL_EXPORT int EVP_HPKE_CTX_setup_recipient( const EVP_HPKE_AEAD *aead, const uint8_t *enc, size_t enc_len, const uint8_t *info, size_t info_len); +// EVP_HPKE_CTX_setup_auth_sender implements the SetupAuthS HPKE operation. It +// behaves like |EVP_HPKE_CTX_setup_sender| but authenticates the resulting +// context with |key|. +OPENSSL_EXPORT int EVP_HPKE_CTX_setup_auth_sender( + EVP_HPKE_CTX *ctx, uint8_t *out_enc, size_t *out_enc_len, size_t max_enc, + const EVP_HPKE_KEY *key, const EVP_HPKE_KDF *kdf, const EVP_HPKE_AEAD *aead, + const uint8_t *peer_public_key, size_t peer_public_key_len, + const uint8_t *info, size_t info_len); + +// EVP_HPKE_CTX_setup_auth_sender_with_seed_for_testing behaves like +// |EVP_HPKE_CTX_setup_auth_sender|, but takes a seed to behave +// deterministically. The seed's format depends on |kem|. For X25519, it is the +// sender's ephemeral private key. +OPENSSL_EXPORT int EVP_HPKE_CTX_setup_auth_sender_with_seed_for_testing( + EVP_HPKE_CTX *ctx, uint8_t *out_enc, size_t *out_enc_len, size_t max_enc, + const EVP_HPKE_KEY *key, const EVP_HPKE_KDF *kdf, const EVP_HPKE_AEAD *aead, + const uint8_t *peer_public_key, size_t peer_public_key_len, + const uint8_t *info, size_t info_len, const uint8_t *seed, size_t seed_len); + +// EVP_HPKE_CTX_setup_auth_recipient implements the SetupAuthR HPKE operation. +// It behaves like |EVP_HPKE_CTX_setup_recipient| but checks the resulting +// context was authenticated with |peer_public_key|. +OPENSSL_EXPORT int EVP_HPKE_CTX_setup_auth_recipient( + EVP_HPKE_CTX *ctx, const EVP_HPKE_KEY *key, const EVP_HPKE_KDF *kdf, + const EVP_HPKE_AEAD *aead, const uint8_t *enc, size_t enc_len, + const uint8_t *info, size_t info_len, const uint8_t *peer_public_key, + size_t peer_public_key_len); + // Using an HPKE context. // diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_nid.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_nid.h index 8edd2082..a1c03a07 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_nid.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_nid.h @@ -4235,9 +4235,6 @@ extern "C" { #define LN_auth_any "auth-any" #define NID_auth_any 958 -#define SN_CECPQ2 "CECPQ2" -#define NID_CECPQ2 959 - #define SN_ED448 "ED448" #define NID_ED448 960 #define OBJ_ED448 1L, 3L, 101L, 113L @@ -4255,14 +4252,8 @@ extern "C" { #define LN_hkdf "hkdf" #define NID_hkdf 963 -#define SN_X25519Kyber768 "X25519Kyber768" -#define NID_X25519Kyber768 964 - -#define SN_P256Kyber768 "P256Kyber768" -#define NID_P256Kyber768 965 - -#define SN_P384Kyber768 "P384Kyber768" -#define NID_P384Kyber768 966 +#define SN_X25519Kyber768Draft00 "X25519Kyber768Draft00" +#define NID_X25519Kyber768Draft00 964 #if defined(__cplusplus) diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_rand.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_rand.h index 92e81a4d..18f4c505 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_rand.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_rand.h @@ -29,20 +29,6 @@ extern "C" { // event that sufficient random data can not be obtained, |abort| is called. OPENSSL_EXPORT int RAND_bytes(uint8_t *buf, size_t len); -// RAND_get_system_entropy_for_custom_prng writes |len| bytes of random data -// from a system entropy source to |buf|. The maximum length of entropy which -// may be requested is 256 bytes. If more than 256 bytes of data is requested, -// or if sufficient random data can not be obtained, |abort| is called. -// |RAND_bytes| should normally be used instead of this function. This function -// should only be used for seed values or where |malloc| should not be called -// from BoringSSL. This function is not FIPS compliant. -OPENSSL_EXPORT void RAND_get_system_entropy_for_custom_prng(uint8_t *buf, - size_t len); - -// RAND_cleanup frees any resources used by the RNG. This is not safe if other -// threads might still be calling |RAND_bytes|. -OPENSSL_EXPORT void RAND_cleanup(void); - // Obscure functions. @@ -65,6 +51,16 @@ OPENSSL_EXPORT void RAND_enable_fork_unsafe_buffering(int fd); OPENSSL_EXPORT void RAND_reset_for_fuzzing(void); #endif +// RAND_get_system_entropy_for_custom_prng writes |len| bytes of random data +// from a system entropy source to |buf|. The maximum length of entropy which +// may be requested is 256 bytes. If more than 256 bytes of data is requested, +// or if sufficient random data can not be obtained, |abort| is called. +// |RAND_bytes| should normally be used instead of this function. This function +// should only be used for seed values or where |malloc| should not be called +// from BoringSSL. This function is not FIPS compliant. +OPENSSL_EXPORT void RAND_get_system_entropy_for_custom_prng(uint8_t *buf, + size_t len); + // Deprecated functions @@ -93,6 +89,9 @@ OPENSSL_EXPORT int RAND_poll(void); // RAND_status returns one. OPENSSL_EXPORT int RAND_status(void); +// RAND_cleanup does nothing. +OPENSSL_EXPORT void RAND_cleanup(void); + // rand_meth_st is typedefed to |RAND_METHOD| in base.h. It isn't used; it // exists only to be the return type of |RAND_SSLeay|. It's // external so that variables of this type can be initialized. diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_rsa.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_rsa.h index 6599ffcd..0be61d25 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_rsa.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_rsa.h @@ -79,7 +79,22 @@ extern "C" { // documented, functions which take a |const| pointer are non-mutating and // functions which take a non-|const| pointer are mutating. -// RSA_new returns a new, empty |RSA| object or NULL on error. +// RSA_new_public_key returns a new |RSA| object containing a public key with +// the specified parameters, or NULL on error or invalid input. +OPENSSL_EXPORT RSA *RSA_new_public_key(const BIGNUM *n, const BIGNUM *e); + +// RSA_new_private_key returns a new |RSA| object containing a private key with +// the specified parameters, or NULL on error or invalid input. All parameters +// are mandatory and may not be NULL. +// +// This function creates standard RSA private keys with CRT parameters. +OPENSSL_EXPORT RSA *RSA_new_private_key(const BIGNUM *n, const BIGNUM *e, + const BIGNUM *d, const BIGNUM *p, + const BIGNUM *q, const BIGNUM *dmp1, + const BIGNUM *dmq1, const BIGNUM *iqmp); + +// RSA_new returns a new, empty |RSA| object or NULL on error. Prefer using +// |RSA_new_public_key| or |RSA_new_private_key| to import an RSA key. OPENSSL_EXPORT RSA *RSA_new(void); // RSA_new_method acts the same as |RSA_new| but takes an explicit |ENGINE|. @@ -148,6 +163,20 @@ OPENSSL_EXPORT void RSA_get0_crt_params(const RSA *rsa, const BIGNUM **out_dmp1, const BIGNUM **out_dmq1, const BIGNUM **out_iqmp); + +// Setting individual properties. +// +// These functions allow setting individual properties of an |RSA| object. This +// is typically used with |RSA_new| to construct an RSA key field by field. +// Prefer instead to use |RSA_new_public_key| and |RSA_new_private_key|. These +// functions defer some initialization to the first use of an |RSA| object. This +// means invalid inputs may be caught late. +// +// TODO(crbug.com/boringssl/316): This deferred initialization also causes +// performance problems in multi-threaded applications. The preferred APIs +// currently have the same issues, but they will initialize eagerly in the +// future. + // RSA_set0_key sets |rsa|'s modulus, public exponent, and private exponent to // |n|, |e|, and |d| respectively, if non-NULL. On success, it takes ownership // of each argument and returns one. Otherwise, it returns zero. @@ -570,6 +599,48 @@ OPENSSL_EXPORT int RSA_private_key_to_bytes(uint8_t **out_bytes, size_t *out_len, const RSA *rsa); +// Obscure RSA variants. +// +// These functions allow creating RSA keys with obscure combinations of +// parameters. + +// RSA_new_private_key_no_crt behaves like |RSA_new_private_key| but constructs +// an RSA key without CRT coefficients. +// +// Keys created by this function will be less performant and cannot be +// serialized. +OPENSSL_EXPORT RSA *RSA_new_private_key_no_crt(const BIGNUM *n, const BIGNUM *e, + const BIGNUM *d); + +// RSA_new_private_key_no_e behaves like |RSA_new_private_key| but constructs an +// RSA key without CRT parameters or public exponent. +// +// Keys created by this function will be less performant, cannot be serialized, +// and lack hardening measures that protect against side channels and fault +// attacks. +OPENSSL_EXPORT RSA *RSA_new_private_key_no_e(const BIGNUM *n, const BIGNUM *d); + +// RSA_new_public_key_large_e behaves like |RSA_new_public_key| but allows any +// |e| up to |n|. +// +// BoringSSL typically bounds public exponents as a denial-of-service +// mitigation. Keys created by this function may perform worse than those +// created by |RSA_new_public_key|. +OPENSSL_EXPORT RSA *RSA_new_public_key_large_e(const BIGNUM *n, + const BIGNUM *e); + +// RSA_new_private_key_large_e behaves like |RSA_new_private_key| but allows any +// |e| up to |n|. +// +// BoringSSL typically bounds public exponents as a denial-of-service +// mitigation. Keys created by this function may perform worse than those +// created by |RSA_new_private_key|. +OPENSSL_EXPORT RSA *RSA_new_private_key_large_e( + const BIGNUM *n, const BIGNUM *e, const BIGNUM *d, const BIGNUM *p, + const BIGNUM *q, const BIGNUM *dmp1, const BIGNUM *dmq1, + const BIGNUM *iqmp); + + // ex_data functions. // // See |ex_data.h| for details. @@ -600,6 +671,17 @@ OPENSSL_EXPORT void *RSA_get_ex_data(const RSA *rsa, int idx); // RSA_FLAG_EXT_PKEY is deprecated and ignored. #define RSA_FLAG_EXT_PKEY 0x20 +// RSA_FLAG_NO_PUBLIC_EXPONENT indicates that private keys without a public +// exponent are allowed. This is an internal constant. Use +// |RSA_new_private_key_no_e| to construct such keys. +#define RSA_FLAG_NO_PUBLIC_EXPONENT 0x40 + +// RSA_FLAG_LARGE_PUBLIC_EXPONENT indicates that keys with a large public +// exponent are allowed. This is an internal constant. Use +// |RSA_new_public_key_large_e| and |RSA_new_private_key_large_e| to construct +// such keys. +#define RSA_FLAG_LARGE_PUBLIC_EXPONENT 0x80 + // RSA public exponent values. @@ -688,6 +770,14 @@ OPENSSL_EXPORT int RSA_print(BIO *bio, const RSA *rsa, int indent); // the id-RSASSA-PSS key encoding. OPENSSL_EXPORT const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *rsa); +// RSA_new_method_no_e returns a newly-allocated |RSA| object backed by +// |engine|, with a public modulus of |n| and no known public exponent. +// +// Do not use this function. It exists only to support Conscrypt, whose use +// should be replaced with a more sound mechanism. See +// https://crbug.com/boringssl/602. +OPENSSL_EXPORT RSA *RSA_new_method_no_e(const ENGINE *engine, const BIGNUM *n); + struct rsa_meth_st { struct openssl_method_common_st common; @@ -728,67 +818,6 @@ struct rsa_meth_st { }; -// Private functions. - -typedef struct bn_blinding_st BN_BLINDING; - -struct rsa_st { - RSA_METHOD *meth; - - // Access to the following fields was historically allowed, but - // deprecated. Use |RSA_get0_*| and |RSA_set0_*| instead. Access to all other - // fields is forbidden and will cause threading errors. - BIGNUM *n; - BIGNUM *e; - BIGNUM *d; - BIGNUM *p; - BIGNUM *q; - BIGNUM *dmp1; - BIGNUM *dmq1; - BIGNUM *iqmp; - - // be careful using this if the RSA structure is shared - CRYPTO_EX_DATA ex_data; - CRYPTO_refcount_t references; - int flags; - - CRYPTO_MUTEX lock; - - // Used to cache montgomery values. The creation of these values is protected - // by |lock|. - BN_MONT_CTX *mont_n; - BN_MONT_CTX *mont_p; - BN_MONT_CTX *mont_q; - - // The following fields are copies of |d|, |dmp1|, and |dmq1|, respectively, - // but with the correct widths to prevent side channels. These must use - // separate copies due to threading concerns caused by OpenSSL's API - // mistakes. See https://github.com/openssl/openssl/issues/5158 and - // the |freeze_private_key| implementation. - BIGNUM *d_fixed, *dmp1_fixed, *dmq1_fixed; - - // inv_small_mod_large_mont is q^-1 mod p in Montgomery form, using |mont_p|, - // if |p| >= |q|. Otherwise, it is p^-1 mod q in Montgomery form, using - // |mont_q|. - BIGNUM *inv_small_mod_large_mont; - - // num_blindings contains the size of the |blindings| and |blindings_inuse| - // arrays. This member and the |blindings_inuse| array are protected by - // |lock|. - size_t num_blindings; - // blindings is an array of BN_BLINDING structures that can be reserved by a - // thread by locking |lock| and changing the corresponding element in - // |blindings_inuse| from 0 to 1. - BN_BLINDING **blindings; - unsigned char *blindings_inuse; - uint64_t blinding_fork_generation; - - // private_key_frozen is one if the key has been used for a private key - // operation and may no longer be mutated. - unsigned private_key_frozen:1; -}; - - #if defined(__cplusplus) } // extern C diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_span.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_span.h index 4f01e569..b7e781fc 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_span.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_span.h @@ -114,36 +114,37 @@ class Span : private internal::SpanBase { template , typename = std::enable_if_t::value, C>> - Span(const C &container) : data_(container.data()), size_(container.size()) {} + constexpr Span(const C &container) + : data_(container.data()), size_(container.size()) {} template , typename = std::enable_if_t::value, C>> - explicit Span(C &container) + constexpr explicit Span(C &container) : data_(container.data()), size_(container.size()) {} - T *data() const { return data_; } - size_t size() const { return size_; } - bool empty() const { return size_ == 0; } + constexpr T *data() const { return data_; } + constexpr size_t size() const { return size_; } + constexpr bool empty() const { return size_ == 0; } - T *begin() const { return data_; } - const T *cbegin() const { return data_; } - T *end() const { return data_ + size_; } - const T *cend() const { return end(); } + constexpr T *begin() const { return data_; } + constexpr const T *cbegin() const { return data_; } + constexpr T *end() const { return data_ + size_; } + constexpr const T *cend() const { return end(); } - T &front() const { + constexpr T &front() const { if (size_ == 0) { abort(); } return data_[0]; } - T &back() const { + constexpr T &back() const { if (size_ == 0) { abort(); } return data_[size_ - 1]; } - T &operator[](size_t i) const { + constexpr T &operator[](size_t i) const { if (i >= size_) { abort(); } @@ -151,7 +152,7 @@ class Span : private internal::SpanBase { } T &at(size_t i) const { return (*this)[i]; } - Span subspan(size_t pos = 0, size_t len = npos) const { + constexpr Span subspan(size_t pos = 0, size_t len = npos) const { if (pos > size_) { // absl::Span throws an exception here. Note std::span and Chromium // base::span additionally forbid pos + len being out of range, with a @@ -163,14 +164,14 @@ class Span : private internal::SpanBase { return Span(data_ + pos, std::min(size_ - pos, len)); } - Span first(size_t len) { + constexpr Span first(size_t len) const { if (len > size_) { abort(); } return Span(data_, len); } - Span last(size_t len) { + constexpr Span last(size_t len) const { if (len > size_) { abort(); } @@ -186,25 +187,31 @@ template const size_t Span::npos; template -Span MakeSpan(T *ptr, size_t size) { +constexpr Span MakeSpan(T *ptr, size_t size) { return Span(ptr, size); } template -auto MakeSpan(C &c) -> decltype(MakeSpan(c.data(), c.size())) { +constexpr auto MakeSpan(C &c) -> decltype(MakeSpan(c.data(), c.size())) { return MakeSpan(c.data(), c.size()); } template -Span MakeConstSpan(T *ptr, size_t size) { +constexpr Span MakeConstSpan(T *ptr, size_t size) { return Span(ptr, size); } template -auto MakeConstSpan(const C &c) -> decltype(MakeConstSpan(c.data(), c.size())) { +constexpr auto MakeConstSpan(const C &c) + -> decltype(MakeConstSpan(c.data(), c.size())) { return MakeConstSpan(c.data(), c.size()); } +template +constexpr Span MakeConstSpan(T (&array)[size]) { + return array; +} + BSSL_NAMESPACE_END } // extern C++ diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_stack.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_stack.h index 5a9d0d57..879be51b 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_stack.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_stack.h @@ -138,7 +138,8 @@ STACK_OF(SAMPLE) *sk_SAMPLE_new(sk_SAMPLE_cmp_func comp); // NULL on allocation failure. STACK_OF(SAMPLE) *sk_SAMPLE_new_null(void); -// sk_SAMPLE_num returns the number of elements in |sk|. +// sk_SAMPLE_num returns the number of elements in |sk|. It is safe to cast this +// value to |int|. |sk| is guaranteed to have at most |INT_MAX| elements. size_t sk_SAMPLE_num(const STACK_OF(SAMPLE) *sk); // sk_SAMPLE_zero resets |sk| to the empty state but does nothing to free the @@ -244,8 +245,11 @@ STACK_OF(SAMPLE) *sk_SAMPLE_deep_copy(const STACK_OF(SAMPLE) *sk, // Private functions. // -// TODO(https://crbug.com/boringssl/499): Rename to |OPENSSL_sk_foo|, after -// external code that calls them is fixed. +// The |sk_*| functions generated above are implemented internally using the +// type-erased functions below. Callers should use the typed wrappers instead. +// When using the type-erased functions, callers are responsible for ensuring +// the underlying types are correct. Casting pointers to the wrong types will +// result in memory errors. // OPENSSL_sk_free_func is a function that frees an element in a stack. Note its // actual type is void (*)(T *) for some T. Low-level |sk_*| functions will be @@ -275,69 +279,87 @@ typedef int (*OPENSSL_sk_delete_if_func)(void *obj, void *data); // true types. typedef void (*OPENSSL_sk_call_free_func)(OPENSSL_sk_free_func, void *); typedef void *(*OPENSSL_sk_call_copy_func)(OPENSSL_sk_copy_func, const void *); -typedef int (*OPENSSL_sk_call_cmp_func)(OPENSSL_sk_cmp_func, - const void *const *, - const void *const *); +typedef int (*OPENSSL_sk_call_cmp_func)(OPENSSL_sk_cmp_func, const void *, + const void *); typedef int (*OPENSSL_sk_call_delete_if_func)(OPENSSL_sk_delete_if_func, void *, void *); -// stack_st contains an array of pointers. It is not designed to be used +// An OPENSSL_STACK contains an array of pointers. It is not designed to be used // directly, rather the wrapper macros should be used. -typedef struct stack_st { - // num contains the number of valid pointers in |data|. - size_t num; - void **data; - // sorted is non-zero if the values pointed to by |data| are in ascending - // order, based on |comp|. - int sorted; - // num_alloc contains the number of pointers allocated in the buffer pointed - // to by |data|, which may be larger than |num|. - size_t num_alloc; - // comp is an optional comparison function. - OPENSSL_sk_cmp_func comp; -} _STACK; +typedef struct stack_st OPENSSL_STACK; // The following are raw stack functions. They implement the corresponding typed // |sk_SAMPLE_*| functions generated by |DEFINE_STACK_OF|. Callers shouldn't be // using them. Rather, callers should use the typed functions. -OPENSSL_EXPORT _STACK *sk_new(OPENSSL_sk_cmp_func comp); -OPENSSL_EXPORT _STACK *sk_new_null(void); -OPENSSL_EXPORT size_t sk_num(const _STACK *sk); -OPENSSL_EXPORT void sk_zero(_STACK *sk); -OPENSSL_EXPORT void *sk_value(const _STACK *sk, size_t i); -OPENSSL_EXPORT void *sk_set(_STACK *sk, size_t i, void *p); -OPENSSL_EXPORT void sk_free(_STACK *sk); -OPENSSL_EXPORT void sk_pop_free_ex(_STACK *sk, - OPENSSL_sk_call_free_func call_free_func, - OPENSSL_sk_free_func free_func); -OPENSSL_EXPORT size_t sk_insert(_STACK *sk, void *p, size_t where); -OPENSSL_EXPORT void *sk_delete(_STACK *sk, size_t where); -OPENSSL_EXPORT void *sk_delete_ptr(_STACK *sk, const void *p); -OPENSSL_EXPORT void sk_delete_if(_STACK *sk, - OPENSSL_sk_call_delete_if_func call_func, - OPENSSL_sk_delete_if_func func, void *data); -OPENSSL_EXPORT int sk_find(const _STACK *sk, size_t *out_index, const void *p, - OPENSSL_sk_call_cmp_func call_cmp_func); -OPENSSL_EXPORT void *sk_shift(_STACK *sk); -OPENSSL_EXPORT size_t sk_push(_STACK *sk, void *p); -OPENSSL_EXPORT void *sk_pop(_STACK *sk); -OPENSSL_EXPORT _STACK *sk_dup(const _STACK *sk); -OPENSSL_EXPORT void sk_sort(_STACK *sk, OPENSSL_sk_call_cmp_func call_cmp_func); -OPENSSL_EXPORT int sk_is_sorted(const _STACK *sk); -OPENSSL_EXPORT OPENSSL_sk_cmp_func sk_set_cmp_func(_STACK *sk, - OPENSSL_sk_cmp_func comp); -OPENSSL_EXPORT _STACK *sk_deep_copy(const _STACK *sk, - OPENSSL_sk_call_copy_func call_copy_func, - OPENSSL_sk_copy_func copy_func, - OPENSSL_sk_call_free_func call_free_func, - OPENSSL_sk_free_func free_func); +OPENSSL_EXPORT OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_cmp_func comp); +OPENSSL_EXPORT OPENSSL_STACK *OPENSSL_sk_new_null(void); +OPENSSL_EXPORT size_t OPENSSL_sk_num(const OPENSSL_STACK *sk); +OPENSSL_EXPORT void OPENSSL_sk_zero(OPENSSL_STACK *sk); +OPENSSL_EXPORT void *OPENSSL_sk_value(const OPENSSL_STACK *sk, size_t i); +OPENSSL_EXPORT void *OPENSSL_sk_set(OPENSSL_STACK *sk, size_t i, void *p); +OPENSSL_EXPORT void OPENSSL_sk_free(OPENSSL_STACK *sk); +OPENSSL_EXPORT void OPENSSL_sk_pop_free_ex( + OPENSSL_STACK *sk, OPENSSL_sk_call_free_func call_free_func, + OPENSSL_sk_free_func free_func); +OPENSSL_EXPORT size_t OPENSSL_sk_insert(OPENSSL_STACK *sk, void *p, + size_t where); +OPENSSL_EXPORT void *OPENSSL_sk_delete(OPENSSL_STACK *sk, size_t where); +OPENSSL_EXPORT void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *sk, const void *p); +OPENSSL_EXPORT void OPENSSL_sk_delete_if( + OPENSSL_STACK *sk, OPENSSL_sk_call_delete_if_func call_func, + OPENSSL_sk_delete_if_func func, void *data); +OPENSSL_EXPORT int OPENSSL_sk_find(const OPENSSL_STACK *sk, size_t *out_index, + const void *p, + OPENSSL_sk_call_cmp_func call_cmp_func); +OPENSSL_EXPORT void *OPENSSL_sk_shift(OPENSSL_STACK *sk); +OPENSSL_EXPORT size_t OPENSSL_sk_push(OPENSSL_STACK *sk, void *p); +OPENSSL_EXPORT void *OPENSSL_sk_pop(OPENSSL_STACK *sk); +OPENSSL_EXPORT OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *sk); +OPENSSL_EXPORT void OPENSSL_sk_sort(OPENSSL_STACK *sk, + OPENSSL_sk_call_cmp_func call_cmp_func); +OPENSSL_EXPORT int OPENSSL_sk_is_sorted(const OPENSSL_STACK *sk); +OPENSSL_EXPORT OPENSSL_sk_cmp_func +OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk, OPENSSL_sk_cmp_func comp); +OPENSSL_EXPORT OPENSSL_STACK *OPENSSL_sk_deep_copy( + const OPENSSL_STACK *sk, OPENSSL_sk_call_copy_func call_copy_func, + OPENSSL_sk_copy_func copy_func, OPENSSL_sk_call_free_func call_free_func, + OPENSSL_sk_free_func free_func); -// sk_pop_free behaves like |sk_pop_free_ex| but performs an invalid function -// pointer cast. It exists because some existing callers called |sk_pop_free| -// directly. + +// Deprecated private functions (hidden). +// +// TODO(crbug.com/boringssl/499): Migrate callers to the typed wrappers, or at +// least the new names and remove the old ones. +// +// TODO(b/290792019, b/290785937): Ideally these would at least be inline +// functions, so we do not squat the symbols. + +typedef OPENSSL_STACK _STACK; + +// The following functions call the corresponding |OPENSSL_sk_*| function. +OPENSSL_EXPORT OPENSSL_DEPRECATED OPENSSL_STACK *sk_new_null(void); +OPENSSL_EXPORT OPENSSL_DEPRECATED size_t sk_num(const OPENSSL_STACK *sk); +OPENSSL_EXPORT OPENSSL_DEPRECATED void *sk_value(const OPENSSL_STACK *sk, + size_t i); +OPENSSL_EXPORT OPENSSL_DEPRECATED void sk_free(OPENSSL_STACK *sk); +OPENSSL_EXPORT OPENSSL_DEPRECATED size_t sk_push(OPENSSL_STACK *sk, void *p); +OPENSSL_EXPORT OPENSSL_DEPRECATED void *sk_pop(OPENSSL_STACK *sk); + +// sk_pop_free_ex calls |OPENSSL_sk_pop_free_ex|. +// +// TODO(b/291994116): Remove this. +OPENSSL_EXPORT OPENSSL_DEPRECATED void sk_pop_free_ex( + OPENSSL_STACK *sk, OPENSSL_sk_call_free_func call_free_func, + OPENSSL_sk_free_func free_func); + +// sk_pop_free behaves like |OPENSSL_sk_pop_free_ex| but performs an invalid +// function pointer cast. It exists because some existing callers called +// |sk_pop_free| directly. // // TODO(davidben): Migrate callers to bssl::UniquePtr and remove this. -OPENSSL_EXPORT void sk_pop_free(_STACK *sk, OPENSSL_sk_free_func free_func); +OPENSSL_EXPORT OPENSSL_DEPRECATED void sk_pop_free( + OPENSSL_STACK *sk, OPENSSL_sk_free_func free_func); + #if !defined(BORINGSSL_NO_CXX) extern "C++" { @@ -367,153 +389,151 @@ BSSL_NAMESPACE_END #define BORINGSSL_DEFINE_STACK_TRAITS(name, type, is_const) #endif -#define BORINGSSL_DEFINE_STACK_OF_IMPL(name, ptrtype, constptrtype) \ - /* We disable MSVC C4191 in this macro, which warns when pointers are cast \ - * to the wrong type. While the cast itself is valid, it is often a bug \ - * because calling it through the cast is UB. However, we never actually \ - * call functions as |OPENSSL_sk_cmp_func|. The type is just a type-erased \ - * function pointer. (C does not guarantee function pointers fit in \ - * |void*|, and GCC will warn on this.) Thus we just disable the false \ - * positive warning. */ \ - OPENSSL_MSVC_PRAGMA(warning(push)) \ - OPENSSL_MSVC_PRAGMA(warning(disable : 4191)) \ - \ - DECLARE_STACK_OF(name) \ - \ - typedef void (*sk_##name##_free_func)(ptrtype); \ - typedef ptrtype (*sk_##name##_copy_func)(constptrtype); \ - typedef int (*sk_##name##_cmp_func)(constptrtype const *, \ - constptrtype const *); \ - typedef int (*sk_##name##_delete_if_func)(ptrtype, void *); \ - \ - OPENSSL_INLINE void sk_##name##_call_free_func( \ - OPENSSL_sk_free_func free_func, void *ptr) { \ - ((sk_##name##_free_func)free_func)((ptrtype)ptr); \ - } \ - \ - OPENSSL_INLINE void *sk_##name##_call_copy_func( \ - OPENSSL_sk_copy_func copy_func, const void *ptr) { \ - return (void *)((sk_##name##_copy_func)copy_func)((constptrtype)ptr); \ - } \ - \ - OPENSSL_INLINE int sk_##name##_call_cmp_func(OPENSSL_sk_cmp_func cmp_func, \ - const void *const *a, \ - const void *const *b) { \ - /* The data is actually stored as |void*| pointers, so read the pointer \ - * as |void*| and then pass the corrected type into the caller-supplied \ - * function, which expects |constptrtype*|. */ \ - constptrtype a_ptr = (constptrtype)*a; \ - constptrtype b_ptr = (constptrtype)*b; \ - return ((sk_##name##_cmp_func)cmp_func)(&a_ptr, &b_ptr); \ - } \ - \ - OPENSSL_INLINE int sk_##name##_call_delete_if_func( \ - OPENSSL_sk_delete_if_func func, void *obj, void *data) { \ - return ((sk_##name##_delete_if_func)func)((ptrtype)obj, data); \ - } \ - \ - OPENSSL_INLINE STACK_OF(name) *sk_##name##_new(sk_##name##_cmp_func comp) { \ - return (STACK_OF(name) *)sk_new((OPENSSL_sk_cmp_func)comp); \ - } \ - \ - OPENSSL_INLINE STACK_OF(name) *sk_##name##_new_null(void) { \ - return (STACK_OF(name) *)sk_new_null(); \ - } \ - \ - OPENSSL_INLINE size_t sk_##name##_num(const STACK_OF(name) *sk) { \ - return sk_num((const _STACK *)sk); \ - } \ - \ - OPENSSL_INLINE void sk_##name##_zero(STACK_OF(name) *sk) { \ - sk_zero((_STACK *)sk); \ - } \ - \ - OPENSSL_INLINE ptrtype sk_##name##_value(const STACK_OF(name) *sk, \ - size_t i) { \ - return (ptrtype)sk_value((const _STACK *)sk, i); \ - } \ - \ - OPENSSL_INLINE ptrtype sk_##name##_set(STACK_OF(name) *sk, size_t i, \ - ptrtype p) { \ - return (ptrtype)sk_set((_STACK *)sk, i, (void *)p); \ - } \ - \ - OPENSSL_INLINE void sk_##name##_free(STACK_OF(name) *sk) { \ - sk_free((_STACK *)sk); \ - } \ - \ - OPENSSL_INLINE void sk_##name##_pop_free(STACK_OF(name) *sk, \ - sk_##name##_free_func free_func) { \ - sk_pop_free_ex((_STACK *)sk, sk_##name##_call_free_func, \ - (OPENSSL_sk_free_func)free_func); \ - } \ - \ - OPENSSL_INLINE size_t sk_##name##_insert(STACK_OF(name) *sk, ptrtype p, \ - size_t where) { \ - return sk_insert((_STACK *)sk, (void *)p, where); \ - } \ - \ - OPENSSL_INLINE ptrtype sk_##name##_delete(STACK_OF(name) *sk, \ - size_t where) { \ - return (ptrtype)sk_delete((_STACK *)sk, where); \ - } \ - \ - OPENSSL_INLINE ptrtype sk_##name##_delete_ptr(STACK_OF(name) *sk, \ - constptrtype p) { \ - return (ptrtype)sk_delete_ptr((_STACK *)sk, (const void *)p); \ - } \ - \ - OPENSSL_INLINE void sk_##name##_delete_if( \ - STACK_OF(name) *sk, sk_##name##_delete_if_func func, void *data) { \ - sk_delete_if((_STACK *)sk, sk_##name##_call_delete_if_func, \ - (OPENSSL_sk_delete_if_func)func, data); \ - } \ - \ - OPENSSL_INLINE int sk_##name##_find(const STACK_OF(name) *sk, \ - size_t *out_index, constptrtype p) { \ - return sk_find((const _STACK *)sk, out_index, (const void *)p, \ - sk_##name##_call_cmp_func); \ - } \ - \ - OPENSSL_INLINE ptrtype sk_##name##_shift(STACK_OF(name) *sk) { \ - return (ptrtype)sk_shift((_STACK *)sk); \ - } \ - \ - OPENSSL_INLINE size_t sk_##name##_push(STACK_OF(name) *sk, ptrtype p) { \ - return sk_push((_STACK *)sk, (void *)p); \ - } \ - \ - OPENSSL_INLINE ptrtype sk_##name##_pop(STACK_OF(name) *sk) { \ - return (ptrtype)sk_pop((_STACK *)sk); \ - } \ - \ - OPENSSL_INLINE STACK_OF(name) *sk_##name##_dup(const STACK_OF(name) *sk) { \ - return (STACK_OF(name) *)sk_dup((const _STACK *)sk); \ - } \ - \ - OPENSSL_INLINE void sk_##name##_sort(STACK_OF(name) *sk) { \ - sk_sort((_STACK *)sk, sk_##name##_call_cmp_func); \ - } \ - \ - OPENSSL_INLINE int sk_##name##_is_sorted(const STACK_OF(name) *sk) { \ - return sk_is_sorted((const _STACK *)sk); \ - } \ - \ - OPENSSL_INLINE sk_##name##_cmp_func sk_##name##_set_cmp_func( \ - STACK_OF(name) *sk, sk_##name##_cmp_func comp) { \ - return (sk_##name##_cmp_func)sk_set_cmp_func((_STACK *)sk, \ - (OPENSSL_sk_cmp_func)comp); \ - } \ - \ - OPENSSL_INLINE STACK_OF(name) *sk_##name##_deep_copy( \ - const STACK_OF(name) *sk, sk_##name##_copy_func copy_func, \ - sk_##name##_free_func free_func) { \ - return (STACK_OF(name) *)sk_deep_copy( \ - (const _STACK *)sk, sk_##name##_call_copy_func, \ - (OPENSSL_sk_copy_func)copy_func, sk_##name##_call_free_func, \ - (OPENSSL_sk_free_func)free_func); \ - } \ - \ +#define BORINGSSL_DEFINE_STACK_OF_IMPL(name, ptrtype, constptrtype) \ + /* We disable MSVC C4191 in this macro, which warns when pointers are cast \ + * to the wrong type. While the cast itself is valid, it is often a bug \ + * because calling it through the cast is UB. However, we never actually \ + * call functions as |OPENSSL_sk_cmp_func|. The type is just a type-erased \ + * function pointer. (C does not guarantee function pointers fit in \ + * |void*|, and GCC will warn on this.) Thus we just disable the false \ + * positive warning. */ \ + OPENSSL_MSVC_PRAGMA(warning(push)) \ + OPENSSL_MSVC_PRAGMA(warning(disable : 4191)) \ + \ + DECLARE_STACK_OF(name) \ + \ + typedef void (*sk_##name##_free_func)(ptrtype); \ + typedef ptrtype (*sk_##name##_copy_func)(constptrtype); \ + typedef int (*sk_##name##_cmp_func)(constptrtype const *, \ + constptrtype const *); \ + typedef int (*sk_##name##_delete_if_func)(ptrtype, void *); \ + \ + OPENSSL_INLINE void sk_##name##_call_free_func( \ + OPENSSL_sk_free_func free_func, void *ptr) { \ + ((sk_##name##_free_func)free_func)((ptrtype)ptr); \ + } \ + \ + OPENSSL_INLINE void *sk_##name##_call_copy_func( \ + OPENSSL_sk_copy_func copy_func, const void *ptr) { \ + return (void *)((sk_##name##_copy_func)copy_func)((constptrtype)ptr); \ + } \ + \ + OPENSSL_INLINE int sk_##name##_call_cmp_func(OPENSSL_sk_cmp_func cmp_func, \ + const void *a, const void *b) { \ + constptrtype a_ptr = (constptrtype)a; \ + constptrtype b_ptr = (constptrtype)b; \ + /* |cmp_func| expects an extra layer of pointers to match qsort. */ \ + return ((sk_##name##_cmp_func)cmp_func)(&a_ptr, &b_ptr); \ + } \ + \ + OPENSSL_INLINE int sk_##name##_call_delete_if_func( \ + OPENSSL_sk_delete_if_func func, void *obj, void *data) { \ + return ((sk_##name##_delete_if_func)func)((ptrtype)obj, data); \ + } \ + \ + OPENSSL_INLINE STACK_OF(name) *sk_##name##_new(sk_##name##_cmp_func comp) { \ + return (STACK_OF(name) *)OPENSSL_sk_new((OPENSSL_sk_cmp_func)comp); \ + } \ + \ + OPENSSL_INLINE STACK_OF(name) *sk_##name##_new_null(void) { \ + return (STACK_OF(name) *)OPENSSL_sk_new_null(); \ + } \ + \ + OPENSSL_INLINE size_t sk_##name##_num(const STACK_OF(name) *sk) { \ + return OPENSSL_sk_num((const OPENSSL_STACK *)sk); \ + } \ + \ + OPENSSL_INLINE void sk_##name##_zero(STACK_OF(name) *sk) { \ + OPENSSL_sk_zero((OPENSSL_STACK *)sk); \ + } \ + \ + OPENSSL_INLINE ptrtype sk_##name##_value(const STACK_OF(name) *sk, \ + size_t i) { \ + return (ptrtype)OPENSSL_sk_value((const OPENSSL_STACK *)sk, i); \ + } \ + \ + OPENSSL_INLINE ptrtype sk_##name##_set(STACK_OF(name) *sk, size_t i, \ + ptrtype p) { \ + return (ptrtype)OPENSSL_sk_set((OPENSSL_STACK *)sk, i, (void *)p); \ + } \ + \ + OPENSSL_INLINE void sk_##name##_free(STACK_OF(name) *sk) { \ + OPENSSL_sk_free((OPENSSL_STACK *)sk); \ + } \ + \ + OPENSSL_INLINE void sk_##name##_pop_free(STACK_OF(name) *sk, \ + sk_##name##_free_func free_func) { \ + OPENSSL_sk_pop_free_ex((OPENSSL_STACK *)sk, sk_##name##_call_free_func, \ + (OPENSSL_sk_free_func)free_func); \ + } \ + \ + OPENSSL_INLINE size_t sk_##name##_insert(STACK_OF(name) *sk, ptrtype p, \ + size_t where) { \ + return OPENSSL_sk_insert((OPENSSL_STACK *)sk, (void *)p, where); \ + } \ + \ + OPENSSL_INLINE ptrtype sk_##name##_delete(STACK_OF(name) *sk, \ + size_t where) { \ + return (ptrtype)OPENSSL_sk_delete((OPENSSL_STACK *)sk, where); \ + } \ + \ + OPENSSL_INLINE ptrtype sk_##name##_delete_ptr(STACK_OF(name) *sk, \ + constptrtype p) { \ + return (ptrtype)OPENSSL_sk_delete_ptr((OPENSSL_STACK *)sk, \ + (const void *)p); \ + } \ + \ + OPENSSL_INLINE void sk_##name##_delete_if( \ + STACK_OF(name) *sk, sk_##name##_delete_if_func func, void *data) { \ + OPENSSL_sk_delete_if((OPENSSL_STACK *)sk, sk_##name##_call_delete_if_func, \ + (OPENSSL_sk_delete_if_func)func, data); \ + } \ + \ + OPENSSL_INLINE int sk_##name##_find(const STACK_OF(name) *sk, \ + size_t *out_index, constptrtype p) { \ + return OPENSSL_sk_find((const OPENSSL_STACK *)sk, out_index, \ + (const void *)p, sk_##name##_call_cmp_func); \ + } \ + \ + OPENSSL_INLINE ptrtype sk_##name##_shift(STACK_OF(name) *sk) { \ + return (ptrtype)OPENSSL_sk_shift((OPENSSL_STACK *)sk); \ + } \ + \ + OPENSSL_INLINE size_t sk_##name##_push(STACK_OF(name) *sk, ptrtype p) { \ + return OPENSSL_sk_push((OPENSSL_STACK *)sk, (void *)p); \ + } \ + \ + OPENSSL_INLINE ptrtype sk_##name##_pop(STACK_OF(name) *sk) { \ + return (ptrtype)OPENSSL_sk_pop((OPENSSL_STACK *)sk); \ + } \ + \ + OPENSSL_INLINE STACK_OF(name) *sk_##name##_dup(const STACK_OF(name) *sk) { \ + return (STACK_OF(name) *)OPENSSL_sk_dup((const OPENSSL_STACK *)sk); \ + } \ + \ + OPENSSL_INLINE void sk_##name##_sort(STACK_OF(name) *sk) { \ + OPENSSL_sk_sort((OPENSSL_STACK *)sk, sk_##name##_call_cmp_func); \ + } \ + \ + OPENSSL_INLINE int sk_##name##_is_sorted(const STACK_OF(name) *sk) { \ + return OPENSSL_sk_is_sorted((const OPENSSL_STACK *)sk); \ + } \ + \ + OPENSSL_INLINE sk_##name##_cmp_func sk_##name##_set_cmp_func( \ + STACK_OF(name) *sk, sk_##name##_cmp_func comp) { \ + return (sk_##name##_cmp_func)OPENSSL_sk_set_cmp_func( \ + (OPENSSL_STACK *)sk, (OPENSSL_sk_cmp_func)comp); \ + } \ + \ + OPENSSL_INLINE STACK_OF(name) *sk_##name##_deep_copy( \ + const STACK_OF(name) *sk, sk_##name##_copy_func copy_func, \ + sk_##name##_free_func free_func) { \ + return (STACK_OF(name) *)OPENSSL_sk_deep_copy( \ + (const OPENSSL_STACK *)sk, sk_##name##_call_copy_func, \ + (OPENSSL_sk_copy_func)copy_func, sk_##name##_call_free_func, \ + (OPENSSL_sk_free_func)free_func); \ + } \ + \ OPENSSL_MSVC_PRAGMA(warning(pop)) @@ -541,7 +561,9 @@ namespace internal { // Stacks defined with |DEFINE_CONST_STACK_OF| are freed with |sk_free|. template struct DeleterImpl::kIsConst>> { - static void Free(Stack *sk) { sk_free(reinterpret_cast<_STACK *>(sk)); } + static void Free(Stack *sk) { + OPENSSL_sk_free(reinterpret_cast(sk)); + } }; // Stacks defined with |DEFINE_STACK_OF| are freed with |sk_pop_free| and the @@ -552,11 +574,12 @@ struct DeleterImpl::kIsConst>> { // sk_FOO_pop_free is defined by macros and bound by name, so we cannot // access it from C++ here. using Type = typename StackTraits::Type; - sk_pop_free_ex(reinterpret_cast<_STACK *>(sk), - [](OPENSSL_sk_free_func /* unused */, void *ptr) { - DeleterImpl::Free(reinterpret_cast(ptr)); - }, - nullptr); + OPENSSL_sk_pop_free_ex( + reinterpret_cast(sk), + [](OPENSSL_sk_free_func /* unused */, void *ptr) { + DeleterImpl::Free(reinterpret_cast(ptr)); + }, + nullptr); } }; @@ -577,7 +600,7 @@ class StackIteratorImpl { Type *operator*() const { return reinterpret_cast( - sk_value(reinterpret_cast(sk_), idx_)); + OPENSSL_sk_value(reinterpret_cast(sk_), idx_)); } StackIteratorImpl &operator++(/* prefix */) { @@ -608,10 +631,10 @@ template inline std::enable_if_t::kIsConst, bool> PushToStack(Stack *sk, UniquePtr::Type> elem) { - if (!sk_push(reinterpret_cast<_STACK *>(sk), elem.get())) { + if (!OPENSSL_sk_push(reinterpret_cast(sk), elem.get())) { return false; } - // sk_push takes ownership on success. + // OPENSSL_sk_push takes ownership on success. elem.release(); return true; } @@ -627,7 +650,7 @@ inline bssl::internal::StackIterator begin(const Stack *sk) { template inline bssl::internal::StackIterator end(const Stack *sk) { return bssl::internal::StackIterator( - sk, sk_num(reinterpret_cast(sk))); + sk, OPENSSL_sk_num(reinterpret_cast(sk))); } } // extern C++ diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_target.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_target.h new file mode 100644 index 00000000..f830c14c --- /dev/null +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_target.h @@ -0,0 +1,177 @@ +/* Copyright (c) 2023, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef OPENSSL_HEADER_TARGET_H +#define OPENSSL_HEADER_TARGET_H + +// Preprocessor symbols that define the target platform. +// +// This file may be included in C, C++, and assembler and must be compatible +// with each environment. It is separated out only to share code between +// and . Prefer to include those headers +// instead. + +#if defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) +#define OPENSSL_64_BIT +#define OPENSSL_X86_64 +#elif defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86) +#define OPENSSL_32_BIT +#define OPENSSL_X86 +#elif defined(__AARCH64EL__) || defined(_M_ARM64) +#define OPENSSL_64_BIT +#define OPENSSL_AARCH64 +#elif defined(__ARMEL__) || defined(_M_ARM) +#define OPENSSL_32_BIT +#define OPENSSL_ARM +#elif defined(__MIPSEL__) && !defined(__LP64__) +#define OPENSSL_32_BIT +#define OPENSSL_MIPS +#elif defined(__MIPSEL__) && defined(__LP64__) +#define OPENSSL_64_BIT +#define OPENSSL_MIPS64 +#elif defined(__riscv) && __SIZEOF_POINTER__ == 8 +#define OPENSSL_64_BIT +#define OPENSSL_RISCV64 +#elif defined(__riscv) && __SIZEOF_POINTER__ == 4 +#define OPENSSL_32_BIT +#elif defined(__pnacl__) +#define OPENSSL_32_BIT +#define OPENSSL_PNACL +#elif defined(__wasm__) +#define OPENSSL_32_BIT +#elif defined(__asmjs__) +#define OPENSSL_32_BIT +#elif defined(__myriad2__) +#define OPENSSL_32_BIT +#else +// Note BoringSSL only supports standard 32-bit and 64-bit two's-complement, +// little-endian architectures. Functions will not produce the correct answer +// on other systems. Run the crypto_test binary, notably +// crypto/compiler_test.cc, before adding a new architecture. +#error "Unknown target CPU" +#endif + +#if defined(__APPLE__) +#define OPENSSL_APPLE +#endif + +#if defined(_WIN32) +#define OPENSSL_WINDOWS +#endif + +// Trusty and Android baremetal aren't't Linux but currently define __linux__. +// As a workaround, we exclude them here. +// +// TODO(b/169780122): Remove this workaround once Trusty no longer defines it. +// TODO(b/291101350): Remove this workaround once Android baremetal no longer +// defines it. +#if defined(__linux__) && !defined(__TRUSTY__) && !defined(ANDROID_BAREMETAL) +#define OPENSSL_LINUX +#endif + +#if defined(__Fuchsia__) +#define OPENSSL_FUCHSIA +#endif + +// Trusty is Android's TEE target. See +// https://source.android.com/docs/security/features/trusty +// +// Defining this on any other platform is not supported. Other embedded +// platforms must introduce their own defines. +#if defined(__TRUSTY__) +#define OPENSSL_TRUSTY +#define OPENSSL_NO_FILESYSTEM +#define OPENSSL_NO_POSIX_IO +#define OPENSSL_NO_SOCK +#define OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED +#endif + +// nanolibc is a particular minimal libc implementation. Defining this on any +// other platform is not supported. Other embedded platforms must introduce +// their own defines. +#if defined(OPENSSL_NANOLIBC) +#define OPENSSL_NO_FILESYSTEM +#define OPENSSL_NO_POSIX_IO +#define OPENSSL_NO_SOCK +#define OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED +#endif + +// Android baremetal is an embedded target that uses a subset of bionic. +// Defining this on any other platform is not supported. Other embedded +// platforms must introduce their own defines. +#if defined(ANDROID_BAREMETAL) +#define OPENSSL_NO_FILESYSTEM +#define OPENSSL_NO_POSIX_IO +#define OPENSSL_NO_SOCK +#define OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED +#endif + +#if defined(__ANDROID_API__) +#define OPENSSL_ANDROID +#endif + +#if defined(__FreeBSD__) +#define OPENSSL_FREEBSD +#endif + +#if defined(__OpenBSD__) +#define OPENSSL_OPENBSD +#endif + +// BoringSSL requires platform's locking APIs to make internal global state +// thread-safe, including the PRNG. On some single-threaded embedded platforms, +// locking APIs may not exist, so this dependency may be disabled with the +// following build flag. +// +// IMPORTANT: Doing so means the consumer promises the library will never be +// used in any multi-threaded context. It causes BoringSSL to be globally +// thread-unsafe. Setting it inappropriately will subtly and unpredictably +// corrupt memory and leak secret keys. +// +// Do not set this flag on any platform where threads are possible. BoringSSL +// maintainers will not provide support for any consumers that do so. Changes +// which break such unsupported configurations will not be reverted. +#if !defined(OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED) +#define OPENSSL_THREADS +#endif + +#if defined(BORINGSSL_UNSAFE_FUZZER_MODE) && \ + !defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) +#define BORINGSSL_UNSAFE_DETERMINISTIC_MODE +#endif + +#if defined(__has_feature) +#if __has_feature(address_sanitizer) +#define OPENSSL_ASAN +#endif +#if __has_feature(thread_sanitizer) +#define OPENSSL_TSAN +#endif +#if __has_feature(memory_sanitizer) +#define OPENSSL_MSAN +#define OPENSSL_ASM_INCOMPATIBLE +#endif +#if __has_feature(hwaddress_sanitizer) +#define OPENSSL_HWASAN +#endif +#endif + +#if defined(OPENSSL_ASM_INCOMPATIBLE) +#undef OPENSSL_ASM_INCOMPATIBLE +#if !defined(OPENSSL_NO_ASM) +#define OPENSSL_NO_ASM +#endif +#endif // OPENSSL_ASM_INCOMPATIBLE + +#endif // OPENSSL_HEADER_TARGET_H diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_thread.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_thread.h index b17a8c32..b893e0a4 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_thread.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_thread.h @@ -66,37 +66,13 @@ extern "C" { #endif -#if !defined(OPENSSL_THREADS) -typedef struct crypto_mutex_st { - char padding; // Empty structs have different sizes in C and C++. -} CRYPTO_MUTEX; -#elif defined(OPENSSL_WINDOWS) -// CRYPTO_MUTEX can appear in public header files so we really don't want to -// pull in windows.h. It's statically asserted that this structure is large -// enough to contain a Windows SRWLOCK by thread_win.c. -typedef union crypto_mutex_st { - void *handle; -} CRYPTO_MUTEX; -#elif !defined(__GLIBC__) -typedef pthread_rwlock_t CRYPTO_MUTEX; -#else -// On glibc, |pthread_rwlock_t| is hidden under feature flags, and we can't -// ensure that we'll be able to get it from a public header. It's statically -// asserted that this structure is large enough to contain a |pthread_rwlock_t| -// by thread_pthread.c. -typedef union crypto_mutex_st { - double alignment; - uint8_t padding[3*sizeof(int) + 5*sizeof(unsigned) + 16 + 8]; -} CRYPTO_MUTEX; -#endif - // CRYPTO_refcount_t is the type of a reference count. // // Since some platforms use C11 atomics to access this, it should have the // _Atomic qualifier. However, this header is included by C++ programs as well // as C code that might not set -std=c11. So, in practice, it's not possible to // do that. Instead we statically assert that the size and native alignment of -// a plain uint32_t and an _Atomic uint32_t are equal in refcount_c11.c. +// a plain uint32_t and an _Atomic uint32_t are equal in refcount.c. typedef uint32_t CRYPTO_refcount_t; diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_x509.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_x509.h index aa96df9c..a9c187f6 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_x509.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_x509.h @@ -277,6 +277,12 @@ OPENSSL_EXPORT int X509_get_signature_nid(const X509 *x509); // |i2d_re_X509_tbs| instead. OPENSSL_EXPORT int i2d_X509_tbs(X509 *x509, unsigned char **outp); +// X509_verify checks that |x509| has a valid signature by |pkey|. It returns +// one if the signature is valid and zero otherwise. Note this function only +// checks the signature itself and does not perform a full certificate +// validation. +OPENSSL_EXPORT int X509_verify(X509 *x509, EVP_PKEY *pkey); + // Issuing certificates. // @@ -342,16 +348,17 @@ OPENSSL_EXPORT X509_EXTENSION *X509_delete_ext(X509 *x, int loc); OPENSSL_EXPORT int X509_add_ext(X509 *x, const X509_EXTENSION *ex, int loc); // X509_sign signs |x509| with |pkey| and replaces the signature algorithm and -// signature fields. It returns one on success and zero on error. This function -// uses digest algorithm |md|, or |pkey|'s default if NULL. Other signing -// parameters use |pkey|'s defaults. To customize them, use |X509_sign_ctx|. +// signature fields. It returns the length of the signature on success and zero +// on error. This function uses digest algorithm |md|, or |pkey|'s default if +// NULL. Other signing parameters use |pkey|'s defaults. To customize them, use +// |X509_sign_ctx|. OPENSSL_EXPORT int X509_sign(X509 *x509, EVP_PKEY *pkey, const EVP_MD *md); // X509_sign_ctx signs |x509| with |ctx| and replaces the signature algorithm -// and signature fields. It returns one on success and zero on error. The -// signature algorithm and parameters come from |ctx|, which must have been -// initialized with |EVP_DigestSignInit|. The caller should configure the -// corresponding |EVP_PKEY_CTX| before calling this function. +// and signature fields. It returns the length of the signature on success and +// zero on error. The signature algorithm and parameters come from |ctx|, which +// must have been initialized with |EVP_DigestSignInit|. The caller should +// configure the corresponding |EVP_PKEY_CTX| before calling this function. OPENSSL_EXPORT int X509_sign_ctx(X509 *x509, EVP_MD_CTX *ctx); // i2d_re_X509_tbs serializes the TBSCertificate portion of |x509|, as described @@ -576,6 +583,10 @@ OPENSSL_EXPORT int X509_CRL_get_signature_nid(const X509_CRL *crl); // instead. OPENSSL_EXPORT int i2d_X509_CRL_tbs(X509_CRL *crl, unsigned char **outp); +// X509_CRL_verify checks that |crl| has a valid signature by |pkey|. It returns +// one if the signature is valid and zero otherwise. +OPENSSL_EXPORT int X509_CRL_verify(X509_CRL *crl, EVP_PKEY *pkey); + // Issuing certificate revocation lists. // @@ -624,18 +635,18 @@ OPENSSL_EXPORT int X509_CRL_add_ext(X509_CRL *x, const X509_EXTENSION *ex, int loc); // X509_CRL_sign signs |crl| with |pkey| and replaces the signature algorithm -// and signature fields. It returns one on success and zero on error. This -// function uses digest algorithm |md|, or |pkey|'s default if NULL. Other -// signing parameters use |pkey|'s defaults. To customize them, use -// |X509_CRL_sign_ctx|. +// and signature fields. It returns the length of the signature on success and +// zero on error. This function uses digest algorithm |md|, or |pkey|'s default +// if NULL. Other signing parameters use |pkey|'s defaults. To customize them, +// use |X509_CRL_sign_ctx|. OPENSSL_EXPORT int X509_CRL_sign(X509_CRL *crl, EVP_PKEY *pkey, const EVP_MD *md); // X509_CRL_sign_ctx signs |crl| with |ctx| and replaces the signature algorithm -// and signature fields. It returns one on success and zero on error. The -// signature algorithm and parameters come from |ctx|, which must have been -// initialized with |EVP_DigestSignInit|. The caller should configure the -// corresponding |EVP_PKEY_CTX| before calling this function. +// and signature fields. It returns the length of the signature on success and +// zero on error. The signature algorithm and parameters come from |ctx|, which +// must have been initialized with |EVP_DigestSignInit|. The caller should +// configure the corresponding |EVP_PKEY_CTX| before calling this function. OPENSSL_EXPORT int X509_CRL_sign_ctx(X509_CRL *crl, EVP_MD_CTX *ctx); // i2d_re_X509_CRL_tbs serializes the TBSCertList portion of |crl|, as described @@ -710,7 +721,6 @@ OPENSSL_EXPORT X509_REQ *d2i_X509_REQ(X509_REQ **out, const uint8_t **inp, // mutated. OPENSSL_EXPORT int i2d_X509_REQ(X509_REQ *req, uint8_t **outp); - // X509_REQ_VERSION_1 is the version constant for |X509_REQ| objects. No other // versions are defined. #define X509_REQ_VERSION_1 0 @@ -731,6 +741,46 @@ OPENSSL_EXPORT X509_NAME *X509_REQ_get_subject_name(const X509_REQ *req); // |EVP_PKEY_free| when done. OPENSSL_EXPORT EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req); +// X509_REQ_get_attr_count returns the number of attributes in |req|. +OPENSSL_EXPORT int X509_REQ_get_attr_count(const X509_REQ *req); + +// X509_REQ_get_attr returns the attribute at index |loc| in |req|, or NULL if +// out of bounds. +OPENSSL_EXPORT X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc); + +// X509_REQ_get_attr_by_NID returns the index of the attribute in |req| of type +// |nid|, or a negative number if not found. If found, callers can use +// |X509_REQ_get_attr| to look up the attribute by index. +// +// If |lastpos| is non-negative, it begins searching at |lastpos| + 1. Callers +// can thus loop over all matching attributes by first passing -1 and then +// passing the previously-returned value until no match is returned. +OPENSSL_EXPORT int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, + int lastpos); + +// X509_REQ_get_attr_by_OBJ behaves like |X509_REQ_get_attr_by_NID| but looks +// for attributes of type |obj|. +OPENSSL_EXPORT int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, + const ASN1_OBJECT *obj, + int lastpos); + +// X509_REQ_extension_nid returns one if |nid| is a supported CSR attribute type +// for carrying extensions and zero otherwise. The supported types are +// |NID_ext_req| (pkcs-9-at-extensionRequest from RFC 2985) and |NID_ms_ext_req| +// (a Microsoft szOID_CERT_EXTENSIONS variant). +OPENSSL_EXPORT int X509_REQ_extension_nid(int nid); + +// X509_REQ_get_extensions decodes the list of requested extensions in |req| and +// returns a newly-allocated |STACK_OF(X509_EXTENSION)| containing the result. +// It returns NULL on error, or if |req| did not request extensions. +// +// CSRs do not store extensions directly. Instead there are attribute types +// which are defined to hold extensions. See |X509_REQ_extension_nid|. This +// function supports both pkcs-9-at-extensionRequest from RFC 2985 and the +// Microsoft szOID_CERT_EXTENSIONS variant. If both are present, +// pkcs-9-at-extensionRequest is preferred. +OPENSSL_EXPORT STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req); + // X509_REQ_get0_signature sets |*out_sig| and |*out_alg| to the signature and // signature algorithm of |req|, respectively. Either output pointer may be NULL // to ignore the value. @@ -743,6 +793,10 @@ OPENSSL_EXPORT void X509_REQ_get0_signature(const X509_REQ *req, // a known NID. OPENSSL_EXPORT int X509_REQ_get_signature_nid(const X509_REQ *req); +// X509_REQ_verify checks that |req| has a valid signature by |pkey|. It returns +// one if the signature is valid and zero otherwise. +OPENSSL_EXPORT int X509_REQ_verify(X509_REQ *req, EVP_PKEY *pkey); + // Issuing certificate requests. // @@ -770,19 +824,68 @@ OPENSSL_EXPORT int X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name); // and internally copies and updates reference counts as needed. OPENSSL_EXPORT int X509_REQ_set_pubkey(X509_REQ *req, EVP_PKEY *pkey); +// X509_REQ_delete_attr removes the attribute at index |loc| in |req|. It +// returns the removed attribute to the caller, or NULL if |loc| was out of +// bounds. If non-NULL, the caller must release the result with +// |X509_ATTRIBUTE_free| when done. It is also safe, but not necessary, to call +// |X509_ATTRIBUTE_free| if the result is NULL. +OPENSSL_EXPORT X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); + +// X509_REQ_add1_attr appends a copy of |attr| to |req|'s list of attributes. It +// returns one on success and zero on error. +OPENSSL_EXPORT int X509_REQ_add1_attr(X509_REQ *req, + const X509_ATTRIBUTE *attr); + +// X509_REQ_add1_attr_by_OBJ appends a new attribute to |req| with type |obj|. +// It returns one on success and zero on error. The value is determined by +// |X509_ATTRIBUTE_set1_data|. +// +// WARNING: The interpretation of |attrtype|, |data|, and |len| is complex and +// error-prone. See |X509_ATTRIBUTE_set1_data| for details. +OPENSSL_EXPORT int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, + const ASN1_OBJECT *obj, + int attrtype, + const unsigned char *data, + int len); + +// X509_REQ_add1_attr_by_NID behaves like |X509_REQ_add1_attr_by_OBJ| except the +// attribute type is determined by |nid|. +OPENSSL_EXPORT int X509_REQ_add1_attr_by_NID(X509_REQ *req, int nid, + int attrtype, + const unsigned char *data, + int len); + +// X509_REQ_add1_attr_by_txt behaves like |X509_REQ_add1_attr_by_OBJ| except the +// attribute type is determined by calling |OBJ_txt2obj| with |attrname|. +OPENSSL_EXPORT int X509_REQ_add1_attr_by_txt(X509_REQ *req, + const char *attrname, int attrtype, + const unsigned char *data, + int len); + +// X509_REQ_add_extensions_nid adds an attribute to |req| of type |nid|, to +// request the certificate extensions in |exts|. It returns one on success and +// zero on error. |nid| should be |NID_ext_req| or |NID_ms_ext_req|. +OPENSSL_EXPORT int X509_REQ_add_extensions_nid( + X509_REQ *req, const STACK_OF(X509_EXTENSION) *exts, int nid); + +// X509_REQ_add_extensions behaves like |X509_REQ_add_extensions_nid|, using the +// standard |NID_ext_req| for the attribute type. +OPENSSL_EXPORT int X509_REQ_add_extensions( + X509_REQ *req, const STACK_OF(X509_EXTENSION) *exts); + // X509_REQ_sign signs |req| with |pkey| and replaces the signature algorithm -// and signature fields. It returns one on success and zero on error. This -// function uses digest algorithm |md|, or |pkey|'s default if NULL. Other -// signing parameters use |pkey|'s defaults. To customize them, use -// |X509_REQ_sign_ctx|. +// and signature fields. It returns the length of the signature on success and +// zero on error. This function uses digest algorithm |md|, or |pkey|'s default +// if NULL. Other signing parameters use |pkey|'s defaults. To customize them, +// use |X509_REQ_sign_ctx|. OPENSSL_EXPORT int X509_REQ_sign(X509_REQ *req, EVP_PKEY *pkey, const EVP_MD *md); // X509_REQ_sign_ctx signs |req| with |ctx| and replaces the signature algorithm -// and signature fields. It returns one on success and zero on error. The -// signature algorithm and parameters come from |ctx|, which must have been -// initialized with |EVP_DigestSignInit|. The caller should configure the -// corresponding |EVP_PKEY_CTX| before calling this function. +// and signature fields. It returns the length of the signature on success and +// zero on error. The signature algorithm and parameters come from |ctx|, which +// must have been initialized with |EVP_DigestSignInit|. The caller should +// configure the corresponding |EVP_PKEY_CTX| before calling this function. OPENSSL_EXPORT int X509_REQ_sign_ctx(X509_REQ *req, EVP_MD_CTX *ctx); // i2d_re_X509_REQ_tbs serializes the CertificationRequestInfo (see RFC 2986) @@ -940,22 +1043,25 @@ OPENSSL_EXPORT int X509_NAME_add_entry(X509_NAME *name, // |set| as in |X509_NAME_add_entry|. OPENSSL_EXPORT int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type, - const uint8_t *bytes, int len, - int loc, int set); + const uint8_t *bytes, + ossl_ssize_t len, int loc, + int set); // X509_NAME_add_entry_by_NID behaves like |X509_NAME_add_entry_by_OBJ| but sets // the entry's attribute type to |nid|, which should be one of the |NID_*| // constants. OPENSSL_EXPORT int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, const uint8_t *bytes, - int len, int loc, int set); + ossl_ssize_t len, int loc, + int set); // X509_NAME_add_entry_by_txt behaves like |X509_NAME_add_entry_by_OBJ| but sets // the entry's attribute type to |field|, which is passed to |OBJ_txt2obj|. OPENSSL_EXPORT int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, - const uint8_t *bytes, int len, - int loc, int set); + const uint8_t *bytes, + ossl_ssize_t len, int loc, + int set); // X509_NAME_ENTRY is an |ASN1_ITEM| whose ASN.1 type is AttributeTypeAndValue // (RFC 5280) and C type is |X509_NAME_ENTRY*|. @@ -1021,7 +1127,8 @@ OPENSSL_EXPORT ASN1_STRING *X509_NAME_ENTRY_get_data( // See |ASN1_STRING| for how to format ASN.1 types as an |ASN1_STRING|. If // |type| is |V_ASN1_UNDEF| the previous |ASN1_STRING| type is reused. OPENSSL_EXPORT int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *entry, int type, - const uint8_t *bytes, int len); + const uint8_t *bytes, + ossl_ssize_t len); // X509_NAME_ENTRY_set returns the zero-based index of the RDN which contains // |entry|. Consecutive entries with the same index are part of the same RDN. @@ -1037,19 +1144,20 @@ OPENSSL_EXPORT int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *entry); // object at |*out| instead of allocating a new one. OPENSSL_EXPORT X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ( X509_NAME_ENTRY **out, const ASN1_OBJECT *obj, int type, - const uint8_t *bytes, int len); + const uint8_t *bytes, ossl_ssize_t len); // X509_NAME_ENTRY_create_by_NID behaves like |X509_NAME_ENTRY_create_by_OBJ| // except the attribute type is |nid|, which should be one of the |NID_*| // constants. OPENSSL_EXPORT X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID( - X509_NAME_ENTRY **out, int nid, int type, const uint8_t *bytes, int len); + X509_NAME_ENTRY **out, int nid, int type, const uint8_t *bytes, + ossl_ssize_t len); // X509_NAME_ENTRY_create_by_txt behaves like |X509_NAME_ENTRY_create_by_OBJ| // except the attribute type is |field|, which is passed to |OBJ_txt2obj|. OPENSSL_EXPORT X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt( X509_NAME_ENTRY **out, const char *field, int type, const uint8_t *bytes, - int len); + ossl_ssize_t len); // Extensions. @@ -1291,11 +1399,442 @@ OPENSSL_EXPORT void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md); OPENSSL_EXPORT int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b); +// Attributes. +// +// Unlike certificates and CRLs, CSRs use a separate Attribute structure (RFC +// 2985, RFC 2986) for extensibility. This is represented by the library as +// |X509_ATTRIBUTE|. + +DEFINE_STACK_OF(X509_ATTRIBUTE) + +// X509_ATTRIBUTE is an |ASN1_ITEM| whose ASN.1 type is Attribute (RFC 2986) and +// C type is |X509_ATTRIBUTE*|. +DECLARE_ASN1_ITEM(X509_ATTRIBUTE) + +// X509_ATTRIBUTE_new returns a newly-allocated, empty |X509_ATTRIBUTE| object, +// or NULL on error. |X509_ATTRIBUTE_set1_*| may be used to finish initializing +// it. +OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_new(void); + +// X509_ATTRIBUTE_dup returns a newly-allocated copy of |attr|, or NULL on +// error. This function works by serializing the structure, so if |attr| is +// incomplete, it may fail. +OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_dup(const X509_ATTRIBUTE *attr); + +// X509_ATTRIBUTE_free releases memory associated with |attr|. +OPENSSL_EXPORT void X509_ATTRIBUTE_free(X509_ATTRIBUTE *attr); + +// d2i_X509_ATTRIBUTE parses up to |len| bytes from |*inp| as a DER-encoded +// Attribute (RFC 2986), as described in |d2i_SAMPLE|. +OPENSSL_EXPORT X509_ATTRIBUTE *d2i_X509_ATTRIBUTE(X509_ATTRIBUTE **out, + const uint8_t **inp, + long len); + +// i2d_X509_ATTRIBUTE marshals |alg| as a DER-encoded Attribute (RFC 2986), as +// described in |i2d_SAMPLE|. +OPENSSL_EXPORT int i2d_X509_ATTRIBUTE(const X509_ATTRIBUTE *alg, + uint8_t **outp); + +// X509_ATTRIBUTE_create returns a newly-allocated |X509_ATTRIBUTE|, or NULL on +// error. The attribute has type |nid| and contains a single value determined by +// |attrtype| and |value|, which are interpreted as in |ASN1_TYPE_set|. Note +// this function takes ownership of |value|. +OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int attrtype, + void *value); + +// X509_ATTRIBUTE_create_by_NID returns a newly-allocated |X509_ATTRIBUTE| of +// type |nid|, or NULL on error. The value is determined as in +// |X509_ATTRIBUTE_set1_data|. +// +// If |attr| is non-NULL, the resulting |X509_ATTRIBUTE| is also written to +// |*attr|. If |*attr| was non-NULL when the function was called, |*attr| is +// reused instead of creating a new object. +// +// WARNING: The interpretation of |attrtype|, |data|, and |len| is complex and +// error-prone. See |X509_ATTRIBUTE_set1_data| for details. +// +// WARNING: The object reuse form is deprecated and may be removed in the +// future. It also currently incorrectly appends to the reused object's value +// set rather than overwriting it. +OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID( + X509_ATTRIBUTE **attr, int nid, int attrtype, const void *data, int len); + +// X509_ATTRIBUTE_create_by_OBJ behaves like |X509_ATTRIBUTE_create_by_NID| +// except the attribute's type is determined by |obj|. +OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ( + X509_ATTRIBUTE **attr, const ASN1_OBJECT *obj, int attrtype, + const void *data, int len); + +// X509_ATTRIBUTE_create_by_txt behaves like |X509_ATTRIBUTE_create_by_NID| +// except the attribute's type is determined by calling |OBJ_txt2obj| with +// |attrname|. +OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt( + X509_ATTRIBUTE **attr, const char *attrname, int type, + const unsigned char *bytes, int len); + +// X509_ATTRIBUTE_set1_object sets |attr|'s type to |obj|. It returns one on +// success and zero on error. +OPENSSL_EXPORT int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, + const ASN1_OBJECT *obj); + +// X509_ATTRIBUTE_set1_data appends a value to |attr|'s value set and returns +// one on success or zero on error. The value is determined as follows: +// +// If |attrtype| is a |MBSTRING_*| constant, the value is an ASN.1 string. The +// string is determined by decoding |len| bytes from |data| in the encoding +// specified by |attrtype|, and then re-encoding it in a form appropriate for +// |attr|'s type. If |len| is -1, |strlen(data)| is used instead. See +// |ASN1_STRING_set_by_NID| for details. +// +// Otherwise, if |len| is not -1, the value is an ASN.1 string. |attrtype| is an +// |ASN1_STRING| type value and the |len| bytes from |data| are copied as the +// type-specific representation of |ASN1_STRING|. See |ASN1_STRING| for details. +// +// WARNING: If this form is used to construct a negative INTEGER or ENUMERATED, +// |attrtype| includes the |V_ASN1_NEG| flag for |ASN1_STRING|, but the function +// forgets to clear the flag for |ASN1_TYPE|. This matches OpenSSL but is +// probably a bug. For now, do not use this form with negative values. +// +// Otherwise, if |len| is -1, the value is constructed by passing |attrtype| and +// |data| to |ASN1_TYPE_set1|. That is, |attrtype| is an |ASN1_TYPE| type value, +// and |data| is cast to the corresponding pointer type. +// +// WARNING: Despite the name, this function appends to |attr|'s value set, +// rather than overwriting it. To overwrite the value set, create a new +// |X509_ATTRIBUTE| with |X509_ATTRIBUTE_new|. +// +// WARNING: If using the |MBSTRING_*| form, pass a length rather than relying on +// |strlen|. In particular, |strlen| will not behave correctly if the input is +// |MBSTRING_BMP| or |MBSTRING_UNIV|. +// +// WARNING: This function currently misinterprets |V_ASN1_OTHER| as an +// |MBSTRING_*| constant. This matches OpenSSL but means it is impossible to +// construct a value with a non-universal tag. +OPENSSL_EXPORT int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, + const void *data, int len); + +// X509_ATTRIBUTE_get0_data returns the |idx|th value of |attr| in a +// type-specific representation to |attrtype|, or NULL if out of bounds or the +// type does not match. |attrtype| is one of the type values in |ASN1_TYPE|. On +// match, the return value uses the same representation as |ASN1_TYPE_set0|. See +// |ASN1_TYPE| for details. +OPENSSL_EXPORT void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, + int attrtype, void *unused); + +// X509_ATTRIBUTE_count returns the number of values in |attr|. +OPENSSL_EXPORT int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr); + +// X509_ATTRIBUTE_get0_object returns the type of |attr|. +OPENSSL_EXPORT ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr); + +// X509_ATTRIBUTE_get0_type returns the |idx|th value in |attr|, or NULL if out +// of bounds. Note this function returns one of |attr|'s values, not the type. +OPENSSL_EXPORT ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, + int idx); + + +// SignedPublicKeyAndChallenge structures. +// +// The SignedPublicKeyAndChallenge (SPKAC) is a legacy structure to request +// certificates, primarily in the legacy HTML tag. An SPKAC structure +// is represented by a |NETSCAPE_SPKI| structure. +// +// The structure is described in +// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/keygen + +// A Netscape_spki_st, or |NETSCAPE_SPKI|, represents a +// SignedPublicKeyAndChallenge structure. Although this structure contains a +// |spkac| field of type |NETSCAPE_SPKAC|, these are misnamed. The SPKAC is the +// entire structure, not the signed portion. +struct Netscape_spki_st { + NETSCAPE_SPKAC *spkac; + X509_ALGOR *sig_algor; + ASN1_BIT_STRING *signature; +} /* NETSCAPE_SPKI */; + +// NETSCAPE_SPKI is an |ASN1_ITEM| whose ASN.1 type is +// SignedPublicKeyAndChallenge and C type is |NETSCAPE_SPKI*|. +DECLARE_ASN1_ITEM(NETSCAPE_SPKI) + +// NETSCAPE_SPKI_new returns a newly-allocated, empty |NETSCAPE_SPKI| object, or +// NULL on error. +OPENSSL_EXPORT NETSCAPE_SPKI *NETSCAPE_SPKI_new(void); + +// NETSCAPE_SPKI_free releases memory associated with |spki|. +OPENSSL_EXPORT void NETSCAPE_SPKI_free(NETSCAPE_SPKI *spki); + +// d2i_NETSCAPE_SPKI parses up to |len| bytes from |*inp| as a DER-encoded +// SignedPublicKeyAndChallenge structure, as described in |d2i_SAMPLE|. +OPENSSL_EXPORT NETSCAPE_SPKI *d2i_NETSCAPE_SPKI(NETSCAPE_SPKI **out, + const uint8_t **inp, long len); + +// i2d_NETSCAPE_SPKI marshals |spki| as a DER-encoded +// SignedPublicKeyAndChallenge structure, as described in |i2d_SAMPLE|. +OPENSSL_EXPORT int i2d_NETSCAPE_SPKI(const NETSCAPE_SPKI *spki, uint8_t **outp); + +// NETSCAPE_SPKI_verify checks that |spki| has a valid signature by |pkey|. It +// returns one if the signature is valid and zero otherwise. +OPENSSL_EXPORT int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *spki, EVP_PKEY *pkey); + +// NETSCAPE_SPKI_b64_decode decodes |len| bytes from |str| as a base64-encoded +// SignedPublicKeyAndChallenge structure. It returns a newly-allocated +// |NETSCAPE_SPKI| structure with the result, or NULL on error. If |len| is 0 or +// negative, the length is calculated with |strlen| and |str| must be a +// NUL-terminated C string. +OPENSSL_EXPORT NETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, + ossl_ssize_t len); + +// NETSCAPE_SPKI_b64_encode encodes |spki| as a base64-encoded +// SignedPublicKeyAndChallenge structure. It returns a newly-allocated +// NUL-terminated C string with the result, or NULL on error. The caller must +// release the memory with |OPENSSL_free| when done. +OPENSSL_EXPORT char *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *spki); + +// NETSCAPE_SPKI_get_pubkey decodes and returns the public key in |spki| as an +// |EVP_PKEY|, or NULL on error. The caller takes ownership of the resulting +// pointer and must call |EVP_PKEY_free| when done. +OPENSSL_EXPORT EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *spki); + +// NETSCAPE_SPKI_set_pubkey sets |spki|'s public key to |pkey|. It returns one +// on success or zero on error. This function does not take ownership of |pkey|, +// so the caller may continue to manage its lifetime independently of |spki|. +OPENSSL_EXPORT int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *spki, + EVP_PKEY *pkey); + +// NETSCAPE_SPKI_sign signs |spki| with |pkey| and replaces the signature +// algorithm and signature fields. It returns the length of the signature on +// success and zero on error. This function uses digest algorithm |md|, or +// |pkey|'s default if NULL. Other signing parameters use |pkey|'s defaults. +OPENSSL_EXPORT int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *spki, EVP_PKEY *pkey, + const EVP_MD *md); + +// A Netscape_spkac_st, or |NETSCAPE_SPKAC|, represents a PublicKeyAndChallenge +// structure. This type is misnamed. The full SPKAC includes the signature, +// which is represented with the |NETSCAPE_SPKI| type. +struct Netscape_spkac_st { + X509_PUBKEY *pubkey; + ASN1_IA5STRING *challenge; +} /* NETSCAPE_SPKAC */; + +// NETSCAPE_SPKAC is an |ASN1_ITEM| whose ASN.1 type is PublicKeyAndChallenge +// and C type is |NETSCAPE_SPKAC*|. +DECLARE_ASN1_ITEM(NETSCAPE_SPKAC) + +// NETSCAPE_SPKAC_new returns a newly-allocated, empty |NETSCAPE_SPKAC| object, +// or NULL on error. +OPENSSL_EXPORT NETSCAPE_SPKAC *NETSCAPE_SPKAC_new(void); + +// NETSCAPE_SPKAC_free releases memory associated with |spkac|. +OPENSSL_EXPORT void NETSCAPE_SPKAC_free(NETSCAPE_SPKAC *spkac); + +// d2i_NETSCAPE_SPKAC parses up to |len| bytes from |*inp| as a DER-encoded +// PublicKeyAndChallenge structure, as described in |d2i_SAMPLE|. +OPENSSL_EXPORT NETSCAPE_SPKAC *d2i_NETSCAPE_SPKAC(NETSCAPE_SPKAC **out, + const uint8_t **inp, + long len); + +// i2d_NETSCAPE_SPKAC marshals |spkac| as a DER-encoded PublicKeyAndChallenge +// structure, as described in |i2d_SAMPLE|. +OPENSSL_EXPORT int i2d_NETSCAPE_SPKAC(const NETSCAPE_SPKAC *spkac, + uint8_t **outp); + + // Printing functions. // // The following functions output human-readable representations of // X.509-related structures. They should only be used for debugging or logging -// and not parsed programmatically. +// and not parsed programmatically. In many cases, the outputs are ambiguous, so +// attempting to parse them can lead to string injection vulnerabilities. + +// The following flags control |X509_print_ex| and |X509_REQ_print_ex|. + +// X509_FLAG_COMPAT disables all flags. It additionally causes names to be +// printed with a 16-byte indent. +#define X509_FLAG_COMPAT 0 + +// X509_FLAG_NO_HEADER skips a header identifying the type of object printed. +#define X509_FLAG_NO_HEADER 1L + +// X509_FLAG_NO_VERSION skips printing the X.509 version number. +#define X509_FLAG_NO_VERSION (1L << 1) + +// X509_FLAG_NO_SERIAL skips printing the serial number. It is ignored in +// |X509_REQ_print_fp|. +#define X509_FLAG_NO_SERIAL (1L << 2) + +// X509_FLAG_NO_SIGNAME skips printing the signature algorithm in the +// TBSCertificate. It is ignored in |X509_REQ_print_fp|. +#define X509_FLAG_NO_SIGNAME (1L << 3) + +// X509_FLAG_NO_ISSUER skips printing the issuer. +#define X509_FLAG_NO_ISSUER (1L << 4) + +// X509_FLAG_NO_VALIDITY skips printing the notBefore and notAfter times. It is +// ignored in |X509_REQ_print_fp|. +#define X509_FLAG_NO_VALIDITY (1L << 5) + +// X509_FLAG_NO_SUBJECT skips printing the subject. +#define X509_FLAG_NO_SUBJECT (1L << 6) + +// X509_FLAG_NO_PUBKEY skips printing the public key. +#define X509_FLAG_NO_PUBKEY (1L << 7) + +// X509_FLAG_NO_EXTENSIONS skips printing the extension list. It is ignored in +// |X509_REQ_print_fp|. CSRs instead have attributes, which is controlled by +// |X509_FLAG_NO_ATTRIBUTES|. +#define X509_FLAG_NO_EXTENSIONS (1L << 8) + +// X509_FLAG_NO_SIGDUMP skips printing the signature and outer signature +// algorithm. +#define X509_FLAG_NO_SIGDUMP (1L << 9) + +// X509_FLAG_NO_AUX skips printing auxiliary properties. (See |d2i_X509_AUX| and +// related functions.) +#define X509_FLAG_NO_AUX (1L << 10) + +// X509_FLAG_NO_ATTRIBUTES skips printing CSR attributes. It does nothing for +// certificates and CRLs. +#define X509_FLAG_NO_ATTRIBUTES (1L << 11) + +// X509_FLAG_NO_IDS skips printing the issuerUniqueID and subjectUniqueID in a +// certificate. It is ignored in |X509_REQ_print_fp|. +#define X509_FLAG_NO_IDS (1L << 12) + +// X509_print_ex writes a human-readable representation of |x| to |bp|. It +// returns one on success and zero on error. |nmflags| is the flags parameter +// for |X509_NAME_print_ex| when printing the subject and issuer. |cflag| should +// be some combination of the |X509_FLAG_*| constants. +OPENSSL_EXPORT int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag, + unsigned long cflag); + +// X509_print_ex_fp behaves like |X509_print_ex| but writes to |fp|. +OPENSSL_EXPORT int X509_print_ex_fp(FILE *fp, X509 *x, unsigned long nmflag, + unsigned long cflag); + +// X509_print calls |X509_print_ex| with |XN_FLAG_COMPAT| and |X509_FLAG_COMPAT| +// flags. +OPENSSL_EXPORT int X509_print(BIO *bp, X509 *x); + +// X509_print_fp behaves like |X509_print| but writes to |fp|. +OPENSSL_EXPORT int X509_print_fp(FILE *fp, X509 *x); + +// X509_CRL_print writes a human-readable representation of |x| to |bp|. It +// returns one on success and zero on error. +OPENSSL_EXPORT int X509_CRL_print(BIO *bp, X509_CRL *x); + +// X509_CRL_print_fp behaves like |X509_CRL_print| but writes to |fp|. +OPENSSL_EXPORT int X509_CRL_print_fp(FILE *fp, X509_CRL *x); + +// X509_REQ_print_ex writes a human-readable representation of |x| to |bp|. It +// returns one on success and zero on error. |nmflags| is the flags parameter +// for |X509_NAME_print_ex|, when printing the subject. |cflag| should be some +// combination of the |X509_FLAG_*| constants. +OPENSSL_EXPORT int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, + unsigned long cflag); + +// X509_REQ_print calls |X509_REQ_print_ex| with |XN_FLAG_COMPAT| and +// |X509_FLAG_COMPAT| flags. +OPENSSL_EXPORT int X509_REQ_print(BIO *bp, X509_REQ *req); + +// X509_REQ_print_fp behaves like |X509_REQ_print| but writes to |fp|. +OPENSSL_EXPORT int X509_REQ_print_fp(FILE *fp, X509_REQ *req); + +// The following flags are control |X509_NAME_print_ex|. They must not collide +// with |ASN1_STRFLGS_*|. +// +// TODO(davidben): This is far, far too many options and most of them are +// useless. Trim this down. + +// XN_FLAG_COMPAT prints with |X509_NAME_print|'s format and return value +// convention. +#define XN_FLAG_COMPAT 0 + +// XN_FLAG_SEP_MASK determines the separators to use between attributes. +#define XN_FLAG_SEP_MASK (0xf << 16) + +// XN_FLAG_SEP_COMMA_PLUS separates RDNs with "," and attributes within an RDN +// with "+", as in RFC 2253. +#define XN_FLAG_SEP_COMMA_PLUS (1 << 16) + +// XN_FLAG_SEP_CPLUS_SPC behaves like |XN_FLAG_SEP_COMMA_PLUS| but adds spaces +// between the separators. +#define XN_FLAG_SEP_CPLUS_SPC (2 << 16) + +// XN_FLAG_SEP_SPLUS_SPC separates RDNs with "; " and attributes within an RDN +// with " + ". +#define XN_FLAG_SEP_SPLUS_SPC (3 << 16) + +// XN_FLAG_SEP_MULTILINE prints each attribute on one line. +#define XN_FLAG_SEP_MULTILINE (4 << 16) + +// XN_FLAG_DN_REV prints RDNs in reverse, from least significant to most +// significant, as RFC 2253. +#define XN_FLAG_DN_REV (1 << 20) + +// XN_FLAG_FN_MASK determines how attribute types are displayed. +#define XN_FLAG_FN_MASK (0x3 << 21) + +// XN_FLAG_FN_SN uses the attribute type's short name, when available. +#define XN_FLAG_FN_SN 0 + +// XN_FLAG_SPC_EQ wraps the "=" operator with spaces when printing attributes. +#define XN_FLAG_SPC_EQ (1 << 23) + +// XN_FLAG_DUMP_UNKNOWN_FIELDS causes unknown attribute types to be printed in +// hex, as in RFC 2253. +#define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24) + +// XN_FLAG_RFC2253 prints like RFC 2253. +#define XN_FLAG_RFC2253 \ + (ASN1_STRFLGS_RFC2253 | XN_FLAG_SEP_COMMA_PLUS | XN_FLAG_DN_REV | \ + XN_FLAG_FN_SN | XN_FLAG_DUMP_UNKNOWN_FIELDS) + +// XN_FLAG_ONELINE prints a one-line representation of the name. +#define XN_FLAG_ONELINE \ + (ASN1_STRFLGS_RFC2253 | ASN1_STRFLGS_ESC_QUOTE | XN_FLAG_SEP_CPLUS_SPC | \ + XN_FLAG_SPC_EQ | XN_FLAG_FN_SN) + +// X509_NAME_print_ex writes a human-readable representation of |nm| to |out|. +// Each line of output is indented by |indent| spaces. It returns the number of +// bytes written on success, and -1 on error. If |out| is NULL, it returns the +// number of bytes it would have written but does not write anything. |flags| +// should be some combination of |XN_FLAG_*| and |ASN1_STRFLGS_*| values and +// determines the output. If unsure, use |XN_FLAG_RFC2253|. +// +// If |flags| is |XN_FLAG_COMPAT|, or zero, this function calls +// |X509_NAME_print| instead. In that case, it returns one on success, rather +// than the output length. +OPENSSL_EXPORT int X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent, + unsigned long flags); + +// X509_NAME_print prints a human-readable representation of |name| to |bp|. It +// returns one on success and zero on error. |obase| is ignored. +// +// This function outputs a legacy format that does not correctly handle string +// encodings and other cases. Prefer |X509_NAME_print_ex| if printing a name for +// debugging purposes. +OPENSSL_EXPORT int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase); + +// X509_NAME_oneline writes a human-readable representation to |name| to a +// buffer as a NUL-terminated C string. +// +// If |buf| is NULL, returns a newly-allocated buffer containing the result on +// success, or NULL on error. The buffer must be released with |OPENSSL_free| +// when done. +// +// If |buf| is non-NULL, at most |size| bytes of output are written to |buf| +// instead. |size| includes the trailing NUL. The function then returns |buf| on +// success or NULL on error. If the output does not fit in |size| bytes, the +// output is silently truncated at an attribute boundary. +// +// This function outputs a legacy format that does not correctly handle string +// encodings and other cases. Prefer |X509_NAME_print_ex| if printing a name for +// debugging purposes. +OPENSSL_EXPORT char *X509_NAME_oneline(const X509_NAME *name, char *buf, int size); + +// X509_NAME_print_ex_fp behaves like |X509_NAME_print_ex| but writes to |fp|. +OPENSSL_EXPORT int X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, + int indent, unsigned long flags); // X509_signature_dump writes a human-readable representation of |sig| to |bio|, // indented with |indent| spaces. It returns one on success and zero on error. @@ -1454,6 +1993,39 @@ OPENSSL_EXPORT X509 *X509_find_by_issuer_and_serial(const STACK_OF(X509) *sk, OPENSSL_EXPORT X509 *X509_find_by_subject(const STACK_OF(X509) *sk, X509_NAME *name); +// X509_cmp_time compares |s| against |*t|. On success, it returns a negative +// number if |s| <= |*t| and a positive number if |s| > |*t|. On error, it +// returns zero. If |t| is NULL, it uses the current time instead of |*t|. +// +// WARNING: Unlike most comparison functions, this function returns zero on +// error, not equality. +OPENSSL_EXPORT int X509_cmp_time(const ASN1_TIME *s, const time_t *t); + +// X509_cmp_time_posix compares |s| against |t|. On success, it returns a +// negative number if |s| <= |t| and a positive number if |s| > |t|. On error, +// it returns zero. +// +// WARNING: Unlike most comparison functions, this function returns zero on +// error, not equality. +OPENSSL_EXPORT int X509_cmp_time_posix(const ASN1_TIME *s, int64_t t); + +// X509_cmp_current_time behaves like |X509_cmp_time| but compares |s| against +// the current time. +OPENSSL_EXPORT int X509_cmp_current_time(const ASN1_TIME *s); + +// X509_time_adj calls |X509_time_adj_ex| with |offset_day| equal to zero. +OPENSSL_EXPORT ASN1_TIME *X509_time_adj(ASN1_TIME *s, long offset_sec, + const time_t *t); + +// X509_time_adj_ex behaves like |ASN1_TIME_adj|, but adds an offset to |*t|. If +// |t| is NULL, it uses the current time instead of |*t|. +OPENSSL_EXPORT ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s, int offset_day, + long offset_sec, const time_t *t); + +// X509_gmtime_adj behaves like |X509_time_adj_ex| but adds |offset_sec| to the +// current time. +OPENSSL_EXPORT ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long offset_sec); + // ex_data functions. // @@ -1575,8 +2147,6 @@ struct X509_algor_st { #define X509v3_KU_DECIPHER_ONLY 0x8000 #define X509v3_KU_UNDEF 0xffff -DEFINE_STACK_OF(X509_ATTRIBUTE) - // This stuff is certificate "auxiliary info" // it contains details which are useful in certificate // stores and databases. When used this is tagged onto @@ -1626,74 +2196,6 @@ DEFINE_STACK_OF(X509_TRUST) #define X509_TRUST_REJECTED 2 #define X509_TRUST_UNTRUSTED 3 -// Flags for X509_print_ex() - -#define X509_FLAG_COMPAT 0 -#define X509_FLAG_NO_HEADER 1L -#define X509_FLAG_NO_VERSION (1L << 1) -#define X509_FLAG_NO_SERIAL (1L << 2) -#define X509_FLAG_NO_SIGNAME (1L << 3) -#define X509_FLAG_NO_ISSUER (1L << 4) -#define X509_FLAG_NO_VALIDITY (1L << 5) -#define X509_FLAG_NO_SUBJECT (1L << 6) -#define X509_FLAG_NO_PUBKEY (1L << 7) -#define X509_FLAG_NO_EXTENSIONS (1L << 8) -#define X509_FLAG_NO_SIGDUMP (1L << 9) -#define X509_FLAG_NO_AUX (1L << 10) -#define X509_FLAG_NO_ATTRIBUTES (1L << 11) -#define X509_FLAG_NO_IDS (1L << 12) - -// Flags specific to X509_NAME_print_ex(). These flags must not collide with -// |ASN1_STRFLGS_*|. - -// The field separator information - -#define XN_FLAG_SEP_MASK (0xf << 16) - -#define XN_FLAG_COMPAT 0 // Traditional SSLeay: use old X509_NAME_print -#define XN_FLAG_SEP_COMMA_PLUS (1 << 16) // RFC 2253 ,+ -#define XN_FLAG_SEP_CPLUS_SPC (2 << 16) // ,+ spaced: more readable -#define XN_FLAG_SEP_SPLUS_SPC (3 << 16) // ;+ spaced -#define XN_FLAG_SEP_MULTILINE (4 << 16) // One line per field - -#define XN_FLAG_DN_REV (1 << 20) // Reverse DN order - -// How the field name is shown - -#define XN_FLAG_FN_MASK (0x3 << 21) - -#define XN_FLAG_FN_SN 0 // Object short name -#define XN_FLAG_FN_LN (1 << 21) // Object long name -#define XN_FLAG_FN_OID (2 << 21) // Always use OIDs -#define XN_FLAG_FN_NONE (3 << 21) // No field names - -#define XN_FLAG_SPC_EQ (1 << 23) // Put spaces round '=' - -// This determines if we dump fields we don't recognise: -// RFC 2253 requires this. - -#define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24) - -#define XN_FLAG_FN_ALIGN (1 << 25) // Align field names to 20 characters - -// Complete set of RFC 2253 flags - -#define XN_FLAG_RFC2253 \ - (ASN1_STRFLGS_RFC2253 | XN_FLAG_SEP_COMMA_PLUS | XN_FLAG_DN_REV | \ - XN_FLAG_FN_SN | XN_FLAG_DUMP_UNKNOWN_FIELDS) - -// readable oneline form - -#define XN_FLAG_ONELINE \ - (ASN1_STRFLGS_RFC2253 | ASN1_STRFLGS_ESC_QUOTE | XN_FLAG_SEP_CPLUS_SPC | \ - XN_FLAG_SPC_EQ | XN_FLAG_FN_SN) - -// readable multiline form - -#define XN_FLAG_MULTILINE \ - (ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB | XN_FLAG_SEP_MULTILINE | \ - XN_FLAG_SPC_EQ | XN_FLAG_FN_LN | XN_FLAG_FN_ALIGN) - DEFINE_STACK_OF(X509_REVOKED) DECLARE_STACK_OF(GENERAL_NAMES) @@ -1729,20 +2231,6 @@ struct X509_info_st { DEFINE_STACK_OF(X509_INFO) -// The next 2 structures and their 8 routines were sent to me by -// Pat Richard and are used to manipulate -// Netscapes spki structures - useful if you are writing a CA web page -struct Netscape_spkac_st { - X509_PUBKEY *pubkey; - ASN1_IA5STRING *challenge; // challenge sent in atlas >= PR2 -} /* NETSCAPE_SPKAC */; - -struct Netscape_spki_st { - NETSCAPE_SPKAC *spkac; // signed public key and challenge - X509_ALGOR *sig_algor; - ASN1_BIT_STRING *signature; -} /* NETSCAPE_SPKI */; - // X509_get_pathlen returns path length constraint from the basic constraints // extension in |x509|. (See RFC 5280, section 4.2.1.9.) It returns -1 if the // constraint is not present, or if some extension in |x509| was invalid. @@ -1768,99 +2256,11 @@ OPENSSL_EXPORT void X509_SIG_getm(X509_SIG *sig, X509_ALGOR **out_alg, // a default description. OPENSSL_EXPORT const char *X509_verify_cert_error_string(long err); -// X509_verify checks that |x509| has a valid signature by |pkey|. It returns -// one if the signature is valid and zero otherwise. Note this function only -// checks the signature itself and does not perform a full certificate -// validation. -OPENSSL_EXPORT int X509_verify(X509 *x509, EVP_PKEY *pkey); - -// X509_REQ_verify checks that |req| has a valid signature by |pkey|. It returns -// one if the signature is valid and zero otherwise. -OPENSSL_EXPORT int X509_REQ_verify(X509_REQ *req, EVP_PKEY *pkey); - -// X509_CRL_verify checks that |crl| has a valid signature by |pkey|. It returns -// one if the signature is valid and zero otherwise. -OPENSSL_EXPORT int X509_CRL_verify(X509_CRL *crl, EVP_PKEY *pkey); - -// NETSCAPE_SPKI_verify checks that |spki| has a valid signature by |pkey|. It -// returns one if the signature is valid and zero otherwise. -OPENSSL_EXPORT int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *spki, EVP_PKEY *pkey); - -// NETSCAPE_SPKI_b64_decode decodes |len| bytes from |str| as a base64-encoded -// Netscape signed public key and challenge (SPKAC) structure. It returns a -// newly-allocated |NETSCAPE_SPKI| structure with the result, or NULL on error. -// If |len| is 0 or negative, the length is calculated with |strlen| and |str| -// must be a NUL-terminated C string. -OPENSSL_EXPORT NETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, - ossl_ssize_t len); - -// NETSCAPE_SPKI_b64_encode encodes |spki| as a base64-encoded Netscape signed -// public key and challenge (SPKAC) structure. It returns a newly-allocated -// NUL-terminated C string with the result, or NULL on error. The caller must -// release the memory with |OPENSSL_free| when done. -OPENSSL_EXPORT char *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *spki); - -// NETSCAPE_SPKI_get_pubkey decodes and returns the public key in |spki| as an -// |EVP_PKEY|, or NULL on error. The caller takes ownership of the resulting -// pointer and must call |EVP_PKEY_free| when done. -OPENSSL_EXPORT EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *spki); - -// NETSCAPE_SPKI_set_pubkey sets |spki|'s public key to |pkey|. It returns one -// on success or zero on error. This function does not take ownership of |pkey|, -// so the caller may continue to manage its lifetime independently of |spki|. -OPENSSL_EXPORT int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *spki, - EVP_PKEY *pkey); - -// NETSCAPE_SPKI_sign signs |spki| with |pkey| and replaces the signature -// algorithm and signature fields. It returns one on success and zero on error. -// This function uses digest algorithm |md|, or |pkey|'s default if NULL. Other -// signing parameters use |pkey|'s defaults. -OPENSSL_EXPORT int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *spki, EVP_PKEY *pkey, - const EVP_MD *md); - -// X509_ATTRIBUTE_dup returns a newly-allocated copy of |xa|, or NULL on error. -// This function works by serializing the structure, so if |xa| is incomplete, -// it may fail. -OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_dup(const X509_ATTRIBUTE *xa); - // X509_REVOKED_dup returns a newly-allocated copy of |rev|, or NULL on error. // This function works by serializing the structure, so if |rev| is incomplete, // it may fail. OPENSSL_EXPORT X509_REVOKED *X509_REVOKED_dup(const X509_REVOKED *rev); -// X509_cmp_time compares |s| against |*t|. On success, it returns a negative -// number if |s| <= |*t| and a positive number if |s| > |*t|. On error, it -// returns zero. If |t| is NULL, it uses the current time instead of |*t|. -// -// WARNING: Unlike most comparison functions, this function returns zero on -// error, not equality. -OPENSSL_EXPORT int X509_cmp_time(const ASN1_TIME *s, time_t *t); - -// X509_cmp_time_posix compares |s| against |t|. On success, it returns a -// negative number if |s| <= |t| and a positive number if |s| > |t|. On error, -// it returns zero. -// -// WARNING: Unlike most comparison functions, this function returns zero on -// error, not equality. -OPENSSL_EXPORT int X509_cmp_time_posix(const ASN1_TIME *s, int64_t t); - -// X509_cmp_current_time behaves like |X509_cmp_time| but compares |s| against -// the current time. -OPENSSL_EXPORT int X509_cmp_current_time(const ASN1_TIME *s); - -// X509_time_adj calls |X509_time_adj_ex| with |offset_day| equal to zero. -OPENSSL_EXPORT ASN1_TIME *X509_time_adj(ASN1_TIME *s, long offset_sec, - time_t *t); - -// X509_time_adj_ex behaves like |ASN1_TIME_adj|, but adds an offset to |*t|. If -// |t| is NULL, it uses the current time instead of |*t|. -OPENSSL_EXPORT ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s, int offset_day, - long offset_sec, time_t *t); - -// X509_gmtime_adj behaves like |X509_time_adj_ex| but adds |offset_sec| to the -// current time. -OPENSSL_EXPORT ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long offset_sec); - OPENSSL_EXPORT const char *X509_get_default_cert_area(void); OPENSSL_EXPORT const char *X509_get_default_cert_dir(void); OPENSSL_EXPORT const char *X509_get_default_cert_file(void); @@ -1883,15 +2283,6 @@ OPENSSL_EXPORT EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key); DECLARE_ASN1_FUNCTIONS_const(X509_SIG) -DECLARE_ASN1_FUNCTIONS_const(X509_ATTRIBUTE) - -// X509_ATTRIBUTE_create returns a newly-allocated |X509_ATTRIBUTE|, or NULL on -// error. The attribute has type |nid| and contains a single value determined by -// |attrtype| and |value|, which are interpreted as in |ASN1_TYPE_set|. Note -// this function takes ownership of |value|. -OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int attrtype, - void *value); - OPENSSL_EXPORT int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj); OPENSSL_EXPORT int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj); OPENSSL_EXPORT void X509_trust_clear(X509 *x); @@ -1911,12 +2302,8 @@ OPENSSL_EXPORT int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, OPENSSL_EXPORT X509_PKEY *X509_PKEY_new(void); OPENSSL_EXPORT void X509_PKEY_free(X509_PKEY *a); -DECLARE_ASN1_FUNCTIONS_const(NETSCAPE_SPKI) -DECLARE_ASN1_FUNCTIONS_const(NETSCAPE_SPKAC) - OPENSSL_EXPORT X509_INFO *X509_INFO_new(void); OPENSSL_EXPORT void X509_INFO_free(X509_INFO *a); -OPENSSL_EXPORT char *X509_NAME_oneline(const X509_NAME *a, char *buf, int size); OPENSSL_EXPORT int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data, unsigned char *md, unsigned int *len); @@ -1939,93 +2326,6 @@ OPENSSL_EXPORT int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, ASN1_BIT_STRING *signature, void *asn, EVP_MD_CTX *ctx); -// X509_REQ_extension_nid returns one if |nid| is a supported CSR attribute type -// for carrying extensions and zero otherwise. The supported types are -// |NID_ext_req| (pkcs-9-at-extensionRequest from RFC 2985) and |NID_ms_ext_req| -// (a Microsoft szOID_CERT_EXTENSIONS variant). -OPENSSL_EXPORT int X509_REQ_extension_nid(int nid); - -// X509_REQ_get_extensions decodes the list of requested extensions in |req| and -// returns a newly-allocated |STACK_OF(X509_EXTENSION)| containing the result. -// It returns NULL on error, or if |req| did not request extensions. -// -// This function supports both pkcs-9-at-extensionRequest from RFC 2985 and the -// Microsoft szOID_CERT_EXTENSIONS variant. -OPENSSL_EXPORT STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req); - -// X509_REQ_add_extensions_nid adds an attribute to |req| of type |nid|, to -// request the certificate extensions in |exts|. It returns one on success and -// zero on error. |nid| should be |NID_ext_req| or |NID_ms_ext_req|. -OPENSSL_EXPORT int X509_REQ_add_extensions_nid( - X509_REQ *req, const STACK_OF(X509_EXTENSION) *exts, int nid); - -// X509_REQ_add_extensions behaves like |X509_REQ_add_extensions_nid|, using the -// standard |NID_ext_req| for the attribute type. -OPENSSL_EXPORT int X509_REQ_add_extensions( - X509_REQ *req, const STACK_OF(X509_EXTENSION) *exts); - -// X509_REQ_get_attr_count returns the number of attributes in |req|. -OPENSSL_EXPORT int X509_REQ_get_attr_count(const X509_REQ *req); - -// X509_REQ_get_attr_by_NID returns the index of the attribute in |req| of type -// |nid|, or a negative number if not found. If found, callers can use -// |X509_REQ_get_attr| to look up the attribute by index. -// -// If |lastpos| is non-negative, it begins searching at |lastpos| + 1. Callers -// can thus loop over all matching attributes by first passing -1 and then -// passing the previously-returned value until no match is returned. -OPENSSL_EXPORT int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, - int lastpos); - -// X509_REQ_get_attr_by_OBJ behaves like |X509_REQ_get_attr_by_NID| but looks -// for attributes of type |obj|. -OPENSSL_EXPORT int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, - const ASN1_OBJECT *obj, - int lastpos); - -// X509_REQ_get_attr returns the attribute at index |loc| in |req|, or NULL if -// out of bounds. -OPENSSL_EXPORT X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc); - -// X509_REQ_delete_attr removes the attribute at index |loc| in |req|. It -// returns the removed attribute to the caller, or NULL if |loc| was out of -// bounds. If non-NULL, the caller must release the result with -// |X509_ATTRIBUTE_free| when done. It is also safe, but not necessary, to call -// |X509_ATTRIBUTE_free| if the result is NULL. -OPENSSL_EXPORT X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); - -// X509_REQ_add1_attr appends a copy of |attr| to |req|'s list of attributes. It -// returns one on success and zero on error. -// -// TODO(https://crbug.com/boringssl/407): |attr| should be const. -OPENSSL_EXPORT int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr); - -// X509_REQ_add1_attr_by_OBJ appends a new attribute to |req| with type |obj|. -// It returns one on success and zero on error. The value is determined by -// |X509_ATTRIBUTE_set1_data|. -// -// WARNING: The interpretation of |attrtype|, |data|, and |len| is complex and -// error-prone. See |X509_ATTRIBUTE_set1_data| for details. -OPENSSL_EXPORT int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, - const ASN1_OBJECT *obj, - int attrtype, - const unsigned char *data, - int len); - -// X509_REQ_add1_attr_by_NID behaves like |X509_REQ_add1_attr_by_OBJ| except the -// attribute type is determined by |nid|. -OPENSSL_EXPORT int X509_REQ_add1_attr_by_NID(X509_REQ *req, int nid, - int attrtype, - const unsigned char *data, - int len); - -// X509_REQ_add1_attr_by_txt behaves like |X509_REQ_add1_attr_by_OBJ| except the -// attribute type is determined by calling |OBJ_txt2obj| with |attrname|. -OPENSSL_EXPORT int X509_REQ_add1_attr_by_txt(X509_REQ *req, - const char *attrname, int attrtype, - const unsigned char *data, - int len); - OPENSSL_EXPORT int X509_CRL_sort(X509_CRL *crl); // X509_REVOKED_get0_serialNumber returns the serial number of the certificate @@ -2077,24 +2377,6 @@ OPENSSL_EXPORT unsigned long X509_NAME_hash_old(X509_NAME *x); OPENSSL_EXPORT int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); OPENSSL_EXPORT int X509_CRL_match(const X509_CRL *a, const X509_CRL *b); -OPENSSL_EXPORT int X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag, - unsigned long cflag); -OPENSSL_EXPORT int X509_print_fp(FILE *bp, X509 *x); -OPENSSL_EXPORT int X509_CRL_print_fp(FILE *bp, X509_CRL *x); -OPENSSL_EXPORT int X509_REQ_print_fp(FILE *bp, X509_REQ *req); -OPENSSL_EXPORT int X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, - int indent, unsigned long flags); - -OPENSSL_EXPORT int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase); -OPENSSL_EXPORT int X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent, - unsigned long flags); -OPENSSL_EXPORT int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag, - unsigned long cflag); -OPENSSL_EXPORT int X509_print(BIO *bp, X509 *x); -OPENSSL_EXPORT int X509_CRL_print(BIO *bp, X509_CRL *x); -OPENSSL_EXPORT int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, - unsigned long cflag); -OPENSSL_EXPORT int X509_REQ_print(BIO *bp, X509_REQ *req); // X509_get_ext_d2i behaves like |X509V3_get_d2i| but looks for the extension in // |x509|'s extension list. @@ -2190,153 +2472,6 @@ OPENSSL_EXPORT int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, unsigned long flags); -// X509at_get_attr_count returns the number of attributes in |x|. -OPENSSL_EXPORT int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x); - -// X509at_get_attr_by_NID returns the index of the attribute in |x| of type -// |nid|, or a negative number if not found. If found, callers can use -// |X509at_get_attr| to look up the attribute by index. -// -// If |lastpos| is non-negative, it begins searching at |lastpos| + 1. Callers -// can thus loop over all matching attributes by first passing -1 and then -// passing the previously-returned value until no match is returned. -OPENSSL_EXPORT int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, - int nid, int lastpos); - -// X509at_get_attr_by_OBJ behaves like |X509at_get_attr_by_NID| but looks for -// attributes of type |obj|. -OPENSSL_EXPORT int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, - const ASN1_OBJECT *obj, int lastpos); - -// X509at_get_attr returns the attribute at index |loc| in |x|, or NULL if -// out of bounds. -OPENSSL_EXPORT X509_ATTRIBUTE *X509at_get_attr( - const STACK_OF(X509_ATTRIBUTE) *x, int loc); - -// X509at_delete_attr removes the attribute at index |loc| in |x|. It returns -// the removed attribute to the caller, or NULL if |loc| was out of bounds. If -// non-NULL, the caller must release the result with |X509_ATTRIBUTE_free| when -// done. It is also safe, but not necessary, to call |X509_ATTRIBUTE_free| if -// the result is NULL. -OPENSSL_EXPORT X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, - int loc); - -// X509at_add1_attr appends a copy of |attr| to the attribute list in |*x|. If -// |*x| is NULL, it allocates a new |STACK_OF(X509_ATTRIBUTE)| to hold the copy -// and sets |*x| to the new list. It returns |*x| on success and NULL on error. -// The caller retains ownership of |attr| and can release it independently of -// |*x|. -OPENSSL_EXPORT STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr( - STACK_OF(X509_ATTRIBUTE) **x, X509_ATTRIBUTE *attr); - -// X509at_add1_attr_by_OBJ behaves like |X509at_add1_attr|, but adds an -// attribute created by |X509_ATTRIBUTE_create_by_OBJ|. -OPENSSL_EXPORT STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ( - STACK_OF(X509_ATTRIBUTE) **x, const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len); - -// X509at_add1_attr_by_NID behaves like |X509at_add1_attr|, but adds an -// attribute created by |X509_ATTRIBUTE_create_by_NID|. -OPENSSL_EXPORT STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID( - STACK_OF(X509_ATTRIBUTE) **x, int nid, int type, const unsigned char *bytes, - int len); - -// X509at_add1_attr_by_txt behaves like |X509at_add1_attr|, but adds an -// attribute created by |X509_ATTRIBUTE_create_by_txt|. -OPENSSL_EXPORT STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt( - STACK_OF(X509_ATTRIBUTE) **x, const char *attrname, int type, - const unsigned char *bytes, int len); - -// X509_ATTRIBUTE_create_by_NID returns a newly-allocated |X509_ATTRIBUTE| of -// type |nid|, or NULL on error. The value is determined as in -// |X509_ATTRIBUTE_set1_data|. -// -// If |attr| is non-NULL, the resulting |X509_ATTRIBUTE| is also written to -// |*attr|. If |*attr| was non-NULL when the function was called, |*attr| is -// reused instead of creating a new object. -// -// WARNING: The interpretation of |attrtype|, |data|, and |len| is complex and -// error-prone. See |X509_ATTRIBUTE_set1_data| for details. -// -// WARNING: The object reuse form is deprecated and may be removed in the -// future. It also currently incorrectly appends to the reused object's value -// set rather than overwriting it. -OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID( - X509_ATTRIBUTE **attr, int nid, int attrtype, const void *data, int len); - -// X509_ATTRIBUTE_create_by_OBJ behaves like |X509_ATTRIBUTE_create_by_NID| -// except the attribute's type is determined by |obj|. -OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ( - X509_ATTRIBUTE **attr, const ASN1_OBJECT *obj, int attrtype, - const void *data, int len); - -// X509_ATTRIBUTE_create_by_txt behaves like |X509_ATTRIBUTE_create_by_NID| -// except the attribute's type is determined by calling |OBJ_txt2obj| with -// |attrname|. -OPENSSL_EXPORT X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt( - X509_ATTRIBUTE **attr, const char *attrname, int type, - const unsigned char *bytes, int len); - -// X509_ATTRIBUTE_set1_object sets |attr|'s type to |obj|. It returns one on -// success and zero on error. -OPENSSL_EXPORT int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, - const ASN1_OBJECT *obj); - -// X509_ATTRIBUTE_set1_data appends a value to |attr|'s value set and returns -// one on success or zero on error. The value is determined as follows: -// -// If |attrtype| is a |MBSTRING_*| constant, the value is an ASN.1 string. The -// string is determined by decoding |len| bytes from |data| in the encoding -// specified by |attrtype|, and then re-encoding it in a form appropriate for -// |attr|'s type. If |len| is -1, |strlen(data)| is used instead. See -// |ASN1_STRING_set_by_NID| for details. -// -// Otherwise, if |len| is not -1, the value is an ASN.1 string. |attrtype| is an -// |ASN1_STRING| type value and the |len| bytes from |data| are copied as the -// type-specific representation of |ASN1_STRING|. See |ASN1_STRING| for details. -// -// WARNING: If this form is used to construct a negative INTEGER or ENUMERATED, -// |attrtype| includes the |V_ASN1_NEG| flag for |ASN1_STRING|, but the function -// forgets to clear the flag for |ASN1_TYPE|. This matches OpenSSL but is -// probably a bug. For now, do not use this form with negative values. -// -// Otherwise, if |len| is -1, the value is constructed by passing |attrtype| and -// |data| to |ASN1_TYPE_set1|. That is, |attrtype| is an |ASN1_TYPE| type value, -// and |data| is cast to the corresponding pointer type. -// -// WARNING: Despite the name, this function appends to |attr|'s value set, -// rather than overwriting it. To overwrite the value set, create a new -// |X509_ATTRIBUTE| with |X509_ATTRIBUTE_new|. -// -// WARNING: If using the |MBSTRING_*| form, pass a length rather than relying on -// |strlen|. In particular, |strlen| will not behave correctly if the input is -// |MBSTRING_BMP| or |MBSTRING_UNIV|. -// -// WARNING: This function currently misinterprets |V_ASN1_OTHER| as an -// |MBSTRING_*| constant. This matches OpenSSL but means it is impossible to -// construct a value with a non-universal tag. -OPENSSL_EXPORT int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, - const void *data, int len); - -// X509_ATTRIBUTE_get0_data returns the |idx|th value of |attr| in a -// type-specific representation to |attrtype|, or NULL if out of bounds or the -// type does not match. |attrtype| is one of the type values in |ASN1_TYPE|. On -// match, the return value uses the same representation as |ASN1_TYPE_set0|. See -// |ASN1_TYPE| for details. -OPENSSL_EXPORT void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, - int attrtype, void *unused); - -// X509_ATTRIBUTE_count returns the number of values in |attr|. -OPENSSL_EXPORT int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr); - -// X509_ATTRIBUTE_get0_object returns the type of |attr|. -OPENSSL_EXPORT ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr); - -// X509_ATTRIBUTE_get0_type returns the |idx|th value in |attr|, or NULL if out -// of bounds. Note this function returns one of |attr|'s values, not the type. -OPENSSL_EXPORT ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, - int idx); - OPENSSL_EXPORT int X509_verify_cert(X509_STORE_CTX *ctx); // PKCS#8 utilities @@ -2394,7 +2529,7 @@ OPENSSL_EXPORT X509_TRUST *X509_TRUST_get0(int idx); OPENSSL_EXPORT int X509_TRUST_get_by_id(int id); OPENSSL_EXPORT int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), - char *name, int arg1, void *arg2); + const char *name, int arg1, void *arg2); OPENSSL_EXPORT void X509_TRUST_cleanup(void); OPENSSL_EXPORT int X509_TRUST_get_flags(const X509_TRUST *xp); OPENSSL_EXPORT char *X509_TRUST_get0_name(const X509_TRUST *xp); @@ -2635,6 +2770,11 @@ OPENSSL_EXPORT void X509_STORE_set_verify(X509_STORE *ctx, OPENSSL_EXPORT void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, X509_STORE_CTX_verify_fn verify); OPENSSL_EXPORT X509_STORE_CTX_verify_fn X509_STORE_get_verify(X509_STORE *ctx); + +// X509_STORE_set_verify_cb acts like |X509_STORE_CTX_set_verify_cb| but sets +// the verify callback for any |X509_STORE_CTX| created from this |X509_STORE| +// +// Do not use this funciton. see |X509_STORE_CTX_set_verify_cb|. OPENSSL_EXPORT void X509_STORE_set_verify_cb( X509_STORE *ctx, X509_STORE_CTX_verify_cb verify_cb); #define X509_STORE_set_verify_cb_func(ctx, func) \ @@ -2724,14 +2864,12 @@ OPENSSL_EXPORT int X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, OPENSSL_EXPORT int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret); -#ifndef OPENSSL_NO_STDIO OPENSSL_EXPORT int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); OPENSSL_EXPORT int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); OPENSSL_EXPORT int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); -#endif OPENSSL_EXPORT X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); OPENSSL_EXPORT void X509_LOOKUP_free(X509_LOOKUP *ctx); @@ -2740,11 +2878,9 @@ OPENSSL_EXPORT int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, int type, X509_NAME *name, X509_OBJECT *ret); OPENSSL_EXPORT int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); -#ifndef OPENSSL_NO_STDIO OPENSSL_EXPORT int X509_STORE_load_locations(X509_STORE *ctx, const char *file, const char *dir); OPENSSL_EXPORT int X509_STORE_set_default_paths(X509_STORE *ctx); -#endif OPENSSL_EXPORT int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); OPENSSL_EXPORT void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s); OPENSSL_EXPORT int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); @@ -2775,8 +2911,27 @@ OPENSSL_EXPORT void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, OPENSSL_EXPORT void X509_STORE_CTX_set_time_posix(X509_STORE_CTX *ctx, unsigned long flags, int64_t t); + +// X509_STORE_CTX_set_verify_cb configures a callback function for |ctx| that is +// called multiple times during |X509_verify_cert|. The callback returns zero to +// fail verification and non-zero to proceed. Typically, it will return |ok|, +// which preserves the default behavior. Returning one when |ok| is zero will +// proceed past some error. The callback may inspect |ctx| and the error queue +// to attempt to determine the current stage of certificate verification, but +// this is often unreliable. +// +// WARNING: Do not use this function. It is extremely fragile and unpredictable. +// This callback exposes implementation details of certificate verification, +// which change as the library evolves. Attempting to use it for security checks +// can introduce vulnerabilities if making incorrect assumptions about when the +// callback is called. Additionally, overriding |ok| may leave |ctx| in an +// inconsistent state and break invariants. +// +// Instead, customize certificate verification by configuring options on the +// |X509_STORE_CTX| before verification, or applying additional checks after +// |X509_verify_cert| completes successfully. OPENSSL_EXPORT void X509_STORE_CTX_set_verify_cb( - X509_STORE_CTX *ctx, int (*verify_cb)(int, X509_STORE_CTX *)); + X509_STORE_CTX *ctx, int (*verify_cb)(int ok, X509_STORE_CTX *ctx)); OPENSSL_EXPORT X509_VERIFY_PARAM *X509_STORE_CTX_get0_param( X509_STORE_CTX *ctx); diff --git a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_x509v3.h b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_x509v3.h index 08d38c0f..a9f4af7c 100644 --- a/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_x509v3.h +++ b/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_x509v3.h @@ -104,9 +104,13 @@ typedef void *(*X509V3_EXT_R2I)(const X509V3_EXT_METHOD *method, struct v3_ext_method { int ext_nid; int ext_flags; - // If this is set the following four fields are ignored + + // it determines how values of this extension are allocated, released, parsed, + // and marshalled. This must be non-NULL. ASN1_ITEM_EXP *it; - // Old style ASN1 calls + + // The following functions are ignored in favor of |it|. They are retained in + // the struct only for source compatibility with existing struct definitions. X509V3_EXT_NEW ext_new; X509V3_EXT_FREE ext_free; X509V3_EXT_D2I d2i; @@ -130,7 +134,6 @@ struct v3_ext_method { DEFINE_STACK_OF(X509V3_EXT_METHOD) // ext_flags values -#define X509V3_EXT_DYNAMIC 0x1 #define X509V3_EXT_CTX_DEP 0x2 #define X509V3_EXT_MULTILINE 0x4 @@ -546,9 +549,11 @@ OPENSSL_EXPORT void X509V3_conf_free(CONF_VALUE *val); // // These functions are not safe to use with untrusted inputs. The string formats // may implicitly reference context information and, in OpenSSL (though not -// BoringSSL), one even allows reading arbitrary files. They additionally see -// much less testing and review than most of the library and may have bugs -// including memory leaks or crashes. +// BoringSSL), one even allows reading arbitrary files. Many formats can also +// produce far larger outputs than their inputs, so untrusted inputs may lead to +// denial-of-service attacks. Finally, the parsers see much less testing and +// review than most of the library and may have bugs including memory leaks or +// crashes. // v3_ext_ctx, aka |X509V3_CTX|, contains additional context information for // constructing extensions. Some string formats reference additional values in @@ -663,10 +668,37 @@ OPENSSL_EXPORT ASN1_INTEGER *s2i_ASN1_INTEGER(const X509V3_EXT_METHOD *meth, const char *value); OPENSSL_EXPORT char *i2s_ASN1_ENUMERATED(const X509V3_EXT_METHOD *meth, const ASN1_ENUMERATED *aint); -OPENSSL_EXPORT int X509V3_EXT_add(X509V3_EXT_METHOD *ext); -OPENSSL_EXPORT int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); -OPENSSL_EXPORT int X509V3_EXT_add_alias(int nid_to, int nid_from); -OPENSSL_EXPORT void X509V3_EXT_cleanup(void); + +// X509V3_EXT_add registers |ext| as a custom extension for the extension type +// |ext->ext_nid|. |ext| must be valid for the remainder of the address space's +// lifetime. It returns one on success and zero on error. +// +// WARNING: This function modifies global state. If other code in the same +// address space also registers an extension with type |ext->ext_nid|, the two +// registrations will conflict. Which registration takes effect is undefined. If +// the two registrations use incompatible in-memory representations, code +// expecting the other registration will then cast a type to the wrong type, +// resulting in a potentially exploitable memory error. This conflict can also +// occur if BoringSSL later adds support for |ext->ext_nid|, with a different +// in-memory representation than the one expected by |ext|. +// +// This function, additionally, is not thread-safe and cannot be called +// concurrently with any other BoringSSL function. +// +// As a result, it is impossible to safely use this function. Registering a +// custom extension has no impact on certificate verification so, instead, +// callers should simply handle the custom extension with the byte-based +// |X509_EXTENSION| APIs directly. Registering |ext| with the library has little +// practical value. +OPENSSL_EXPORT OPENSSL_DEPRECATED int X509V3_EXT_add(X509V3_EXT_METHOD *ext); + +// X509V3_EXT_add_alias registers a custom extension with NID |nid_to|. The +// corresponding ASN.1 type is copied from |nid_from|. It returns one on success +// and zero on error. +// +// WARNING: Do not use this function. See |X509V3_EXT_add|. +OPENSSL_EXPORT OPENSSL_DEPRECATED int X509V3_EXT_add_alias(int nid_to, + int nid_from); OPENSSL_EXPORT const X509V3_EXT_METHOD *X509V3_EXT_get( const X509_EXTENSION *ext); @@ -874,12 +906,13 @@ OPENSSL_EXPORT const ASN1_INTEGER *X509_get0_authority_serial(X509 *x509); OPENSSL_EXPORT int X509_PURPOSE_get_count(void); OPENSSL_EXPORT X509_PURPOSE *X509_PURPOSE_get0(int idx); -OPENSSL_EXPORT int X509_PURPOSE_get_by_sname(char *sname); +OPENSSL_EXPORT int X509_PURPOSE_get_by_sname(const char *sname); OPENSSL_EXPORT int X509_PURPOSE_get_by_id(int id); OPENSSL_EXPORT int X509_PURPOSE_add(int id, int trust, int flags, int (*ck)(const X509_PURPOSE *, const X509 *, int), - char *name, char *sname, void *arg); + const char *name, const char *sname, + void *arg); OPENSSL_EXPORT char *X509_PURPOSE_get0_name(const X509_PURPOSE *xp); OPENSSL_EXPORT char *X509_PURPOSE_get0_sname(const X509_PURPOSE *xp); OPENSSL_EXPORT int X509_PURPOSE_get_trust(const X509_PURPOSE *xp); diff --git a/Sources/CCryptoBoringSSL/include/boringssl_prefix_symbols_nasm.inc b/Sources/CCryptoBoringSSL/include/boringssl_prefix_symbols_nasm.inc index 42e5af07..d442f5ab 100644 --- a/Sources/CCryptoBoringSSL/include/boringssl_prefix_symbols_nasm.inc +++ b/Sources/CCryptoBoringSSL/include/boringssl_prefix_symbols_nasm.inc @@ -139,6 +139,7 @@ %xdefine _ASN1_TIME_set _ %+ BORINGSSL_PREFIX %+ _ASN1_TIME_set %xdefine _ASN1_TIME_set_posix _ %+ BORINGSSL_PREFIX %+ _ASN1_TIME_set_posix %xdefine _ASN1_TIME_set_string _ %+ BORINGSSL_PREFIX %+ _ASN1_TIME_set_string +%xdefine _ASN1_TIME_set_string_X509 _ %+ BORINGSSL_PREFIX %+ _ASN1_TIME_set_string_X509 %xdefine _ASN1_TIME_to_generalizedtime _ %+ BORINGSSL_PREFIX %+ _ASN1_TIME_to_generalizedtime %xdefine _ASN1_TIME_to_posix _ %+ BORINGSSL_PREFIX %+ _ASN1_TIME_to_posix %xdefine _ASN1_TIME_to_time_t _ %+ BORINGSSL_PREFIX %+ _ASN1_TIME_to_time_t @@ -574,10 +575,6 @@ %xdefine _CRYPTO_POLYVAL_finish _ %+ BORINGSSL_PREFIX %+ _CRYPTO_POLYVAL_finish %xdefine _CRYPTO_POLYVAL_init _ %+ BORINGSSL_PREFIX %+ _CRYPTO_POLYVAL_init %xdefine _CRYPTO_POLYVAL_update_blocks _ %+ BORINGSSL_PREFIX %+ _CRYPTO_POLYVAL_update_blocks -%xdefine _CRYPTO_STATIC_MUTEX_lock_read _ %+ BORINGSSL_PREFIX %+ _CRYPTO_STATIC_MUTEX_lock_read -%xdefine _CRYPTO_STATIC_MUTEX_lock_write _ %+ BORINGSSL_PREFIX %+ _CRYPTO_STATIC_MUTEX_lock_write -%xdefine _CRYPTO_STATIC_MUTEX_unlock_read _ %+ BORINGSSL_PREFIX %+ _CRYPTO_STATIC_MUTEX_unlock_read -%xdefine _CRYPTO_STATIC_MUTEX_unlock_write _ %+ BORINGSSL_PREFIX %+ _CRYPTO_STATIC_MUTEX_unlock_write %xdefine _CRYPTO_THREADID_current _ %+ BORINGSSL_PREFIX %+ _CRYPTO_THREADID_current %xdefine _CRYPTO_THREADID_set_callback _ %+ BORINGSSL_PREFIX %+ _CRYPTO_THREADID_set_callback %xdefine _CRYPTO_THREADID_set_numeric _ %+ BORINGSSL_PREFIX %+ _CRYPTO_THREADID_set_numeric @@ -651,6 +648,7 @@ %xdefine _CRYPTO_sysrand _ %+ BORINGSSL_PREFIX %+ _CRYPTO_sysrand %xdefine _CRYPTO_sysrand_for_seed _ %+ BORINGSSL_PREFIX %+ _CRYPTO_sysrand_for_seed %xdefine _CRYPTO_sysrand_if_available _ %+ BORINGSSL_PREFIX %+ _CRYPTO_sysrand_if_available +%xdefine _CRYPTO_tls13_hkdf_expand_label _ %+ BORINGSSL_PREFIX %+ _CRYPTO_tls13_hkdf_expand_label %xdefine _CRYPTO_tls1_prf _ %+ BORINGSSL_PREFIX %+ _CRYPTO_tls1_prf %xdefine _CTR_DRBG_clear _ %+ BORINGSSL_PREFIX %+ _CTR_DRBG_clear %xdefine _CTR_DRBG_free _ %+ BORINGSSL_PREFIX %+ _CTR_DRBG_free @@ -852,6 +850,10 @@ %xdefine _EC_curve_nid2nist _ %+ BORINGSSL_PREFIX %+ _EC_curve_nid2nist %xdefine _EC_curve_nist2nid _ %+ BORINGSSL_PREFIX %+ _EC_curve_nist2nid %xdefine _EC_get_builtin_curves _ %+ BORINGSSL_PREFIX %+ _EC_get_builtin_curves +%xdefine _EC_group_p224 _ %+ BORINGSSL_PREFIX %+ _EC_group_p224 +%xdefine _EC_group_p256 _ %+ BORINGSSL_PREFIX %+ _EC_group_p256 +%xdefine _EC_group_p384 _ %+ BORINGSSL_PREFIX %+ _EC_group_p384 +%xdefine _EC_group_p521 _ %+ BORINGSSL_PREFIX %+ _EC_group_p521 %xdefine _EC_hash_to_curve_p256_xmd_sha256_sswu _ %+ BORINGSSL_PREFIX %+ _EC_hash_to_curve_p256_xmd_sha256_sswu %xdefine _EC_hash_to_curve_p384_xmd_sha384_sswu _ %+ BORINGSSL_PREFIX %+ _EC_hash_to_curve_p384_xmd_sha384_sswu %xdefine _ED25519_keypair _ %+ BORINGSSL_PREFIX %+ _ED25519_keypair @@ -1005,6 +1007,9 @@ %xdefine _EVP_HPKE_CTX_new _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_new %xdefine _EVP_HPKE_CTX_open _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_open %xdefine _EVP_HPKE_CTX_seal _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_seal +%xdefine _EVP_HPKE_CTX_setup_auth_recipient _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_auth_recipient +%xdefine _EVP_HPKE_CTX_setup_auth_sender _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_auth_sender +%xdefine _EVP_HPKE_CTX_setup_auth_sender_with_seed_for_testing _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_auth_sender_with_seed_for_testing %xdefine _EVP_HPKE_CTX_setup_recipient _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_recipient %xdefine _EVP_HPKE_CTX_setup_sender _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_sender %xdefine _EVP_HPKE_CTX_setup_sender_with_seed_for_testing _ %+ BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_sender_with_seed_for_testing @@ -1150,6 +1155,7 @@ %xdefine _EVP_add_digest _ %+ BORINGSSL_PREFIX %+ _EVP_add_digest %xdefine _EVP_aead_aes_128_cbc_sha1_tls _ %+ BORINGSSL_PREFIX %+ _EVP_aead_aes_128_cbc_sha1_tls %xdefine _EVP_aead_aes_128_cbc_sha1_tls_implicit_iv _ %+ BORINGSSL_PREFIX %+ _EVP_aead_aes_128_cbc_sha1_tls_implicit_iv +%xdefine _EVP_aead_aes_128_cbc_sha256_tls _ %+ BORINGSSL_PREFIX %+ _EVP_aead_aes_128_cbc_sha256_tls %xdefine _EVP_aead_aes_128_ccm_bluetooth _ %+ BORINGSSL_PREFIX %+ _EVP_aead_aes_128_ccm_bluetooth %xdefine _EVP_aead_aes_128_ccm_bluetooth_8 _ %+ BORINGSSL_PREFIX %+ _EVP_aead_aes_128_ccm_bluetooth_8 %xdefine _EVP_aead_aes_128_ccm_matter _ %+ BORINGSSL_PREFIX %+ _EVP_aead_aes_128_ccm_matter @@ -1171,7 +1177,6 @@ %xdefine _EVP_aead_chacha20_poly1305 _ %+ BORINGSSL_PREFIX %+ _EVP_aead_chacha20_poly1305 %xdefine _EVP_aead_des_ede3_cbc_sha1_tls _ %+ BORINGSSL_PREFIX %+ _EVP_aead_des_ede3_cbc_sha1_tls %xdefine _EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv _ %+ BORINGSSL_PREFIX %+ _EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv -%xdefine _EVP_aead_null_sha1_tls _ %+ BORINGSSL_PREFIX %+ _EVP_aead_null_sha1_tls %xdefine _EVP_aead_xchacha20_poly1305 _ %+ BORINGSSL_PREFIX %+ _EVP_aead_xchacha20_poly1305 %xdefine _EVP_aes_128_cbc _ %+ BORINGSSL_PREFIX %+ _EVP_aes_128_cbc %xdefine _EVP_aes_128_ctr _ %+ BORINGSSL_PREFIX %+ _EVP_aes_128_ctr @@ -1225,6 +1230,7 @@ %xdefine _EVP_sha1_final_with_secret_suffix _ %+ BORINGSSL_PREFIX %+ _EVP_sha1_final_with_secret_suffix %xdefine _EVP_sha224 _ %+ BORINGSSL_PREFIX %+ _EVP_sha224 %xdefine _EVP_sha256 _ %+ BORINGSSL_PREFIX %+ _EVP_sha256 +%xdefine _EVP_sha256_final_with_secret_suffix _ %+ BORINGSSL_PREFIX %+ _EVP_sha256_final_with_secret_suffix %xdefine _EVP_sha384 _ %+ BORINGSSL_PREFIX %+ _EVP_sha384 %xdefine _EVP_sha512 _ %+ BORINGSSL_PREFIX %+ _EVP_sha512 %xdefine _EVP_sha512_256 _ %+ BORINGSSL_PREFIX %+ _EVP_sha512_256 @@ -1356,7 +1362,6 @@ %xdefine _OPENSSL_add_all_algorithms_conf _ %+ BORINGSSL_PREFIX %+ _OPENSSL_add_all_algorithms_conf %xdefine _OPENSSL_armcap_P _ %+ BORINGSSL_PREFIX %+ _OPENSSL_armcap_P %xdefine _OPENSSL_asprintf _ %+ BORINGSSL_PREFIX %+ _OPENSSL_asprintf -%xdefine _OPENSSL_built_in_curves _ %+ BORINGSSL_PREFIX %+ _OPENSSL_built_in_curves %xdefine _OPENSSL_cleanse _ %+ BORINGSSL_PREFIX %+ _OPENSSL_cleanse %xdefine _OPENSSL_cleanup _ %+ BORINGSSL_PREFIX %+ _OPENSSL_cleanup %xdefine _OPENSSL_clear_free _ %+ BORINGSSL_PREFIX %+ _OPENSSL_clear_free @@ -1393,6 +1398,27 @@ %xdefine _OPENSSL_realloc _ %+ BORINGSSL_PREFIX %+ _OPENSSL_realloc %xdefine _OPENSSL_secure_clear_free _ %+ BORINGSSL_PREFIX %+ _OPENSSL_secure_clear_free %xdefine _OPENSSL_secure_malloc _ %+ BORINGSSL_PREFIX %+ _OPENSSL_secure_malloc +%xdefine _OPENSSL_sk_deep_copy _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_deep_copy +%xdefine _OPENSSL_sk_delete _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_delete +%xdefine _OPENSSL_sk_delete_if _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_delete_if +%xdefine _OPENSSL_sk_delete_ptr _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_delete_ptr +%xdefine _OPENSSL_sk_dup _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_dup +%xdefine _OPENSSL_sk_find _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_find +%xdefine _OPENSSL_sk_free _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_free +%xdefine _OPENSSL_sk_insert _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_insert +%xdefine _OPENSSL_sk_is_sorted _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_is_sorted +%xdefine _OPENSSL_sk_new _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_new +%xdefine _OPENSSL_sk_new_null _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_new_null +%xdefine _OPENSSL_sk_num _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_num +%xdefine _OPENSSL_sk_pop _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_pop +%xdefine _OPENSSL_sk_pop_free_ex _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_pop_free_ex +%xdefine _OPENSSL_sk_push _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_push +%xdefine _OPENSSL_sk_set _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_set +%xdefine _OPENSSL_sk_set_cmp_func _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_set_cmp_func +%xdefine _OPENSSL_sk_shift _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_shift +%xdefine _OPENSSL_sk_sort _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_sort +%xdefine _OPENSSL_sk_value _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_value +%xdefine _OPENSSL_sk_zero _ %+ BORINGSSL_PREFIX %+ _OPENSSL_sk_zero %xdefine _OPENSSL_strcasecmp _ %+ BORINGSSL_PREFIX %+ _OPENSSL_strcasecmp %xdefine _OPENSSL_strdup _ %+ BORINGSSL_PREFIX %+ _OPENSSL_strdup %xdefine _OPENSSL_strhash _ %+ BORINGSSL_PREFIX %+ _OPENSSL_strhash @@ -1609,6 +1635,13 @@ %xdefine _RSA_marshal_public_key _ %+ BORINGSSL_PREFIX %+ _RSA_marshal_public_key %xdefine _RSA_new _ %+ BORINGSSL_PREFIX %+ _RSA_new %xdefine _RSA_new_method _ %+ BORINGSSL_PREFIX %+ _RSA_new_method +%xdefine _RSA_new_method_no_e _ %+ BORINGSSL_PREFIX %+ _RSA_new_method_no_e +%xdefine _RSA_new_private_key _ %+ BORINGSSL_PREFIX %+ _RSA_new_private_key +%xdefine _RSA_new_private_key_large_e _ %+ BORINGSSL_PREFIX %+ _RSA_new_private_key_large_e +%xdefine _RSA_new_private_key_no_crt _ %+ BORINGSSL_PREFIX %+ _RSA_new_private_key_no_crt +%xdefine _RSA_new_private_key_no_e _ %+ BORINGSSL_PREFIX %+ _RSA_new_private_key_no_e +%xdefine _RSA_new_public_key _ %+ BORINGSSL_PREFIX %+ _RSA_new_public_key +%xdefine _RSA_new_public_key_large_e _ %+ BORINGSSL_PREFIX %+ _RSA_new_public_key_large_e %xdefine _RSA_padding_add_PKCS1_OAEP_mgf1 _ %+ BORINGSSL_PREFIX %+ _RSA_padding_add_PKCS1_OAEP_mgf1 %xdefine _RSA_padding_add_PKCS1_PSS_mgf1 _ %+ BORINGSSL_PREFIX %+ _RSA_padding_add_PKCS1_PSS_mgf1 %xdefine _RSA_padding_add_PKCS1_type_1 _ %+ BORINGSSL_PREFIX %+ _RSA_padding_add_PKCS1_type_1 @@ -1713,10 +1746,8 @@ %xdefine _X509V3_EXT_REQ_add_nconf _ %+ BORINGSSL_PREFIX %+ _X509V3_EXT_REQ_add_nconf %xdefine _X509V3_EXT_add _ %+ BORINGSSL_PREFIX %+ _X509V3_EXT_add %xdefine _X509V3_EXT_add_alias _ %+ BORINGSSL_PREFIX %+ _X509V3_EXT_add_alias -%xdefine _X509V3_EXT_add_list _ %+ BORINGSSL_PREFIX %+ _X509V3_EXT_add_list %xdefine _X509V3_EXT_add_nconf _ %+ BORINGSSL_PREFIX %+ _X509V3_EXT_add_nconf %xdefine _X509V3_EXT_add_nconf_sk _ %+ BORINGSSL_PREFIX %+ _X509V3_EXT_add_nconf_sk -%xdefine _X509V3_EXT_cleanup _ %+ BORINGSSL_PREFIX %+ _X509V3_EXT_cleanup %xdefine _X509V3_EXT_d2i _ %+ BORINGSSL_PREFIX %+ _X509V3_EXT_d2i %xdefine _X509V3_EXT_free _ %+ BORINGSSL_PREFIX %+ _X509V3_EXT_free %xdefine _X509V3_EXT_get _ %+ BORINGSSL_PREFIX %+ _X509V3_EXT_get @@ -2202,15 +2233,6 @@ %xdefine _X509_verify _ %+ BORINGSSL_PREFIX %+ _X509_verify %xdefine _X509_verify_cert _ %+ BORINGSSL_PREFIX %+ _X509_verify_cert %xdefine _X509_verify_cert_error_string _ %+ BORINGSSL_PREFIX %+ _X509_verify_cert_error_string -%xdefine _X509at_add1_attr _ %+ BORINGSSL_PREFIX %+ _X509at_add1_attr -%xdefine _X509at_add1_attr_by_NID _ %+ BORINGSSL_PREFIX %+ _X509at_add1_attr_by_NID -%xdefine _X509at_add1_attr_by_OBJ _ %+ BORINGSSL_PREFIX %+ _X509at_add1_attr_by_OBJ -%xdefine _X509at_add1_attr_by_txt _ %+ BORINGSSL_PREFIX %+ _X509at_add1_attr_by_txt -%xdefine _X509at_delete_attr _ %+ BORINGSSL_PREFIX %+ _X509at_delete_attr -%xdefine _X509at_get_attr _ %+ BORINGSSL_PREFIX %+ _X509at_get_attr -%xdefine _X509at_get_attr_by_NID _ %+ BORINGSSL_PREFIX %+ _X509at_get_attr_by_NID -%xdefine _X509at_get_attr_by_OBJ _ %+ BORINGSSL_PREFIX %+ _X509at_get_attr_by_OBJ -%xdefine _X509at_get_attr_count _ %+ BORINGSSL_PREFIX %+ _X509at_get_attr_count %xdefine _X509v3_add_ext _ %+ BORINGSSL_PREFIX %+ _X509v3_add_ext %xdefine _X509v3_delete_ext _ %+ BORINGSSL_PREFIX %+ _X509v3_delete_ext %xdefine _X509v3_get_ext _ %+ BORINGSSL_PREFIX %+ _X509v3_get_ext @@ -2276,7 +2298,7 @@ %xdefine _asn1_type_value_as_pointer _ %+ BORINGSSL_PREFIX %+ _asn1_type_value_as_pointer %xdefine _asn1_utctime_to_tm _ %+ BORINGSSL_PREFIX %+ _asn1_utctime_to_tm %xdefine _beeu_mod_inverse_vartime _ %+ BORINGSSL_PREFIX %+ _beeu_mod_inverse_vartime -%xdefine _bio_fd_should_retry _ %+ BORINGSSL_PREFIX %+ _bio_fd_should_retry +%xdefine _bio_errno_should_retry _ %+ BORINGSSL_PREFIX %+ _bio_errno_should_retry %xdefine _bn_abs_sub_consttime _ %+ BORINGSSL_PREFIX %+ _bn_abs_sub_consttime %xdefine _bn_add_words _ %+ BORINGSSL_PREFIX %+ _bn_add_words %xdefine _bn_assert_fits_in_bytes _ %+ BORINGSSL_PREFIX %+ _bn_assert_fits_in_bytes @@ -2299,7 +2321,6 @@ %xdefine _bn_minimal_width _ %+ BORINGSSL_PREFIX %+ _bn_minimal_width %xdefine _bn_mod_add_consttime _ %+ BORINGSSL_PREFIX %+ _bn_mod_add_consttime %xdefine _bn_mod_add_words _ %+ BORINGSSL_PREFIX %+ _bn_mod_add_words -%xdefine _bn_mod_exp_base_2_consttime _ %+ BORINGSSL_PREFIX %+ _bn_mod_exp_base_2_consttime %xdefine _bn_mod_exp_mont_small _ %+ BORINGSSL_PREFIX %+ _bn_mod_exp_mont_small %xdefine _bn_mod_inverse0_prime_mont_small _ %+ BORINGSSL_PREFIX %+ _bn_mod_inverse0_prime_mont_small %xdefine _bn_mod_inverse_consttime _ %+ BORINGSSL_PREFIX %+ _bn_mod_inverse_consttime @@ -2311,6 +2332,9 @@ %xdefine _bn_mod_sub_consttime _ %+ BORINGSSL_PREFIX %+ _bn_mod_sub_consttime %xdefine _bn_mod_sub_words _ %+ BORINGSSL_PREFIX %+ _bn_mod_sub_words %xdefine _bn_mod_u16_consttime _ %+ BORINGSSL_PREFIX %+ _bn_mod_u16_consttime +%xdefine _bn_mont_ctx_cleanup _ %+ BORINGSSL_PREFIX %+ _bn_mont_ctx_cleanup +%xdefine _bn_mont_ctx_init _ %+ BORINGSSL_PREFIX %+ _bn_mont_ctx_init +%xdefine _bn_mont_ctx_set_RR_consttime _ %+ BORINGSSL_PREFIX %+ _bn_mont_ctx_set_RR_consttime %xdefine _bn_mont_n0 _ %+ BORINGSSL_PREFIX %+ _bn_mont_n0 %xdefine _bn_mul_add_words _ %+ BORINGSSL_PREFIX %+ _bn_mul_add_words %xdefine _bn_mul_comba4 _ %+ BORINGSSL_PREFIX %+ _bn_mul_comba4 @@ -2495,9 +2519,6 @@ %xdefine _ec_GFp_mont_felem_reduce _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_reduce %xdefine _ec_GFp_mont_felem_sqr _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_sqr %xdefine _ec_GFp_mont_felem_to_bytes _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_to_bytes -%xdefine _ec_GFp_mont_group_finish _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_group_finish -%xdefine _ec_GFp_mont_group_init _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_group_init -%xdefine _ec_GFp_mont_group_set_curve _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_group_set_curve %xdefine _ec_GFp_mont_init_precomp _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_init_precomp %xdefine _ec_GFp_mont_mul _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_mul %xdefine _ec_GFp_mont_mul_base _ %+ BORINGSSL_PREFIX %+ _ec_GFp_mont_mul_base @@ -2508,9 +2529,7 @@ %xdefine _ec_GFp_simple_cmp_x_coordinate _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_cmp_x_coordinate %xdefine _ec_GFp_simple_felem_from_bytes _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_felem_from_bytes %xdefine _ec_GFp_simple_felem_to_bytes _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_felem_to_bytes -%xdefine _ec_GFp_simple_group_finish _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_group_finish %xdefine _ec_GFp_simple_group_get_curve _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_group_get_curve -%xdefine _ec_GFp_simple_group_init _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_group_init %xdefine _ec_GFp_simple_group_set_curve _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_group_set_curve %xdefine _ec_GFp_simple_invert _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_invert %xdefine _ec_GFp_simple_is_at_infinity _ %+ BORINGSSL_PREFIX %+ _ec_GFp_simple_is_at_infinity @@ -2532,13 +2551,13 @@ %xdefine _ec_felem_from_bytes _ %+ BORINGSSL_PREFIX %+ _ec_felem_from_bytes %xdefine _ec_felem_neg _ %+ BORINGSSL_PREFIX %+ _ec_felem_neg %xdefine _ec_felem_non_zero_mask _ %+ BORINGSSL_PREFIX %+ _ec_felem_non_zero_mask +%xdefine _ec_felem_one _ %+ BORINGSSL_PREFIX %+ _ec_felem_one %xdefine _ec_felem_select _ %+ BORINGSSL_PREFIX %+ _ec_felem_select %xdefine _ec_felem_sub _ %+ BORINGSSL_PREFIX %+ _ec_felem_sub %xdefine _ec_felem_to_bignum _ %+ BORINGSSL_PREFIX %+ _ec_felem_to_bignum %xdefine _ec_felem_to_bytes _ %+ BORINGSSL_PREFIX %+ _ec_felem_to_bytes %xdefine _ec_get_x_coordinate_as_bytes _ %+ BORINGSSL_PREFIX %+ _ec_get_x_coordinate_as_bytes %xdefine _ec_get_x_coordinate_as_scalar _ %+ BORINGSSL_PREFIX %+ _ec_get_x_coordinate_as_scalar -%xdefine _ec_group_new _ %+ BORINGSSL_PREFIX %+ _ec_group_new %xdefine _ec_hash_to_curve_p256_xmd_sha256_sswu _ %+ BORINGSSL_PREFIX %+ _ec_hash_to_curve_p256_xmd_sha256_sswu %xdefine _ec_hash_to_curve_p384_xmd_sha384_sswu _ %+ BORINGSSL_PREFIX %+ _ec_hash_to_curve_p384_xmd_sha384_sswu %xdefine _ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 _ %+ BORINGSSL_PREFIX %+ _ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 @@ -2598,6 +2617,8 @@ %xdefine _ecp_nistz256_sub _ %+ BORINGSSL_PREFIX %+ _ecp_nistz256_sub %xdefine _ed25519_asn1_meth _ %+ BORINGSSL_PREFIX %+ _ed25519_asn1_meth %xdefine _ed25519_pkey_meth _ %+ BORINGSSL_PREFIX %+ _ed25519_pkey_meth +%xdefine _fiat_curve25519_adx_mul _ %+ BORINGSSL_PREFIX %+ _fiat_curve25519_adx_mul +%xdefine _fiat_curve25519_adx_square _ %+ BORINGSSL_PREFIX %+ _fiat_curve25519_adx_square %xdefine _gcm_ghash_avx _ %+ BORINGSSL_PREFIX %+ _gcm_ghash_avx %xdefine _gcm_ghash_clmul _ %+ BORINGSSL_PREFIX %+ _gcm_ghash_clmul %xdefine _gcm_ghash_neon _ %+ BORINGSSL_PREFIX %+ _gcm_ghash_neon @@ -2756,6 +2777,7 @@ %xdefine _i2t_ASN1_OBJECT _ %+ BORINGSSL_PREFIX %+ _i2t_ASN1_OBJECT %xdefine _i2v_GENERAL_NAME _ %+ BORINGSSL_PREFIX %+ _i2v_GENERAL_NAME %xdefine _i2v_GENERAL_NAMES _ %+ BORINGSSL_PREFIX %+ _i2v_GENERAL_NAMES +%xdefine _k25519Precomp _ %+ BORINGSSL_PREFIX %+ _k25519Precomp %xdefine _kBoringSSLRSASqrtTwo _ %+ BORINGSSL_PREFIX %+ _kBoringSSLRSASqrtTwo %xdefine _kBoringSSLRSASqrtTwoLen _ %+ BORINGSSL_PREFIX %+ _kBoringSSLRSASqrtTwoLen %xdefine _kOpenSSLReasonStringData _ %+ BORINGSSL_PREFIX %+ _kOpenSSLReasonStringData @@ -2804,6 +2826,7 @@ %xdefine _rsa_default_private_transform _ %+ BORINGSSL_PREFIX %+ _rsa_default_private_transform %xdefine _rsa_default_sign_raw _ %+ BORINGSSL_PREFIX %+ _rsa_default_sign_raw %xdefine _rsa_default_size _ %+ BORINGSSL_PREFIX %+ _rsa_default_size +%xdefine _rsa_invalidate_key _ %+ BORINGSSL_PREFIX %+ _rsa_invalidate_key %xdefine _rsa_pkey_meth _ %+ BORINGSSL_PREFIX %+ _rsa_pkey_meth %xdefine _rsa_private_transform _ %+ BORINGSSL_PREFIX %+ _rsa_private_transform %xdefine _rsa_private_transform_no_self_test _ %+ BORINGSSL_PREFIX %+ _rsa_private_transform_no_self_test @@ -2821,28 +2844,14 @@ %xdefine _sha1_block_data_order _ %+ BORINGSSL_PREFIX %+ _sha1_block_data_order %xdefine _sha256_block_data_order _ %+ BORINGSSL_PREFIX %+ _sha256_block_data_order %xdefine _sha512_block_data_order _ %+ BORINGSSL_PREFIX %+ _sha512_block_data_order -%xdefine _sk_deep_copy _ %+ BORINGSSL_PREFIX %+ _sk_deep_copy -%xdefine _sk_delete _ %+ BORINGSSL_PREFIX %+ _sk_delete -%xdefine _sk_delete_if _ %+ BORINGSSL_PREFIX %+ _sk_delete_if -%xdefine _sk_delete_ptr _ %+ BORINGSSL_PREFIX %+ _sk_delete_ptr -%xdefine _sk_dup _ %+ BORINGSSL_PREFIX %+ _sk_dup -%xdefine _sk_find _ %+ BORINGSSL_PREFIX %+ _sk_find %xdefine _sk_free _ %+ BORINGSSL_PREFIX %+ _sk_free -%xdefine _sk_insert _ %+ BORINGSSL_PREFIX %+ _sk_insert -%xdefine _sk_is_sorted _ %+ BORINGSSL_PREFIX %+ _sk_is_sorted -%xdefine _sk_new _ %+ BORINGSSL_PREFIX %+ _sk_new %xdefine _sk_new_null _ %+ BORINGSSL_PREFIX %+ _sk_new_null %xdefine _sk_num _ %+ BORINGSSL_PREFIX %+ _sk_num %xdefine _sk_pop _ %+ BORINGSSL_PREFIX %+ _sk_pop %xdefine _sk_pop_free _ %+ BORINGSSL_PREFIX %+ _sk_pop_free %xdefine _sk_pop_free_ex _ %+ BORINGSSL_PREFIX %+ _sk_pop_free_ex %xdefine _sk_push _ %+ BORINGSSL_PREFIX %+ _sk_push -%xdefine _sk_set _ %+ BORINGSSL_PREFIX %+ _sk_set -%xdefine _sk_set_cmp_func _ %+ BORINGSSL_PREFIX %+ _sk_set_cmp_func -%xdefine _sk_shift _ %+ BORINGSSL_PREFIX %+ _sk_shift -%xdefine _sk_sort _ %+ BORINGSSL_PREFIX %+ _sk_sort %xdefine _sk_value _ %+ BORINGSSL_PREFIX %+ _sk_value -%xdefine _sk_zero _ %+ BORINGSSL_PREFIX %+ _sk_zero %xdefine _v2i_GENERAL_NAME _ %+ BORINGSSL_PREFIX %+ _v2i_GENERAL_NAME %xdefine _v2i_GENERAL_NAMES _ %+ BORINGSSL_PREFIX %+ _v2i_GENERAL_NAMES %xdefine _v2i_GENERAL_NAME_ex _ %+ BORINGSSL_PREFIX %+ _v2i_GENERAL_NAME_ex @@ -2885,6 +2894,7 @@ %xdefine _voprf_pst1_issuer_key_from_bytes _ %+ BORINGSSL_PREFIX %+ _voprf_pst1_issuer_key_from_bytes %xdefine _voprf_pst1_read _ %+ BORINGSSL_PREFIX %+ _voprf_pst1_read %xdefine _voprf_pst1_sign _ %+ BORINGSSL_PREFIX %+ _voprf_pst1_sign +%xdefine _voprf_pst1_sign_with_proof_scalar_for_testing _ %+ BORINGSSL_PREFIX %+ _voprf_pst1_sign_with_proof_scalar_for_testing %xdefine _voprf_pst1_unblind _ %+ BORINGSSL_PREFIX %+ _voprf_pst1_unblind %xdefine _vpaes_cbc_encrypt _ %+ BORINGSSL_PREFIX %+ _vpaes_cbc_encrypt %xdefine _vpaes_ctr32_encrypt_blocks _ %+ BORINGSSL_PREFIX %+ _vpaes_ctr32_encrypt_blocks @@ -2900,11 +2910,13 @@ %xdefine _x25519_ge_p3_to_cached _ %+ BORINGSSL_PREFIX %+ _x25519_ge_p3_to_cached %xdefine _x25519_ge_scalarmult _ %+ BORINGSSL_PREFIX %+ _x25519_ge_scalarmult %xdefine _x25519_ge_scalarmult_base _ %+ BORINGSSL_PREFIX %+ _x25519_ge_scalarmult_base +%xdefine _x25519_ge_scalarmult_base_adx _ %+ BORINGSSL_PREFIX %+ _x25519_ge_scalarmult_base_adx %xdefine _x25519_ge_scalarmult_small_precomp _ %+ BORINGSSL_PREFIX %+ _x25519_ge_scalarmult_small_precomp %xdefine _x25519_ge_sub _ %+ BORINGSSL_PREFIX %+ _x25519_ge_sub %xdefine _x25519_ge_tobytes _ %+ BORINGSSL_PREFIX %+ _x25519_ge_tobytes %xdefine _x25519_pkey_meth _ %+ BORINGSSL_PREFIX %+ _x25519_pkey_meth %xdefine _x25519_sc_reduce _ %+ BORINGSSL_PREFIX %+ _x25519_sc_reduce +%xdefine _x25519_scalar_mult_adx _ %+ BORINGSSL_PREFIX %+ _x25519_scalar_mult_adx %xdefine _x509V3_add_value_asn1_string _ %+ BORINGSSL_PREFIX %+ _x509V3_add_value_asn1_string %xdefine _x509_digest_sign_algorithm _ %+ BORINGSSL_PREFIX %+ _x509_digest_sign_algorithm %xdefine _x509_digest_verify_init _ %+ BORINGSSL_PREFIX %+ _x509_digest_verify_init @@ -3043,6 +3055,7 @@ %xdefine ASN1_TIME_set BORINGSSL_PREFIX %+ _ASN1_TIME_set %xdefine ASN1_TIME_set_posix BORINGSSL_PREFIX %+ _ASN1_TIME_set_posix %xdefine ASN1_TIME_set_string BORINGSSL_PREFIX %+ _ASN1_TIME_set_string +%xdefine ASN1_TIME_set_string_X509 BORINGSSL_PREFIX %+ _ASN1_TIME_set_string_X509 %xdefine ASN1_TIME_to_generalizedtime BORINGSSL_PREFIX %+ _ASN1_TIME_to_generalizedtime %xdefine ASN1_TIME_to_posix BORINGSSL_PREFIX %+ _ASN1_TIME_to_posix %xdefine ASN1_TIME_to_time_t BORINGSSL_PREFIX %+ _ASN1_TIME_to_time_t @@ -3478,10 +3491,6 @@ %xdefine CRYPTO_POLYVAL_finish BORINGSSL_PREFIX %+ _CRYPTO_POLYVAL_finish %xdefine CRYPTO_POLYVAL_init BORINGSSL_PREFIX %+ _CRYPTO_POLYVAL_init %xdefine CRYPTO_POLYVAL_update_blocks BORINGSSL_PREFIX %+ _CRYPTO_POLYVAL_update_blocks -%xdefine CRYPTO_STATIC_MUTEX_lock_read BORINGSSL_PREFIX %+ _CRYPTO_STATIC_MUTEX_lock_read -%xdefine CRYPTO_STATIC_MUTEX_lock_write BORINGSSL_PREFIX %+ _CRYPTO_STATIC_MUTEX_lock_write -%xdefine CRYPTO_STATIC_MUTEX_unlock_read BORINGSSL_PREFIX %+ _CRYPTO_STATIC_MUTEX_unlock_read -%xdefine CRYPTO_STATIC_MUTEX_unlock_write BORINGSSL_PREFIX %+ _CRYPTO_STATIC_MUTEX_unlock_write %xdefine CRYPTO_THREADID_current BORINGSSL_PREFIX %+ _CRYPTO_THREADID_current %xdefine CRYPTO_THREADID_set_callback BORINGSSL_PREFIX %+ _CRYPTO_THREADID_set_callback %xdefine CRYPTO_THREADID_set_numeric BORINGSSL_PREFIX %+ _CRYPTO_THREADID_set_numeric @@ -3555,6 +3564,7 @@ %xdefine CRYPTO_sysrand BORINGSSL_PREFIX %+ _CRYPTO_sysrand %xdefine CRYPTO_sysrand_for_seed BORINGSSL_PREFIX %+ _CRYPTO_sysrand_for_seed %xdefine CRYPTO_sysrand_if_available BORINGSSL_PREFIX %+ _CRYPTO_sysrand_if_available +%xdefine CRYPTO_tls13_hkdf_expand_label BORINGSSL_PREFIX %+ _CRYPTO_tls13_hkdf_expand_label %xdefine CRYPTO_tls1_prf BORINGSSL_PREFIX %+ _CRYPTO_tls1_prf %xdefine CTR_DRBG_clear BORINGSSL_PREFIX %+ _CTR_DRBG_clear %xdefine CTR_DRBG_free BORINGSSL_PREFIX %+ _CTR_DRBG_free @@ -3756,6 +3766,10 @@ %xdefine EC_curve_nid2nist BORINGSSL_PREFIX %+ _EC_curve_nid2nist %xdefine EC_curve_nist2nid BORINGSSL_PREFIX %+ _EC_curve_nist2nid %xdefine EC_get_builtin_curves BORINGSSL_PREFIX %+ _EC_get_builtin_curves +%xdefine EC_group_p224 BORINGSSL_PREFIX %+ _EC_group_p224 +%xdefine EC_group_p256 BORINGSSL_PREFIX %+ _EC_group_p256 +%xdefine EC_group_p384 BORINGSSL_PREFIX %+ _EC_group_p384 +%xdefine EC_group_p521 BORINGSSL_PREFIX %+ _EC_group_p521 %xdefine EC_hash_to_curve_p256_xmd_sha256_sswu BORINGSSL_PREFIX %+ _EC_hash_to_curve_p256_xmd_sha256_sswu %xdefine EC_hash_to_curve_p384_xmd_sha384_sswu BORINGSSL_PREFIX %+ _EC_hash_to_curve_p384_xmd_sha384_sswu %xdefine ED25519_keypair BORINGSSL_PREFIX %+ _ED25519_keypair @@ -3909,6 +3923,9 @@ %xdefine EVP_HPKE_CTX_new BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_new %xdefine EVP_HPKE_CTX_open BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_open %xdefine EVP_HPKE_CTX_seal BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_seal +%xdefine EVP_HPKE_CTX_setup_auth_recipient BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_auth_recipient +%xdefine EVP_HPKE_CTX_setup_auth_sender BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_auth_sender +%xdefine EVP_HPKE_CTX_setup_auth_sender_with_seed_for_testing BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_auth_sender_with_seed_for_testing %xdefine EVP_HPKE_CTX_setup_recipient BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_recipient %xdefine EVP_HPKE_CTX_setup_sender BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_sender %xdefine EVP_HPKE_CTX_setup_sender_with_seed_for_testing BORINGSSL_PREFIX %+ _EVP_HPKE_CTX_setup_sender_with_seed_for_testing @@ -4054,6 +4071,7 @@ %xdefine EVP_add_digest BORINGSSL_PREFIX %+ _EVP_add_digest %xdefine EVP_aead_aes_128_cbc_sha1_tls BORINGSSL_PREFIX %+ _EVP_aead_aes_128_cbc_sha1_tls %xdefine EVP_aead_aes_128_cbc_sha1_tls_implicit_iv BORINGSSL_PREFIX %+ _EVP_aead_aes_128_cbc_sha1_tls_implicit_iv +%xdefine EVP_aead_aes_128_cbc_sha256_tls BORINGSSL_PREFIX %+ _EVP_aead_aes_128_cbc_sha256_tls %xdefine EVP_aead_aes_128_ccm_bluetooth BORINGSSL_PREFIX %+ _EVP_aead_aes_128_ccm_bluetooth %xdefine EVP_aead_aes_128_ccm_bluetooth_8 BORINGSSL_PREFIX %+ _EVP_aead_aes_128_ccm_bluetooth_8 %xdefine EVP_aead_aes_128_ccm_matter BORINGSSL_PREFIX %+ _EVP_aead_aes_128_ccm_matter @@ -4075,7 +4093,6 @@ %xdefine EVP_aead_chacha20_poly1305 BORINGSSL_PREFIX %+ _EVP_aead_chacha20_poly1305 %xdefine EVP_aead_des_ede3_cbc_sha1_tls BORINGSSL_PREFIX %+ _EVP_aead_des_ede3_cbc_sha1_tls %xdefine EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv BORINGSSL_PREFIX %+ _EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv -%xdefine EVP_aead_null_sha1_tls BORINGSSL_PREFIX %+ _EVP_aead_null_sha1_tls %xdefine EVP_aead_xchacha20_poly1305 BORINGSSL_PREFIX %+ _EVP_aead_xchacha20_poly1305 %xdefine EVP_aes_128_cbc BORINGSSL_PREFIX %+ _EVP_aes_128_cbc %xdefine EVP_aes_128_ctr BORINGSSL_PREFIX %+ _EVP_aes_128_ctr @@ -4129,6 +4146,7 @@ %xdefine EVP_sha1_final_with_secret_suffix BORINGSSL_PREFIX %+ _EVP_sha1_final_with_secret_suffix %xdefine EVP_sha224 BORINGSSL_PREFIX %+ _EVP_sha224 %xdefine EVP_sha256 BORINGSSL_PREFIX %+ _EVP_sha256 +%xdefine EVP_sha256_final_with_secret_suffix BORINGSSL_PREFIX %+ _EVP_sha256_final_with_secret_suffix %xdefine EVP_sha384 BORINGSSL_PREFIX %+ _EVP_sha384 %xdefine EVP_sha512 BORINGSSL_PREFIX %+ _EVP_sha512 %xdefine EVP_sha512_256 BORINGSSL_PREFIX %+ _EVP_sha512_256 @@ -4260,7 +4278,6 @@ %xdefine OPENSSL_add_all_algorithms_conf BORINGSSL_PREFIX %+ _OPENSSL_add_all_algorithms_conf %xdefine OPENSSL_armcap_P BORINGSSL_PREFIX %+ _OPENSSL_armcap_P %xdefine OPENSSL_asprintf BORINGSSL_PREFIX %+ _OPENSSL_asprintf -%xdefine OPENSSL_built_in_curves BORINGSSL_PREFIX %+ _OPENSSL_built_in_curves %xdefine OPENSSL_cleanse BORINGSSL_PREFIX %+ _OPENSSL_cleanse %xdefine OPENSSL_cleanup BORINGSSL_PREFIX %+ _OPENSSL_cleanup %xdefine OPENSSL_clear_free BORINGSSL_PREFIX %+ _OPENSSL_clear_free @@ -4297,6 +4314,27 @@ %xdefine OPENSSL_realloc BORINGSSL_PREFIX %+ _OPENSSL_realloc %xdefine OPENSSL_secure_clear_free BORINGSSL_PREFIX %+ _OPENSSL_secure_clear_free %xdefine OPENSSL_secure_malloc BORINGSSL_PREFIX %+ _OPENSSL_secure_malloc +%xdefine OPENSSL_sk_deep_copy BORINGSSL_PREFIX %+ _OPENSSL_sk_deep_copy +%xdefine OPENSSL_sk_delete BORINGSSL_PREFIX %+ _OPENSSL_sk_delete +%xdefine OPENSSL_sk_delete_if BORINGSSL_PREFIX %+ _OPENSSL_sk_delete_if +%xdefine OPENSSL_sk_delete_ptr BORINGSSL_PREFIX %+ _OPENSSL_sk_delete_ptr +%xdefine OPENSSL_sk_dup BORINGSSL_PREFIX %+ _OPENSSL_sk_dup +%xdefine OPENSSL_sk_find BORINGSSL_PREFIX %+ _OPENSSL_sk_find +%xdefine OPENSSL_sk_free BORINGSSL_PREFIX %+ _OPENSSL_sk_free +%xdefine OPENSSL_sk_insert BORINGSSL_PREFIX %+ _OPENSSL_sk_insert +%xdefine OPENSSL_sk_is_sorted BORINGSSL_PREFIX %+ _OPENSSL_sk_is_sorted +%xdefine OPENSSL_sk_new BORINGSSL_PREFIX %+ _OPENSSL_sk_new +%xdefine OPENSSL_sk_new_null BORINGSSL_PREFIX %+ _OPENSSL_sk_new_null +%xdefine OPENSSL_sk_num BORINGSSL_PREFIX %+ _OPENSSL_sk_num +%xdefine OPENSSL_sk_pop BORINGSSL_PREFIX %+ _OPENSSL_sk_pop +%xdefine OPENSSL_sk_pop_free_ex BORINGSSL_PREFIX %+ _OPENSSL_sk_pop_free_ex +%xdefine OPENSSL_sk_push BORINGSSL_PREFIX %+ _OPENSSL_sk_push +%xdefine OPENSSL_sk_set BORINGSSL_PREFIX %+ _OPENSSL_sk_set +%xdefine OPENSSL_sk_set_cmp_func BORINGSSL_PREFIX %+ _OPENSSL_sk_set_cmp_func +%xdefine OPENSSL_sk_shift BORINGSSL_PREFIX %+ _OPENSSL_sk_shift +%xdefine OPENSSL_sk_sort BORINGSSL_PREFIX %+ _OPENSSL_sk_sort +%xdefine OPENSSL_sk_value BORINGSSL_PREFIX %+ _OPENSSL_sk_value +%xdefine OPENSSL_sk_zero BORINGSSL_PREFIX %+ _OPENSSL_sk_zero %xdefine OPENSSL_strcasecmp BORINGSSL_PREFIX %+ _OPENSSL_strcasecmp %xdefine OPENSSL_strdup BORINGSSL_PREFIX %+ _OPENSSL_strdup %xdefine OPENSSL_strhash BORINGSSL_PREFIX %+ _OPENSSL_strhash @@ -4513,6 +4551,13 @@ %xdefine RSA_marshal_public_key BORINGSSL_PREFIX %+ _RSA_marshal_public_key %xdefine RSA_new BORINGSSL_PREFIX %+ _RSA_new %xdefine RSA_new_method BORINGSSL_PREFIX %+ _RSA_new_method +%xdefine RSA_new_method_no_e BORINGSSL_PREFIX %+ _RSA_new_method_no_e +%xdefine RSA_new_private_key BORINGSSL_PREFIX %+ _RSA_new_private_key +%xdefine RSA_new_private_key_large_e BORINGSSL_PREFIX %+ _RSA_new_private_key_large_e +%xdefine RSA_new_private_key_no_crt BORINGSSL_PREFIX %+ _RSA_new_private_key_no_crt +%xdefine RSA_new_private_key_no_e BORINGSSL_PREFIX %+ _RSA_new_private_key_no_e +%xdefine RSA_new_public_key BORINGSSL_PREFIX %+ _RSA_new_public_key +%xdefine RSA_new_public_key_large_e BORINGSSL_PREFIX %+ _RSA_new_public_key_large_e %xdefine RSA_padding_add_PKCS1_OAEP_mgf1 BORINGSSL_PREFIX %+ _RSA_padding_add_PKCS1_OAEP_mgf1 %xdefine RSA_padding_add_PKCS1_PSS_mgf1 BORINGSSL_PREFIX %+ _RSA_padding_add_PKCS1_PSS_mgf1 %xdefine RSA_padding_add_PKCS1_type_1 BORINGSSL_PREFIX %+ _RSA_padding_add_PKCS1_type_1 @@ -4617,10 +4662,8 @@ %xdefine X509V3_EXT_REQ_add_nconf BORINGSSL_PREFIX %+ _X509V3_EXT_REQ_add_nconf %xdefine X509V3_EXT_add BORINGSSL_PREFIX %+ _X509V3_EXT_add %xdefine X509V3_EXT_add_alias BORINGSSL_PREFIX %+ _X509V3_EXT_add_alias -%xdefine X509V3_EXT_add_list BORINGSSL_PREFIX %+ _X509V3_EXT_add_list %xdefine X509V3_EXT_add_nconf BORINGSSL_PREFIX %+ _X509V3_EXT_add_nconf %xdefine X509V3_EXT_add_nconf_sk BORINGSSL_PREFIX %+ _X509V3_EXT_add_nconf_sk -%xdefine X509V3_EXT_cleanup BORINGSSL_PREFIX %+ _X509V3_EXT_cleanup %xdefine X509V3_EXT_d2i BORINGSSL_PREFIX %+ _X509V3_EXT_d2i %xdefine X509V3_EXT_free BORINGSSL_PREFIX %+ _X509V3_EXT_free %xdefine X509V3_EXT_get BORINGSSL_PREFIX %+ _X509V3_EXT_get @@ -5106,15 +5149,6 @@ %xdefine X509_verify BORINGSSL_PREFIX %+ _X509_verify %xdefine X509_verify_cert BORINGSSL_PREFIX %+ _X509_verify_cert %xdefine X509_verify_cert_error_string BORINGSSL_PREFIX %+ _X509_verify_cert_error_string -%xdefine X509at_add1_attr BORINGSSL_PREFIX %+ _X509at_add1_attr -%xdefine X509at_add1_attr_by_NID BORINGSSL_PREFIX %+ _X509at_add1_attr_by_NID -%xdefine X509at_add1_attr_by_OBJ BORINGSSL_PREFIX %+ _X509at_add1_attr_by_OBJ -%xdefine X509at_add1_attr_by_txt BORINGSSL_PREFIX %+ _X509at_add1_attr_by_txt -%xdefine X509at_delete_attr BORINGSSL_PREFIX %+ _X509at_delete_attr -%xdefine X509at_get_attr BORINGSSL_PREFIX %+ _X509at_get_attr -%xdefine X509at_get_attr_by_NID BORINGSSL_PREFIX %+ _X509at_get_attr_by_NID -%xdefine X509at_get_attr_by_OBJ BORINGSSL_PREFIX %+ _X509at_get_attr_by_OBJ -%xdefine X509at_get_attr_count BORINGSSL_PREFIX %+ _X509at_get_attr_count %xdefine X509v3_add_ext BORINGSSL_PREFIX %+ _X509v3_add_ext %xdefine X509v3_delete_ext BORINGSSL_PREFIX %+ _X509v3_delete_ext %xdefine X509v3_get_ext BORINGSSL_PREFIX %+ _X509v3_get_ext @@ -5180,7 +5214,7 @@ %xdefine asn1_type_value_as_pointer BORINGSSL_PREFIX %+ _asn1_type_value_as_pointer %xdefine asn1_utctime_to_tm BORINGSSL_PREFIX %+ _asn1_utctime_to_tm %xdefine beeu_mod_inverse_vartime BORINGSSL_PREFIX %+ _beeu_mod_inverse_vartime -%xdefine bio_fd_should_retry BORINGSSL_PREFIX %+ _bio_fd_should_retry +%xdefine bio_errno_should_retry BORINGSSL_PREFIX %+ _bio_errno_should_retry %xdefine bn_abs_sub_consttime BORINGSSL_PREFIX %+ _bn_abs_sub_consttime %xdefine bn_add_words BORINGSSL_PREFIX %+ _bn_add_words %xdefine bn_assert_fits_in_bytes BORINGSSL_PREFIX %+ _bn_assert_fits_in_bytes @@ -5203,7 +5237,6 @@ %xdefine bn_minimal_width BORINGSSL_PREFIX %+ _bn_minimal_width %xdefine bn_mod_add_consttime BORINGSSL_PREFIX %+ _bn_mod_add_consttime %xdefine bn_mod_add_words BORINGSSL_PREFIX %+ _bn_mod_add_words -%xdefine bn_mod_exp_base_2_consttime BORINGSSL_PREFIX %+ _bn_mod_exp_base_2_consttime %xdefine bn_mod_exp_mont_small BORINGSSL_PREFIX %+ _bn_mod_exp_mont_small %xdefine bn_mod_inverse0_prime_mont_small BORINGSSL_PREFIX %+ _bn_mod_inverse0_prime_mont_small %xdefine bn_mod_inverse_consttime BORINGSSL_PREFIX %+ _bn_mod_inverse_consttime @@ -5215,6 +5248,9 @@ %xdefine bn_mod_sub_consttime BORINGSSL_PREFIX %+ _bn_mod_sub_consttime %xdefine bn_mod_sub_words BORINGSSL_PREFIX %+ _bn_mod_sub_words %xdefine bn_mod_u16_consttime BORINGSSL_PREFIX %+ _bn_mod_u16_consttime +%xdefine bn_mont_ctx_cleanup BORINGSSL_PREFIX %+ _bn_mont_ctx_cleanup +%xdefine bn_mont_ctx_init BORINGSSL_PREFIX %+ _bn_mont_ctx_init +%xdefine bn_mont_ctx_set_RR_consttime BORINGSSL_PREFIX %+ _bn_mont_ctx_set_RR_consttime %xdefine bn_mont_n0 BORINGSSL_PREFIX %+ _bn_mont_n0 %xdefine bn_mul_add_words BORINGSSL_PREFIX %+ _bn_mul_add_words %xdefine bn_mul_comba4 BORINGSSL_PREFIX %+ _bn_mul_comba4 @@ -5399,9 +5435,6 @@ %xdefine ec_GFp_mont_felem_reduce BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_reduce %xdefine ec_GFp_mont_felem_sqr BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_sqr %xdefine ec_GFp_mont_felem_to_bytes BORINGSSL_PREFIX %+ _ec_GFp_mont_felem_to_bytes -%xdefine ec_GFp_mont_group_finish BORINGSSL_PREFIX %+ _ec_GFp_mont_group_finish -%xdefine ec_GFp_mont_group_init BORINGSSL_PREFIX %+ _ec_GFp_mont_group_init -%xdefine ec_GFp_mont_group_set_curve BORINGSSL_PREFIX %+ _ec_GFp_mont_group_set_curve %xdefine ec_GFp_mont_init_precomp BORINGSSL_PREFIX %+ _ec_GFp_mont_init_precomp %xdefine ec_GFp_mont_mul BORINGSSL_PREFIX %+ _ec_GFp_mont_mul %xdefine ec_GFp_mont_mul_base BORINGSSL_PREFIX %+ _ec_GFp_mont_mul_base @@ -5412,9 +5445,7 @@ %xdefine ec_GFp_simple_cmp_x_coordinate BORINGSSL_PREFIX %+ _ec_GFp_simple_cmp_x_coordinate %xdefine ec_GFp_simple_felem_from_bytes BORINGSSL_PREFIX %+ _ec_GFp_simple_felem_from_bytes %xdefine ec_GFp_simple_felem_to_bytes BORINGSSL_PREFIX %+ _ec_GFp_simple_felem_to_bytes -%xdefine ec_GFp_simple_group_finish BORINGSSL_PREFIX %+ _ec_GFp_simple_group_finish %xdefine ec_GFp_simple_group_get_curve BORINGSSL_PREFIX %+ _ec_GFp_simple_group_get_curve -%xdefine ec_GFp_simple_group_init BORINGSSL_PREFIX %+ _ec_GFp_simple_group_init %xdefine ec_GFp_simple_group_set_curve BORINGSSL_PREFIX %+ _ec_GFp_simple_group_set_curve %xdefine ec_GFp_simple_invert BORINGSSL_PREFIX %+ _ec_GFp_simple_invert %xdefine ec_GFp_simple_is_at_infinity BORINGSSL_PREFIX %+ _ec_GFp_simple_is_at_infinity @@ -5436,13 +5467,13 @@ %xdefine ec_felem_from_bytes BORINGSSL_PREFIX %+ _ec_felem_from_bytes %xdefine ec_felem_neg BORINGSSL_PREFIX %+ _ec_felem_neg %xdefine ec_felem_non_zero_mask BORINGSSL_PREFIX %+ _ec_felem_non_zero_mask +%xdefine ec_felem_one BORINGSSL_PREFIX %+ _ec_felem_one %xdefine ec_felem_select BORINGSSL_PREFIX %+ _ec_felem_select %xdefine ec_felem_sub BORINGSSL_PREFIX %+ _ec_felem_sub %xdefine ec_felem_to_bignum BORINGSSL_PREFIX %+ _ec_felem_to_bignum %xdefine ec_felem_to_bytes BORINGSSL_PREFIX %+ _ec_felem_to_bytes %xdefine ec_get_x_coordinate_as_bytes BORINGSSL_PREFIX %+ _ec_get_x_coordinate_as_bytes %xdefine ec_get_x_coordinate_as_scalar BORINGSSL_PREFIX %+ _ec_get_x_coordinate_as_scalar -%xdefine ec_group_new BORINGSSL_PREFIX %+ _ec_group_new %xdefine ec_hash_to_curve_p256_xmd_sha256_sswu BORINGSSL_PREFIX %+ _ec_hash_to_curve_p256_xmd_sha256_sswu %xdefine ec_hash_to_curve_p384_xmd_sha384_sswu BORINGSSL_PREFIX %+ _ec_hash_to_curve_p384_xmd_sha384_sswu %xdefine ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 BORINGSSL_PREFIX %+ _ec_hash_to_curve_p384_xmd_sha512_sswu_draft07 @@ -5502,6 +5533,8 @@ %xdefine ecp_nistz256_sub BORINGSSL_PREFIX %+ _ecp_nistz256_sub %xdefine ed25519_asn1_meth BORINGSSL_PREFIX %+ _ed25519_asn1_meth %xdefine ed25519_pkey_meth BORINGSSL_PREFIX %+ _ed25519_pkey_meth +%xdefine fiat_curve25519_adx_mul BORINGSSL_PREFIX %+ _fiat_curve25519_adx_mul +%xdefine fiat_curve25519_adx_square BORINGSSL_PREFIX %+ _fiat_curve25519_adx_square %xdefine gcm_ghash_avx BORINGSSL_PREFIX %+ _gcm_ghash_avx %xdefine gcm_ghash_clmul BORINGSSL_PREFIX %+ _gcm_ghash_clmul %xdefine gcm_ghash_neon BORINGSSL_PREFIX %+ _gcm_ghash_neon @@ -5660,6 +5693,7 @@ %xdefine i2t_ASN1_OBJECT BORINGSSL_PREFIX %+ _i2t_ASN1_OBJECT %xdefine i2v_GENERAL_NAME BORINGSSL_PREFIX %+ _i2v_GENERAL_NAME %xdefine i2v_GENERAL_NAMES BORINGSSL_PREFIX %+ _i2v_GENERAL_NAMES +%xdefine k25519Precomp BORINGSSL_PREFIX %+ _k25519Precomp %xdefine kBoringSSLRSASqrtTwo BORINGSSL_PREFIX %+ _kBoringSSLRSASqrtTwo %xdefine kBoringSSLRSASqrtTwoLen BORINGSSL_PREFIX %+ _kBoringSSLRSASqrtTwoLen %xdefine kOpenSSLReasonStringData BORINGSSL_PREFIX %+ _kOpenSSLReasonStringData @@ -5708,6 +5742,7 @@ %xdefine rsa_default_private_transform BORINGSSL_PREFIX %+ _rsa_default_private_transform %xdefine rsa_default_sign_raw BORINGSSL_PREFIX %+ _rsa_default_sign_raw %xdefine rsa_default_size BORINGSSL_PREFIX %+ _rsa_default_size +%xdefine rsa_invalidate_key BORINGSSL_PREFIX %+ _rsa_invalidate_key %xdefine rsa_pkey_meth BORINGSSL_PREFIX %+ _rsa_pkey_meth %xdefine rsa_private_transform BORINGSSL_PREFIX %+ _rsa_private_transform %xdefine rsa_private_transform_no_self_test BORINGSSL_PREFIX %+ _rsa_private_transform_no_self_test @@ -5725,28 +5760,14 @@ %xdefine sha1_block_data_order BORINGSSL_PREFIX %+ _sha1_block_data_order %xdefine sha256_block_data_order BORINGSSL_PREFIX %+ _sha256_block_data_order %xdefine sha512_block_data_order BORINGSSL_PREFIX %+ _sha512_block_data_order -%xdefine sk_deep_copy BORINGSSL_PREFIX %+ _sk_deep_copy -%xdefine sk_delete BORINGSSL_PREFIX %+ _sk_delete -%xdefine sk_delete_if BORINGSSL_PREFIX %+ _sk_delete_if -%xdefine sk_delete_ptr BORINGSSL_PREFIX %+ _sk_delete_ptr -%xdefine sk_dup BORINGSSL_PREFIX %+ _sk_dup -%xdefine sk_find BORINGSSL_PREFIX %+ _sk_find %xdefine sk_free BORINGSSL_PREFIX %+ _sk_free -%xdefine sk_insert BORINGSSL_PREFIX %+ _sk_insert -%xdefine sk_is_sorted BORINGSSL_PREFIX %+ _sk_is_sorted -%xdefine sk_new BORINGSSL_PREFIX %+ _sk_new %xdefine sk_new_null BORINGSSL_PREFIX %+ _sk_new_null %xdefine sk_num BORINGSSL_PREFIX %+ _sk_num %xdefine sk_pop BORINGSSL_PREFIX %+ _sk_pop %xdefine sk_pop_free BORINGSSL_PREFIX %+ _sk_pop_free %xdefine sk_pop_free_ex BORINGSSL_PREFIX %+ _sk_pop_free_ex %xdefine sk_push BORINGSSL_PREFIX %+ _sk_push -%xdefine sk_set BORINGSSL_PREFIX %+ _sk_set -%xdefine sk_set_cmp_func BORINGSSL_PREFIX %+ _sk_set_cmp_func -%xdefine sk_shift BORINGSSL_PREFIX %+ _sk_shift -%xdefine sk_sort BORINGSSL_PREFIX %+ _sk_sort %xdefine sk_value BORINGSSL_PREFIX %+ _sk_value -%xdefine sk_zero BORINGSSL_PREFIX %+ _sk_zero %xdefine v2i_GENERAL_NAME BORINGSSL_PREFIX %+ _v2i_GENERAL_NAME %xdefine v2i_GENERAL_NAMES BORINGSSL_PREFIX %+ _v2i_GENERAL_NAMES %xdefine v2i_GENERAL_NAME_ex BORINGSSL_PREFIX %+ _v2i_GENERAL_NAME_ex @@ -5789,6 +5810,7 @@ %xdefine voprf_pst1_issuer_key_from_bytes BORINGSSL_PREFIX %+ _voprf_pst1_issuer_key_from_bytes %xdefine voprf_pst1_read BORINGSSL_PREFIX %+ _voprf_pst1_read %xdefine voprf_pst1_sign BORINGSSL_PREFIX %+ _voprf_pst1_sign +%xdefine voprf_pst1_sign_with_proof_scalar_for_testing BORINGSSL_PREFIX %+ _voprf_pst1_sign_with_proof_scalar_for_testing %xdefine voprf_pst1_unblind BORINGSSL_PREFIX %+ _voprf_pst1_unblind %xdefine vpaes_cbc_encrypt BORINGSSL_PREFIX %+ _vpaes_cbc_encrypt %xdefine vpaes_ctr32_encrypt_blocks BORINGSSL_PREFIX %+ _vpaes_ctr32_encrypt_blocks @@ -5804,11 +5826,13 @@ %xdefine x25519_ge_p3_to_cached BORINGSSL_PREFIX %+ _x25519_ge_p3_to_cached %xdefine x25519_ge_scalarmult BORINGSSL_PREFIX %+ _x25519_ge_scalarmult %xdefine x25519_ge_scalarmult_base BORINGSSL_PREFIX %+ _x25519_ge_scalarmult_base +%xdefine x25519_ge_scalarmult_base_adx BORINGSSL_PREFIX %+ _x25519_ge_scalarmult_base_adx %xdefine x25519_ge_scalarmult_small_precomp BORINGSSL_PREFIX %+ _x25519_ge_scalarmult_small_precomp %xdefine x25519_ge_sub BORINGSSL_PREFIX %+ _x25519_ge_sub %xdefine x25519_ge_tobytes BORINGSSL_PREFIX %+ _x25519_ge_tobytes %xdefine x25519_pkey_meth BORINGSSL_PREFIX %+ _x25519_pkey_meth %xdefine x25519_sc_reduce BORINGSSL_PREFIX %+ _x25519_sc_reduce +%xdefine x25519_scalar_mult_adx BORINGSSL_PREFIX %+ _x25519_scalar_mult_adx %xdefine x509V3_add_value_asn1_string BORINGSSL_PREFIX %+ _x509V3_add_value_asn1_string %xdefine x509_digest_sign_algorithm BORINGSSL_PREFIX %+ _x509_digest_sign_algorithm %xdefine x509_digest_verify_init BORINGSSL_PREFIX %+ _x509_digest_verify_init diff --git a/Sources/CCryptoBoringSSL/third_party/fiat/asm/fiat_curve25519_adx_mul.S b/Sources/CCryptoBoringSSL/third_party/fiat/asm/fiat_curve25519_adx_mul.S new file mode 100644 index 00000000..d0d765c8 --- /dev/null +++ b/Sources/CCryptoBoringSSL/third_party/fiat/asm/fiat_curve25519_adx_mul.S @@ -0,0 +1,175 @@ +#define BORINGSSL_PREFIX CCryptoBoringSSL +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \ + (defined(__APPLE__) || defined(__ELF__)) + +.intel_syntax noprefix +.text +#if defined(__APPLE__) +.private_extern _fiat_curve25519_adx_mul +.global _fiat_curve25519_adx_mul +_fiat_curve25519_adx_mul: +#else +.type fiat_curve25519_adx_mul, @function +.hidden fiat_curve25519_adx_mul +.global fiat_curve25519_adx_mul +fiat_curve25519_adx_mul: +#endif + +.cfi_startproc +_CET_ENDBR +mov [rsp - 0x08], rbp +.cfi_offset rbp, -8-0x08 +mov rbp, rsp + +mov rax, rdx +mov rdx, [ rsi + 0x18 ] +mulx r11, r10, [ rax + 0x8 ] +mov rdx, [ rax + 0x0 ] +mov [ rsp - 0x58 ], r15 +.cfi_offset r15, -8-0x58 +mulx r8, rcx, [ rsi + 0x18 ] +mov rdx, [ rsi + 0x8 ] +mov [ rsp - 0x80 ], rbx +.cfi_offset rbx, -8-0x80 +mulx rbx, r9, [ rax + 0x18 ] +mov rdx, [ rsi + 0x8 ] +mov [ rsp - 0x70 ], r12 +.cfi_offset r12, -8-0x70 +mulx r15, r12, [ rax + 0x8 ] +mov rdx, [ rsi + 0x0 ] +mov [ rsp - 0x68 ], r13 +.cfi_offset r13, -8-0x68 +mov [ rsp - 0x60 ], r14 +.cfi_offset r14, -8-0x60 +mulx r14, r13, [ rax + 0x0 ] +mov rdx, [ rax + 0x10 ] +mov [ rsp - 0x18 ], r15 +mov [ rsp - 0x50 ], rdi +mulx rdi, r15, [ rsi + 0x0 ] +mov rdx, [ rax + 0x18 ] +mov [ rsp - 0x48 ], r13 +mov [ rsp - 0x40 ], r9 +mulx r9, r13, [ rsi + 0x0 ] +test al, al +adox rcx, rdi +mov rdx, [ rsi + 0x10 ] +mov [ rsp - 0x38 ], r13 +mulx r13, rdi, [ rax + 0x8 ] +adox r10, r9 +mov rdx, 0x0 +adox rbx, rdx +adcx rdi, rcx +adcx r8, r10 +mov r9, rdx +adcx r9, rbx +mov rdx, [ rsi + 0x10 ] +mulx r10, rcx, [ rax + 0x0 ] +mov rdx, [ rsi + 0x0 ] +mov [ rsp - 0x30 ], r15 +mulx r15, rbx, [ rax + 0x8 ] +mov rdx, -0x2 +inc rdx +adox rcx, r15 +setc r15b +clc +adcx rcx, r12 +adox r10, rdi +mov rdx, [ rax + 0x10 ] +mov [ rsp - 0x78 ], rcx +mulx rcx, rdi, [ rsi + 0x10 ] +adox rdi, r8 +mov rdx, [ rax + 0x18 ] +mov [ rsp - 0x28 ], rcx +mulx rcx, r8, [ rsi + 0x10 ] +mov rdx, [ rax + 0x10 ] +mov [ rsp - 0x20 ], r8 +mulx r12, r8, [ rsi + 0x18 ] +adox r8, r9 +mov rdx, [ rsi + 0x8 ] +mov [ rsp - 0x10 ], r12 +mulx r12, r9, [ rax + 0x10 ] +movzx rdx, r15b +lea rdx, [ rdx + rcx ] +adcx r9, r10 +adcx r13, rdi +mov r15, 0x0 +mov r10, r15 +adox r10, rdx +mov rdx, [ rax + 0x18 ] +mulx rcx, rdi, [ rsi + 0x18 ] +adox rcx, r15 +adcx r11, r8 +mov rdx, r15 +adcx rdx, r10 +adcx rcx, r15 +mov r8, rdx +mov rdx, [ rax + 0x0 ] +mulx r15, r10, [ rsi + 0x8 ] +test al, al +adox r10, r14 +adcx rbx, r10 +adox r15, [ rsp - 0x78 ] +adcx r15, [ rsp - 0x30 ] +adox r9, [ rsp - 0x18 ] +adcx r9, [ rsp - 0x38 ] +adox r13, [ rsp - 0x40 ] +adcx r12, r13 +adox r11, [ rsp - 0x20 ] +adcx r11, [ rsp - 0x28 ] +mov rdx, 0x26 +mulx rsi, r14, r12 +adox rdi, r8 +adcx rdi, [ rsp - 0x10 ] +mulx r10, r8, r11 +mov r13, 0x0 +adox rcx, r13 +adcx rcx, r13 +mulx r11, r12, rdi +xor rdi, rdi +adox r8, rbx +adox r12, r15 +mulx rbx, r13, rcx +adcx r14, [ rsp - 0x48 ] +adox r13, r9 +adox rbx, rdi +adcx rsi, r8 +adcx r10, r12 +adcx r11, r13 +adc rbx, 0x0 +mulx r9, r15, rbx +xor r9, r9 +adox r15, r14 +mov rdi, r9 +adox rdi, rsi +mov rcx, r9 +adox rcx, r10 +mov r8, [ rsp - 0x50 ] +mov [ r8 + 0x8 ], rdi +mov r12, r9 +adox r12, r11 +mov r14, r9 +cmovo r14, rdx +mov [ r8 + 0x18 ], r12 +adcx r15, r14 +mov [ r8 + 0x0 ], r15 +mov [ r8 + 0x10 ], rcx +mov rbx, [ rsp - 0x80 ] +mov r12, [ rsp - 0x70 ] +mov r13, [ rsp - 0x68 ] +mov r14, [ rsp - 0x60 ] +mov r15, [ rsp - 0x58 ] + +mov rbp, [rsp - 0x08] +ret +.cfi_endproc +#if defined(__ELF__) +.size fiat_curve25519_adx_mul, .-fiat_curve25519_adx_mul +#endif + +#endif +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif + diff --git a/Sources/CCryptoBoringSSL/third_party/fiat/asm/fiat_curve25519_adx_square.S b/Sources/CCryptoBoringSSL/third_party/fiat/asm/fiat_curve25519_adx_square.S new file mode 100644 index 00000000..7ea6f6cb --- /dev/null +++ b/Sources/CCryptoBoringSSL/third_party/fiat/asm/fiat_curve25519_adx_square.S @@ -0,0 +1,143 @@ +#define BORINGSSL_PREFIX CCryptoBoringSSL +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \ + (defined(__APPLE__) || defined(__ELF__)) + +.intel_syntax noprefix +.text +#if defined(__APPLE__) +.private_extern _fiat_curve25519_adx_square +.global _fiat_curve25519_adx_square +_fiat_curve25519_adx_square: +#else +.type fiat_curve25519_adx_square, @function +.hidden fiat_curve25519_adx_square +.global fiat_curve25519_adx_square +fiat_curve25519_adx_square: +#endif + +.cfi_startproc +_CET_ENDBR +mov [rsp - 0x08], rbp +.cfi_offset rbp, -8-0x08 +mov rbp, rsp + +mov rdx, [ rsi + 0x0 ] +mulx r10, rax, [ rsi + 0x8 ] +mov rdx, [ rsi + 0x0 ] +mulx rcx, r11, [ rsi + 0x10 ] +xor rdx, rdx +adox r11, r10 +mov rdx, [ rsi + 0x0 ] +mulx r9, r8, [ rsi + 0x18 ] +mov rdx, [ rsi + 0x8 ] +mov [ rsp - 0x80 ], rbx +.cfi_offset rbx, -8-0x80 +mulx rbx, r10, [ rsi + 0x18 ] +adox r8, rcx +mov [rsp - 0x48 ], rdi +adox r10, r9 +adcx rax, rax +mov rdx, [ rsi + 0x10 ] +mulx r9, rcx, [ rsi + 0x18 ] +adox rcx, rbx +mov rdx, [ rsi + 0x10 ] +mulx rdi, rbx, [ rsi + 0x8 ] +mov rdx, 0x0 +adox r9, rdx +mov [ rsp - 0x70 ], r12 +.cfi_offset r12, -8-0x70 +mov r12, -0x3 +inc r12 +adox rbx, r8 +adox rdi, r10 +adcx r11, r11 +mov r8, rdx +adox r8, rcx +mov r10, rdx +adox r10, r9 +adcx rbx, rbx +mov rdx, [ rsi + 0x0 ] +mulx r9, rcx, rdx +mov rdx, [ rsi + 0x8 ] +mov [ rsp - 0x68 ], r13 +.cfi_offset r13, -8-0x68 +mov [ rsp - 0x60 ], r14 +.cfi_offset r14, -8-0x60 +mulx r14, r13, rdx +seto dl +inc r12 +adox r9, rax +adox r13, r11 +adox r14, rbx +adcx rdi, rdi +mov al, dl +mov rdx, [ rsi + 0x10 ] +mulx rbx, r11, rdx +adox r11, rdi +adcx r8, r8 +adox rbx, r8 +adcx r10, r10 +movzx rdx, al +mov rdi, 0x0 +adcx rdx, rdi +movzx r8, al +lea r8, [ r8 + rdx ] +mov rdx, [ rsi + 0x18 ] +mulx rdi, rax, rdx +adox rax, r10 +mov rdx, 0x26 +mov [ rsp - 0x58 ], r15 +.cfi_offset r15, -8-0x58 +mulx r15, r10, r11 +clc +adcx r10, rcx +mulx r11, rcx, rbx +adox r8, rdi +mulx rdi, rbx, r8 +inc r12 +adox rcx, r9 +mulx r8, r9, rax +adcx r15, rcx +adox r9, r13 +adcx r11, r9 +adox rbx, r14 +adox rdi, r12 +adcx r8, rbx +adc rdi, 0x0 +mulx r14, r13, rdi +test al, al +mov rdi, [ rsp - 0x48 ] +adox r13, r10 +mov r14, r12 +adox r14, r15 +mov [ rdi + 0x8 ], r14 +mov rax, r12 +adox rax, r11 +mov r10, r12 +adox r10, r8 +mov [ rdi + 0x10 ], rax +mov rcx, r12 +cmovo rcx, rdx +adcx r13, rcx +mov [ rdi + 0x0 ], r13 +mov [ rdi + 0x18 ], r10 +mov rbx, [ rsp - 0x80 ] +mov r12, [ rsp - 0x70 ] +mov r13, [ rsp - 0x68 ] +mov r14, [ rsp - 0x60 ] +mov r15, [ rsp - 0x58 ] + +mov rbp, [rsp - 0x08] +ret +.cfi_endproc +#if defined(__ELF__) +.size fiat_curve25519_adx_square, .-fiat_curve25519_adx_square +#endif + +#endif +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif + diff --git a/Sources/CCryptoBoringSSL/third_party/fiat/curve25519_64_adx.h b/Sources/CCryptoBoringSSL/third_party/fiat/curve25519_64_adx.h new file mode 100644 index 00000000..f50f5b83 --- /dev/null +++ b/Sources/CCryptoBoringSSL/third_party/fiat/curve25519_64_adx.h @@ -0,0 +1,691 @@ +#include +#include +#include +#include + +typedef uint64_t fe4[4]; +typedef uint8_t fiat_uint1; +typedef int8_t fiat_int1; + +static __inline__ uint64_t fiat_value_barrier_u64(uint64_t a) { + __asm__("" : "+r"(a) : /* no inputs */); + return a; +} + +__attribute__((target("adx,bmi2"))) +static inline void fe4_mul(fe4 out, const fe4 x, const fe4 y) { fiat_curve25519_adx_mul(out, x, y); } + +__attribute__((target("adx,bmi2"))) +static inline void fe4_sq(fe4 out, const fe4 x) { fiat_curve25519_adx_square(out, x); } + +/* + * The function fiat_mulx_u64 is a multiplication, returning the full double-width result. + * + * Postconditions: + * out1 = (arg1 * arg2) mod 2^64 + * out2 = ⌊arg1 * arg2 / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0xffffffffffffffff] + * arg2: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0xffffffffffffffff] + */ +__attribute__((target("adx,bmi2"))) +static inline void fiat_mulx_u64(uint64_t* out1, uint64_t* out2, uint64_t arg1, uint64_t arg2) { +// NOTE: edited after generation +#if defined(_M_X64) + unsigned long long t; + *out1 = _umul128(arg1, arg2, &t); + *out2 = t; +#elif defined(_M_ARM64) + *out1 = arg1 * arg2; + *out2 = __umulh(arg1, arg2); +#else + unsigned __int128 t = (unsigned __int128)arg1 * arg2; + *out1 = t; + *out2 = (t >> 64); +#endif +} + +/* + * The function fiat_addcarryx_u64 is an addition with carry. + * + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^64 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +__attribute__((target("adx,bmi2"))) +static inline void fiat_addcarryx_u64(uint64_t* out1, fiat_uint1* out2, fiat_uint1 arg1, uint64_t arg2, uint64_t arg3) { +// NOTE: edited after generation +#if defined(__has_builtin) +# if __has_builtin(__builtin_ia32_addcarryx_u64) +# define addcarry64 __builtin_ia32_addcarryx_u64 +# endif +#endif +#if defined(addcarry64) + long long unsigned int t; + *out2 = addcarry64(arg1, arg2, arg3, &t); + *out1 = t; +#elif defined(_M_X64) + long long unsigned int t; + *out2 = _addcarry_u64(arg1, arg2, arg3, out1); + *out1 = t; +#else + arg2 += arg1; + arg1 = arg2 < arg1; + uint64_t ret = arg2 + arg3; + arg1 += ret < arg2; + *out1 = ret; + *out2 = arg1; +#endif +#undef addcarry64 +} + +/* + * The function fiat_subborrowx_u64 is a subtraction with borrow. + * + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^64 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +__attribute__((target("adx,bmi2"))) +static inline void fiat_subborrowx_u64(uint64_t* out1, fiat_uint1* out2, fiat_uint1 arg1, uint64_t arg2, uint64_t arg3) { +#if defined(__has_builtin) +# if __has_builtin(__builtin_ia32_subborrow_u64) +# define subborrow64 __builtin_ia32_subborrow_u64 +# endif +#endif +#if defined(subborrow64) + long long unsigned int t; + *out2 = subborrow64(arg1, arg2, arg3, &t); + *out1 = t; +#elif defined(_M_X64) + long long unsigned int t; + *out2 = _subborrow_u64(arg1, arg2, arg3, &t); // NOTE: edited after generation + *out1 = t; +#else + *out1 = arg2 - arg3 - arg1; + *out2 = (arg2 < arg3) | ((arg2 == arg3) & arg1); +#endif +#undef subborrow64 +} + +/* + * The function fiat_cmovznz_u64 is a single-word conditional move. + * + * Postconditions: + * out1 = (if arg1 = 0 then arg2 else arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + */ +__attribute__((target("adx,bmi2"))) +static inline void fiat_cmovznz_u64(uint64_t* out1, fiat_uint1 arg1, uint64_t arg2, uint64_t arg3) { + fiat_uint1 x1; + uint64_t x2; + uint64_t x3; + x1 = (!(!arg1)); + x2 = ((fiat_int1)(0x0 - x1) & UINT64_C(0xffffffffffffffff)); + x3 = ((fiat_value_barrier_u64(x2) & arg3) | (fiat_value_barrier_u64((~x2)) & arg2)); + *out1 = x3; +} + +/* + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +__attribute__((target("adx,bmi2"))) +static void fe4_add(uint64_t out1[4], const uint64_t arg1[4], const uint64_t arg2[4]) { + uint64_t x1; + fiat_uint1 x2; + uint64_t x3; + fiat_uint1 x4; + uint64_t x5; + fiat_uint1 x6; + uint64_t x7; + fiat_uint1 x8; + uint64_t x9; + uint64_t x10; + fiat_uint1 x11; + uint64_t x12; + fiat_uint1 x13; + uint64_t x14; + fiat_uint1 x15; + uint64_t x16; + fiat_uint1 x17; + uint64_t x18; + uint64_t x19; + fiat_uint1 x20; + fiat_addcarryx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); + fiat_addcarryx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1])); + fiat_addcarryx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2])); + fiat_addcarryx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3])); + fiat_cmovznz_u64(&x9, x8, 0x0, UINT8_C(0x26)); // NOTE: clang 14 for Zen 2 uses sbb, and + fiat_addcarryx_u64(&x10, &x11, 0x0, x1, x9); + fiat_addcarryx_u64(&x12, &x13, x11, x3, 0x0); + fiat_addcarryx_u64(&x14, &x15, x13, x5, 0x0); + fiat_addcarryx_u64(&x16, &x17, x15, x7, 0x0); + fiat_cmovznz_u64(&x18, x17, 0x0, UINT8_C(0x26)); // NOTE: clang 14 for Zen 2 uses sbb, and + fiat_addcarryx_u64(&x19, &x20, 0x0, x10, x18); + out1[0] = x19; + out1[1] = x12; + out1[2] = x14; + out1[3] = x16; +} + +/* + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +__attribute__((target("adx,bmi2"))) +static void fe4_sub(uint64_t out1[4], const uint64_t arg1[4], const uint64_t arg2[4]) { + uint64_t x1; + uint64_t x2; + fiat_uint1 x3; + uint64_t x4; + uint64_t x5; + fiat_uint1 x6; + uint64_t x7; + uint64_t x8; + fiat_uint1 x9; + uint64_t x10; + uint64_t x11; + fiat_uint1 x12; + uint64_t x13; + uint64_t x14; + fiat_uint1 x15; + uint64_t x16; + fiat_uint1 x17; + uint64_t x18; + fiat_uint1 x19; + uint64_t x20; + fiat_uint1 x21; + uint64_t x22; + uint64_t x23; + fiat_uint1 x24; + x1 = (arg2[0]); + fiat_subborrowx_u64(&x2, &x3, 0x0, (arg1[0]), x1); + x4 = (arg2[1]); + fiat_subborrowx_u64(&x5, &x6, x3, (arg1[1]), x4); + x7 = (arg2[2]); + fiat_subborrowx_u64(&x8, &x9, x6, (arg1[2]), x7); + x10 = (arg2[3]); + fiat_subborrowx_u64(&x11, &x12, x9, (arg1[3]), x10); + fiat_cmovznz_u64(&x13, x12, 0x0, UINT8_C(0x26)); // NOTE: clang 14 for Zen 2 uses sbb, and + fiat_subborrowx_u64(&x14, &x15, 0x0, x2, x13); + fiat_subborrowx_u64(&x16, &x17, x15, x5, 0x0); + fiat_subborrowx_u64(&x18, &x19, x17, x8, 0x0); + fiat_subborrowx_u64(&x20, &x21, x19, x11, 0x0); + fiat_cmovznz_u64(&x22, x21, 0x0, UINT8_C(0x26)); // NOTE: clang 14 for Zen 2 uses sbb, and + fiat_subborrowx_u64(&x23, &x24, 0x0, x14, x22); + out1[0] = x23; + out1[1] = x16; + out1[2] = x18; + out1[3] = x20; +} + +/* + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg2: [0x0 ~> 0x3ffffffffffffff] // NOTE: this is not any uint64! + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +__attribute__((target("adx,bmi2"))) +static void fe4_scmul(uint64_t out1[4], const uint64_t arg1[4], uint64_t arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + fiat_uint1 x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + fiat_uint1 x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_uint1 x14; + uint64_t x15; + uint64_t x16; + uint64_t x17; + fiat_uint1 x18; + uint64_t x19; + fiat_uint1 x20; + uint64_t x21; + fiat_uint1 x22; + uint64_t x23; + fiat_uint1 x24; + uint64_t x25; + uint64_t x26; + fiat_uint1 x27; + fiat_mulx_u64(&x1, &x2, (arg1[0]), arg2); + fiat_mulx_u64(&x3, &x4, (arg1[1]), arg2); + fiat_addcarryx_u64(&x5, &x6, 0x0, x2, x3); + fiat_mulx_u64(&x7, &x8, (arg1[2]), arg2); + fiat_addcarryx_u64(&x9, &x10, x6, x4, x7); + fiat_mulx_u64(&x11, &x12, (arg1[3]), arg2); + fiat_addcarryx_u64(&x13, &x14, x10, x8, x11); + fiat_mulx_u64(&x15, &x16, (x12 + (uint64_t)x14), UINT8_C(0x26)); + fiat_addcarryx_u64(&x17, &x18, 0x0, x1, x15); + fiat_addcarryx_u64(&x19, &x20, x18, x5, 0x0); + fiat_addcarryx_u64(&x21, &x22, x20, x9, 0x0); + fiat_addcarryx_u64(&x23, &x24, x22, x13, 0x0); + fiat_cmovznz_u64(&x25, x24, 0x0, UINT8_C(0x26)); // NOTE: clang 14 for Zen 2 uses sbb, and + fiat_addcarryx_u64(&x26, &x27, 0x0, x17, x25); + out1[0] = x26; + out1[1] = x19; + out1[2] = x21; + out1[3] = x23; +} + +/* + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +__attribute__((target("adx,bmi2"))) +static void fe4_canon(uint64_t out1[4], const uint64_t arg1[4]) { + uint64_t x1; + fiat_uint1 x2; + uint64_t x3; + fiat_uint1 x4; + uint64_t x5; + fiat_uint1 x6; + uint64_t x7; + fiat_uint1 x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_uint1 x14; + uint64_t x15; + fiat_uint1 x16; + uint64_t x17; + fiat_uint1 x18; + uint64_t x19; + fiat_uint1 x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + fiat_subborrowx_u64(&x1, &x2, 0x0, (arg1[0]), UINT64_C(0xffffffffffffffed)); + fiat_subborrowx_u64(&x3, &x4, x2, (arg1[1]), UINT64_C(0xffffffffffffffff)); + fiat_subborrowx_u64(&x5, &x6, x4, (arg1[2]), UINT64_C(0xffffffffffffffff)); + fiat_subborrowx_u64(&x7, &x8, x6, (arg1[3]), UINT64_C(0x7fffffffffffffff)); + fiat_cmovznz_u64(&x9, x8, x1, (arg1[0])); + fiat_cmovznz_u64(&x10, x8, x3, (arg1[1])); + fiat_cmovznz_u64(&x11, x8, x5, (arg1[2])); + fiat_cmovznz_u64(&x12, x8, x7, (arg1[3])); + fiat_subborrowx_u64(&x13, &x14, 0x0, x9, UINT64_C(0xffffffffffffffed)); + fiat_subborrowx_u64(&x15, &x16, x14, x10, UINT64_C(0xffffffffffffffff)); + fiat_subborrowx_u64(&x17, &x18, x16, x11, UINT64_C(0xffffffffffffffff)); + fiat_subborrowx_u64(&x19, &x20, x18, x12, UINT64_C(0x7fffffffffffffff)); + fiat_cmovznz_u64(&x21, x20, x13, x9); + fiat_cmovznz_u64(&x22, x20, x15, x10); + fiat_cmovznz_u64(&x23, x20, x17, x11); + fiat_cmovznz_u64(&x24, x20, x19, x12); + out1[0] = x21; + out1[1] = x22; + out1[2] = x23; + out1[3] = x24; +} + +/* + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * out2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +__attribute__((target("adx,bmi2"))) +static void fe4_cswap(uint64_t out1[4], uint64_t out2[4], fiat_uint1 arg1, const uint64_t arg2[4], const uint64_t arg3[4]) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + // NOTE: clang 14 for Zen 2 uses YMM registers + fiat_cmovznz_u64(&x1, arg1, (arg2[0]), (arg3[0])); + fiat_cmovznz_u64(&x2, arg1, (arg2[1]), (arg3[1])); + fiat_cmovznz_u64(&x3, arg1, (arg2[2]), (arg3[2])); + fiat_cmovznz_u64(&x4, arg1, (arg2[3]), (arg3[3])); + fiat_cmovznz_u64(&x5, arg1, (arg3[0]), (arg2[0])); + fiat_cmovznz_u64(&x6, arg1, (arg3[1]), (arg2[1])); + fiat_cmovznz_u64(&x7, arg1, (arg3[2]), (arg2[2])); + fiat_cmovznz_u64(&x8, arg1, (arg3[3]), (arg2[3])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out2[0] = x5; + out2[1] = x6; + out2[2] = x7; + out2[3] = x8; +} + +// The following functions are adaped from crypto/curve25519/curve25519.c +// It would be desirable to share the code, but with the current field +// implementations both 4-limb and 5-limb versions of the curve-level code need +// to be included in builds targetting an unknown variant of x86_64. + +__attribute__((target("adx,bmi2"))) +static void fe4_invert(fe4 out, const fe4 z) { + fe4 t0; + fe4 t1; + fe4 t2; + fe4 t3; + int i; + + fe4_sq(t0, z); + fe4_sq(t1, t0); + for (i = 1; i < 2; ++i) { + fe4_sq(t1, t1); + } + fe4_mul(t1, z, t1); + fe4_mul(t0, t0, t1); + fe4_sq(t2, t0); + fe4_mul(t1, t1, t2); + fe4_sq(t2, t1); + for (i = 1; i < 5; ++i) { + fe4_sq(t2, t2); + } + fe4_mul(t1, t2, t1); + fe4_sq(t2, t1); + for (i = 1; i < 10; ++i) { + fe4_sq(t2, t2); + } + fe4_mul(t2, t2, t1); + fe4_sq(t3, t2); + for (i = 1; i < 20; ++i) { + fe4_sq(t3, t3); + } + fe4_mul(t2, t3, t2); + fe4_sq(t2, t2); + for (i = 1; i < 10; ++i) { + fe4_sq(t2, t2); + } + fe4_mul(t1, t2, t1); + fe4_sq(t2, t1); + for (i = 1; i < 50; ++i) { + fe4_sq(t2, t2); + } + fe4_mul(t2, t2, t1); + fe4_sq(t3, t2); + for (i = 1; i < 100; ++i) { + fe4_sq(t3, t3); + } + fe4_mul(t2, t3, t2); + fe4_sq(t2, t2); + for (i = 1; i < 50; ++i) { + fe4_sq(t2, t2); + } + fe4_mul(t1, t2, t1); + fe4_sq(t1, t1); + for (i = 1; i < 5; ++i) { + fe4_sq(t1, t1); + } + fe4_mul(out, t1, t0); +} + +__attribute__((target("adx,bmi2"))) +void x25519_scalar_mult_adx(uint8_t out[32], const uint8_t scalar[32], + const uint8_t point[32]) { + uint8_t e[32]; + memcpy(e, scalar, 32); + e[0] &= 248; + e[31] &= 127; + e[31] |= 64; + + // The following implementation was transcribed to Coq and proven to + // correspond to unary scalar multiplication in affine coordinates given that + // x1 != 0 is the x coordinate of some point on the curve. It was also checked + // in Coq that doing a ladderstep with x1 = x3 = 0 gives z2' = z3' = 0, and z2 + // = z3 = 0 gives z2' = z3' = 0. The statement was quantified over the + // underlying field, so it applies to Curve25519 itself and the quadratic + // twist of Curve25519. It was not proven in Coq that prime-field arithmetic + // correctly simulates extension-field arithmetic on prime-field values. + // The decoding of the byte array representation of e was not considered. + // Specification of Montgomery curves in affine coordinates: + // + // Proof that these form a group that is isomorphic to a Weierstrass curve: + // + // Coq transcription and correctness proof of the loop (where scalarbits=255): + // + // + // preconditions: 0 <= e < 2^255 (not necessarily e < order), fe_invert(0) = 0 + fe4 x1, x2 = {1}, z2 = {0}, x3, z3 = {1}, tmp0, tmp1; + OPENSSL_memcpy(x1, point, sizeof(fe4)); + x1[3] &= (uint64_t)(-1)>>1; + OPENSSL_memcpy(x3, x1, sizeof(fe4)); + + unsigned swap = 0; + int pos; + for (pos = 254; pos >= 0; --pos) { + // loop invariant as of right before the test, for the case where x1 != 0: + // pos >= -1; if z2 = 0 then x2 is nonzero; if z3 = 0 then x3 is nonzero + // let r := e >> (pos+1) in the following equalities of projective points: + // to_xz (r*P) === if swap then (x3, z3) else (x2, z2) + // to_xz ((r+1)*P) === if swap then (x2, z2) else (x3, z3) + // x1 is the nonzero x coordinate of the nonzero point (r*P-(r+1)*P) + unsigned b = 1 & (e[pos / 8] >> (pos & 7)); + swap ^= b; + fe4_cswap(x2, x3, swap, x2, x3); + fe4_cswap(z2, z3, swap, z2, z3); + swap = b; + // Coq transcription of ladderstep formula (called from transcribed loop): + // + // + // x1 != 0 + // x1 = 0 + fe4_sub(tmp0, x3, z3); + fe4_sub(tmp1, x2, z2); + fe4_add(x2, x2, z2); + fe4_add(z2, x3, z3); + fe4_mul(z3, tmp0, x2); + fe4_mul(z2, z2, tmp1); + fe4_sq(tmp0, tmp1); + fe4_sq(tmp1, x2); + fe4_add(x3, z3, z2); + fe4_sub(z2, z3, z2); + fe4_mul(x2, tmp1, tmp0); + fe4_sub(tmp1, tmp1, tmp0); + fe4_sq(z2, z2); + fe4_scmul(z3, tmp1, 121666); + fe4_sq(x3, x3); + fe4_add(tmp0, tmp0, z3); + fe4_mul(z3, x1, z2); + fe4_mul(z2, tmp1, tmp0); + } + // here pos=-1, so r=e, so to_xz (e*P) === if swap then (x3, z3) else (x2, z2) + fe4_cswap(x2, x3, swap, x2, x3); + fe4_cswap(z2, z3, swap, z2, z3); + + fe4_invert(z2, z2); + fe4_mul(x2, x2, z2); + fe4_canon(x2, x2); + OPENSSL_memcpy(out, x2, sizeof(fe4)); +} + +typedef struct { + fe4 X; + fe4 Y; + fe4 Z; + fe4 T; +} ge_p3_4; + +typedef struct { + fe4 yplusx; + fe4 yminusx; + fe4 xy2d; +} ge_precomp_4; + +__attribute__((target("adx,bmi2"))) +static void inline_x25519_ge_dbl_4(ge_p3_4 *r, const ge_p3_4 *p, bool skip_t) { + // Transcribed from a Coq function proven against affine coordinates. + // https://github.com/mit-plv/fiat-crypto/blob/9943ba9e7d8f3e1c0054b2c94a5edca46ea73ef8/src/Curves/Edwards/XYZT/Basic.v#L136-L165 + fe4 trX, trZ, trT, t0, cX, cY, cZ, cT; + fe4_sq(trX, p->X); + fe4_sq(trZ, p->Y); + fe4_sq(trT, p->Z); + fe4_add(trT, trT, trT); + fe4_add(cY, p->X, p->Y); + fe4_sq(t0, cY); + fe4_add(cY, trZ, trX); + fe4_sub(cZ, trZ, trX); + fe4_sub(cX, t0, cY); + fe4_sub(cT, trT, cZ); + fe4_mul(r->X, cX, cT); + fe4_mul(r->Y, cY, cZ); + fe4_mul(r->Z, cZ, cT); + if (!skip_t) { + fe4_mul(r->T, cX, cY); + } +} + +__attribute__((target("adx,bmi2"))) +__attribute__((always_inline)) // 4% speedup with clang14 and zen2 +static inline void +ge_p3_add_p3_precomp_4(ge_p3_4 *r, const ge_p3_4 *p, const ge_precomp_4 *q) { + fe4 A, B, C, YplusX, YminusX, D, X3, Y3, Z3, T3; + // Transcribed from a Coq function proven against affine coordinates. + // https://github.com/mit-plv/fiat-crypto/blob/a36568d1d73aff5d7accc79fd28be672882f9c17/src/Curves/Edwards/XYZT/Precomputed.v#L38-L56 + fe4_add(YplusX, p->Y, p->X); + fe4_sub(YminusX, p->Y, p->X); + fe4_mul(A, YplusX, q->yplusx); + fe4_mul(B, YminusX, q->yminusx); + fe4_mul(C, q->xy2d, p->T); + fe4_add(D, p->Z, p->Z); + fe4_sub(X3, A, B); + fe4_add(Y3, A, B); + fe4_add(Z3, D, C); + fe4_sub(T3, D, C); + fe4_mul(r->X, X3, T3); + fe4_mul(r->Y, Y3, Z3); + fe4_mul(r->Z, Z3, T3); + fe4_mul(r->T, X3, Y3); +} + +__attribute__((always_inline)) // 25% speedup with clang14 and zen2 +static inline void table_select_4(ge_precomp_4 *t, const int pos, + const signed char b) { + uint8_t bnegative = constant_time_msb_w(b); + uint8_t babs = b - ((bnegative & b) << 1); + + uint8_t t_bytes[3][32] = { + {constant_time_is_zero_w(b) & 1}, {constant_time_is_zero_w(b) & 1}, {0}}; +#if defined(__clang__) + __asm__("" : "+m" (t_bytes) : /*no inputs*/); +#endif + static_assert(sizeof(t_bytes) == sizeof(k25519Precomp[pos][0]), ""); + for (int i = 0; i < 8; i++) { + constant_time_conditional_memxor(t_bytes, k25519Precomp[pos][i], + sizeof(t_bytes), + constant_time_eq_w(babs, 1 + i)); + } + + static_assert(sizeof(t_bytes) == sizeof(ge_precomp_4), ""); + + // fe4 uses saturated 64-bit limbs, so converting from bytes is just a copy. + OPENSSL_memcpy(t, t_bytes, sizeof(ge_precomp_4)); + + fe4 xy2d_neg = {0}; + fe4_sub(xy2d_neg, xy2d_neg, t->xy2d); + constant_time_conditional_memcpy(t->yplusx, t_bytes[1], sizeof(fe4), + bnegative); + constant_time_conditional_memcpy(t->yminusx, t_bytes[0], sizeof(fe4), + bnegative); + constant_time_conditional_memcpy(t->xy2d, xy2d_neg, sizeof(fe4), bnegative); +} + +// h = a * B +// where a = a[0]+256*a[1]+...+256^31 a[31] +// B is the Ed25519 base point (x,4/5) with x positive. +// +// Preconditions: +// a[31] <= 127 +__attribute__((target("adx,bmi2"))) +void x25519_ge_scalarmult_base_adx(uint8_t h[4][32], const uint8_t a[32]) { + signed char e[64]; + signed char carry; + + for (unsigned i = 0; i < 32; ++i) { + e[2 * i + 0] = (a[i] >> 0) & 15; + e[2 * i + 1] = (a[i] >> 4) & 15; + } + // each e[i] is between 0 and 15 + // e[63] is between 0 and 7 + + carry = 0; + for (unsigned i = 0; i < 63; ++i) { + e[i] += carry; + carry = e[i] + 8; + carry >>= 4; + e[i] -= carry << 4; + } + e[63] += carry; + // each e[i] is between -8 and 8 + + ge_p3_4 r = {{0}, {1}, {1}, {0}}; + for (unsigned i = 1; i < 64; i += 2) { + ge_precomp_4 t; + table_select_4(&t, i / 2, e[i]); + ge_p3_add_p3_precomp_4(&r, &r, &t); + } + + inline_x25519_ge_dbl_4(&r, &r, /*skip_t=*/true); + inline_x25519_ge_dbl_4(&r, &r, /*skip_t=*/true); + inline_x25519_ge_dbl_4(&r, &r, /*skip_t=*/true); + inline_x25519_ge_dbl_4(&r, &r, /*skip_t=*/false); + + for (unsigned i = 0; i < 64; i += 2) { + ge_precomp_4 t; + table_select_4(&t, i / 2, e[i]); + ge_p3_add_p3_precomp_4(&r, &r, &t); + } + + // fe4 uses saturated 64-bit limbs, so converting to bytes is just a copy. + // Satisfy stated precondition of fiat_25519_from_bytes; tests pass either way + fe4_canon(r.X, r.X); + fe4_canon(r.Y, r.Y); + fe4_canon(r.Z, r.Z); + fe4_canon(r.T, r.T); + static_assert(sizeof(ge_p3_4) == sizeof(uint8_t[4][32]), ""); + OPENSSL_memcpy(h, &r, sizeof(ge_p3_4)); +} diff --git a/Sources/CCryptoBoringSSL/third_party/fiat/curve25519_64_msvc.h b/Sources/CCryptoBoringSSL/third_party/fiat/curve25519_64_msvc.h new file mode 100644 index 00000000..d20ec853 --- /dev/null +++ b/Sources/CCryptoBoringSSL/third_party/fiat/curve25519_64_msvc.h @@ -0,0 +1,1281 @@ +/* Autogenerated: 'src/ExtractionOCaml/unsaturated_solinas' --inline --static --use-value-barrier --no-wide-int 25519 64 '(auto)' '2^255 - 19' carry_mul carry_square carry add sub opp selectznz to_bytes from_bytes relax carry_scmul121666 */ +/* curve description: 25519 */ +/* machine_wordsize = 64 (from "64") */ +/* requested operations: carry_mul, carry_square, carry, add, sub, opp, selectznz, to_bytes, from_bytes, relax, carry_scmul121666 */ +/* n = 5 (from "(auto)") */ +/* s-c = 2^255 - [(1, 19)] (from "2^255 - 19") */ +/* tight_bounds_multiplier = 1 (from "") */ +/* */ +/* Computed values: */ +/* carry_chain = [0, 1, 2, 3, 4, 0, 1] */ +/* eval z = z[0] + (z[1] << 51) + (z[2] << 102) + (z[3] << 153) + (z[4] << 204) */ +/* bytes_eval z = z[0] + (z[1] << 8) + (z[2] << 16) + (z[3] << 24) + (z[4] << 32) + (z[5] << 40) + (z[6] << 48) + (z[7] << 56) + (z[8] << 64) + (z[9] << 72) + (z[10] << 80) + (z[11] << 88) + (z[12] << 96) + (z[13] << 104) + (z[14] << 112) + (z[15] << 120) + (z[16] << 128) + (z[17] << 136) + (z[18] << 144) + (z[19] << 152) + (z[20] << 160) + (z[21] << 168) + (z[22] << 176) + (z[23] << 184) + (z[24] << 192) + (z[25] << 200) + (z[26] << 208) + (z[27] << 216) + (z[28] << 224) + (z[29] << 232) + (z[30] << 240) + (z[31] << 248) */ +/* balance = [0xfffffffffffda, 0xffffffffffffe, 0xffffffffffffe, 0xffffffffffffe, 0xffffffffffffe] */ + +#include +#include +#if defined(_M_X64) +#include +#endif + +typedef unsigned char fiat_25519_uint1; +typedef signed char fiat_25519_int1; + +#define FIAT_25519_FIAT_INLINE inline + +/* The type fiat_25519_loose_field_element is a field element with loose bounds. */ +/* Bounds: [[0x0 ~> 0x18000000000000], [0x0 ~> 0x18000000000000], [0x0 ~> 0x18000000000000], [0x0 ~> 0x18000000000000], [0x0 ~> 0x18000000000000]] */ +typedef uint64_t fiat_25519_loose_field_element[5]; + +/* The type fiat_25519_tight_field_element is a field element with tight bounds. */ +/* Bounds: [[0x0 ~> 0x8000000000000], [0x0 ~> 0x8000000000000], [0x0 ~> 0x8000000000000], [0x0 ~> 0x8000000000000], [0x0 ~> 0x8000000000000]] */ +typedef uint64_t fiat_25519_tight_field_element[5]; + +#if (-1 & 3) != 3 +#error "This code only works on a two's complement system" +#endif + +#define fiat_25519_value_barrier_u64(x) (x) + +/* + * The function fiat_25519_addcarryx_u64 is an addition with carry. + * + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^64 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_addcarryx_u64(uint64_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint64_t arg2, uint64_t arg3) { +// NOTE: edited after generation +#if defined(_M_X64) + *out2 = _addcarry_u64(arg1, arg2, arg3, out1); +#else + arg2 += arg1; + arg1 = arg2 < arg1; + arg3 += arg2; + arg1 += arg3 < arg2; + *out1 = arg3; + *out2 = arg1; +#endif +} + +/* + * The function fiat_25519_subborrowx_u64 is a subtraction with borrow. + * + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^64 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_subborrowx_u64(uint64_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint64_t arg2, uint64_t arg3) { +#if defined(_M_X64) + *out2 = _subborrow_u64(arg1, arg2, arg3, out1); // NOTE: edited after generation +#else + *out1 = arg2 - arg3 - arg1; + *out2 = (arg2 < arg3) | ((arg2 == arg3) & arg1); +#endif +} + +/* + * The function fiat_25519_addcarryx_u51 is an addition with carry. + * + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^51 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^51⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0x7ffffffffffff] + * arg3: [0x0 ~> 0x7ffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0x7ffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_addcarryx_u51(uint64_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint64_t arg2, uint64_t arg3) { + uint64_t x1; + uint64_t x2; + fiat_25519_uint1 x3; + x1 = ((arg1 + arg2) + arg3); + x2 = (x1 & UINT64_C(0x7ffffffffffff)); + x3 = (fiat_25519_uint1)(x1 >> 51); + *out1 = x2; + *out2 = x3; +} + +/* + * The function fiat_25519_subborrowx_u51 is a subtraction with borrow. + * + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^51 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^51⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0x7ffffffffffff] + * arg3: [0x0 ~> 0x7ffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0x7ffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_subborrowx_u51(uint64_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint64_t arg2, uint64_t arg3) { + int64_t x1; + fiat_25519_int1 x2; + uint64_t x3; + x1 = ((int64_t)(arg2 - (int64_t)arg1) - (int64_t)arg3); + x2 = (fiat_25519_int1)(x1 >> 51); + x3 = (x1 & UINT64_C(0x7ffffffffffff)); + *out1 = x3; + *out2 = (fiat_25519_uint1)(0x0 - x2); +} + +/* + * The function fiat_25519_mulx_u64 is a multiplication, returning the full double-width result. + * + * Postconditions: + * out1 = (arg1 * arg2) mod 2^64 + * out2 = ⌊arg1 * arg2 / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0xffffffffffffffff] + * arg2: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_mulx_u64(uint64_t* out1, uint64_t* out2, uint64_t arg1, uint64_t arg2) { +// NOTE: edited after generation +#if defined(_M_X64) + *out1 = _umul128(arg1, arg2, out2); +#elif defined(_M_ARM64) + *out1 = arg1 * arg2; + *out2 = __umulh(arg1, arg2); +#else +#error "This file is intended for MSVC on X64 or ARM64" +#endif +} + +/* + * The function fiat_25519_cmovznz_u64 is a single-word conditional move. + * + * Postconditions: + * out1 = (if arg1 = 0 then arg2 else arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_cmovznz_u64(uint64_t* out1, fiat_25519_uint1 arg1, uint64_t arg2, uint64_t arg3) { + fiat_25519_uint1 x1; + uint64_t x2; + uint64_t x3; + x1 = (!(!arg1)); + x2 = ((fiat_25519_int1)(0x0 - x1) & UINT64_C(0xffffffffffffffff)); + x3 = ((fiat_25519_value_barrier_u64(x2) & arg3) | (fiat_25519_value_barrier_u64((~x2)) & arg2)); + *out1 = x3; +} + +/* + * The function fiat_25519_carry_mul multiplies two field elements and reduces the result. + * + * Postconditions: + * eval out1 mod m = (eval arg1 * eval arg2) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry_mul(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1, const fiat_25519_loose_field_element arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + uint64_t x14; + uint64_t x15; + uint64_t x16; + uint64_t x17; + uint64_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + uint64_t x29; + uint64_t x30; + uint64_t x31; + uint64_t x32; + uint64_t x33; + uint64_t x34; + uint64_t x35; + uint64_t x36; + uint64_t x37; + uint64_t x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + uint64_t x48; + uint64_t x49; + uint64_t x50; + uint64_t x51; + fiat_25519_uint1 x52; + uint64_t x53; + fiat_25519_uint1 x54; + uint64_t x55; + fiat_25519_uint1 x56; + uint64_t x57; + fiat_25519_uint1 x58; + uint64_t x59; + fiat_25519_uint1 x60; + uint64_t x61; + fiat_25519_uint1 x62; + uint64_t x63; + fiat_25519_uint1 x64; + uint64_t x65; + fiat_25519_uint1 x66; + uint64_t x67; + uint64_t x68; + uint64_t x69; + fiat_25519_uint1 x70; + uint64_t x71; + fiat_25519_uint1 x72; + uint64_t x73; + fiat_25519_uint1 x74; + uint64_t x75; + fiat_25519_uint1 x76; + uint64_t x77; + fiat_25519_uint1 x78; + uint64_t x79; + fiat_25519_uint1 x80; + uint64_t x81; + fiat_25519_uint1 x82; + uint64_t x83; + fiat_25519_uint1 x84; + uint64_t x85; + fiat_25519_uint1 x86; + uint64_t x87; + fiat_25519_uint1 x88; + uint64_t x89; + fiat_25519_uint1 x90; + uint64_t x91; + fiat_25519_uint1 x92; + uint64_t x93; + fiat_25519_uint1 x94; + uint64_t x95; + fiat_25519_uint1 x96; + uint64_t x97; + fiat_25519_uint1 x98; + uint64_t x99; + fiat_25519_uint1 x100; + uint64_t x101; + fiat_25519_uint1 x102; + uint64_t x103; + fiat_25519_uint1 x104; + uint64_t x105; + fiat_25519_uint1 x106; + uint64_t x107; + fiat_25519_uint1 x108; + uint64_t x109; + fiat_25519_uint1 x110; + uint64_t x111; + fiat_25519_uint1 x112; + uint64_t x113; + fiat_25519_uint1 x114; + uint64_t x115; + fiat_25519_uint1 x116; + uint64_t x117; + fiat_25519_uint1 x118; + uint64_t x119; + fiat_25519_uint1 x120; + uint64_t x121; + fiat_25519_uint1 x122; + uint64_t x123; + fiat_25519_uint1 x124; + uint64_t x125; + fiat_25519_uint1 x126; + uint64_t x127; + fiat_25519_uint1 x128; + uint64_t x129; + fiat_25519_uint1 x130; + uint64_t x131; + fiat_25519_uint1 x132; + uint64_t x133; + fiat_25519_uint1 x134; + uint64_t x135; + uint64_t x136; + uint64_t x137; + uint64_t x138; + fiat_25519_uint1 x139; + uint64_t x140; + uint64_t x141; + uint64_t x142; + uint64_t x143; + fiat_25519_uint1 x144; + uint64_t x145; + uint64_t x146; + uint64_t x147; + uint64_t x148; + fiat_25519_uint1 x149; + uint64_t x150; + uint64_t x151; + uint64_t x152; + uint64_t x153; + uint64_t x154; + uint64_t x155; + uint64_t x156; + uint64_t x157; + fiat_25519_uint1 x158; + uint64_t x159; + uint64_t x160; + fiat_25519_mulx_u64(&x1, &x2, (arg1[4]), ((arg2[4]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x3, &x4, (arg1[4]), ((arg2[3]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x5, &x6, (arg1[4]), ((arg2[2]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x7, &x8, (arg1[4]), ((arg2[1]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x9, &x10, (arg1[3]), ((arg2[4]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x11, &x12, (arg1[3]), ((arg2[3]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x13, &x14, (arg1[3]), ((arg2[2]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x15, &x16, (arg1[2]), ((arg2[4]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x17, &x18, (arg1[2]), ((arg2[3]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x19, &x20, (arg1[1]), ((arg2[4]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x21, &x22, (arg1[4]), (arg2[0])); + fiat_25519_mulx_u64(&x23, &x24, (arg1[3]), (arg2[1])); + fiat_25519_mulx_u64(&x25, &x26, (arg1[3]), (arg2[0])); + fiat_25519_mulx_u64(&x27, &x28, (arg1[2]), (arg2[2])); + fiat_25519_mulx_u64(&x29, &x30, (arg1[2]), (arg2[1])); + fiat_25519_mulx_u64(&x31, &x32, (arg1[2]), (arg2[0])); + fiat_25519_mulx_u64(&x33, &x34, (arg1[1]), (arg2[3])); + fiat_25519_mulx_u64(&x35, &x36, (arg1[1]), (arg2[2])); + fiat_25519_mulx_u64(&x37, &x38, (arg1[1]), (arg2[1])); + fiat_25519_mulx_u64(&x39, &x40, (arg1[1]), (arg2[0])); + fiat_25519_mulx_u64(&x41, &x42, (arg1[0]), (arg2[4])); + fiat_25519_mulx_u64(&x43, &x44, (arg1[0]), (arg2[3])); + fiat_25519_mulx_u64(&x45, &x46, (arg1[0]), (arg2[2])); + fiat_25519_mulx_u64(&x47, &x48, (arg1[0]), (arg2[1])); + fiat_25519_mulx_u64(&x49, &x50, (arg1[0]), (arg2[0])); + fiat_25519_addcarryx_u64(&x51, &x52, 0x0, x13, x7); + fiat_25519_addcarryx_u64(&x53, &x54, x52, x14, x8); + fiat_25519_addcarryx_u64(&x55, &x56, 0x0, x17, x51); + fiat_25519_addcarryx_u64(&x57, &x58, x56, x18, x53); + fiat_25519_addcarryx_u64(&x59, &x60, 0x0, x19, x55); + fiat_25519_addcarryx_u64(&x61, &x62, x60, x20, x57); + fiat_25519_addcarryx_u64(&x63, &x64, 0x0, x49, x59); + fiat_25519_addcarryx_u64(&x65, &x66, x64, x50, x61); + x67 = ((x63 >> 51) | ((x65 << 13) & UINT64_C(0xffffffffffffffff))); + x68 = (x63 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x69, &x70, 0x0, x23, x21); + fiat_25519_addcarryx_u64(&x71, &x72, x70, x24, x22); + fiat_25519_addcarryx_u64(&x73, &x74, 0x0, x27, x69); + fiat_25519_addcarryx_u64(&x75, &x76, x74, x28, x71); + fiat_25519_addcarryx_u64(&x77, &x78, 0x0, x33, x73); + fiat_25519_addcarryx_u64(&x79, &x80, x78, x34, x75); + fiat_25519_addcarryx_u64(&x81, &x82, 0x0, x41, x77); + fiat_25519_addcarryx_u64(&x83, &x84, x82, x42, x79); + fiat_25519_addcarryx_u64(&x85, &x86, 0x0, x25, x1); + fiat_25519_addcarryx_u64(&x87, &x88, x86, x26, x2); + fiat_25519_addcarryx_u64(&x89, &x90, 0x0, x29, x85); + fiat_25519_addcarryx_u64(&x91, &x92, x90, x30, x87); + fiat_25519_addcarryx_u64(&x93, &x94, 0x0, x35, x89); + fiat_25519_addcarryx_u64(&x95, &x96, x94, x36, x91); + fiat_25519_addcarryx_u64(&x97, &x98, 0x0, x43, x93); + fiat_25519_addcarryx_u64(&x99, &x100, x98, x44, x95); + fiat_25519_addcarryx_u64(&x101, &x102, 0x0, x9, x3); + fiat_25519_addcarryx_u64(&x103, &x104, x102, x10, x4); + fiat_25519_addcarryx_u64(&x105, &x106, 0x0, x31, x101); + fiat_25519_addcarryx_u64(&x107, &x108, x106, x32, x103); + fiat_25519_addcarryx_u64(&x109, &x110, 0x0, x37, x105); + fiat_25519_addcarryx_u64(&x111, &x112, x110, x38, x107); + fiat_25519_addcarryx_u64(&x113, &x114, 0x0, x45, x109); + fiat_25519_addcarryx_u64(&x115, &x116, x114, x46, x111); + fiat_25519_addcarryx_u64(&x117, &x118, 0x0, x11, x5); + fiat_25519_addcarryx_u64(&x119, &x120, x118, x12, x6); + fiat_25519_addcarryx_u64(&x121, &x122, 0x0, x15, x117); + fiat_25519_addcarryx_u64(&x123, &x124, x122, x16, x119); + fiat_25519_addcarryx_u64(&x125, &x126, 0x0, x39, x121); + fiat_25519_addcarryx_u64(&x127, &x128, x126, x40, x123); + fiat_25519_addcarryx_u64(&x129, &x130, 0x0, x47, x125); + fiat_25519_addcarryx_u64(&x131, &x132, x130, x48, x127); + fiat_25519_addcarryx_u64(&x133, &x134, 0x0, x67, x129); + x135 = (x134 + x131); + x136 = ((x133 >> 51) | ((x135 << 13) & UINT64_C(0xffffffffffffffff))); + x137 = (x133 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x138, &x139, 0x0, x136, x113); + x140 = (x139 + x115); + x141 = ((x138 >> 51) | ((x140 << 13) & UINT64_C(0xffffffffffffffff))); + x142 = (x138 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x143, &x144, 0x0, x141, x97); + x145 = (x144 + x99); + x146 = ((x143 >> 51) | ((x145 << 13) & UINT64_C(0xffffffffffffffff))); + x147 = (x143 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x148, &x149, 0x0, x146, x81); + x150 = (x149 + x83); + x151 = ((x148 >> 51) | ((x150 << 13) & UINT64_C(0xffffffffffffffff))); + x152 = (x148 & UINT64_C(0x7ffffffffffff)); + x153 = (x151 * UINT8_C(0x13)); + x154 = (x68 + x153); + x155 = (x154 >> 51); + x156 = (x154 & UINT64_C(0x7ffffffffffff)); + x157 = (x155 + x137); + x158 = (fiat_25519_uint1)(x157 >> 51); + x159 = (x157 & UINT64_C(0x7ffffffffffff)); + x160 = (x158 + x142); + out1[0] = x156; + out1[1] = x159; + out1[2] = x160; + out1[3] = x147; + out1[4] = x152; +} + +/* + * The function fiat_25519_carry_square squares a field element and reduces the result. + * + * Postconditions: + * eval out1 mod m = (eval arg1 * eval arg1) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry_square(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + uint64_t x14; + uint64_t x15; + uint64_t x16; + uint64_t x17; + uint64_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + uint64_t x29; + uint64_t x30; + uint64_t x31; + uint64_t x32; + uint64_t x33; + uint64_t x34; + uint64_t x35; + uint64_t x36; + uint64_t x37; + uint64_t x38; + uint64_t x39; + fiat_25519_uint1 x40; + uint64_t x41; + fiat_25519_uint1 x42; + uint64_t x43; + fiat_25519_uint1 x44; + uint64_t x45; + fiat_25519_uint1 x46; + uint64_t x47; + uint64_t x48; + uint64_t x49; + fiat_25519_uint1 x50; + uint64_t x51; + fiat_25519_uint1 x52; + uint64_t x53; + fiat_25519_uint1 x54; + uint64_t x55; + fiat_25519_uint1 x56; + uint64_t x57; + fiat_25519_uint1 x58; + uint64_t x59; + fiat_25519_uint1 x60; + uint64_t x61; + fiat_25519_uint1 x62; + uint64_t x63; + fiat_25519_uint1 x64; + uint64_t x65; + fiat_25519_uint1 x66; + uint64_t x67; + fiat_25519_uint1 x68; + uint64_t x69; + fiat_25519_uint1 x70; + uint64_t x71; + fiat_25519_uint1 x72; + uint64_t x73; + fiat_25519_uint1 x74; + uint64_t x75; + fiat_25519_uint1 x76; + uint64_t x77; + fiat_25519_uint1 x78; + uint64_t x79; + fiat_25519_uint1 x80; + uint64_t x81; + fiat_25519_uint1 x82; + uint64_t x83; + uint64_t x84; + uint64_t x85; + uint64_t x86; + fiat_25519_uint1 x87; + uint64_t x88; + uint64_t x89; + uint64_t x90; + uint64_t x91; + fiat_25519_uint1 x92; + uint64_t x93; + uint64_t x94; + uint64_t x95; + uint64_t x96; + fiat_25519_uint1 x97; + uint64_t x98; + uint64_t x99; + uint64_t x100; + uint64_t x101; + uint64_t x102; + uint64_t x103; + uint64_t x104; + uint64_t x105; + fiat_25519_uint1 x106; + uint64_t x107; + uint64_t x108; + x1 = ((arg1[4]) * UINT8_C(0x13)); + x2 = (x1 * 0x2); + x3 = ((arg1[4]) * 0x2); + x4 = ((arg1[3]) * UINT8_C(0x13)); + x5 = (x4 * 0x2); + x6 = ((arg1[3]) * 0x2); + x7 = ((arg1[2]) * 0x2); + x8 = ((arg1[1]) * 0x2); + fiat_25519_mulx_u64(&x9, &x10, (arg1[4]), x1); + fiat_25519_mulx_u64(&x11, &x12, (arg1[3]), x2); + fiat_25519_mulx_u64(&x13, &x14, (arg1[3]), x4); + fiat_25519_mulx_u64(&x15, &x16, (arg1[2]), x2); + fiat_25519_mulx_u64(&x17, &x18, (arg1[2]), x5); + fiat_25519_mulx_u64(&x19, &x20, (arg1[2]), (arg1[2])); + fiat_25519_mulx_u64(&x21, &x22, (arg1[1]), x2); + fiat_25519_mulx_u64(&x23, &x24, (arg1[1]), x6); + fiat_25519_mulx_u64(&x25, &x26, (arg1[1]), x7); + fiat_25519_mulx_u64(&x27, &x28, (arg1[1]), (arg1[1])); + fiat_25519_mulx_u64(&x29, &x30, (arg1[0]), x3); + fiat_25519_mulx_u64(&x31, &x32, (arg1[0]), x6); + fiat_25519_mulx_u64(&x33, &x34, (arg1[0]), x7); + fiat_25519_mulx_u64(&x35, &x36, (arg1[0]), x8); + fiat_25519_mulx_u64(&x37, &x38, (arg1[0]), (arg1[0])); + fiat_25519_addcarryx_u64(&x39, &x40, 0x0, x21, x17); + fiat_25519_addcarryx_u64(&x41, &x42, x40, x22, x18); + fiat_25519_addcarryx_u64(&x43, &x44, 0x0, x37, x39); + fiat_25519_addcarryx_u64(&x45, &x46, x44, x38, x41); + x47 = ((x43 >> 51) | ((x45 << 13) & UINT64_C(0xffffffffffffffff))); + x48 = (x43 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x49, &x50, 0x0, x23, x19); + fiat_25519_addcarryx_u64(&x51, &x52, x50, x24, x20); + fiat_25519_addcarryx_u64(&x53, &x54, 0x0, x29, x49); + fiat_25519_addcarryx_u64(&x55, &x56, x54, x30, x51); + fiat_25519_addcarryx_u64(&x57, &x58, 0x0, x25, x9); + fiat_25519_addcarryx_u64(&x59, &x60, x58, x26, x10); + fiat_25519_addcarryx_u64(&x61, &x62, 0x0, x31, x57); + fiat_25519_addcarryx_u64(&x63, &x64, x62, x32, x59); + fiat_25519_addcarryx_u64(&x65, &x66, 0x0, x27, x11); + fiat_25519_addcarryx_u64(&x67, &x68, x66, x28, x12); + fiat_25519_addcarryx_u64(&x69, &x70, 0x0, x33, x65); + fiat_25519_addcarryx_u64(&x71, &x72, x70, x34, x67); + fiat_25519_addcarryx_u64(&x73, &x74, 0x0, x15, x13); + fiat_25519_addcarryx_u64(&x75, &x76, x74, x16, x14); + fiat_25519_addcarryx_u64(&x77, &x78, 0x0, x35, x73); + fiat_25519_addcarryx_u64(&x79, &x80, x78, x36, x75); + fiat_25519_addcarryx_u64(&x81, &x82, 0x0, x47, x77); + x83 = (x82 + x79); + x84 = ((x81 >> 51) | ((x83 << 13) & UINT64_C(0xffffffffffffffff))); + x85 = (x81 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x86, &x87, 0x0, x84, x69); + x88 = (x87 + x71); + x89 = ((x86 >> 51) | ((x88 << 13) & UINT64_C(0xffffffffffffffff))); + x90 = (x86 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x91, &x92, 0x0, x89, x61); + x93 = (x92 + x63); + x94 = ((x91 >> 51) | ((x93 << 13) & UINT64_C(0xffffffffffffffff))); + x95 = (x91 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x96, &x97, 0x0, x94, x53); + x98 = (x97 + x55); + x99 = ((x96 >> 51) | ((x98 << 13) & UINT64_C(0xffffffffffffffff))); + x100 = (x96 & UINT64_C(0x7ffffffffffff)); + x101 = (x99 * UINT8_C(0x13)); + x102 = (x48 + x101); + x103 = (x102 >> 51); + x104 = (x102 & UINT64_C(0x7ffffffffffff)); + x105 = (x103 + x85); + x106 = (fiat_25519_uint1)(x105 >> 51); + x107 = (x105 & UINT64_C(0x7ffffffffffff)); + x108 = (x106 + x90); + out1[0] = x104; + out1[1] = x107; + out1[2] = x108; + out1[3] = x95; + out1[4] = x100; +} + +/* + * The function fiat_25519_carry reduces a field element. + * + * Postconditions: + * eval out1 mod m = eval arg1 mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + x1 = (arg1[0]); + x2 = ((x1 >> 51) + (arg1[1])); + x3 = ((x2 >> 51) + (arg1[2])); + x4 = ((x3 >> 51) + (arg1[3])); + x5 = ((x4 >> 51) + (arg1[4])); + x6 = ((x1 & UINT64_C(0x7ffffffffffff)) + ((x5 >> 51) * UINT8_C(0x13))); + x7 = ((fiat_25519_uint1)(x6 >> 51) + (x2 & UINT64_C(0x7ffffffffffff))); + x8 = (x6 & UINT64_C(0x7ffffffffffff)); + x9 = (x7 & UINT64_C(0x7ffffffffffff)); + x10 = ((fiat_25519_uint1)(x7 >> 51) + (x3 & UINT64_C(0x7ffffffffffff))); + x11 = (x4 & UINT64_C(0x7ffffffffffff)); + x12 = (x5 & UINT64_C(0x7ffffffffffff)); + out1[0] = x8; + out1[1] = x9; + out1[2] = x10; + out1[3] = x11; + out1[4] = x12; +} + +/* + * The function fiat_25519_add adds two field elements. + * + * Postconditions: + * eval out1 mod m = (eval arg1 + eval arg2) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_add(fiat_25519_loose_field_element out1, const fiat_25519_tight_field_element arg1, const fiat_25519_tight_field_element arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + x1 = ((arg1[0]) + (arg2[0])); + x2 = ((arg1[1]) + (arg2[1])); + x3 = ((arg1[2]) + (arg2[2])); + x4 = ((arg1[3]) + (arg2[3])); + x5 = ((arg1[4]) + (arg2[4])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; +} + +/* + * The function fiat_25519_sub subtracts two field elements. + * + * Postconditions: + * eval out1 mod m = (eval arg1 - eval arg2) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_sub(fiat_25519_loose_field_element out1, const fiat_25519_tight_field_element arg1, const fiat_25519_tight_field_element arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + x1 = ((UINT64_C(0xfffffffffffda) + (arg1[0])) - (arg2[0])); + x2 = ((UINT64_C(0xffffffffffffe) + (arg1[1])) - (arg2[1])); + x3 = ((UINT64_C(0xffffffffffffe) + (arg1[2])) - (arg2[2])); + x4 = ((UINT64_C(0xffffffffffffe) + (arg1[3])) - (arg2[3])); + x5 = ((UINT64_C(0xffffffffffffe) + (arg1[4])) - (arg2[4])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; +} + +/* + * The function fiat_25519_opp negates a field element. + * + * Postconditions: + * eval out1 mod m = -eval arg1 mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_opp(fiat_25519_loose_field_element out1, const fiat_25519_tight_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + x1 = (UINT64_C(0xfffffffffffda) - (arg1[0])); + x2 = (UINT64_C(0xffffffffffffe) - (arg1[1])); + x3 = (UINT64_C(0xffffffffffffe) - (arg1[2])); + x4 = (UINT64_C(0xffffffffffffe) - (arg1[3])); + x5 = (UINT64_C(0xffffffffffffe) - (arg1[4])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; +} + +/* + * The function fiat_25519_selectznz is a multi-limb conditional select. + * + * Postconditions: + * out1 = (if arg1 = 0 then arg2 else arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_selectznz(uint64_t out1[5], fiat_25519_uint1 arg1, const uint64_t arg2[5], const uint64_t arg3[5]) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + fiat_25519_cmovznz_u64(&x1, arg1, (arg2[0]), (arg3[0])); + fiat_25519_cmovznz_u64(&x2, arg1, (arg2[1]), (arg3[1])); + fiat_25519_cmovznz_u64(&x3, arg1, (arg2[2]), (arg3[2])); + fiat_25519_cmovznz_u64(&x4, arg1, (arg2[3]), (arg3[3])); + fiat_25519_cmovznz_u64(&x5, arg1, (arg2[4]), (arg3[4])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; +} + +/* + * The function fiat_25519_to_bytes serializes a field element to bytes in little-endian order. + * + * Postconditions: + * out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..31] + * + * Output Bounds: + * out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x7f]] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_to_bytes(uint8_t out1[32], const fiat_25519_tight_field_element arg1) { + uint64_t x1; + fiat_25519_uint1 x2; + uint64_t x3; + fiat_25519_uint1 x4; + uint64_t x5; + fiat_25519_uint1 x6; + uint64_t x7; + fiat_25519_uint1 x8; + uint64_t x9; + fiat_25519_uint1 x10; + uint64_t x11; + uint64_t x12; + fiat_25519_uint1 x13; + uint64_t x14; + fiat_25519_uint1 x15; + uint64_t x16; + fiat_25519_uint1 x17; + uint64_t x18; + fiat_25519_uint1 x19; + uint64_t x20; + fiat_25519_uint1 x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint8_t x26; + uint64_t x27; + uint8_t x28; + uint64_t x29; + uint8_t x30; + uint64_t x31; + uint8_t x32; + uint64_t x33; + uint8_t x34; + uint64_t x35; + uint8_t x36; + uint8_t x37; + uint64_t x38; + uint8_t x39; + uint64_t x40; + uint8_t x41; + uint64_t x42; + uint8_t x43; + uint64_t x44; + uint8_t x45; + uint64_t x46; + uint8_t x47; + uint64_t x48; + uint8_t x49; + uint8_t x50; + uint64_t x51; + uint8_t x52; + uint64_t x53; + uint8_t x54; + uint64_t x55; + uint8_t x56; + uint64_t x57; + uint8_t x58; + uint64_t x59; + uint8_t x60; + uint64_t x61; + uint8_t x62; + uint64_t x63; + uint8_t x64; + fiat_25519_uint1 x65; + uint64_t x66; + uint8_t x67; + uint64_t x68; + uint8_t x69; + uint64_t x70; + uint8_t x71; + uint64_t x72; + uint8_t x73; + uint64_t x74; + uint8_t x75; + uint64_t x76; + uint8_t x77; + uint8_t x78; + uint64_t x79; + uint8_t x80; + uint64_t x81; + uint8_t x82; + uint64_t x83; + uint8_t x84; + uint64_t x85; + uint8_t x86; + uint64_t x87; + uint8_t x88; + uint64_t x89; + uint8_t x90; + uint8_t x91; + fiat_25519_subborrowx_u51(&x1, &x2, 0x0, (arg1[0]), UINT64_C(0x7ffffffffffed)); + fiat_25519_subborrowx_u51(&x3, &x4, x2, (arg1[1]), UINT64_C(0x7ffffffffffff)); + fiat_25519_subborrowx_u51(&x5, &x6, x4, (arg1[2]), UINT64_C(0x7ffffffffffff)); + fiat_25519_subborrowx_u51(&x7, &x8, x6, (arg1[3]), UINT64_C(0x7ffffffffffff)); + fiat_25519_subborrowx_u51(&x9, &x10, x8, (arg1[4]), UINT64_C(0x7ffffffffffff)); + fiat_25519_cmovznz_u64(&x11, x10, 0x0, UINT64_C(0xffffffffffffffff)); + fiat_25519_addcarryx_u51(&x12, &x13, 0x0, x1, (x11 & UINT64_C(0x7ffffffffffed))); + fiat_25519_addcarryx_u51(&x14, &x15, x13, x3, (x11 & UINT64_C(0x7ffffffffffff))); + fiat_25519_addcarryx_u51(&x16, &x17, x15, x5, (x11 & UINT64_C(0x7ffffffffffff))); + fiat_25519_addcarryx_u51(&x18, &x19, x17, x7, (x11 & UINT64_C(0x7ffffffffffff))); + fiat_25519_addcarryx_u51(&x20, &x21, x19, x9, (x11 & UINT64_C(0x7ffffffffffff))); + x22 = (x20 << 4); + x23 = (x18 * (uint64_t)0x2); + x24 = (x16 << 6); + x25 = (x14 << 3); + x26 = (uint8_t)(x12 & UINT8_C(0xff)); + x27 = (x12 >> 8); + x28 = (uint8_t)(x27 & UINT8_C(0xff)); + x29 = (x27 >> 8); + x30 = (uint8_t)(x29 & UINT8_C(0xff)); + x31 = (x29 >> 8); + x32 = (uint8_t)(x31 & UINT8_C(0xff)); + x33 = (x31 >> 8); + x34 = (uint8_t)(x33 & UINT8_C(0xff)); + x35 = (x33 >> 8); + x36 = (uint8_t)(x35 & UINT8_C(0xff)); + x37 = (uint8_t)(x35 >> 8); + x38 = (x25 + (uint64_t)x37); + x39 = (uint8_t)(x38 & UINT8_C(0xff)); + x40 = (x38 >> 8); + x41 = (uint8_t)(x40 & UINT8_C(0xff)); + x42 = (x40 >> 8); + x43 = (uint8_t)(x42 & UINT8_C(0xff)); + x44 = (x42 >> 8); + x45 = (uint8_t)(x44 & UINT8_C(0xff)); + x46 = (x44 >> 8); + x47 = (uint8_t)(x46 & UINT8_C(0xff)); + x48 = (x46 >> 8); + x49 = (uint8_t)(x48 & UINT8_C(0xff)); + x50 = (uint8_t)(x48 >> 8); + x51 = (x24 + (uint64_t)x50); + x52 = (uint8_t)(x51 & UINT8_C(0xff)); + x53 = (x51 >> 8); + x54 = (uint8_t)(x53 & UINT8_C(0xff)); + x55 = (x53 >> 8); + x56 = (uint8_t)(x55 & UINT8_C(0xff)); + x57 = (x55 >> 8); + x58 = (uint8_t)(x57 & UINT8_C(0xff)); + x59 = (x57 >> 8); + x60 = (uint8_t)(x59 & UINT8_C(0xff)); + x61 = (x59 >> 8); + x62 = (uint8_t)(x61 & UINT8_C(0xff)); + x63 = (x61 >> 8); + x64 = (uint8_t)(x63 & UINT8_C(0xff)); + x65 = (fiat_25519_uint1)(x63 >> 8); + x66 = (x23 + (uint64_t)x65); + x67 = (uint8_t)(x66 & UINT8_C(0xff)); + x68 = (x66 >> 8); + x69 = (uint8_t)(x68 & UINT8_C(0xff)); + x70 = (x68 >> 8); + x71 = (uint8_t)(x70 & UINT8_C(0xff)); + x72 = (x70 >> 8); + x73 = (uint8_t)(x72 & UINT8_C(0xff)); + x74 = (x72 >> 8); + x75 = (uint8_t)(x74 & UINT8_C(0xff)); + x76 = (x74 >> 8); + x77 = (uint8_t)(x76 & UINT8_C(0xff)); + x78 = (uint8_t)(x76 >> 8); + x79 = (x22 + (uint64_t)x78); + x80 = (uint8_t)(x79 & UINT8_C(0xff)); + x81 = (x79 >> 8); + x82 = (uint8_t)(x81 & UINT8_C(0xff)); + x83 = (x81 >> 8); + x84 = (uint8_t)(x83 & UINT8_C(0xff)); + x85 = (x83 >> 8); + x86 = (uint8_t)(x85 & UINT8_C(0xff)); + x87 = (x85 >> 8); + x88 = (uint8_t)(x87 & UINT8_C(0xff)); + x89 = (x87 >> 8); + x90 = (uint8_t)(x89 & UINT8_C(0xff)); + x91 = (uint8_t)(x89 >> 8); + out1[0] = x26; + out1[1] = x28; + out1[2] = x30; + out1[3] = x32; + out1[4] = x34; + out1[5] = x36; + out1[6] = x39; + out1[7] = x41; + out1[8] = x43; + out1[9] = x45; + out1[10] = x47; + out1[11] = x49; + out1[12] = x52; + out1[13] = x54; + out1[14] = x56; + out1[15] = x58; + out1[16] = x60; + out1[17] = x62; + out1[18] = x64; + out1[19] = x67; + out1[20] = x69; + out1[21] = x71; + out1[22] = x73; + out1[23] = x75; + out1[24] = x77; + out1[25] = x80; + out1[26] = x82; + out1[27] = x84; + out1[28] = x86; + out1[29] = x88; + out1[30] = x90; + out1[31] = x91; +} + +/* + * The function fiat_25519_from_bytes deserializes a field element from bytes in little-endian order. + * + * Postconditions: + * eval out1 mod m = bytes_eval arg1 mod m + * + * Input Bounds: + * arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x7f]] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_from_bytes(fiat_25519_tight_field_element out1, const uint8_t arg1[32]) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + uint64_t x14; + uint64_t x15; + uint64_t x16; + uint64_t x17; + uint64_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + uint64_t x29; + uint64_t x30; + uint64_t x31; + uint8_t x32; + uint64_t x33; + uint64_t x34; + uint64_t x35; + uint64_t x36; + uint64_t x37; + uint64_t x38; + uint64_t x39; + uint8_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + uint8_t x48; + uint64_t x49; + uint64_t x50; + uint64_t x51; + uint64_t x52; + uint64_t x53; + uint64_t x54; + uint64_t x55; + uint64_t x56; + uint8_t x57; + uint64_t x58; + uint64_t x59; + uint64_t x60; + uint64_t x61; + uint64_t x62; + uint64_t x63; + uint64_t x64; + uint8_t x65; + uint64_t x66; + uint64_t x67; + uint64_t x68; + uint64_t x69; + uint64_t x70; + uint64_t x71; + x1 = ((uint64_t)(arg1[31]) << 44); + x2 = ((uint64_t)(arg1[30]) << 36); + x3 = ((uint64_t)(arg1[29]) << 28); + x4 = ((uint64_t)(arg1[28]) << 20); + x5 = ((uint64_t)(arg1[27]) << 12); + x6 = ((uint64_t)(arg1[26]) << 4); + x7 = ((uint64_t)(arg1[25]) << 47); + x8 = ((uint64_t)(arg1[24]) << 39); + x9 = ((uint64_t)(arg1[23]) << 31); + x10 = ((uint64_t)(arg1[22]) << 23); + x11 = ((uint64_t)(arg1[21]) << 15); + x12 = ((uint64_t)(arg1[20]) << 7); + x13 = ((uint64_t)(arg1[19]) << 50); + x14 = ((uint64_t)(arg1[18]) << 42); + x15 = ((uint64_t)(arg1[17]) << 34); + x16 = ((uint64_t)(arg1[16]) << 26); + x17 = ((uint64_t)(arg1[15]) << 18); + x18 = ((uint64_t)(arg1[14]) << 10); + x19 = ((uint64_t)(arg1[13]) << 2); + x20 = ((uint64_t)(arg1[12]) << 45); + x21 = ((uint64_t)(arg1[11]) << 37); + x22 = ((uint64_t)(arg1[10]) << 29); + x23 = ((uint64_t)(arg1[9]) << 21); + x24 = ((uint64_t)(arg1[8]) << 13); + x25 = ((uint64_t)(arg1[7]) << 5); + x26 = ((uint64_t)(arg1[6]) << 48); + x27 = ((uint64_t)(arg1[5]) << 40); + x28 = ((uint64_t)(arg1[4]) << 32); + x29 = ((uint64_t)(arg1[3]) << 24); + x30 = ((uint64_t)(arg1[2]) << 16); + x31 = ((uint64_t)(arg1[1]) << 8); + x32 = (arg1[0]); + x33 = (x31 + (uint64_t)x32); + x34 = (x30 + x33); + x35 = (x29 + x34); + x36 = (x28 + x35); + x37 = (x27 + x36); + x38 = (x26 + x37); + x39 = (x38 & UINT64_C(0x7ffffffffffff)); + x40 = (uint8_t)(x38 >> 51); + x41 = (x25 + (uint64_t)x40); + x42 = (x24 + x41); + x43 = (x23 + x42); + x44 = (x22 + x43); + x45 = (x21 + x44); + x46 = (x20 + x45); + x47 = (x46 & UINT64_C(0x7ffffffffffff)); + x48 = (uint8_t)(x46 >> 51); + x49 = (x19 + (uint64_t)x48); + x50 = (x18 + x49); + x51 = (x17 + x50); + x52 = (x16 + x51); + x53 = (x15 + x52); + x54 = (x14 + x53); + x55 = (x13 + x54); + x56 = (x55 & UINT64_C(0x7ffffffffffff)); + x57 = (uint8_t)(x55 >> 51); + x58 = (x12 + (uint64_t)x57); + x59 = (x11 + x58); + x60 = (x10 + x59); + x61 = (x9 + x60); + x62 = (x8 + x61); + x63 = (x7 + x62); + x64 = (x63 & UINT64_C(0x7ffffffffffff)); + x65 = (uint8_t)(x63 >> 51); + x66 = (x6 + (uint64_t)x65); + x67 = (x5 + x66); + x68 = (x4 + x67); + x69 = (x3 + x68); + x70 = (x2 + x69); + x71 = (x1 + x70); + out1[0] = x39; + out1[1] = x47; + out1[2] = x56; + out1[3] = x64; + out1[4] = x71; +} + +/* + * The function fiat_25519_relax is the identity function converting from tight field elements to loose field elements. + * + * Postconditions: + * out1 = arg1 + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_relax(fiat_25519_loose_field_element out1, const fiat_25519_tight_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + x1 = (arg1[0]); + x2 = (arg1[1]); + x3 = (arg1[2]); + x4 = (arg1[3]); + x5 = (arg1[4]); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; +} + +/* + * The function fiat_25519_carry_scmul_121666 multiplies a field element by 121666 and reduces the result. + * + * Postconditions: + * eval out1 mod m = (121666 * eval arg1) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry_scmul_121666(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_25519_uint1 x14; + uint64_t x15; + uint64_t x16; + uint64_t x17; + uint64_t x18; + fiat_25519_uint1 x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + fiat_25519_uint1 x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + fiat_25519_uint1 x29; + uint64_t x30; + uint64_t x31; + uint64_t x32; + uint64_t x33; + uint64_t x34; + fiat_25519_uint1 x35; + uint64_t x36; + uint64_t x37; + fiat_25519_uint1 x38; + uint64_t x39; + uint64_t x40; + fiat_25519_mulx_u64(&x1, &x2, UINT32_C(0x1db42), (arg1[4])); + fiat_25519_mulx_u64(&x3, &x4, UINT32_C(0x1db42), (arg1[3])); + fiat_25519_mulx_u64(&x5, &x6, UINT32_C(0x1db42), (arg1[2])); + fiat_25519_mulx_u64(&x7, &x8, UINT32_C(0x1db42), (arg1[1])); + fiat_25519_mulx_u64(&x9, &x10, UINT32_C(0x1db42), (arg1[0])); + x11 = ((x9 >> 51) | ((x10 << 13) & UINT64_C(0xffffffffffffffff))); + x12 = (x9 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x13, &x14, 0x0, x11, x7); + x15 = (x14 + x8); + x16 = ((x13 >> 51) | ((x15 << 13) & UINT64_C(0xffffffffffffffff))); + x17 = (x13 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x18, &x19, 0x0, x16, x5); + x20 = (x19 + x6); + x21 = ((x18 >> 51) | ((x20 << 13) & UINT64_C(0xffffffffffffffff))); + x22 = (x18 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x23, &x24, 0x0, x21, x3); + x25 = (x24 + x4); + x26 = ((x23 >> 51) | ((x25 << 13) & UINT64_C(0xffffffffffffffff))); + x27 = (x23 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x28, &x29, 0x0, x26, x1); + x30 = (x29 + x2); + x31 = ((x28 >> 51) | ((x30 << 13) & UINT64_C(0xffffffffffffffff))); + x32 = (x28 & UINT64_C(0x7ffffffffffff)); + x33 = (x31 * UINT8_C(0x13)); + x34 = (x12 + x33); + x35 = (fiat_25519_uint1)(x34 >> 51); + x36 = (x34 & UINT64_C(0x7ffffffffffff)); + x37 = (x35 + x17); + x38 = (fiat_25519_uint1)(x37 >> 51); + x39 = (x37 & UINT64_C(0x7ffffffffffff)); + x40 = (x38 + x22); + out1[0] = x36; + out1[1] = x39; + out1[2] = x40; + out1[3] = x27; + out1[4] = x32; +} diff --git a/Sources/CCryptoBoringSSL/third_party/fiat/p256_64_msvc.h b/Sources/CCryptoBoringSSL/third_party/fiat/p256_64_msvc.h new file mode 100644 index 00000000..8b65a373 --- /dev/null +++ b/Sources/CCryptoBoringSSL/third_party/fiat/p256_64_msvc.h @@ -0,0 +1,2002 @@ +/* Autogenerated: 'src/ExtractionOCaml/word_by_word_montgomery' --inline --static --use-value-barrier --no-wide-int p256 64 '2^256 - 2^224 + 2^192 + 2^96 - 1' mul square add sub opp from_montgomery to_montgomery nonzero selectznz to_bytes from_bytes one msat divstep divstep_precomp */ +/* curve description: p256 */ +/* machine_wordsize = 64 (from "64") */ +/* requested operations: mul, square, add, sub, opp, from_montgomery, to_montgomery, nonzero, selectznz, to_bytes, from_bytes, one, msat, divstep, divstep_precomp */ +/* m = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff (from "2^256 - 2^224 + 2^192 + 2^96 - 1") */ +/* */ +/* NOTE: In addition to the bounds specified above each function, all */ +/* functions synthesized for this Montgomery arithmetic require the */ +/* input to be strictly less than the prime modulus (m), and also */ +/* require the input to be in the unique saturated representation. */ +/* All functions also ensure that these two properties are true of */ +/* return values. */ +/* */ +/* Computed values: */ +/* eval z = z[0] + (z[1] << 64) + (z[2] << 128) + (z[3] << 192) */ +/* bytes_eval z = z[0] + (z[1] << 8) + (z[2] << 16) + (z[3] << 24) + (z[4] << 32) + (z[5] << 40) + (z[6] << 48) + (z[7] << 56) + (z[8] << 64) + (z[9] << 72) + (z[10] << 80) + (z[11] << 88) + (z[12] << 96) + (z[13] << 104) + (z[14] << 112) + (z[15] << 120) + (z[16] << 128) + (z[17] << 136) + (z[18] << 144) + (z[19] << 152) + (z[20] << 160) + (z[21] << 168) + (z[22] << 176) + (z[23] << 184) + (z[24] << 192) + (z[25] << 200) + (z[26] << 208) + (z[27] << 216) + (z[28] << 224) + (z[29] << 232) + (z[30] << 240) + (z[31] << 248) */ +/* twos_complement_eval z = let x1 := z[0] + (z[1] << 64) + (z[2] << 128) + (z[3] << 192) in */ +/* if x1 & (2^256-1) < 2^255 then x1 & (2^256-1) else (x1 & (2^256-1)) - 2^256 */ + +#include +#include +#if defined(_M_X64) +#include +#endif + +typedef unsigned char fiat_p256_uint1; +typedef signed char fiat_p256_int1; + +#define FIAT_P256_FIAT_INLINE inline + +/* The type fiat_p256_montgomery_domain_field_element is a field element in the Montgomery domain. */ +/* Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ +typedef uint64_t fiat_p256_montgomery_domain_field_element[4]; + +/* The type fiat_p256_non_montgomery_domain_field_element is a field element NOT in the Montgomery domain. */ +/* Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ +typedef uint64_t fiat_p256_non_montgomery_domain_field_element[4]; + +#if (-1 & 3) != 3 +#error "This code only works on a two's complement system" +#endif + +#define fiat_p256_value_barrier_u64(x) (x) + + +/* + * The function fiat_p256_addcarryx_u64 is an addition with carry. + * + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^64 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_addcarryx_u64(uint64_t* out1, fiat_p256_uint1* out2, fiat_p256_uint1 arg1, uint64_t arg2, uint64_t arg3) { +#if defined(_M_X64) + *out2 = _addcarry_u64(arg1, arg2, arg3, out1); +#else + arg2 += arg1; + arg1 = arg2 < arg1; + arg3 += arg2; + arg1 += arg3 < arg2; + *out1 = arg3; + *out2 = arg1; +#endif +} + +/* + * The function fiat_p256_subborrowx_u64 is a subtraction with borrow. + * + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^64 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_subborrowx_u64(uint64_t* out1, fiat_p256_uint1* out2, fiat_p256_uint1 arg1, uint64_t arg2, uint64_t arg3) { +#if defined(_M_X64) + *out2 = _subborrow_u64(arg1, arg2, arg3, out1); // NOTE: edited after generation +#else + *out1 = arg2 - arg3 - arg1; + *out2 = (arg2 < arg3) | ((arg2 == arg3) & arg1); +#endif +} + +/* + * The function fiat_p256_mulx_u64 is a multiplication, returning the full double-width result. + * + * Postconditions: + * out1 = (arg1 * arg2) mod 2^64 + * out2 = ⌊arg1 * arg2 / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0xffffffffffffffff] + * arg2: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_mulx_u64(uint64_t* out1, uint64_t* out2, uint64_t arg1, uint64_t arg2) { +// NOTE: edited after generation +#if defined(_M_X64) + *out1 = _umul128(arg1, arg2, out2); +#elif defined(_M_ARM64) + *out1 = arg1 * arg2; + *out2 = __umulh(arg1, arg2); +#else +#error "This file is intended for MSVC on X64 or ARM64" +#endif +} + +/* + * The function fiat_p256_cmovznz_u64 is a single-word conditional move. + * + * Postconditions: + * out1 = (if arg1 = 0 then arg2 else arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_cmovznz_u64(uint64_t* out1, fiat_p256_uint1 arg1, uint64_t arg2, uint64_t arg3) { + fiat_p256_uint1 x1; + uint64_t x2; + uint64_t x3; + x1 = (!(!arg1)); + x2 = ((fiat_p256_int1)(0x0 - x1) & UINT64_C(0xffffffffffffffff)); + x3 = ((fiat_p256_value_barrier_u64(x2) & arg3) | (fiat_p256_value_barrier_u64((~x2)) & arg2)); + *out1 = x3; +} + +/* + * The function fiat_p256_mul multiplies two field elements in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * 0 ≤ eval arg2 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg2)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_mul(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1, const fiat_p256_montgomery_domain_field_element arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_p256_uint1 x14; + uint64_t x15; + fiat_p256_uint1 x16; + uint64_t x17; + fiat_p256_uint1 x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + fiat_p256_uint1 x27; + uint64_t x28; + uint64_t x29; + fiat_p256_uint1 x30; + uint64_t x31; + fiat_p256_uint1 x32; + uint64_t x33; + fiat_p256_uint1 x34; + uint64_t x35; + fiat_p256_uint1 x36; + uint64_t x37; + fiat_p256_uint1 x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + fiat_p256_uint1 x48; + uint64_t x49; + fiat_p256_uint1 x50; + uint64_t x51; + fiat_p256_uint1 x52; + uint64_t x53; + uint64_t x54; + fiat_p256_uint1 x55; + uint64_t x56; + fiat_p256_uint1 x57; + uint64_t x58; + fiat_p256_uint1 x59; + uint64_t x60; + fiat_p256_uint1 x61; + uint64_t x62; + fiat_p256_uint1 x63; + uint64_t x64; + uint64_t x65; + uint64_t x66; + uint64_t x67; + uint64_t x68; + uint64_t x69; + uint64_t x70; + fiat_p256_uint1 x71; + uint64_t x72; + uint64_t x73; + fiat_p256_uint1 x74; + uint64_t x75; + fiat_p256_uint1 x76; + uint64_t x77; + fiat_p256_uint1 x78; + uint64_t x79; + fiat_p256_uint1 x80; + uint64_t x81; + fiat_p256_uint1 x82; + uint64_t x83; + uint64_t x84; + uint64_t x85; + uint64_t x86; + uint64_t x87; + uint64_t x88; + uint64_t x89; + uint64_t x90; + uint64_t x91; + uint64_t x92; + fiat_p256_uint1 x93; + uint64_t x94; + fiat_p256_uint1 x95; + uint64_t x96; + fiat_p256_uint1 x97; + uint64_t x98; + uint64_t x99; + fiat_p256_uint1 x100; + uint64_t x101; + fiat_p256_uint1 x102; + uint64_t x103; + fiat_p256_uint1 x104; + uint64_t x105; + fiat_p256_uint1 x106; + uint64_t x107; + fiat_p256_uint1 x108; + uint64_t x109; + uint64_t x110; + uint64_t x111; + uint64_t x112; + uint64_t x113; + uint64_t x114; + uint64_t x115; + fiat_p256_uint1 x116; + uint64_t x117; + uint64_t x118; + fiat_p256_uint1 x119; + uint64_t x120; + fiat_p256_uint1 x121; + uint64_t x122; + fiat_p256_uint1 x123; + uint64_t x124; + fiat_p256_uint1 x125; + uint64_t x126; + fiat_p256_uint1 x127; + uint64_t x128; + uint64_t x129; + uint64_t x130; + uint64_t x131; + uint64_t x132; + uint64_t x133; + uint64_t x134; + uint64_t x135; + uint64_t x136; + uint64_t x137; + fiat_p256_uint1 x138; + uint64_t x139; + fiat_p256_uint1 x140; + uint64_t x141; + fiat_p256_uint1 x142; + uint64_t x143; + uint64_t x144; + fiat_p256_uint1 x145; + uint64_t x146; + fiat_p256_uint1 x147; + uint64_t x148; + fiat_p256_uint1 x149; + uint64_t x150; + fiat_p256_uint1 x151; + uint64_t x152; + fiat_p256_uint1 x153; + uint64_t x154; + uint64_t x155; + uint64_t x156; + uint64_t x157; + uint64_t x158; + uint64_t x159; + uint64_t x160; + fiat_p256_uint1 x161; + uint64_t x162; + uint64_t x163; + fiat_p256_uint1 x164; + uint64_t x165; + fiat_p256_uint1 x166; + uint64_t x167; + fiat_p256_uint1 x168; + uint64_t x169; + fiat_p256_uint1 x170; + uint64_t x171; + fiat_p256_uint1 x172; + uint64_t x173; + uint64_t x174; + fiat_p256_uint1 x175; + uint64_t x176; + fiat_p256_uint1 x177; + uint64_t x178; + fiat_p256_uint1 x179; + uint64_t x180; + fiat_p256_uint1 x181; + uint64_t x182; + fiat_p256_uint1 x183; + uint64_t x184; + uint64_t x185; + uint64_t x186; + uint64_t x187; + x1 = (arg1[1]); + x2 = (arg1[2]); + x3 = (arg1[3]); + x4 = (arg1[0]); + fiat_p256_mulx_u64(&x5, &x6, x4, (arg2[3])); + fiat_p256_mulx_u64(&x7, &x8, x4, (arg2[2])); + fiat_p256_mulx_u64(&x9, &x10, x4, (arg2[1])); + fiat_p256_mulx_u64(&x11, &x12, x4, (arg2[0])); + fiat_p256_addcarryx_u64(&x13, &x14, 0x0, x12, x9); + fiat_p256_addcarryx_u64(&x15, &x16, x14, x10, x7); + fiat_p256_addcarryx_u64(&x17, &x18, x16, x8, x5); + x19 = (x18 + x6); + fiat_p256_mulx_u64(&x20, &x21, x11, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x22, &x23, x11, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x24, &x25, x11, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x26, &x27, 0x0, x25, x22); + x28 = (x27 + x23); + fiat_p256_addcarryx_u64(&x29, &x30, 0x0, x11, x24); + fiat_p256_addcarryx_u64(&x31, &x32, x30, x13, x26); + fiat_p256_addcarryx_u64(&x33, &x34, x32, x15, x28); + fiat_p256_addcarryx_u64(&x35, &x36, x34, x17, x20); + fiat_p256_addcarryx_u64(&x37, &x38, x36, x19, x21); + fiat_p256_mulx_u64(&x39, &x40, x1, (arg2[3])); + fiat_p256_mulx_u64(&x41, &x42, x1, (arg2[2])); + fiat_p256_mulx_u64(&x43, &x44, x1, (arg2[1])); + fiat_p256_mulx_u64(&x45, &x46, x1, (arg2[0])); + fiat_p256_addcarryx_u64(&x47, &x48, 0x0, x46, x43); + fiat_p256_addcarryx_u64(&x49, &x50, x48, x44, x41); + fiat_p256_addcarryx_u64(&x51, &x52, x50, x42, x39); + x53 = (x52 + x40); + fiat_p256_addcarryx_u64(&x54, &x55, 0x0, x31, x45); + fiat_p256_addcarryx_u64(&x56, &x57, x55, x33, x47); + fiat_p256_addcarryx_u64(&x58, &x59, x57, x35, x49); + fiat_p256_addcarryx_u64(&x60, &x61, x59, x37, x51); + fiat_p256_addcarryx_u64(&x62, &x63, x61, x38, x53); + fiat_p256_mulx_u64(&x64, &x65, x54, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x66, &x67, x54, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x68, &x69, x54, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x70, &x71, 0x0, x69, x66); + x72 = (x71 + x67); + fiat_p256_addcarryx_u64(&x73, &x74, 0x0, x54, x68); + fiat_p256_addcarryx_u64(&x75, &x76, x74, x56, x70); + fiat_p256_addcarryx_u64(&x77, &x78, x76, x58, x72); + fiat_p256_addcarryx_u64(&x79, &x80, x78, x60, x64); + fiat_p256_addcarryx_u64(&x81, &x82, x80, x62, x65); + x83 = ((uint64_t)x82 + x63); + fiat_p256_mulx_u64(&x84, &x85, x2, (arg2[3])); + fiat_p256_mulx_u64(&x86, &x87, x2, (arg2[2])); + fiat_p256_mulx_u64(&x88, &x89, x2, (arg2[1])); + fiat_p256_mulx_u64(&x90, &x91, x2, (arg2[0])); + fiat_p256_addcarryx_u64(&x92, &x93, 0x0, x91, x88); + fiat_p256_addcarryx_u64(&x94, &x95, x93, x89, x86); + fiat_p256_addcarryx_u64(&x96, &x97, x95, x87, x84); + x98 = (x97 + x85); + fiat_p256_addcarryx_u64(&x99, &x100, 0x0, x75, x90); + fiat_p256_addcarryx_u64(&x101, &x102, x100, x77, x92); + fiat_p256_addcarryx_u64(&x103, &x104, x102, x79, x94); + fiat_p256_addcarryx_u64(&x105, &x106, x104, x81, x96); + fiat_p256_addcarryx_u64(&x107, &x108, x106, x83, x98); + fiat_p256_mulx_u64(&x109, &x110, x99, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x111, &x112, x99, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x113, &x114, x99, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x115, &x116, 0x0, x114, x111); + x117 = (x116 + x112); + fiat_p256_addcarryx_u64(&x118, &x119, 0x0, x99, x113); + fiat_p256_addcarryx_u64(&x120, &x121, x119, x101, x115); + fiat_p256_addcarryx_u64(&x122, &x123, x121, x103, x117); + fiat_p256_addcarryx_u64(&x124, &x125, x123, x105, x109); + fiat_p256_addcarryx_u64(&x126, &x127, x125, x107, x110); + x128 = ((uint64_t)x127 + x108); + fiat_p256_mulx_u64(&x129, &x130, x3, (arg2[3])); + fiat_p256_mulx_u64(&x131, &x132, x3, (arg2[2])); + fiat_p256_mulx_u64(&x133, &x134, x3, (arg2[1])); + fiat_p256_mulx_u64(&x135, &x136, x3, (arg2[0])); + fiat_p256_addcarryx_u64(&x137, &x138, 0x0, x136, x133); + fiat_p256_addcarryx_u64(&x139, &x140, x138, x134, x131); + fiat_p256_addcarryx_u64(&x141, &x142, x140, x132, x129); + x143 = (x142 + x130); + fiat_p256_addcarryx_u64(&x144, &x145, 0x0, x120, x135); + fiat_p256_addcarryx_u64(&x146, &x147, x145, x122, x137); + fiat_p256_addcarryx_u64(&x148, &x149, x147, x124, x139); + fiat_p256_addcarryx_u64(&x150, &x151, x149, x126, x141); + fiat_p256_addcarryx_u64(&x152, &x153, x151, x128, x143); + fiat_p256_mulx_u64(&x154, &x155, x144, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x156, &x157, x144, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x158, &x159, x144, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x160, &x161, 0x0, x159, x156); + x162 = (x161 + x157); + fiat_p256_addcarryx_u64(&x163, &x164, 0x0, x144, x158); + fiat_p256_addcarryx_u64(&x165, &x166, x164, x146, x160); + fiat_p256_addcarryx_u64(&x167, &x168, x166, x148, x162); + fiat_p256_addcarryx_u64(&x169, &x170, x168, x150, x154); + fiat_p256_addcarryx_u64(&x171, &x172, x170, x152, x155); + x173 = ((uint64_t)x172 + x153); + fiat_p256_subborrowx_u64(&x174, &x175, 0x0, x165, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x176, &x177, x175, x167, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x178, &x179, x177, x169, 0x0); + fiat_p256_subborrowx_u64(&x180, &x181, x179, x171, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x182, &x183, x181, x173, 0x0); + fiat_p256_cmovznz_u64(&x184, x183, x174, x165); + fiat_p256_cmovznz_u64(&x185, x183, x176, x167); + fiat_p256_cmovznz_u64(&x186, x183, x178, x169); + fiat_p256_cmovznz_u64(&x187, x183, x180, x171); + out1[0] = x184; + out1[1] = x185; + out1[2] = x186; + out1[3] = x187; +} + +/* + * The function fiat_p256_square squares a field element in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg1)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_square(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_p256_uint1 x14; + uint64_t x15; + fiat_p256_uint1 x16; + uint64_t x17; + fiat_p256_uint1 x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + fiat_p256_uint1 x27; + uint64_t x28; + uint64_t x29; + fiat_p256_uint1 x30; + uint64_t x31; + fiat_p256_uint1 x32; + uint64_t x33; + fiat_p256_uint1 x34; + uint64_t x35; + fiat_p256_uint1 x36; + uint64_t x37; + fiat_p256_uint1 x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + fiat_p256_uint1 x48; + uint64_t x49; + fiat_p256_uint1 x50; + uint64_t x51; + fiat_p256_uint1 x52; + uint64_t x53; + uint64_t x54; + fiat_p256_uint1 x55; + uint64_t x56; + fiat_p256_uint1 x57; + uint64_t x58; + fiat_p256_uint1 x59; + uint64_t x60; + fiat_p256_uint1 x61; + uint64_t x62; + fiat_p256_uint1 x63; + uint64_t x64; + uint64_t x65; + uint64_t x66; + uint64_t x67; + uint64_t x68; + uint64_t x69; + uint64_t x70; + fiat_p256_uint1 x71; + uint64_t x72; + uint64_t x73; + fiat_p256_uint1 x74; + uint64_t x75; + fiat_p256_uint1 x76; + uint64_t x77; + fiat_p256_uint1 x78; + uint64_t x79; + fiat_p256_uint1 x80; + uint64_t x81; + fiat_p256_uint1 x82; + uint64_t x83; + uint64_t x84; + uint64_t x85; + uint64_t x86; + uint64_t x87; + uint64_t x88; + uint64_t x89; + uint64_t x90; + uint64_t x91; + uint64_t x92; + fiat_p256_uint1 x93; + uint64_t x94; + fiat_p256_uint1 x95; + uint64_t x96; + fiat_p256_uint1 x97; + uint64_t x98; + uint64_t x99; + fiat_p256_uint1 x100; + uint64_t x101; + fiat_p256_uint1 x102; + uint64_t x103; + fiat_p256_uint1 x104; + uint64_t x105; + fiat_p256_uint1 x106; + uint64_t x107; + fiat_p256_uint1 x108; + uint64_t x109; + uint64_t x110; + uint64_t x111; + uint64_t x112; + uint64_t x113; + uint64_t x114; + uint64_t x115; + fiat_p256_uint1 x116; + uint64_t x117; + uint64_t x118; + fiat_p256_uint1 x119; + uint64_t x120; + fiat_p256_uint1 x121; + uint64_t x122; + fiat_p256_uint1 x123; + uint64_t x124; + fiat_p256_uint1 x125; + uint64_t x126; + fiat_p256_uint1 x127; + uint64_t x128; + uint64_t x129; + uint64_t x130; + uint64_t x131; + uint64_t x132; + uint64_t x133; + uint64_t x134; + uint64_t x135; + uint64_t x136; + uint64_t x137; + fiat_p256_uint1 x138; + uint64_t x139; + fiat_p256_uint1 x140; + uint64_t x141; + fiat_p256_uint1 x142; + uint64_t x143; + uint64_t x144; + fiat_p256_uint1 x145; + uint64_t x146; + fiat_p256_uint1 x147; + uint64_t x148; + fiat_p256_uint1 x149; + uint64_t x150; + fiat_p256_uint1 x151; + uint64_t x152; + fiat_p256_uint1 x153; + uint64_t x154; + uint64_t x155; + uint64_t x156; + uint64_t x157; + uint64_t x158; + uint64_t x159; + uint64_t x160; + fiat_p256_uint1 x161; + uint64_t x162; + uint64_t x163; + fiat_p256_uint1 x164; + uint64_t x165; + fiat_p256_uint1 x166; + uint64_t x167; + fiat_p256_uint1 x168; + uint64_t x169; + fiat_p256_uint1 x170; + uint64_t x171; + fiat_p256_uint1 x172; + uint64_t x173; + uint64_t x174; + fiat_p256_uint1 x175; + uint64_t x176; + fiat_p256_uint1 x177; + uint64_t x178; + fiat_p256_uint1 x179; + uint64_t x180; + fiat_p256_uint1 x181; + uint64_t x182; + fiat_p256_uint1 x183; + uint64_t x184; + uint64_t x185; + uint64_t x186; + uint64_t x187; + x1 = (arg1[1]); + x2 = (arg1[2]); + x3 = (arg1[3]); + x4 = (arg1[0]); + fiat_p256_mulx_u64(&x5, &x6, x4, (arg1[3])); + fiat_p256_mulx_u64(&x7, &x8, x4, (arg1[2])); + fiat_p256_mulx_u64(&x9, &x10, x4, (arg1[1])); + fiat_p256_mulx_u64(&x11, &x12, x4, (arg1[0])); + fiat_p256_addcarryx_u64(&x13, &x14, 0x0, x12, x9); + fiat_p256_addcarryx_u64(&x15, &x16, x14, x10, x7); + fiat_p256_addcarryx_u64(&x17, &x18, x16, x8, x5); + x19 = (x18 + x6); + fiat_p256_mulx_u64(&x20, &x21, x11, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x22, &x23, x11, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x24, &x25, x11, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x26, &x27, 0x0, x25, x22); + x28 = (x27 + x23); + fiat_p256_addcarryx_u64(&x29, &x30, 0x0, x11, x24); + fiat_p256_addcarryx_u64(&x31, &x32, x30, x13, x26); + fiat_p256_addcarryx_u64(&x33, &x34, x32, x15, x28); + fiat_p256_addcarryx_u64(&x35, &x36, x34, x17, x20); + fiat_p256_addcarryx_u64(&x37, &x38, x36, x19, x21); + fiat_p256_mulx_u64(&x39, &x40, x1, (arg1[3])); + fiat_p256_mulx_u64(&x41, &x42, x1, (arg1[2])); + fiat_p256_mulx_u64(&x43, &x44, x1, (arg1[1])); + fiat_p256_mulx_u64(&x45, &x46, x1, (arg1[0])); + fiat_p256_addcarryx_u64(&x47, &x48, 0x0, x46, x43); + fiat_p256_addcarryx_u64(&x49, &x50, x48, x44, x41); + fiat_p256_addcarryx_u64(&x51, &x52, x50, x42, x39); + x53 = (x52 + x40); + fiat_p256_addcarryx_u64(&x54, &x55, 0x0, x31, x45); + fiat_p256_addcarryx_u64(&x56, &x57, x55, x33, x47); + fiat_p256_addcarryx_u64(&x58, &x59, x57, x35, x49); + fiat_p256_addcarryx_u64(&x60, &x61, x59, x37, x51); + fiat_p256_addcarryx_u64(&x62, &x63, x61, x38, x53); + fiat_p256_mulx_u64(&x64, &x65, x54, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x66, &x67, x54, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x68, &x69, x54, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x70, &x71, 0x0, x69, x66); + x72 = (x71 + x67); + fiat_p256_addcarryx_u64(&x73, &x74, 0x0, x54, x68); + fiat_p256_addcarryx_u64(&x75, &x76, x74, x56, x70); + fiat_p256_addcarryx_u64(&x77, &x78, x76, x58, x72); + fiat_p256_addcarryx_u64(&x79, &x80, x78, x60, x64); + fiat_p256_addcarryx_u64(&x81, &x82, x80, x62, x65); + x83 = ((uint64_t)x82 + x63); + fiat_p256_mulx_u64(&x84, &x85, x2, (arg1[3])); + fiat_p256_mulx_u64(&x86, &x87, x2, (arg1[2])); + fiat_p256_mulx_u64(&x88, &x89, x2, (arg1[1])); + fiat_p256_mulx_u64(&x90, &x91, x2, (arg1[0])); + fiat_p256_addcarryx_u64(&x92, &x93, 0x0, x91, x88); + fiat_p256_addcarryx_u64(&x94, &x95, x93, x89, x86); + fiat_p256_addcarryx_u64(&x96, &x97, x95, x87, x84); + x98 = (x97 + x85); + fiat_p256_addcarryx_u64(&x99, &x100, 0x0, x75, x90); + fiat_p256_addcarryx_u64(&x101, &x102, x100, x77, x92); + fiat_p256_addcarryx_u64(&x103, &x104, x102, x79, x94); + fiat_p256_addcarryx_u64(&x105, &x106, x104, x81, x96); + fiat_p256_addcarryx_u64(&x107, &x108, x106, x83, x98); + fiat_p256_mulx_u64(&x109, &x110, x99, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x111, &x112, x99, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x113, &x114, x99, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x115, &x116, 0x0, x114, x111); + x117 = (x116 + x112); + fiat_p256_addcarryx_u64(&x118, &x119, 0x0, x99, x113); + fiat_p256_addcarryx_u64(&x120, &x121, x119, x101, x115); + fiat_p256_addcarryx_u64(&x122, &x123, x121, x103, x117); + fiat_p256_addcarryx_u64(&x124, &x125, x123, x105, x109); + fiat_p256_addcarryx_u64(&x126, &x127, x125, x107, x110); + x128 = ((uint64_t)x127 + x108); + fiat_p256_mulx_u64(&x129, &x130, x3, (arg1[3])); + fiat_p256_mulx_u64(&x131, &x132, x3, (arg1[2])); + fiat_p256_mulx_u64(&x133, &x134, x3, (arg1[1])); + fiat_p256_mulx_u64(&x135, &x136, x3, (arg1[0])); + fiat_p256_addcarryx_u64(&x137, &x138, 0x0, x136, x133); + fiat_p256_addcarryx_u64(&x139, &x140, x138, x134, x131); + fiat_p256_addcarryx_u64(&x141, &x142, x140, x132, x129); + x143 = (x142 + x130); + fiat_p256_addcarryx_u64(&x144, &x145, 0x0, x120, x135); + fiat_p256_addcarryx_u64(&x146, &x147, x145, x122, x137); + fiat_p256_addcarryx_u64(&x148, &x149, x147, x124, x139); + fiat_p256_addcarryx_u64(&x150, &x151, x149, x126, x141); + fiat_p256_addcarryx_u64(&x152, &x153, x151, x128, x143); + fiat_p256_mulx_u64(&x154, &x155, x144, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x156, &x157, x144, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x158, &x159, x144, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x160, &x161, 0x0, x159, x156); + x162 = (x161 + x157); + fiat_p256_addcarryx_u64(&x163, &x164, 0x0, x144, x158); + fiat_p256_addcarryx_u64(&x165, &x166, x164, x146, x160); + fiat_p256_addcarryx_u64(&x167, &x168, x166, x148, x162); + fiat_p256_addcarryx_u64(&x169, &x170, x168, x150, x154); + fiat_p256_addcarryx_u64(&x171, &x172, x170, x152, x155); + x173 = ((uint64_t)x172 + x153); + fiat_p256_subborrowx_u64(&x174, &x175, 0x0, x165, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x176, &x177, x175, x167, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x178, &x179, x177, x169, 0x0); + fiat_p256_subborrowx_u64(&x180, &x181, x179, x171, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x182, &x183, x181, x173, 0x0); + fiat_p256_cmovznz_u64(&x184, x183, x174, x165); + fiat_p256_cmovznz_u64(&x185, x183, x176, x167); + fiat_p256_cmovznz_u64(&x186, x183, x178, x169); + fiat_p256_cmovznz_u64(&x187, x183, x180, x171); + out1[0] = x184; + out1[1] = x185; + out1[2] = x186; + out1[3] = x187; +} + +/* + * The function fiat_p256_add adds two field elements in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * 0 ≤ eval arg2 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) + eval (from_montgomery arg2)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_add(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1, const fiat_p256_montgomery_domain_field_element arg2) { + uint64_t x1; + fiat_p256_uint1 x2; + uint64_t x3; + fiat_p256_uint1 x4; + uint64_t x5; + fiat_p256_uint1 x6; + uint64_t x7; + fiat_p256_uint1 x8; + uint64_t x9; + fiat_p256_uint1 x10; + uint64_t x11; + fiat_p256_uint1 x12; + uint64_t x13; + fiat_p256_uint1 x14; + uint64_t x15; + fiat_p256_uint1 x16; + uint64_t x17; + fiat_p256_uint1 x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + fiat_p256_addcarryx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); + fiat_p256_addcarryx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1])); + fiat_p256_addcarryx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2])); + fiat_p256_addcarryx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3])); + fiat_p256_subborrowx_u64(&x9, &x10, 0x0, x1, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x11, &x12, x10, x3, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x13, &x14, x12, x5, 0x0); + fiat_p256_subborrowx_u64(&x15, &x16, x14, x7, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x17, &x18, x16, x8, 0x0); + fiat_p256_cmovznz_u64(&x19, x18, x9, x1); + fiat_p256_cmovznz_u64(&x20, x18, x11, x3); + fiat_p256_cmovznz_u64(&x21, x18, x13, x5); + fiat_p256_cmovznz_u64(&x22, x18, x15, x7); + out1[0] = x19; + out1[1] = x20; + out1[2] = x21; + out1[3] = x22; +} + +/* + * The function fiat_p256_sub subtracts two field elements in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * 0 ≤ eval arg2 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) - eval (from_montgomery arg2)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_sub(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1, const fiat_p256_montgomery_domain_field_element arg2) { + uint64_t x1; + fiat_p256_uint1 x2; + uint64_t x3; + fiat_p256_uint1 x4; + uint64_t x5; + fiat_p256_uint1 x6; + uint64_t x7; + fiat_p256_uint1 x8; + uint64_t x9; + uint64_t x10; + fiat_p256_uint1 x11; + uint64_t x12; + fiat_p256_uint1 x13; + uint64_t x14; + fiat_p256_uint1 x15; + uint64_t x16; + fiat_p256_uint1 x17; + fiat_p256_subborrowx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); + fiat_p256_subborrowx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1])); + fiat_p256_subborrowx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2])); + fiat_p256_subborrowx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3])); + fiat_p256_cmovznz_u64(&x9, x8, 0x0, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x10, &x11, 0x0, x1, x9); + fiat_p256_addcarryx_u64(&x12, &x13, x11, x3, (x9 & UINT32_C(0xffffffff))); + fiat_p256_addcarryx_u64(&x14, &x15, x13, x5, 0x0); + fiat_p256_addcarryx_u64(&x16, &x17, x15, x7, (x9 & UINT64_C(0xffffffff00000001))); + out1[0] = x10; + out1[1] = x12; + out1[2] = x14; + out1[3] = x16; +} + +/* + * The function fiat_p256_opp negates a field element in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * eval (from_montgomery out1) mod m = -eval (from_montgomery arg1) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_opp(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1) { + uint64_t x1; + fiat_p256_uint1 x2; + uint64_t x3; + fiat_p256_uint1 x4; + uint64_t x5; + fiat_p256_uint1 x6; + uint64_t x7; + fiat_p256_uint1 x8; + uint64_t x9; + uint64_t x10; + fiat_p256_uint1 x11; + uint64_t x12; + fiat_p256_uint1 x13; + uint64_t x14; + fiat_p256_uint1 x15; + uint64_t x16; + fiat_p256_uint1 x17; + fiat_p256_subborrowx_u64(&x1, &x2, 0x0, 0x0, (arg1[0])); + fiat_p256_subborrowx_u64(&x3, &x4, x2, 0x0, (arg1[1])); + fiat_p256_subborrowx_u64(&x5, &x6, x4, 0x0, (arg1[2])); + fiat_p256_subborrowx_u64(&x7, &x8, x6, 0x0, (arg1[3])); + fiat_p256_cmovznz_u64(&x9, x8, 0x0, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x10, &x11, 0x0, x1, x9); + fiat_p256_addcarryx_u64(&x12, &x13, x11, x3, (x9 & UINT32_C(0xffffffff))); + fiat_p256_addcarryx_u64(&x14, &x15, x13, x5, 0x0); + fiat_p256_addcarryx_u64(&x16, &x17, x15, x7, (x9 & UINT64_C(0xffffffff00000001))); + out1[0] = x10; + out1[1] = x12; + out1[2] = x14; + out1[3] = x16; +} + +/* + * The function fiat_p256_from_montgomery translates a field element out of the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * eval out1 mod m = (eval arg1 * ((2^64)⁻¹ mod m)^4) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_from_montgomery(fiat_p256_non_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + fiat_p256_uint1 x9; + uint64_t x10; + fiat_p256_uint1 x11; + uint64_t x12; + fiat_p256_uint1 x13; + uint64_t x14; + fiat_p256_uint1 x15; + uint64_t x16; + uint64_t x17; + uint64_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + fiat_p256_uint1 x23; + uint64_t x24; + fiat_p256_uint1 x25; + uint64_t x26; + fiat_p256_uint1 x27; + uint64_t x28; + fiat_p256_uint1 x29; + uint64_t x30; + fiat_p256_uint1 x31; + uint64_t x32; + fiat_p256_uint1 x33; + uint64_t x34; + fiat_p256_uint1 x35; + uint64_t x36; + fiat_p256_uint1 x37; + uint64_t x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + fiat_p256_uint1 x45; + uint64_t x46; + fiat_p256_uint1 x47; + uint64_t x48; + fiat_p256_uint1 x49; + uint64_t x50; + fiat_p256_uint1 x51; + uint64_t x52; + fiat_p256_uint1 x53; + uint64_t x54; + fiat_p256_uint1 x55; + uint64_t x56; + fiat_p256_uint1 x57; + uint64_t x58; + fiat_p256_uint1 x59; + uint64_t x60; + uint64_t x61; + uint64_t x62; + uint64_t x63; + uint64_t x64; + uint64_t x65; + uint64_t x66; + fiat_p256_uint1 x67; + uint64_t x68; + fiat_p256_uint1 x69; + uint64_t x70; + fiat_p256_uint1 x71; + uint64_t x72; + fiat_p256_uint1 x73; + uint64_t x74; + fiat_p256_uint1 x75; + uint64_t x76; + uint64_t x77; + fiat_p256_uint1 x78; + uint64_t x79; + fiat_p256_uint1 x80; + uint64_t x81; + fiat_p256_uint1 x82; + uint64_t x83; + fiat_p256_uint1 x84; + uint64_t x85; + fiat_p256_uint1 x86; + uint64_t x87; + uint64_t x88; + uint64_t x89; + uint64_t x90; + x1 = (arg1[0]); + fiat_p256_mulx_u64(&x2, &x3, x1, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x4, &x5, x1, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x6, &x7, x1, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x8, &x9, 0x0, x7, x4); + fiat_p256_addcarryx_u64(&x10, &x11, 0x0, x1, x6); + fiat_p256_addcarryx_u64(&x12, &x13, x11, 0x0, x8); + fiat_p256_addcarryx_u64(&x14, &x15, 0x0, x12, (arg1[1])); + fiat_p256_mulx_u64(&x16, &x17, x14, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x18, &x19, x14, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x20, &x21, x14, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x22, &x23, 0x0, x21, x18); + fiat_p256_addcarryx_u64(&x24, &x25, 0x0, x14, x20); + fiat_p256_addcarryx_u64(&x26, &x27, x25, (x15 + (x13 + (x9 + x5))), x22); + fiat_p256_addcarryx_u64(&x28, &x29, x27, x2, (x23 + x19)); + fiat_p256_addcarryx_u64(&x30, &x31, x29, x3, x16); + fiat_p256_addcarryx_u64(&x32, &x33, 0x0, x26, (arg1[2])); + fiat_p256_addcarryx_u64(&x34, &x35, x33, x28, 0x0); + fiat_p256_addcarryx_u64(&x36, &x37, x35, x30, 0x0); + fiat_p256_mulx_u64(&x38, &x39, x32, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x40, &x41, x32, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x42, &x43, x32, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x44, &x45, 0x0, x43, x40); + fiat_p256_addcarryx_u64(&x46, &x47, 0x0, x32, x42); + fiat_p256_addcarryx_u64(&x48, &x49, x47, x34, x44); + fiat_p256_addcarryx_u64(&x50, &x51, x49, x36, (x45 + x41)); + fiat_p256_addcarryx_u64(&x52, &x53, x51, (x37 + (x31 + x17)), x38); + fiat_p256_addcarryx_u64(&x54, &x55, 0x0, x48, (arg1[3])); + fiat_p256_addcarryx_u64(&x56, &x57, x55, x50, 0x0); + fiat_p256_addcarryx_u64(&x58, &x59, x57, x52, 0x0); + fiat_p256_mulx_u64(&x60, &x61, x54, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x62, &x63, x54, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x64, &x65, x54, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x66, &x67, 0x0, x65, x62); + fiat_p256_addcarryx_u64(&x68, &x69, 0x0, x54, x64); + fiat_p256_addcarryx_u64(&x70, &x71, x69, x56, x66); + fiat_p256_addcarryx_u64(&x72, &x73, x71, x58, (x67 + x63)); + fiat_p256_addcarryx_u64(&x74, &x75, x73, (x59 + (x53 + x39)), x60); + x76 = (x75 + x61); + fiat_p256_subborrowx_u64(&x77, &x78, 0x0, x70, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x79, &x80, x78, x72, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x81, &x82, x80, x74, 0x0); + fiat_p256_subborrowx_u64(&x83, &x84, x82, x76, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x85, &x86, x84, 0x0, 0x0); + fiat_p256_cmovznz_u64(&x87, x86, x77, x70); + fiat_p256_cmovznz_u64(&x88, x86, x79, x72); + fiat_p256_cmovznz_u64(&x89, x86, x81, x74); + fiat_p256_cmovznz_u64(&x90, x86, x83, x76); + out1[0] = x87; + out1[1] = x88; + out1[2] = x89; + out1[3] = x90; +} + +/* + * The function fiat_p256_to_montgomery translates a field element into the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * eval (from_montgomery out1) mod m = eval arg1 mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_to_montgomery(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_non_montgomery_domain_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_p256_uint1 x14; + uint64_t x15; + fiat_p256_uint1 x16; + uint64_t x17; + fiat_p256_uint1 x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + fiat_p256_uint1 x26; + uint64_t x27; + fiat_p256_uint1 x28; + uint64_t x29; + fiat_p256_uint1 x30; + uint64_t x31; + fiat_p256_uint1 x32; + uint64_t x33; + fiat_p256_uint1 x34; + uint64_t x35; + fiat_p256_uint1 x36; + uint64_t x37; + uint64_t x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + fiat_p256_uint1 x46; + uint64_t x47; + fiat_p256_uint1 x48; + uint64_t x49; + fiat_p256_uint1 x50; + uint64_t x51; + fiat_p256_uint1 x52; + uint64_t x53; + fiat_p256_uint1 x54; + uint64_t x55; + fiat_p256_uint1 x56; + uint64_t x57; + fiat_p256_uint1 x58; + uint64_t x59; + uint64_t x60; + uint64_t x61; + uint64_t x62; + uint64_t x63; + uint64_t x64; + uint64_t x65; + fiat_p256_uint1 x66; + uint64_t x67; + fiat_p256_uint1 x68; + uint64_t x69; + fiat_p256_uint1 x70; + uint64_t x71; + fiat_p256_uint1 x72; + uint64_t x73; + fiat_p256_uint1 x74; + uint64_t x75; + fiat_p256_uint1 x76; + uint64_t x77; + uint64_t x78; + uint64_t x79; + uint64_t x80; + uint64_t x81; + uint64_t x82; + uint64_t x83; + uint64_t x84; + uint64_t x85; + fiat_p256_uint1 x86; + uint64_t x87; + fiat_p256_uint1 x88; + uint64_t x89; + fiat_p256_uint1 x90; + uint64_t x91; + fiat_p256_uint1 x92; + uint64_t x93; + fiat_p256_uint1 x94; + uint64_t x95; + fiat_p256_uint1 x96; + uint64_t x97; + fiat_p256_uint1 x98; + uint64_t x99; + uint64_t x100; + uint64_t x101; + uint64_t x102; + uint64_t x103; + uint64_t x104; + uint64_t x105; + fiat_p256_uint1 x106; + uint64_t x107; + fiat_p256_uint1 x108; + uint64_t x109; + fiat_p256_uint1 x110; + uint64_t x111; + fiat_p256_uint1 x112; + uint64_t x113; + fiat_p256_uint1 x114; + uint64_t x115; + fiat_p256_uint1 x116; + uint64_t x117; + uint64_t x118; + uint64_t x119; + uint64_t x120; + uint64_t x121; + uint64_t x122; + uint64_t x123; + uint64_t x124; + uint64_t x125; + fiat_p256_uint1 x126; + uint64_t x127; + fiat_p256_uint1 x128; + uint64_t x129; + fiat_p256_uint1 x130; + uint64_t x131; + fiat_p256_uint1 x132; + uint64_t x133; + fiat_p256_uint1 x134; + uint64_t x135; + fiat_p256_uint1 x136; + uint64_t x137; + fiat_p256_uint1 x138; + uint64_t x139; + uint64_t x140; + uint64_t x141; + uint64_t x142; + uint64_t x143; + uint64_t x144; + uint64_t x145; + fiat_p256_uint1 x146; + uint64_t x147; + fiat_p256_uint1 x148; + uint64_t x149; + fiat_p256_uint1 x150; + uint64_t x151; + fiat_p256_uint1 x152; + uint64_t x153; + fiat_p256_uint1 x154; + uint64_t x155; + fiat_p256_uint1 x156; + uint64_t x157; + fiat_p256_uint1 x158; + uint64_t x159; + fiat_p256_uint1 x160; + uint64_t x161; + fiat_p256_uint1 x162; + uint64_t x163; + fiat_p256_uint1 x164; + uint64_t x165; + fiat_p256_uint1 x166; + uint64_t x167; + uint64_t x168; + uint64_t x169; + uint64_t x170; + x1 = (arg1[1]); + x2 = (arg1[2]); + x3 = (arg1[3]); + x4 = (arg1[0]); + fiat_p256_mulx_u64(&x5, &x6, x4, UINT64_C(0x4fffffffd)); + fiat_p256_mulx_u64(&x7, &x8, x4, UINT64_C(0xfffffffffffffffe)); + fiat_p256_mulx_u64(&x9, &x10, x4, UINT64_C(0xfffffffbffffffff)); + fiat_p256_mulx_u64(&x11, &x12, x4, 0x3); + fiat_p256_addcarryx_u64(&x13, &x14, 0x0, x12, x9); + fiat_p256_addcarryx_u64(&x15, &x16, x14, x10, x7); + fiat_p256_addcarryx_u64(&x17, &x18, x16, x8, x5); + fiat_p256_mulx_u64(&x19, &x20, x11, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x21, &x22, x11, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x23, &x24, x11, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x25, &x26, 0x0, x24, x21); + fiat_p256_addcarryx_u64(&x27, &x28, 0x0, x11, x23); + fiat_p256_addcarryx_u64(&x29, &x30, x28, x13, x25); + fiat_p256_addcarryx_u64(&x31, &x32, x30, x15, (x26 + x22)); + fiat_p256_addcarryx_u64(&x33, &x34, x32, x17, x19); + fiat_p256_addcarryx_u64(&x35, &x36, x34, (x18 + x6), x20); + fiat_p256_mulx_u64(&x37, &x38, x1, UINT64_C(0x4fffffffd)); + fiat_p256_mulx_u64(&x39, &x40, x1, UINT64_C(0xfffffffffffffffe)); + fiat_p256_mulx_u64(&x41, &x42, x1, UINT64_C(0xfffffffbffffffff)); + fiat_p256_mulx_u64(&x43, &x44, x1, 0x3); + fiat_p256_addcarryx_u64(&x45, &x46, 0x0, x44, x41); + fiat_p256_addcarryx_u64(&x47, &x48, x46, x42, x39); + fiat_p256_addcarryx_u64(&x49, &x50, x48, x40, x37); + fiat_p256_addcarryx_u64(&x51, &x52, 0x0, x29, x43); + fiat_p256_addcarryx_u64(&x53, &x54, x52, x31, x45); + fiat_p256_addcarryx_u64(&x55, &x56, x54, x33, x47); + fiat_p256_addcarryx_u64(&x57, &x58, x56, x35, x49); + fiat_p256_mulx_u64(&x59, &x60, x51, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x61, &x62, x51, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x63, &x64, x51, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x65, &x66, 0x0, x64, x61); + fiat_p256_addcarryx_u64(&x67, &x68, 0x0, x51, x63); + fiat_p256_addcarryx_u64(&x69, &x70, x68, x53, x65); + fiat_p256_addcarryx_u64(&x71, &x72, x70, x55, (x66 + x62)); + fiat_p256_addcarryx_u64(&x73, &x74, x72, x57, x59); + fiat_p256_addcarryx_u64(&x75, &x76, x74, (((uint64_t)x58 + x36) + (x50 + x38)), x60); + fiat_p256_mulx_u64(&x77, &x78, x2, UINT64_C(0x4fffffffd)); + fiat_p256_mulx_u64(&x79, &x80, x2, UINT64_C(0xfffffffffffffffe)); + fiat_p256_mulx_u64(&x81, &x82, x2, UINT64_C(0xfffffffbffffffff)); + fiat_p256_mulx_u64(&x83, &x84, x2, 0x3); + fiat_p256_addcarryx_u64(&x85, &x86, 0x0, x84, x81); + fiat_p256_addcarryx_u64(&x87, &x88, x86, x82, x79); + fiat_p256_addcarryx_u64(&x89, &x90, x88, x80, x77); + fiat_p256_addcarryx_u64(&x91, &x92, 0x0, x69, x83); + fiat_p256_addcarryx_u64(&x93, &x94, x92, x71, x85); + fiat_p256_addcarryx_u64(&x95, &x96, x94, x73, x87); + fiat_p256_addcarryx_u64(&x97, &x98, x96, x75, x89); + fiat_p256_mulx_u64(&x99, &x100, x91, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x101, &x102, x91, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x103, &x104, x91, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x105, &x106, 0x0, x104, x101); + fiat_p256_addcarryx_u64(&x107, &x108, 0x0, x91, x103); + fiat_p256_addcarryx_u64(&x109, &x110, x108, x93, x105); + fiat_p256_addcarryx_u64(&x111, &x112, x110, x95, (x106 + x102)); + fiat_p256_addcarryx_u64(&x113, &x114, x112, x97, x99); + fiat_p256_addcarryx_u64(&x115, &x116, x114, (((uint64_t)x98 + x76) + (x90 + x78)), x100); + fiat_p256_mulx_u64(&x117, &x118, x3, UINT64_C(0x4fffffffd)); + fiat_p256_mulx_u64(&x119, &x120, x3, UINT64_C(0xfffffffffffffffe)); + fiat_p256_mulx_u64(&x121, &x122, x3, UINT64_C(0xfffffffbffffffff)); + fiat_p256_mulx_u64(&x123, &x124, x3, 0x3); + fiat_p256_addcarryx_u64(&x125, &x126, 0x0, x124, x121); + fiat_p256_addcarryx_u64(&x127, &x128, x126, x122, x119); + fiat_p256_addcarryx_u64(&x129, &x130, x128, x120, x117); + fiat_p256_addcarryx_u64(&x131, &x132, 0x0, x109, x123); + fiat_p256_addcarryx_u64(&x133, &x134, x132, x111, x125); + fiat_p256_addcarryx_u64(&x135, &x136, x134, x113, x127); + fiat_p256_addcarryx_u64(&x137, &x138, x136, x115, x129); + fiat_p256_mulx_u64(&x139, &x140, x131, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x141, &x142, x131, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x143, &x144, x131, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x145, &x146, 0x0, x144, x141); + fiat_p256_addcarryx_u64(&x147, &x148, 0x0, x131, x143); + fiat_p256_addcarryx_u64(&x149, &x150, x148, x133, x145); + fiat_p256_addcarryx_u64(&x151, &x152, x150, x135, (x146 + x142)); + fiat_p256_addcarryx_u64(&x153, &x154, x152, x137, x139); + fiat_p256_addcarryx_u64(&x155, &x156, x154, (((uint64_t)x138 + x116) + (x130 + x118)), x140); + fiat_p256_subborrowx_u64(&x157, &x158, 0x0, x149, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x159, &x160, x158, x151, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x161, &x162, x160, x153, 0x0); + fiat_p256_subborrowx_u64(&x163, &x164, x162, x155, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x165, &x166, x164, x156, 0x0); + fiat_p256_cmovznz_u64(&x167, x166, x157, x149); + fiat_p256_cmovznz_u64(&x168, x166, x159, x151); + fiat_p256_cmovznz_u64(&x169, x166, x161, x153); + fiat_p256_cmovznz_u64(&x170, x166, x163, x155); + out1[0] = x167; + out1[1] = x168; + out1[2] = x169; + out1[3] = x170; +} + +/* + * The function fiat_p256_nonzero outputs a single non-zero word if the input is non-zero and zero otherwise. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * out1 = 0 ↔ eval (from_montgomery arg1) mod m = 0 + * + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_nonzero(uint64_t* out1, const uint64_t arg1[4]) { + uint64_t x1; + x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | (arg1[3])))); + *out1 = x1; +} + +/* + * The function fiat_p256_selectznz is a multi-limb conditional select. + * + * Postconditions: + * out1 = (if arg1 = 0 then arg2 else arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_selectznz(uint64_t out1[4], fiat_p256_uint1 arg1, const uint64_t arg2[4], const uint64_t arg3[4]) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + fiat_p256_cmovznz_u64(&x1, arg1, (arg2[0]), (arg3[0])); + fiat_p256_cmovznz_u64(&x2, arg1, (arg2[1]), (arg3[1])); + fiat_p256_cmovznz_u64(&x3, arg1, (arg2[2]), (arg3[2])); + fiat_p256_cmovznz_u64(&x4, arg1, (arg2[3]), (arg3[3])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; +} + +/* + * The function fiat_p256_to_bytes serializes a field element NOT in the Montgomery domain to bytes in little-endian order. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..31] + * + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_to_bytes(uint8_t out1[32], const uint64_t arg1[4]) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint8_t x5; + uint64_t x6; + uint8_t x7; + uint64_t x8; + uint8_t x9; + uint64_t x10; + uint8_t x11; + uint64_t x12; + uint8_t x13; + uint64_t x14; + uint8_t x15; + uint64_t x16; + uint8_t x17; + uint8_t x18; + uint8_t x19; + uint64_t x20; + uint8_t x21; + uint64_t x22; + uint8_t x23; + uint64_t x24; + uint8_t x25; + uint64_t x26; + uint8_t x27; + uint64_t x28; + uint8_t x29; + uint64_t x30; + uint8_t x31; + uint8_t x32; + uint8_t x33; + uint64_t x34; + uint8_t x35; + uint64_t x36; + uint8_t x37; + uint64_t x38; + uint8_t x39; + uint64_t x40; + uint8_t x41; + uint64_t x42; + uint8_t x43; + uint64_t x44; + uint8_t x45; + uint8_t x46; + uint8_t x47; + uint64_t x48; + uint8_t x49; + uint64_t x50; + uint8_t x51; + uint64_t x52; + uint8_t x53; + uint64_t x54; + uint8_t x55; + uint64_t x56; + uint8_t x57; + uint64_t x58; + uint8_t x59; + uint8_t x60; + x1 = (arg1[3]); + x2 = (arg1[2]); + x3 = (arg1[1]); + x4 = (arg1[0]); + x5 = (uint8_t)(x4 & UINT8_C(0xff)); + x6 = (x4 >> 8); + x7 = (uint8_t)(x6 & UINT8_C(0xff)); + x8 = (x6 >> 8); + x9 = (uint8_t)(x8 & UINT8_C(0xff)); + x10 = (x8 >> 8); + x11 = (uint8_t)(x10 & UINT8_C(0xff)); + x12 = (x10 >> 8); + x13 = (uint8_t)(x12 & UINT8_C(0xff)); + x14 = (x12 >> 8); + x15 = (uint8_t)(x14 & UINT8_C(0xff)); + x16 = (x14 >> 8); + x17 = (uint8_t)(x16 & UINT8_C(0xff)); + x18 = (uint8_t)(x16 >> 8); + x19 = (uint8_t)(x3 & UINT8_C(0xff)); + x20 = (x3 >> 8); + x21 = (uint8_t)(x20 & UINT8_C(0xff)); + x22 = (x20 >> 8); + x23 = (uint8_t)(x22 & UINT8_C(0xff)); + x24 = (x22 >> 8); + x25 = (uint8_t)(x24 & UINT8_C(0xff)); + x26 = (x24 >> 8); + x27 = (uint8_t)(x26 & UINT8_C(0xff)); + x28 = (x26 >> 8); + x29 = (uint8_t)(x28 & UINT8_C(0xff)); + x30 = (x28 >> 8); + x31 = (uint8_t)(x30 & UINT8_C(0xff)); + x32 = (uint8_t)(x30 >> 8); + x33 = (uint8_t)(x2 & UINT8_C(0xff)); + x34 = (x2 >> 8); + x35 = (uint8_t)(x34 & UINT8_C(0xff)); + x36 = (x34 >> 8); + x37 = (uint8_t)(x36 & UINT8_C(0xff)); + x38 = (x36 >> 8); + x39 = (uint8_t)(x38 & UINT8_C(0xff)); + x40 = (x38 >> 8); + x41 = (uint8_t)(x40 & UINT8_C(0xff)); + x42 = (x40 >> 8); + x43 = (uint8_t)(x42 & UINT8_C(0xff)); + x44 = (x42 >> 8); + x45 = (uint8_t)(x44 & UINT8_C(0xff)); + x46 = (uint8_t)(x44 >> 8); + x47 = (uint8_t)(x1 & UINT8_C(0xff)); + x48 = (x1 >> 8); + x49 = (uint8_t)(x48 & UINT8_C(0xff)); + x50 = (x48 >> 8); + x51 = (uint8_t)(x50 & UINT8_C(0xff)); + x52 = (x50 >> 8); + x53 = (uint8_t)(x52 & UINT8_C(0xff)); + x54 = (x52 >> 8); + x55 = (uint8_t)(x54 & UINT8_C(0xff)); + x56 = (x54 >> 8); + x57 = (uint8_t)(x56 & UINT8_C(0xff)); + x58 = (x56 >> 8); + x59 = (uint8_t)(x58 & UINT8_C(0xff)); + x60 = (uint8_t)(x58 >> 8); + out1[0] = x5; + out1[1] = x7; + out1[2] = x9; + out1[3] = x11; + out1[4] = x13; + out1[5] = x15; + out1[6] = x17; + out1[7] = x18; + out1[8] = x19; + out1[9] = x21; + out1[10] = x23; + out1[11] = x25; + out1[12] = x27; + out1[13] = x29; + out1[14] = x31; + out1[15] = x32; + out1[16] = x33; + out1[17] = x35; + out1[18] = x37; + out1[19] = x39; + out1[20] = x41; + out1[21] = x43; + out1[22] = x45; + out1[23] = x46; + out1[24] = x47; + out1[25] = x49; + out1[26] = x51; + out1[27] = x53; + out1[28] = x55; + out1[29] = x57; + out1[30] = x59; + out1[31] = x60; +} + +/* + * The function fiat_p256_from_bytes deserializes a field element NOT in the Montgomery domain from bytes in little-endian order. + * + * Preconditions: + * 0 ≤ bytes_eval arg1 < m + * Postconditions: + * eval out1 mod m = bytes_eval arg1 mod m + * 0 ≤ eval out1 < m + * + * Input Bounds: + * arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_from_bytes(uint64_t out1[4], const uint8_t arg1[32]) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint8_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + uint64_t x14; + uint64_t x15; + uint8_t x16; + uint64_t x17; + uint64_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint8_t x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + uint64_t x29; + uint64_t x30; + uint64_t x31; + uint8_t x32; + uint64_t x33; + uint64_t x34; + uint64_t x35; + uint64_t x36; + uint64_t x37; + uint64_t x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + uint64_t x48; + uint64_t x49; + uint64_t x50; + uint64_t x51; + uint64_t x52; + uint64_t x53; + uint64_t x54; + uint64_t x55; + uint64_t x56; + uint64_t x57; + uint64_t x58; + uint64_t x59; + uint64_t x60; + x1 = ((uint64_t)(arg1[31]) << 56); + x2 = ((uint64_t)(arg1[30]) << 48); + x3 = ((uint64_t)(arg1[29]) << 40); + x4 = ((uint64_t)(arg1[28]) << 32); + x5 = ((uint64_t)(arg1[27]) << 24); + x6 = ((uint64_t)(arg1[26]) << 16); + x7 = ((uint64_t)(arg1[25]) << 8); + x8 = (arg1[24]); + x9 = ((uint64_t)(arg1[23]) << 56); + x10 = ((uint64_t)(arg1[22]) << 48); + x11 = ((uint64_t)(arg1[21]) << 40); + x12 = ((uint64_t)(arg1[20]) << 32); + x13 = ((uint64_t)(arg1[19]) << 24); + x14 = ((uint64_t)(arg1[18]) << 16); + x15 = ((uint64_t)(arg1[17]) << 8); + x16 = (arg1[16]); + x17 = ((uint64_t)(arg1[15]) << 56); + x18 = ((uint64_t)(arg1[14]) << 48); + x19 = ((uint64_t)(arg1[13]) << 40); + x20 = ((uint64_t)(arg1[12]) << 32); + x21 = ((uint64_t)(arg1[11]) << 24); + x22 = ((uint64_t)(arg1[10]) << 16); + x23 = ((uint64_t)(arg1[9]) << 8); + x24 = (arg1[8]); + x25 = ((uint64_t)(arg1[7]) << 56); + x26 = ((uint64_t)(arg1[6]) << 48); + x27 = ((uint64_t)(arg1[5]) << 40); + x28 = ((uint64_t)(arg1[4]) << 32); + x29 = ((uint64_t)(arg1[3]) << 24); + x30 = ((uint64_t)(arg1[2]) << 16); + x31 = ((uint64_t)(arg1[1]) << 8); + x32 = (arg1[0]); + x33 = (x31 + (uint64_t)x32); + x34 = (x30 + x33); + x35 = (x29 + x34); + x36 = (x28 + x35); + x37 = (x27 + x36); + x38 = (x26 + x37); + x39 = (x25 + x38); + x40 = (x23 + (uint64_t)x24); + x41 = (x22 + x40); + x42 = (x21 + x41); + x43 = (x20 + x42); + x44 = (x19 + x43); + x45 = (x18 + x44); + x46 = (x17 + x45); + x47 = (x15 + (uint64_t)x16); + x48 = (x14 + x47); + x49 = (x13 + x48); + x50 = (x12 + x49); + x51 = (x11 + x50); + x52 = (x10 + x51); + x53 = (x9 + x52); + x54 = (x7 + (uint64_t)x8); + x55 = (x6 + x54); + x56 = (x5 + x55); + x57 = (x4 + x56); + x58 = (x3 + x57); + x59 = (x2 + x58); + x60 = (x1 + x59); + out1[0] = x39; + out1[1] = x46; + out1[2] = x53; + out1[3] = x60; +} + +/* + * The function fiat_p256_set_one returns the field element one in the Montgomery domain. + * + * Postconditions: + * eval (from_montgomery out1) mod m = 1 mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_set_one(fiat_p256_montgomery_domain_field_element out1) { + out1[0] = 0x1; + out1[1] = UINT64_C(0xffffffff00000000); + out1[2] = UINT64_C(0xffffffffffffffff); + out1[3] = UINT32_C(0xfffffffe); +} + +/* + * The function fiat_p256_msat returns the saturated representation of the prime modulus. + * + * Postconditions: + * twos_complement_eval out1 = m + * 0 ≤ eval out1 < m + * + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_msat(uint64_t out1[5]) { + out1[0] = UINT64_C(0xffffffffffffffff); + out1[1] = UINT32_C(0xffffffff); + out1[2] = 0x0; + out1[3] = UINT64_C(0xffffffff00000001); + out1[4] = 0x0; +} + +/* + * The function fiat_p256_divstep computes a divstep. + * + * Preconditions: + * 0 ≤ eval arg4 < m + * 0 ≤ eval arg5 < m + * Postconditions: + * out1 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then 1 - arg1 else 1 + arg1) + * twos_complement_eval out2 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then twos_complement_eval arg3 else twos_complement_eval arg2) + * twos_complement_eval out3 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then ⌊(twos_complement_eval arg3 - twos_complement_eval arg2) / 2⌋ else ⌊(twos_complement_eval arg3 + (twos_complement_eval arg3 mod 2) * twos_complement_eval arg2) / 2⌋) + * eval (from_montgomery out4) mod m = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then (2 * eval (from_montgomery arg5)) mod m else (2 * eval (from_montgomery arg4)) mod m) + * eval (from_montgomery out5) mod m = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then (eval (from_montgomery arg4) - eval (from_montgomery arg4)) mod m else (eval (from_montgomery arg5) + (twos_complement_eval arg3 mod 2) * eval (from_montgomery arg4)) mod m) + * 0 ≤ eval out5 < m + * 0 ≤ eval out5 < m + * 0 ≤ eval out2 < m + * 0 ≤ eval out3 < m + * + * Input Bounds: + * arg1: [0x0 ~> 0xffffffffffffffff] + * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * out3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * out4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * out5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_divstep(uint64_t* out1, uint64_t out2[5], uint64_t out3[5], uint64_t out4[4], uint64_t out5[4], uint64_t arg1, const uint64_t arg2[5], const uint64_t arg3[5], const uint64_t arg4[4], const uint64_t arg5[4]) { + uint64_t x1; + fiat_p256_uint1 x2; + fiat_p256_uint1 x3; + uint64_t x4; + fiat_p256_uint1 x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + fiat_p256_uint1 x13; + uint64_t x14; + fiat_p256_uint1 x15; + uint64_t x16; + fiat_p256_uint1 x17; + uint64_t x18; + fiat_p256_uint1 x19; + uint64_t x20; + fiat_p256_uint1 x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + uint64_t x29; + uint64_t x30; + uint64_t x31; + fiat_p256_uint1 x32; + uint64_t x33; + fiat_p256_uint1 x34; + uint64_t x35; + fiat_p256_uint1 x36; + uint64_t x37; + fiat_p256_uint1 x38; + uint64_t x39; + fiat_p256_uint1 x40; + uint64_t x41; + fiat_p256_uint1 x42; + uint64_t x43; + fiat_p256_uint1 x44; + uint64_t x45; + fiat_p256_uint1 x46; + uint64_t x47; + fiat_p256_uint1 x48; + uint64_t x49; + uint64_t x50; + uint64_t x51; + uint64_t x52; + uint64_t x53; + fiat_p256_uint1 x54; + uint64_t x55; + fiat_p256_uint1 x56; + uint64_t x57; + fiat_p256_uint1 x58; + uint64_t x59; + fiat_p256_uint1 x60; + uint64_t x61; + uint64_t x62; + fiat_p256_uint1 x63; + uint64_t x64; + fiat_p256_uint1 x65; + uint64_t x66; + fiat_p256_uint1 x67; + uint64_t x68; + fiat_p256_uint1 x69; + uint64_t x70; + uint64_t x71; + uint64_t x72; + uint64_t x73; + fiat_p256_uint1 x74; + uint64_t x75; + uint64_t x76; + uint64_t x77; + uint64_t x78; + uint64_t x79; + uint64_t x80; + fiat_p256_uint1 x81; + uint64_t x82; + fiat_p256_uint1 x83; + uint64_t x84; + fiat_p256_uint1 x85; + uint64_t x86; + fiat_p256_uint1 x87; + uint64_t x88; + fiat_p256_uint1 x89; + uint64_t x90; + uint64_t x91; + uint64_t x92; + uint64_t x93; + uint64_t x94; + fiat_p256_uint1 x95; + uint64_t x96; + fiat_p256_uint1 x97; + uint64_t x98; + fiat_p256_uint1 x99; + uint64_t x100; + fiat_p256_uint1 x101; + uint64_t x102; + fiat_p256_uint1 x103; + uint64_t x104; + fiat_p256_uint1 x105; + uint64_t x106; + fiat_p256_uint1 x107; + uint64_t x108; + fiat_p256_uint1 x109; + uint64_t x110; + fiat_p256_uint1 x111; + uint64_t x112; + fiat_p256_uint1 x113; + uint64_t x114; + uint64_t x115; + uint64_t x116; + uint64_t x117; + uint64_t x118; + uint64_t x119; + uint64_t x120; + uint64_t x121; + uint64_t x122; + uint64_t x123; + uint64_t x124; + uint64_t x125; + uint64_t x126; + fiat_p256_addcarryx_u64(&x1, &x2, 0x0, (~arg1), 0x1); + x3 = (fiat_p256_uint1)((fiat_p256_uint1)(x1 >> 63) & (fiat_p256_uint1)((arg3[0]) & 0x1)); + fiat_p256_addcarryx_u64(&x4, &x5, 0x0, (~arg1), 0x1); + fiat_p256_cmovznz_u64(&x6, x3, arg1, x4); + fiat_p256_cmovznz_u64(&x7, x3, (arg2[0]), (arg3[0])); + fiat_p256_cmovznz_u64(&x8, x3, (arg2[1]), (arg3[1])); + fiat_p256_cmovznz_u64(&x9, x3, (arg2[2]), (arg3[2])); + fiat_p256_cmovznz_u64(&x10, x3, (arg2[3]), (arg3[3])); + fiat_p256_cmovznz_u64(&x11, x3, (arg2[4]), (arg3[4])); + fiat_p256_addcarryx_u64(&x12, &x13, 0x0, 0x1, (~(arg2[0]))); + fiat_p256_addcarryx_u64(&x14, &x15, x13, 0x0, (~(arg2[1]))); + fiat_p256_addcarryx_u64(&x16, &x17, x15, 0x0, (~(arg2[2]))); + fiat_p256_addcarryx_u64(&x18, &x19, x17, 0x0, (~(arg2[3]))); + fiat_p256_addcarryx_u64(&x20, &x21, x19, 0x0, (~(arg2[4]))); + fiat_p256_cmovznz_u64(&x22, x3, (arg3[0]), x12); + fiat_p256_cmovznz_u64(&x23, x3, (arg3[1]), x14); + fiat_p256_cmovznz_u64(&x24, x3, (arg3[2]), x16); + fiat_p256_cmovznz_u64(&x25, x3, (arg3[3]), x18); + fiat_p256_cmovznz_u64(&x26, x3, (arg3[4]), x20); + fiat_p256_cmovznz_u64(&x27, x3, (arg4[0]), (arg5[0])); + fiat_p256_cmovznz_u64(&x28, x3, (arg4[1]), (arg5[1])); + fiat_p256_cmovznz_u64(&x29, x3, (arg4[2]), (arg5[2])); + fiat_p256_cmovznz_u64(&x30, x3, (arg4[3]), (arg5[3])); + fiat_p256_addcarryx_u64(&x31, &x32, 0x0, x27, x27); + fiat_p256_addcarryx_u64(&x33, &x34, x32, x28, x28); + fiat_p256_addcarryx_u64(&x35, &x36, x34, x29, x29); + fiat_p256_addcarryx_u64(&x37, &x38, x36, x30, x30); + fiat_p256_subborrowx_u64(&x39, &x40, 0x0, x31, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x41, &x42, x40, x33, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x43, &x44, x42, x35, 0x0); + fiat_p256_subborrowx_u64(&x45, &x46, x44, x37, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x47, &x48, x46, x38, 0x0); + x49 = (arg4[3]); + x50 = (arg4[2]); + x51 = (arg4[1]); + x52 = (arg4[0]); + fiat_p256_subborrowx_u64(&x53, &x54, 0x0, 0x0, x52); + fiat_p256_subborrowx_u64(&x55, &x56, x54, 0x0, x51); + fiat_p256_subborrowx_u64(&x57, &x58, x56, 0x0, x50); + fiat_p256_subborrowx_u64(&x59, &x60, x58, 0x0, x49); + fiat_p256_cmovznz_u64(&x61, x60, 0x0, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x62, &x63, 0x0, x53, x61); + fiat_p256_addcarryx_u64(&x64, &x65, x63, x55, (x61 & UINT32_C(0xffffffff))); + fiat_p256_addcarryx_u64(&x66, &x67, x65, x57, 0x0); + fiat_p256_addcarryx_u64(&x68, &x69, x67, x59, (x61 & UINT64_C(0xffffffff00000001))); + fiat_p256_cmovznz_u64(&x70, x3, (arg5[0]), x62); + fiat_p256_cmovznz_u64(&x71, x3, (arg5[1]), x64); + fiat_p256_cmovznz_u64(&x72, x3, (arg5[2]), x66); + fiat_p256_cmovznz_u64(&x73, x3, (arg5[3]), x68); + x74 = (fiat_p256_uint1)(x22 & 0x1); + fiat_p256_cmovznz_u64(&x75, x74, 0x0, x7); + fiat_p256_cmovznz_u64(&x76, x74, 0x0, x8); + fiat_p256_cmovznz_u64(&x77, x74, 0x0, x9); + fiat_p256_cmovznz_u64(&x78, x74, 0x0, x10); + fiat_p256_cmovznz_u64(&x79, x74, 0x0, x11); + fiat_p256_addcarryx_u64(&x80, &x81, 0x0, x22, x75); + fiat_p256_addcarryx_u64(&x82, &x83, x81, x23, x76); + fiat_p256_addcarryx_u64(&x84, &x85, x83, x24, x77); + fiat_p256_addcarryx_u64(&x86, &x87, x85, x25, x78); + fiat_p256_addcarryx_u64(&x88, &x89, x87, x26, x79); + fiat_p256_cmovznz_u64(&x90, x74, 0x0, x27); + fiat_p256_cmovznz_u64(&x91, x74, 0x0, x28); + fiat_p256_cmovznz_u64(&x92, x74, 0x0, x29); + fiat_p256_cmovznz_u64(&x93, x74, 0x0, x30); + fiat_p256_addcarryx_u64(&x94, &x95, 0x0, x70, x90); + fiat_p256_addcarryx_u64(&x96, &x97, x95, x71, x91); + fiat_p256_addcarryx_u64(&x98, &x99, x97, x72, x92); + fiat_p256_addcarryx_u64(&x100, &x101, x99, x73, x93); + fiat_p256_subborrowx_u64(&x102, &x103, 0x0, x94, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x104, &x105, x103, x96, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x106, &x107, x105, x98, 0x0); + fiat_p256_subborrowx_u64(&x108, &x109, x107, x100, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x110, &x111, x109, x101, 0x0); + fiat_p256_addcarryx_u64(&x112, &x113, 0x0, x6, 0x1); + x114 = ((x80 >> 1) | ((x82 << 63) & UINT64_C(0xffffffffffffffff))); + x115 = ((x82 >> 1) | ((x84 << 63) & UINT64_C(0xffffffffffffffff))); + x116 = ((x84 >> 1) | ((x86 << 63) & UINT64_C(0xffffffffffffffff))); + x117 = ((x86 >> 1) | ((x88 << 63) & UINT64_C(0xffffffffffffffff))); + x118 = ((x88 & UINT64_C(0x8000000000000000)) | (x88 >> 1)); + fiat_p256_cmovznz_u64(&x119, x48, x39, x31); + fiat_p256_cmovznz_u64(&x120, x48, x41, x33); + fiat_p256_cmovznz_u64(&x121, x48, x43, x35); + fiat_p256_cmovznz_u64(&x122, x48, x45, x37); + fiat_p256_cmovznz_u64(&x123, x111, x102, x94); + fiat_p256_cmovznz_u64(&x124, x111, x104, x96); + fiat_p256_cmovznz_u64(&x125, x111, x106, x98); + fiat_p256_cmovznz_u64(&x126, x111, x108, x100); + *out1 = x112; + out2[0] = x7; + out2[1] = x8; + out2[2] = x9; + out2[3] = x10; + out2[4] = x11; + out3[0] = x114; + out3[1] = x115; + out3[2] = x116; + out3[3] = x117; + out3[4] = x118; + out4[0] = x119; + out4[1] = x120; + out4[2] = x121; + out4[3] = x122; + out5[0] = x123; + out5[1] = x124; + out5[2] = x125; + out5[3] = x126; +} + +/* + * The function fiat_p256_divstep_precomp returns the precomputed value for Bernstein-Yang-inversion (in montgomery form). + * + * Postconditions: + * eval (from_montgomery out1) = ⌊(m - 1) / 2⌋^(if ⌊log2 m⌋ + 1 < 46 then ⌊(49 * (⌊log2 m⌋ + 1) + 80) / 17⌋ else ⌊(49 * (⌊log2 m⌋ + 1) + 57) / 17⌋) + * 0 ≤ eval out1 < m + * + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_divstep_precomp(uint64_t out1[4]) { + out1[0] = UINT64_C(0x67ffffffb8000000); + out1[1] = UINT64_C(0xc000000038000000); + out1[2] = UINT64_C(0xd80000007fffffff); + out1[3] = UINT64_C(0x2fffffffffffffff); +} diff --git a/Sources/_CryptoExtras/RSA/RSA_boring.swift b/Sources/_CryptoExtras/RSA/RSA_boring.swift index 129d34b3..3f6c0000 100644 --- a/Sources/_CryptoExtras/RSA/RSA_boring.swift +++ b/Sources/_CryptoExtras/RSA/RSA_boring.swift @@ -109,9 +109,9 @@ extension BoringSSLRSAPublicKey { extension BoringSSLRSAPublicKey { fileprivate final class Backing { - private let pointer: UnsafeMutablePointer + private let pointer: OpaquePointer - fileprivate init(takingOwnershipOf pointer: UnsafeMutablePointer) { + fileprivate init(takingOwnershipOf pointer: OpaquePointer) { self.pointer = pointer } @@ -277,7 +277,7 @@ extension BoringSSLRSAPublicKey { extension BoringSSLRSAPrivateKey { fileprivate final class Backing { - private let pointer: UnsafeMutablePointer + private let pointer: OpaquePointer fileprivate init(copying other: Backing) { self.pointer = CCryptoBoringSSL_RSAPrivateKey_dup(other.pointer) @@ -316,7 +316,7 @@ extension BoringSSLRSAPrivateKey { } } - private static func pkcs8DERPrivateKey(_ derRepresentation: Bytes) -> UnsafeMutablePointer? { + private static func pkcs8DERPrivateKey(_ derRepresentation: Bytes) -> OpaquePointer? { return derRepresentation.withUnsafeBytes { derPtr in return BIOHelper.withReadOnlyMemoryBIO(wrapping: derPtr) { bio in guard let p8 = CCryptoBoringSSL_d2i_PKCS8_PRIV_KEY_INFO_bio(bio, nil) else { @@ -337,7 +337,7 @@ extension BoringSSLRSAPrivateKey { } } - private static func pkcs1DERPrivateKey(_ derRepresentation: Bytes) -> UnsafeMutablePointer? { + private static func pkcs1DERPrivateKey(_ derRepresentation: Bytes) -> OpaquePointer? { return derRepresentation.withUnsafeBytes { derPtr in return BIOHelper.withReadOnlyMemoryBIO(wrapping: derPtr) { bio in return CCryptoBoringSSL_d2i_RSAPrivateKey_bio(bio, nil) diff --git a/scripts/vendor-boringssl.sh b/scripts/vendor-boringssl.sh index 3cd517a3..78a4e0fd 100755 --- a/scripts/vendor-boringssl.sh +++ b/scripts/vendor-boringssl.sh @@ -44,8 +44,6 @@ HERE=$(pwd) DSTROOT=Sources/CCryptoBoringSSL TMPDIR=$(mktemp -d /tmp/.workingXXXXXX) SRCROOT="${TMPDIR}/src/boringssl.googlesource.com/boringssl" -CROSS_COMPILE_TARGET_LOCATION="/Library/Developer/Destinations" -CROSS_COMPILE_VERSION="5.6.1" # This function namespaces the awkward inline functions declared in OpenSSL # and BoringSSL. @@ -103,13 +101,10 @@ function mangle_symbols { ) # Now cross compile for our targets. - # If you have trouble with the script around this point, consider - # https://github.com/CSCIX65G/SwiftCrossCompilers to obtain cross - # compilers for the architectures we care about. - for cc_target in "${CROSS_COMPILE_TARGET_LOCATION}"/*"${CROSS_COMPILE_VERSION}"*.json; do - echo "Cross compiling for ${cc_target}" - swift build --product CCryptoBoringSSL --destination "${cc_target}" --enable-test-discovery - done; + docker run -t -i --rm --privileged -v$(pwd):/src -w/src --platform linux/arm64 swift:5.8-jammy \ + swift build --product CCryptoBoringSSL + docker run -t -i --rm --privileged -v$(pwd):/src -w/src --platform linux/amd64 swift:5.8-jammy \ + swift build --product CCryptoBoringSSL # Now we need to generate symbol mangles for Linux. We can do this in # one go for all of them. @@ -204,6 +199,7 @@ PATTERNS=( 'crypto/*/*/*.S' 'crypto/*/*/*/*.c' 'third_party/fiat/*.h' +'third_party/fiat/asm/*.S' #'third_party/fiat/*.c' )