Skip to content

Commit 4518e5e

Browse files
authored
Fix windows build and update BoringSSL to 2587c4974dbe9872451151c8e975f58567a1ce0d (#279)
* Update vendoring script * Update BoringSSL to 2587c4974dbe9872451151c8e975f58567a1ce0d
1 parent 4324b40 commit 4518e5e

File tree

7 files changed

+32
-13
lines changed

7 files changed

+32
-13
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// Sources/CCryptoBoringSSL directory. The source repository is at
2121
// https://boringssl.googlesource.com/boringssl.
2222
//
23-
// BoringSSL Commit: 76968bb3d53982560bcf08bcd0ba3e1865fe15cd
23+
// BoringSSL Commit: 2587c4974dbe9872451151c8e975f58567a1ce0d
2424

2525
import PackageDescription
2626

Sources/CCryptoBoringSSL/crypto/bio/connect.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,11 @@ static long conn_callback_ctrl(BIO *bio, int cmd, bio_info_cb fp) {
487487
// convention.
488488
OPENSSL_MSVC_PRAGMA(warning(push))
489489
OPENSSL_MSVC_PRAGMA(warning(disable : 4191))
490+
OPENSSL_CLANG_PRAGMA("clang diagnostic push")
491+
OPENSSL_CLANG_PRAGMA("clang diagnostic ignored \"-Wunknown-warning-option\"")
492+
OPENSSL_CLANG_PRAGMA("clang diagnostic ignored \"-Wcast-function-type\"")
490493
data->info_callback = (int (*)(const struct bio_st *, int, int))fp;
494+
OPENSSL_CLANG_PRAGMA("clang diagnostic pop")
491495
OPENSSL_MSVC_PRAGMA(warning(pop))
492496
break;
493497
default:

Sources/CCryptoBoringSSL/crypto/poly1305/poly1305_vec.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131

3232
typedef __m128i xmmi;
3333

34-
static const alignas(16) uint32_t poly1305_x64_sse2_message_mask[4] = {
34+
alignas(16) static const uint32_t poly1305_x64_sse2_message_mask[4] = {
3535
(1 << 26) - 1, 0, (1 << 26) - 1, 0};
36-
static const alignas(16) uint32_t poly1305_x64_sse2_5[4] = {5, 0, 5, 0};
37-
static const alignas(16) uint32_t poly1305_x64_sse2_1shl128[4] = {
38-
(1 << 24), 0, (1 << 24), 0};
36+
alignas(16) static const uint32_t poly1305_x64_sse2_5[4] = {5, 0, 5, 0};
37+
alignas(16) static const uint32_t poly1305_x64_sse2_1shl128[4] = {(1 << 24), 0,
38+
(1 << 24), 0};
3939

4040
static inline uint128_t add128(uint128_t a, uint128_t b) { return a + b; }
4141

@@ -136,7 +136,8 @@ void CRYPTO_poly1305_init(poly1305_state *state, const uint8_t key[32]) {
136136

137137
static void poly1305_first_block(poly1305_state_internal *st,
138138
const uint8_t *m) {
139-
const xmmi MMASK = _mm_load_si128((const xmmi *)poly1305_x64_sse2_message_mask);
139+
const xmmi MMASK =
140+
_mm_load_si128((const xmmi *)poly1305_x64_sse2_message_mask);
140141
const xmmi FIVE = _mm_load_si128((const xmmi *)poly1305_x64_sse2_5);
141142
const xmmi HIBIT = _mm_load_si128((const xmmi *)poly1305_x64_sse2_1shl128);
142143
xmmi T5, T6;
@@ -181,7 +182,7 @@ static void poly1305_first_block(poly1305_state_internal *st,
181182
r20 = r20 & 0xfffffffffff;
182183
r21 += c;
183184

184-
p->R20.v = _mm_shuffle_epi32(_mm_cvtsi32_si128((uint32_t)(r20)&0x3ffffff),
185+
p->R20.v = _mm_shuffle_epi32(_mm_cvtsi32_si128((uint32_t)(r20) & 0x3ffffff),
185186
_MM_SHUFFLE(1, 0, 1, 0));
186187
p->R21.v = _mm_shuffle_epi32(
187188
_mm_cvtsi32_si128((uint32_t)((r20 >> 26) | (r21 << 18)) & 0x3ffffff),
@@ -229,7 +230,8 @@ static void poly1305_first_block(poly1305_state_internal *st,
229230

230231
static void poly1305_blocks(poly1305_state_internal *st, const uint8_t *m,
231232
size_t bytes) {
232-
const xmmi MMASK = _mm_load_si128((const xmmi *)poly1305_x64_sse2_message_mask);
233+
const xmmi MMASK =
234+
_mm_load_si128((const xmmi *)poly1305_x64_sse2_message_mask);
233235
const xmmi FIVE = _mm_load_si128((const xmmi *)poly1305_x64_sse2_5);
234236
const xmmi HIBIT = _mm_load_si128((const xmmi *)poly1305_x64_sse2_1shl128);
235237

@@ -419,7 +421,8 @@ static void poly1305_blocks(poly1305_state_internal *st, const uint8_t *m,
419421

420422
static size_t poly1305_combine(poly1305_state_internal *st, const uint8_t *m,
421423
size_t bytes) {
422-
const xmmi MMASK = _mm_load_si128((const xmmi *)poly1305_x64_sse2_message_mask);
424+
const xmmi MMASK =
425+
_mm_load_si128((const xmmi *)poly1305_x64_sse2_message_mask);
423426
const xmmi HIBIT = _mm_load_si128((const xmmi *)poly1305_x64_sse2_1shl128);
424427
const xmmi FIVE = _mm_load_si128((const xmmi *)poly1305_x64_sse2_5);
425428

@@ -547,7 +550,7 @@ static size_t poly1305_combine(poly1305_state_internal *st, const uint8_t *m,
547550
r1 = ((uint64_t)p->R21.d[3] << 32) | (uint64_t)p->R21.d[1];
548551
r2 = ((uint64_t)p->R22.d[3] << 32) | (uint64_t)p->R22.d[1];
549552

550-
p->R20.d[2] = (uint32_t)(r0)&0x3ffffff;
553+
p->R20.d[2] = (uint32_t)(r0) & 0x3ffffff;
551554
p->R21.d[2] = (uint32_t)((r0 >> 26) | (r1 << 18)) & 0x3ffffff;
552555
p->R22.d[2] = (uint32_t)((r1 >> 8)) & 0x3ffffff;
553556
p->R23.d[2] = (uint32_t)((r1 >> 34) | (r2 << 10)) & 0x3ffffff;
@@ -838,7 +841,7 @@ void CRYPTO_poly1305_finish(poly1305_state *state, uint8_t mac[16]) {
838841
c = (h1 >> 44);
839842
h1 &= 0xfffffffffff;
840843
t1 = (t1 >> 24);
841-
h2 += (t1)+c;
844+
h2 += (t1) + c;
842845

843846
CRYPTO_store_u64_le(mac + 0, ((h0) | (h1 << 44)));
844847
CRYPTO_store_u64_le(mac + 8, ((h1 >> 20) | (h2 << 24)));

Sources/CCryptoBoringSSL/hash.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 76968bb3d53982560bcf08bcd0ba3e1865fe15cd
1+
This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 2587c4974dbe9872451151c8e975f58567a1ce0d

Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_base.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
#define OPENSSL_HEADER_BASE_H
5555

5656
#define BORINGSSL_PREFIX CCryptoBoringSSL
57+
#if defined(_WIN32) && (defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86))
58+
#define OPENSSL_NO_ASM
59+
#endif
5760

5861

5962
// This file should be the first included by all BoringSSL headers.

Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_evp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ OPENSSL_EXPORT int PKCS5_PBKDF2_HMAC_SHA1(const char *password,
495495
// as described below.
496496
//
497497
// |N|, |r|, and |p| are as described in RFC 7914 section 6. They determine the
498-
// cost of the operation. If |max_mem| is zero, a defult limit of 32MiB will be
498+
// cost of the operation. If |max_mem| is zero, a default limit of 32MiB will be
499499
// used.
500500
//
501501
// The parameters are considered invalid under any of the following conditions:

scripts/vendor-boringssl.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,15 @@ echo "REMOVING libssl"
241241
rm -rf "ssl"
242242
)
243243

244+
echo "DISABLING assembly on x86 Windows"
245+
(
246+
# x86 Windows builds require nasm for acceleration. SwiftPM can't do that right now,
247+
# so we disable the assembly.
248+
cd "$DSTROOT"
249+
gsed -i "/#define OPENSSL_HEADER_BASE_H/a#if defined(_WIN32) && (defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86))\n#define OPENSSL_NO_ASM\n#endif" "include/openssl/base.h"
250+
251+
)
252+
244253
mangle_symbols
245254

246255
echo "RENAMING header files"

0 commit comments

Comments
 (0)