From bd235c580bd4e76beeefdefd86b86e08bd267d49 Mon Sep 17 00:00:00 2001 From: Cory Benfield Date: Thu, 10 Oct 2019 13:36:50 +0100 Subject: [PATCH] Update BoringSSL to 4ca15d5dcbe6e8051a4654df7c971ea8307abfe0 (#142) --- Package.swift | 2 +- .../crypto/chacha/chacha-armv4.linux.arm.S | 1 + .../chacha/chacha-armv8.linux.aarch64.S | 1 + .../crypto/chacha/chacha-x86.linux.x86.S | 1 + .../chacha/chacha-x86_64.linux.x86_64.S | 1 + .../aes128gcmsiv-x86_64.linux.x86_64.S | 1 + .../chacha20_poly1305_x86_64.linux.x86_64.S | 1 + .../crypto/curve25519/asm/x25519-asm-arm.S | 4 + .../crypto/fipsmodule/aes-586.linux.x86.S | 1 + .../crypto/fipsmodule/aes-armv4.linux.arm.S | 1 + .../fipsmodule/aes-x86_64.linux.x86_64.S | 1 + .../aesni-gcm-x86_64.linux.x86_64.S | 1 + .../crypto/fipsmodule/aesni-x86.linux.x86.S | 1 + .../fipsmodule/aesni-x86_64.linux.x86_64.S | 1 + .../fipsmodule/aesv8-armx32.linux.arm.S | 1 + .../fipsmodule/aesv8-armx64.linux.aarch64.S | 1 + .../crypto/fipsmodule/armv4-mont.linux.arm.S | 1 + .../fipsmodule/armv8-mont.linux.aarch64.S | 1 + .../crypto/fipsmodule/bn-586.linux.x86.S | 1 + .../crypto/fipsmodule/bsaes-armv7.linux.arm.S | 1 + .../crypto/fipsmodule/co-586.linux.x86.S | 1 + .../crypto/fipsmodule/ghash-armv4.linux.arm.S | 1 + .../ghash-neon-armv8.linux.aarch64.S | 1 + .../fipsmodule/ghash-ssse3-x86.linux.x86.S | 1 + .../ghash-ssse3-x86_64.linux.x86_64.S | 1 + .../crypto/fipsmodule/ghash-x86.linux.x86.S | 1 + .../fipsmodule/ghash-x86_64.linux.x86_64.S | 1 + .../fipsmodule/ghashv8-armx32.linux.arm.S | 1 + .../fipsmodule/ghashv8-armx64.linux.aarch64.S | 1 + .../crypto/fipsmodule/md5-586.linux.x86.S | 1 + .../fipsmodule/md5-x86_64.linux.x86_64.S | 1 + .../fipsmodule/p256-x86_64-asm.linux.x86_64.S | 1 + .../p256_beeu-x86_64-asm.linux.x86_64.S | 1 + .../crypto/fipsmodule/rand/internal.h | 5 + .../crypto/fipsmodule/rand/rand.c | 14 +-- .../crypto/fipsmodule/rand/urandom.c | 63 ++++++++++- .../fipsmodule/rdrand-x86_64.linux.x86_64.S | 1 + .../fipsmodule/rsaz-avx2.linux.x86_64.S | 1 + .../crypto/fipsmodule/sha1-586.linux.x86.S | 1 + .../fipsmodule/sha1-armv4-large.linux.arm.S | 1 + .../fipsmodule/sha1-armv8.linux.aarch64.S | 1 + .../fipsmodule/sha1-x86_64.linux.x86_64.S | 1 + .../crypto/fipsmodule/sha256-586.linux.x86.S | 1 + .../fipsmodule/sha256-armv4.linux.arm.S | 1 + .../fipsmodule/sha256-armv8.linux.aarch64.S | 1 + .../fipsmodule/sha256-x86_64.linux.x86_64.S | 1 + .../crypto/fipsmodule/sha512-586.linux.x86.S | 1 + .../fipsmodule/sha512-armv4.linux.arm.S | 1 + .../fipsmodule/sha512-armv8.linux.aarch64.S | 1 + .../fipsmodule/sha512-x86_64.linux.x86_64.S | 1 + .../crypto/fipsmodule/vpaes-armv7.linux.arm.S | 1 + .../fipsmodule/vpaes-armv8.linux.aarch64.S | 1 + .../crypto/fipsmodule/vpaes-x86.linux.x86.S | 1 + .../fipsmodule/vpaes-x86_64.linux.x86_64.S | 1 + .../crypto/fipsmodule/x86-mont.linux.x86.S | 1 + .../fipsmodule/x86_64-mont.linux.x86_64.S | 1 + .../fipsmodule/x86_64-mont5.linux.x86_64.S | 1 + .../crypto/hrss/asm/poly_rq_mul.S | 4 + .../crypto/poly1305/poly1305_arm_asm.S | 4 + .../sike/asm/fp-armv8.linux.aarch64.S | 1 + .../sike/asm/fp-x86_64.linux.x86_64.S | 1 + Sources/CNIOBoringSSL/hash.txt | 2 +- .../CNIOBoringSSL_boringssl_prefix_symbols.h | 23 ---- .../CNIOBoringSSL/include/CNIOBoringSSL_ssl.h | 28 ++++- Sources/CNIOBoringSSL/ssl/internal.h | 99 ++++++++++++++++- Sources/CNIOBoringSSL/ssl/s3_lib.cc | 3 +- Sources/CNIOBoringSSL/ssl/ssl_lib.cc | 100 ++++++++++-------- Sources/CNIOBoringSSL/ssl/t1_lib.cc | 20 ++-- Sources/CNIOBoringSSL/ssl/tls13_both.cc | 12 +-- Sources/CNIOBoringSSL/ssl/tls13_server.cc | 2 +- 70 files changed, 329 insertions(+), 110 deletions(-) diff --git a/Package.swift b/Package.swift index b625ca3a..f6a143a1 100644 --- a/Package.swift +++ b/Package.swift @@ -22,7 +22,7 @@ import PackageDescription // Sources/CNIOBoringSSL directory. The source repository is at // https://boringssl.googlesource.com/boringssl. // -// BoringSSL Commit: 6e7255c17e1a7348a2377fbc804441dd284806e2 +// BoringSSL Commit: 4ca15d5dcbe6e8051a4654df7c971ea8307abfe0 let package = Package( name: "swift-nio-ssl", diff --git a/Sources/CNIOBoringSSL/crypto/chacha/chacha-armv4.linux.arm.S b/Sources/CNIOBoringSSL/crypto/chacha/chacha-armv4.linux.arm.S index 0ea2f2df..b0bb2ba9 100644 --- a/Sources/CNIOBoringSSL/crypto/chacha/chacha-armv4.linux.arm.S +++ b/Sources/CNIOBoringSSL/crypto/chacha/chacha-armv4.linux.arm.S @@ -1490,6 +1490,7 @@ ChaCha20_neon: .size ChaCha20_neon,.-ChaCha20_neon .comm OPENSSL_armcap_P,4,4 #endif +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__arm__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/chacha/chacha-armv8.linux.aarch64.S b/Sources/CNIOBoringSSL/crypto/chacha/chacha-armv8.linux.aarch64.S index 06a671ff..2f8867c4 100644 --- a/Sources/CNIOBoringSSL/crypto/chacha/chacha-armv8.linux.aarch64.S +++ b/Sources/CNIOBoringSSL/crypto/chacha/chacha-armv8.linux.aarch64.S @@ -1982,6 +1982,7 @@ ChaCha20_512_neon: ldp x29,x30,[sp],#96 ret .size ChaCha20_512_neon,.-ChaCha20_512_neon +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__aarch64__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/chacha/chacha-x86.linux.x86.S b/Sources/CNIOBoringSSL/crypto/chacha/chacha-x86.linux.x86.S index dcffd50e..db3ec462 100644 --- a/Sources/CNIOBoringSSL/crypto/chacha/chacha-x86.linux.x86.S +++ b/Sources/CNIOBoringSSL/crypto/chacha/chacha-x86.linux.x86.S @@ -973,6 +973,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 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/chacha/chacha-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/chacha/chacha-x86_64.linux.x86_64.S index 580bba11..469749d1 100644 --- a/Sources/CNIOBoringSSL/crypto/chacha/chacha-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/chacha/chacha-x86_64.linux.x86_64.S @@ -1631,6 +1631,7 @@ ChaCha20_8x: .byte 0xf3,0xc3 .cfi_endproc .size ChaCha20_8x,.-ChaCha20_8x +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/cipher_extra/aes128gcmsiv-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/cipher_extra/aes128gcmsiv-x86_64.linux.x86_64.S index 210c5ba4..3d92e9ab 100644 --- a/Sources/CNIOBoringSSL/crypto/cipher_extra/aes128gcmsiv-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/cipher_extra/aes128gcmsiv-x86_64.linux.x86_64.S @@ -3077,6 +3077,7 @@ aes256gcmsiv_kdf: .byte 0xf3,0xc3 .cfi_endproc .size aes256gcmsiv_kdf, .-aes256gcmsiv_kdf +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/cipher_extra/chacha20_poly1305_x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/cipher_extra/chacha20_poly1305_x86_64.linux.x86_64.S index 16b4b6e0..4e90bf72 100644 --- a/Sources/CNIOBoringSSL/crypto/cipher_extra/chacha20_poly1305_x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/cipher_extra/chacha20_poly1305_x86_64.linux.x86_64.S @@ -8985,6 +8985,7 @@ seal_avx2_short_tail: vzeroupper jmp seal_sse_tail_16 .cfi_endproc +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/curve25519/asm/x25519-asm-arm.S b/Sources/CNIOBoringSSL/crypto/curve25519/asm/x25519-asm-arm.S index f7cfa89c..9790e82f 100644 --- a/Sources/CNIOBoringSSL/crypto/curve25519/asm/x25519-asm-arm.S +++ b/Sources/CNIOBoringSSL/crypto/curve25519/asm/x25519-asm-arm.S @@ -2131,6 +2131,10 @@ mov sp,r12 vpop {q4,q5,q6,q7} bx lr +#if defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif + #endif /* !OPENSSL_NO_ASM && __arm__ && !__APPLE__ */ #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/aes-586.linux.x86.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/aes-586.linux.x86.S index 8417a873..01b12773 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/aes-586.linux.x86.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/aes-586.linux.x86.S @@ -3261,6 +3261,7 @@ aes_nohw_set_decrypt_key: .byte 65,69,83,32,102,111,114,32,120,56,54,44,32,67,82,89 .byte 80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114 .byte 111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/aes-armv4.linux.arm.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/aes-armv4.linux.arm.S index f3225862..ff89aaae 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/aes-armv4.linux.arm.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/aes-armv4.linux.arm.S @@ -1219,6 +1219,7 @@ _armv4_AES_decrypt: .byte 65,69,83,32,102,111,114,32,65,82,77,118,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 2 .align 2 +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__arm__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/aes-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/aes-x86_64.linux.x86_64.S index 8d8af479..1af1f11a 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/aes-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/aes-x86_64.linux.x86_64.S @@ -2663,6 +2663,7 @@ aes_nohw_cbc_encrypt: .long 0x1b1b1b1b, 0x1b1b1b1b, 0, 0 .byte 65,69,83,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 64 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/aesni-gcm-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/aesni-gcm-x86_64.linux.x86_64.S index 6b05267a..201dca40 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/aesni-gcm-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/aesni-gcm-x86_64.linux.x86_64.S @@ -850,6 +850,7 @@ aesni_gcm_encrypt: .byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 65,69,83,45,78,73,32,71,67,77,32,109,111,100,117,108,101,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 64 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/aesni-x86.linux.x86.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/aesni-x86.linux.x86.S index b3173b0e..59c4f35d 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/aesni-x86.linux.x86.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/aesni-x86.linux.x86.S @@ -2511,6 +2511,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 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/aesni-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/aesni-x86_64.linux.x86_64.S index ce3d1b5c..04f2173b 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/aesni-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/aesni-x86_64.linux.x86_64.S @@ -2504,6 +2504,7 @@ __aesni_set_encrypt_key: .byte 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69,83,45,78,73,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 64 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/aesv8-armx32.linux.arm.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/aesv8-armx32.linux.arm.S index 3b7c706e..dbd8644c 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/aesv8-armx32.linux.arm.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/aesv8-armx32.linux.arm.S @@ -778,6 +778,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 +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__arm__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/aesv8-armx64.linux.aarch64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/aesv8-armx64.linux.aarch64.S index b209c1c8..63ef8ec4 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/aesv8-armx64.linux.aarch64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/aesv8-armx64.linux.aarch64.S @@ -772,6 +772,7 @@ aes_hw_ctr32_encrypt_blocks: ret .size aes_hw_ctr32_encrypt_blocks,.-aes_hw_ctr32_encrypt_blocks #endif +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__aarch64__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/armv4-mont.linux.arm.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/armv4-mont.linux.arm.S index 96f19616..86241ebb 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/armv4-mont.linux.arm.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/armv4-mont.linux.arm.S @@ -974,6 +974,7 @@ bn_mul8x_mont_neon: .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__arm__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/armv8-mont.linux.aarch64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/armv8-mont.linux.aarch64.S index 990a48c2..e99633e3 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/armv8-mont.linux.aarch64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/armv8-mont.linux.aarch64.S @@ -1420,6 +1420,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 +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__aarch64__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/bn-586.linux.x86.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/bn-586.linux.x86.S index 2aa20979..0c77f84c 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/bn-586.linux.x86.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/bn-586.linux.x86.S @@ -1542,6 +1542,7 @@ bn_sub_part_words: popl %ebp ret .size bn_sub_part_words,.-.L_bn_sub_part_words_begin +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/bsaes-armv7.linux.arm.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/bsaes-armv7.linux.arm.S index 0c370814..681126aa 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/bsaes-armv7.linux.arm.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/bsaes-armv7.linux.arm.S @@ -1526,6 +1526,7 @@ bsaes_ctr32_encrypt_blocks: @ out to retain a constant-time implementation. .size bsaes_ctr32_encrypt_blocks,.-bsaes_ctr32_encrypt_blocks #endif +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__arm__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/co-586.linux.x86.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/co-586.linux.x86.S index f190e683..13291235 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/co-586.linux.x86.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/co-586.linux.x86.S @@ -1264,6 +1264,7 @@ bn_sqr_comba4: popl %esi ret .size bn_sqr_comba4,.-.L_bn_sqr_comba4_begin +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-armv4.linux.arm.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-armv4.linux.arm.S index df71148f..f3ccb94d 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-armv4.linux.arm.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-armv4.linux.arm.S @@ -588,6 +588,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 +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__arm__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-neon-armv8.linux.aarch64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-neon-armv8.linux.aarch64.S index ab85fa9b..580d1ae1 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-neon-armv8.linux.aarch64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-neon-armv8.linux.aarch64.S @@ -338,6 +338,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 +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__aarch64__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-ssse3-x86.linux.x86.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-ssse3-x86.linux.x86.S index 386d54fd..79666959 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-ssse3-x86.linux.x86.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-ssse3-x86.linux.x86.S @@ -292,6 +292,7 @@ gcm_ghash_ssse3: .align 16 .Llow4_mask: .long 252645135,252645135,252645135,252645135 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-ssse3-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-ssse3-x86_64.linux.x86_64.S index 3dcca86d..c68ef6ac 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-ssse3-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-ssse3-x86_64.linux.x86_64.S @@ -425,6 +425,7 @@ gcm_ghash_ssse3: .Llow4_mask: .quad 0x0f0f0f0f0f0f0f0f, 0x0f0f0f0f0f0f0f0f +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-x86.linux.x86.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-x86.linux.x86.S index d448059f..4412c6eb 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-x86.linux.x86.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-x86.linux.x86.S @@ -1073,6 +1073,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 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-x86_64.linux.x86_64.S index c538f518..3cd2ca5f 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghash-x86_64.linux.x86_64.S @@ -1870,6 +1870,7 @@ gcm_ghash_avx: .byte 71,72,65,83,72,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 64 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghashv8-armx32.linux.arm.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghashv8-armx32.linux.arm.S index 84e35abc..c799a5f5 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghashv8-armx32.linux.arm.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghashv8-armx32.linux.arm.S @@ -250,6 +250,7 @@ gcm_ghash_v8: .byte 71,72,65,83,72,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 +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__arm__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghashv8-armx64.linux.aarch64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghashv8-armx64.linux.aarch64.S index 55a8a040..b5084d90 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/ghashv8-armx64.linux.aarch64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/ghashv8-armx64.linux.aarch64.S @@ -246,6 +246,7 @@ gcm_ghash_v8: .byte 71,72,65,83,72,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 +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__aarch64__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/md5-586.linux.x86.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/md5-586.linux.x86.S index ec02e420..0fc466e0 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/md5-586.linux.x86.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/md5-586.linux.x86.S @@ -686,6 +686,7 @@ md5_block_asm_data_order: popl %esi ret .size md5_block_asm_data_order,.-.L_md5_block_asm_data_order_begin +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/md5-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/md5-x86_64.linux.x86_64.S index e4e4b047..04700a1d 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/md5-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/md5-x86_64.linux.x86_64.S @@ -700,6 +700,7 @@ md5_block_asm_data_order: .byte 0xf3,0xc3 .cfi_endproc .size md5_block_asm_data_order,.-md5_block_asm_data_order +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/p256-x86_64-asm.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/p256-x86_64-asm.linux.x86_64.S index a996d29a..52e40597 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/p256-x86_64-asm.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/p256-x86_64-asm.linux.x86_64.S @@ -4541,6 +4541,7 @@ ecp_nistz256_point_add_affinex: .byte 0xf3,0xc3 .cfi_endproc .size ecp_nistz256_point_add_affinex,.-ecp_nistz256_point_add_affinex +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/p256_beeu-x86_64-asm.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/p256_beeu-x86_64-asm.linux.x86_64.S index 5eb35260..0881f5a0 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/p256_beeu-x86_64-asm.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/p256_beeu-x86_64-asm.linux.x86_64.S @@ -341,6 +341,7 @@ beeu_mod_inverse_vartime: .cfi_endproc .size beeu_mod_inverse_vartime, .-beeu_mod_inverse_vartime +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/rand/internal.h b/Sources/CNIOBoringSSL/crypto/fipsmodule/rand/internal.h index 29ab87af..9b99a5d6 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/rand/internal.h +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/rand/internal.h @@ -41,6 +41,11 @@ void RAND_bytes_with_additional_data(uint8_t *out, size_t out_len, void CRYPTO_sysrand(uint8_t *buf, size_t len); #if defined(OPENSSL_URANDOM) && defined(BORINGSSL_FIPS) +// CRYPTO_sysrand_for_seed fills |len| bytes at |buf| with entropy from the +// operating system. It may draw from the |GRND_RANDOM| pool on Android, +// depending on the vendor's configuration. +void CRYPTO_sysrand_for_seed(uint8_t *buf, size_t len); + // CRYPTO_sysrand_if_available fills |len| bytes at |buf| with entropy from the // operating system, if the entropy pool is initialized. If it is uninitialized, // it will not block and will instead fill |buf| with all zeros or early diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/rand/rand.c b/Sources/CNIOBoringSSL/crypto/fipsmodule/rand/rand.c index 3574f84a..76b93f2e 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/rand/rand.c +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/rand/rand.c @@ -32,9 +32,9 @@ // It's assumed that the operating system always has an unfailing source of -// entropy which is accessed via |CRYPTO_sysrand|. (If the operating system -// entropy source fails, it's up to |CRYPTO_sysrand| to abort the process—we -// don't try to handle it.) +// entropy which is accessed via |CRYPTO_sysrand[_for_seed]|. (If the operating +// system entropy source fails, it's up to |CRYPTO_sysrand| to abort the +// process—we don't try to handle it.) // // In addition, the hardware may provide a low-latency RNG. Intel's rdrand // instruction is the canonical example of this. When a hardware RNG is @@ -61,11 +61,11 @@ struct rand_thread_state { // (re)seeded. This is bound by |kReseedInterval|. unsigned calls; // last_block_valid is non-zero iff |last_block| contains data from - // |CRYPTO_sysrand|. + // |CRYPTO_sysrand_for_seed|. int last_block_valid; #if defined(BORINGSSL_FIPS) - // last_block contains the previous block from |CRYPTO_sysrand|. + // last_block contains the previous block from |CRYPTO_sysrand_for_seed|. uint8_t last_block[CRNGT_BLOCK_SIZE]; // next and prev form a NULL-terminated, double-linked list of all states in // a process. @@ -169,7 +169,7 @@ static void rand_get_seed(struct rand_thread_state *state, uint8_t seed[CTR_DRBG_ENTROPY_LEN]) { if (!state->last_block_valid) { if (!hwrand(state->last_block, sizeof(state->last_block))) { - CRYPTO_sysrand(state->last_block, sizeof(state->last_block)); + CRYPTO_sysrand_for_seed(state->last_block, sizeof(state->last_block)); } state->last_block_valid = 1; } @@ -181,7 +181,7 @@ static void rand_get_seed(struct rand_thread_state *state, int used_hwrand = hwrand(entropy, sizeof(entropy)); if (!used_hwrand) { - CRYPTO_sysrand(entropy, sizeof(entropy)); + CRYPTO_sysrand_for_seed(entropy, sizeof(entropy)); } // See FIPS 140-2, section 4.9.2. This is the “continuous random number diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/rand/urandom.c b/Sources/CNIOBoringSSL/crypto/fipsmodule/rand/urandom.c index e65cae49..7ee0db3b 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/rand/urandom.c +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/rand/urandom.c @@ -36,6 +36,10 @@ #endif #include +#if defined(OPENSSL_ANDROID) +#include +#endif + #if !defined(OPENSSL_ANDROID) #define OPENSSL_HAS_GETAUXVAL #endif @@ -120,6 +124,9 @@ static ssize_t boringssl_getrandom(void *buf, size_t buf_len, unsigned flags) { #if !defined(GRND_NONBLOCK) #define GRND_NONBLOCK 1 #endif +#if !defined(GRND_RANDOM) +#define GRND_RANDOM 2 +#endif #endif // OPENSSL_LINUX @@ -138,10 +145,36 @@ DEFINE_BSS_GET(int, urandom_fd_requested) DEFINE_BSS_GET(int, urandom_fd) #if defined(USE_NR_getrandom) + // getrandom_ready is one if |getrandom| had been initialized by the time // |init_once| was called and zero otherwise. DEFINE_BSS_GET(int, getrandom_ready) + +// extra_getrandom_flags_for_seed contains a value that is ORed into the flags +// for getrandom() when reading entropy for a seed. +DEFINE_BSS_GET(int, extra_getrandom_flags_for_seed) + +// On Android, check a system property to decide whether to set +// |extra_getrandom_flags_for_seed| otherwise they will default to zero. If +// ro.oem_boringcrypto_hwrand is true then |extra_getrandom_flags_for_seed| will +// be set to GRND_RANDOM, causing all random data to be drawn from the same +// source as /dev/random. +static void maybe_set_extra_getrandom_flags(void) { +#if defined(BORINGSSL_FIPS) && defined(OPENSSL_ANDROID) + char value[PROP_VALUE_MAX + 1]; + int length = __system_property_get("ro.boringcrypto.hwrand", value); + if (length < 0 || length > PROP_VALUE_MAX) { + return; + } + + value[length] = 0; + if (strcasecmp(value, "true") == 0) { + *extra_getrandom_flags_for_seed_bss_get() = GRND_RANDOM; + } #endif +} + +#endif // USE_NR_getrandom DEFINE_STATIC_ONCE(rand_once) @@ -176,6 +209,7 @@ static void init_once(void) { if (have_getrandom) { *urandom_fd_bss_get() = kHaveGetrandom; + maybe_set_extra_getrandom_flags(); return; } #endif // USE_NR_getrandom @@ -346,11 +380,23 @@ void RAND_set_urandom_fd(int fd) { // on success and zero on error. If |block| is one, this function will block // until the entropy pool is initialized. Otherwise, this function may fail, // setting |errno| to |EAGAIN| if the entropy pool has not yet been initialized. -static int fill_with_entropy(uint8_t *out, size_t len, int block) { +// If |seed| is one, this function will OR in the value of +// |*extra_getrandom_flags_for_seed()| when using |getrandom|. +static int fill_with_entropy(uint8_t *out, size_t len, int block, int seed) { if (len == 0) { return 1; } +#if defined(USE_NR_getrandom) + int getrandom_flags = 0; + if (block) { + getrandom_flags |= GRND_NONBLOCK; + } + if (seed) { + getrandom_flags |= *extra_getrandom_flags_for_seed_bss_get(); + } +#endif + CRYPTO_once(rand_once_bss_get(), init_once); if (block) { CRYPTO_once(wait_for_entropy_once_bss_get(), wait_for_entropy); @@ -364,7 +410,7 @@ static int fill_with_entropy(uint8_t *out, size_t len, int block) { if (*urandom_fd_bss_get() == kHaveGetrandom) { #if defined(USE_NR_getrandom) - r = boringssl_getrandom(out, len, block ? 0 : GRND_NONBLOCK); + r = boringssl_getrandom(out, len, getrandom_flags); #elif defined(OPENSSL_MACOS) if (__builtin_available(macos 10.12, *)) { // |getentropy| can only request 256 bytes at a time. @@ -400,7 +446,15 @@ static int fill_with_entropy(uint8_t *out, size_t len, int block) { // CRYPTO_sysrand puts |requested| random bytes into |out|. void CRYPTO_sysrand(uint8_t *out, size_t requested) { - if (!fill_with_entropy(out, requested, /*block=*/1)) { + if (!fill_with_entropy(out, requested, /*block=*/1, /*seed=*/0)) { + perror("entropy fill failed"); + abort(); + } +} + +#if defined(BORINGSSL_FIPS) +void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) { + if (!fill_with_entropy(out, requested, /*block=*/1, /*seed=*/1)) { perror("entropy fill failed"); abort(); } @@ -412,12 +466,11 @@ void CRYPTO_sysrand(uint8_t *out, size_t requested) { #endif } -#if defined(BORINGSSL_FIPS) void CRYPTO_sysrand_if_available(uint8_t *out, size_t requested) { // Return all zeros if |fill_with_entropy| fails. OPENSSL_memset(out, 0, requested); - if (!fill_with_entropy(out, requested, /*block=*/0) && + if (!fill_with_entropy(out, requested, /*block=*/0, /*seed=*/0) && errno != EAGAIN) { perror("opportunistic entropy fill failed"); abort(); diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/rdrand-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/rdrand-x86_64.linux.x86_64.S index 8d8237f6..f1a14d1c 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/rdrand-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/rdrand-x86_64.linux.x86_64.S @@ -61,6 +61,7 @@ CRYPTO_rdrand_multiple8_buf: .byte 0xf3,0xc3 .cfi_endproc .size CRYPTO_rdrand_multiple8_buf,.-CRYPTO_rdrand_multiple8_buf +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/rsaz-avx2.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/rsaz-avx2.linux.x86_64.S index 78e469aa..d70602ad 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/rsaz-avx2.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/rsaz-avx2.linux.x86_64.S @@ -1747,6 +1747,7 @@ rsaz_1024_gather5_avx2: .long 2,2,2,2, 3,3,3,3 .long 4,4,4,4, 4,4,4,4 .align 64 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-586.linux.x86.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-586.linux.x86.S index fe6b96e5..2bfe8d6a 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-586.linux.x86.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-586.linux.x86.S @@ -3806,6 +3806,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 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-armv4-large.linux.arm.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-armv4-large.linux.arm.S index 83ef801c..6dccd4a1 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-armv4-large.linux.arm.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-armv4-large.linux.arm.S @@ -1508,6 +1508,7 @@ sha1_block_data_order_armv8: .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__arm__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-armv8.linux.aarch64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-armv8.linux.aarch64.S index fd4953a6..e1689886 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-armv8.linux.aarch64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-armv8.linux.aarch64.S @@ -1232,6 +1232,7 @@ sha1_block_armv8: .align 2 .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__aarch64__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-x86_64.linux.x86_64.S index c34fb084..5037ba16 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha1-x86_64.linux.x86_64.S @@ -3599,6 +3599,7 @@ K_XX_XX: .byte 0xf,0xe,0xd,0xc,0xb,0xa,0x9,0x8,0x7,0x6,0x5,0x4,0x3,0x2,0x1,0x0 .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,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 64 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-586.linux.x86.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-586.linux.x86.S index 2c7d44e1..755f0013 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-586.linux.x86.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-586.linux.x86.S @@ -5565,6 +5565,7 @@ sha256_block_data_order: popl %ebp ret .size sha256_block_data_order,.-.L_sha256_block_data_order_begin +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-armv4.linux.arm.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-armv4.linux.arm.S index df05c0cf..4dbd7795 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-armv4.linux.arm.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-armv4.linux.arm.S @@ -2836,6 +2836,7 @@ sha256_block_data_order_armv8: .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__arm__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-armv8.linux.aarch64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-armv8.linux.aarch64.S index 0ce6f777..bedfcf34 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-armv8.linux.aarch64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-armv8.linux.aarch64.S @@ -1210,6 +1210,7 @@ sha256_block_armv8: .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__aarch64__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-x86_64.linux.x86_64.S index fd55e248..22ddccf9 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha256-x86_64.linux.x86_64.S @@ -3971,6 +3971,7 @@ sha256_block_data_order_avx: .byte 0xf3,0xc3 .cfi_endproc .size sha256_block_data_order_avx,.-sha256_block_data_order_avx +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-586.linux.x86.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-586.linux.x86.S index a3dd7b3d..5d6ef335 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-586.linux.x86.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-586.linux.x86.S @@ -2835,6 +2835,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 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-armv4.linux.arm.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-armv4.linux.arm.S index 5b85ae47..d6b066f1 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-armv4.linux.arm.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-armv4.linux.arm.S @@ -1891,6 +1891,7 @@ sha512_block_data_order_neon: .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__arm__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-armv8.linux.aarch64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-armv8.linux.aarch64.S index 027c7158..2a0766f0 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-armv8.linux.aarch64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-armv8.linux.aarch64.S @@ -1082,6 +1082,7 @@ sha512_block_data_order: .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P #endif +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__aarch64__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-x86_64.linux.x86_64.S index d58f3687..ece179eb 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/sha512-x86_64.linux.x86_64.S @@ -2990,6 +2990,7 @@ sha512_block_data_order_avx: .byte 0xf3,0xc3 .cfi_endproc .size sha512_block_data_order_avx,.-sha512_block_data_order_avx +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-armv7.linux.arm.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-armv7.linux.arm.S index 7599d7ef..dfb1f38c 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-armv7.linux.arm.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-armv7.linux.arm.S @@ -1233,6 +1233,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 +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__arm__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-armv8.linux.aarch64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-armv8.linux.aarch64.S index 869275fe..d190c14d 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-armv8.linux.aarch64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-armv8.linux.aarch64.S @@ -1213,6 +1213,7 @@ vpaes_ctr32_encrypt_blocks: ldp x29,x30,[sp],#16 ret .size vpaes_ctr32_encrypt_blocks,.-vpaes_ctr32_encrypt_blocks +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__aarch64__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-x86.linux.x86.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-x86.linux.x86.S index d58b51f4..b625f9a8 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-x86.linux.x86.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-x86.linux.x86.S @@ -706,6 +706,7 @@ vpaes_cbc_encrypt: popl %ebp ret .size vpaes_cbc_encrypt,.-.L_vpaes_cbc_encrypt_begin +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-x86_64.linux.x86_64.S index c741009b..0ee27f39 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/vpaes-x86_64.linux.x86_64.S @@ -1131,6 +1131,7 @@ _vpaes_consts: .byte 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105,111,110,32,65,69,83,32,102,111,114,32,120,56,54,95,54,52,47,83,83,83,69,51,44,32,77,105,107,101,32,72,97,109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105,118,101,114,115,105,116,121,41,0 .align 64 .size _vpaes_consts,.-_vpaes_consts +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/x86-mont.linux.x86.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/x86-mont.linux.x86.S index 84b44423..3174f59e 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/x86-mont.linux.x86.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/x86-mont.linux.x86.S @@ -482,6 +482,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 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__i386__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/x86_64-mont.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/x86_64-mont.linux.x86_64.S index 8876bb9d..3cef093b 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/x86_64-mont.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/x86_64-mont.linux.x86_64.S @@ -1258,6 +1258,7 @@ bn_mulx4x_mont: .size bn_mulx4x_mont,.-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 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/fipsmodule/x86_64-mont5.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/fipsmodule/x86_64-mont5.linux.x86_64.S index d86374d4..cf180eb0 100644 --- a/Sources/CNIOBoringSSL/crypto/fipsmodule/x86_64-mont5.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/fipsmodule/x86_64-mont5.linux.x86_64.S @@ -3788,6 +3788,7 @@ bn_gather5: .long 0,0, 1,1 .long 2,2, 2,2 .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 +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/hrss/asm/poly_rq_mul.S b/Sources/CNIOBoringSSL/crypto/hrss/asm/poly_rq_mul.S index 1d4a2dc9..8913e173 100644 --- a/Sources/CNIOBoringSSL/crypto/hrss/asm/poly_rq_mul.S +++ b/Sources/CNIOBoringSSL/crypto/hrss/asm/poly_rq_mul.S @@ -8462,6 +8462,10 @@ ret .cfi_endproc .size poly_Rq_mul,.-poly_Rq_mul +#if defined(__ELF__) +.section .note.GNU-stack,"",@progbits +#endif + #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/poly1305/poly1305_arm_asm.S b/Sources/CNIOBoringSSL/crypto/poly1305/poly1305_arm_asm.S index 9d503236..17ec74aa 100644 --- a/Sources/CNIOBoringSSL/crypto/poly1305/poly1305_arm_asm.S +++ b/Sources/CNIOBoringSSL/crypto/poly1305/poly1305_arm_asm.S @@ -2024,6 +2024,10 @@ vst1.8 d4,[r0,: 64] add sp,sp,#0 bx lr +#if defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif + #endif /* __arm__ && !OPENSSL_NO_ASM && !__APPLE__ */ #endif // defined(__arm__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/crypto/third_party/sike/asm/fp-armv8.linux.aarch64.S b/Sources/CNIOBoringSSL/crypto/third_party/sike/asm/fp-armv8.linux.aarch64.S index 7b0268c4..a9542b78 100644 --- a/Sources/CNIOBoringSSL/crypto/third_party/sike/asm/fp-armv8.linux.aarch64.S +++ b/Sources/CNIOBoringSSL/crypto/third_party/sike/asm/fp-armv8.linux.aarch64.S @@ -996,6 +996,7 @@ sike_mpdblsubx2_asm: ldp x29, x30, [sp],#16 ret +.section .note.GNU-stack,"",%progbits #endif #endif // !OPENSSL_NO_ASM #endif // defined(__aarch64__) && defined(__linux__) diff --git a/Sources/CNIOBoringSSL/crypto/third_party/sike/asm/fp-x86_64.linux.x86_64.S b/Sources/CNIOBoringSSL/crypto/third_party/sike/asm/fp-x86_64.linux.x86_64.S index 06c8700b..36cd37b8 100644 --- a/Sources/CNIOBoringSSL/crypto/third_party/sike/asm/fp-x86_64.linux.x86_64.S +++ b/Sources/CNIOBoringSSL/crypto/third_party/sike/asm/fp-x86_64.linux.x86_64.S @@ -1869,6 +1869,7 @@ sike_mpmul: .cfi_adjust_cfa_offset -8 .byte 0xf3,0xc3 .cfi_endproc +.section .note.GNU-stack,"",@progbits #endif #endif // defined(__x86_64__) && defined(__linux__) #if defined(__linux__) && defined(__ELF__) diff --git a/Sources/CNIOBoringSSL/hash.txt b/Sources/CNIOBoringSSL/hash.txt index a07e920f..90de272b 100644 --- a/Sources/CNIOBoringSSL/hash.txt +++ b/Sources/CNIOBoringSSL/hash.txt @@ -1 +1 @@ -This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 6e7255c17e1a7348a2377fbc804441dd284806e2 +This directory is derived from BoringSSL cloned from https://boringssl.googlesource.com/boringssl at revision 4ca15d5dcbe6e8051a4654df7c971ea8307abfe0 diff --git a/Sources/CNIOBoringSSL/include/CNIOBoringSSL_boringssl_prefix_symbols.h b/Sources/CNIOBoringSSL/include/CNIOBoringSSL_boringssl_prefix_symbols.h index d9ecd766..cb449a3b 100644 --- a/Sources/CNIOBoringSSL/include/CNIOBoringSSL_boringssl_prefix_symbols.h +++ b/Sources/CNIOBoringSSL/include/CNIOBoringSSL_boringssl_prefix_symbols.h @@ -4195,29 +4195,6 @@ #define sk_ASN1_VALUE_is_sorted BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_ASN1_VALUE_is_sorted) #define sk_ASN1_VALUE_set_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_ASN1_VALUE_set_cmp_func) #define sk_ASN1_VALUE_deep_copy BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_ASN1_VALUE_deep_copy) -#define sk_CertCompressionAlg_call_free_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_call_free_func) -#define sk_CertCompressionAlg_call_copy_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_call_copy_func) -#define sk_CertCompressionAlg_call_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_call_cmp_func) -#define sk_CertCompressionAlg_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_new) -#define sk_CertCompressionAlg_new_null BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_new_null) -#define sk_CertCompressionAlg_num BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_num) -#define sk_CertCompressionAlg_zero BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_zero) -#define sk_CertCompressionAlg_value BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_value) -#define sk_CertCompressionAlg_set BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_set) -#define sk_CertCompressionAlg_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_free) -#define sk_CertCompressionAlg_pop_free BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_pop_free) -#define sk_CertCompressionAlg_insert BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_insert) -#define sk_CertCompressionAlg_delete BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_delete) -#define sk_CertCompressionAlg_delete_ptr BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_delete_ptr) -#define sk_CertCompressionAlg_find BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_find) -#define sk_CertCompressionAlg_shift BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_shift) -#define sk_CertCompressionAlg_push BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_push) -#define sk_CertCompressionAlg_pop BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_pop) -#define sk_CertCompressionAlg_dup BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_dup) -#define sk_CertCompressionAlg_sort BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_sort) -#define sk_CertCompressionAlg_is_sorted BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_is_sorted) -#define sk_CertCompressionAlg_set_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_set_cmp_func) -#define sk_CertCompressionAlg_deep_copy BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, sk_CertCompressionAlg_deep_copy) #define lh_ASN1_OBJECT_call_cmp_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, lh_ASN1_OBJECT_call_cmp_func) #define lh_ASN1_OBJECT_call_hash_func BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, lh_ASN1_OBJECT_call_hash_func) #define lh_ASN1_OBJECT_new BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, lh_ASN1_OBJECT_new) diff --git a/Sources/CNIOBoringSSL/include/CNIOBoringSSL_ssl.h b/Sources/CNIOBoringSSL/include/CNIOBoringSSL_ssl.h index 6d5538f2..026bfe31 100644 --- a/Sources/CNIOBoringSSL/include/CNIOBoringSSL_ssl.h +++ b/Sources/CNIOBoringSSL/include/CNIOBoringSSL_ssl.h @@ -560,6 +560,13 @@ OPENSSL_EXPORT int SSL_get_error(const SSL *ssl, int ret_code); #define SSL_ERROR_HANDOFF 17 #define SSL_ERROR_HANDBACK 18 +// SSL_ERROR_WANT_RENEGOTIATE indicates the operation is pending a response to +// a renegotiation request from the server. The caller may call +// |SSL_renegotiate| to schedule a renegotiation and retry the operation. +// +// See also |ssl_renegotiate_explicit|. +#define SSL_ERROR_WANT_RENEGOTIATE 19 + // SSL_error_description returns a string representation of |err|, where |err| // is one of the |SSL_ERROR_*| constants returned by |SSL_get_error|, or NULL // if the value is unrecognized. @@ -3605,6 +3612,7 @@ enum ssl_renegotiate_mode_t BORINGSSL_ENUM_INT { ssl_renegotiate_once, ssl_renegotiate_freely, ssl_renegotiate_ignore, + ssl_renegotiate_explicit, }; // SSL_set_renegotiate_mode configures how |ssl|, a client, reacts to @@ -3618,6 +3626,13 @@ enum ssl_renegotiate_mode_t BORINGSSL_ENUM_INT { // Note that ignoring HelloRequest messages may cause the connection to stall // if the server waits for the renegotiation to complete. // +// If set to |ssl_renegotiate_explicit|, |SSL_read| and |SSL_peek| calls which +// encounter a HelloRequest will pause with |SSL_ERROR_WANT_RENEGOTIATE|. +// |SSL_write| will continue to work while paused. The caller may call +// |SSL_renegotiate| to begin the renegotiation at a later point. This mode may +// be used if callers wish to eagerly call |SSL_peek| without triggering a +// renegotiation. +// // If configuration shedding is enabled (see |SSL_set_shed_handshake_config|), // configuration is released if, at any point after the handshake, renegotiation // is disabled. It is not possible to switch from disabling renegotiation to @@ -3630,6 +3645,16 @@ enum ssl_renegotiate_mode_t BORINGSSL_ENUM_INT { OPENSSL_EXPORT void SSL_set_renegotiate_mode(SSL *ssl, enum ssl_renegotiate_mode_t mode); +// SSL_renegotiate starts a deferred renegotiation on |ssl| if it was configured +// with |ssl_renegotiate_explicit| and has a pending HelloRequest. It returns +// one on success and zero on error. +// +// This function does not do perform any I/O. On success, a subsequent +// |SSL_do_handshake| call will run the handshake. |SSL_write| and +// |SSL_read| will also complete the handshake before sending or receiving +// application data. +OPENSSL_EXPORT int SSL_renegotiate(SSL *ssl); + // SSL_renegotiate_pending returns one if |ssl| is in the middle of a // renegotiation. OPENSSL_EXPORT int SSL_renegotiate_pending(SSL *ssl); @@ -4081,9 +4106,6 @@ OPENSSL_EXPORT int SSL_get_read_ahead(const SSL *ssl); // SSL_set_read_ahead returns one. OPENSSL_EXPORT int SSL_set_read_ahead(SSL *ssl, int yes); -// SSL_renegotiate put an error on the error queue and returns zero. -OPENSSL_EXPORT int SSL_renegotiate(SSL *ssl); - // SSL_set_state does nothing. OPENSSL_EXPORT void SSL_set_state(SSL *ssl, int state); diff --git a/Sources/CNIOBoringSSL/ssl/internal.h b/Sources/CNIOBoringSSL/ssl/internal.h index 2cc2cfef..41a1a255 100644 --- a/Sources/CNIOBoringSSL/ssl/internal.h +++ b/Sources/CNIOBoringSSL/ssl/internal.h @@ -353,6 +353,97 @@ class Array { size_t size_ = 0; }; +// GrowableArray is an array that owns elements of |T|, backed by an +// Array. When necessary, pushing will automatically trigger a resize. +// +// Note, for simplicity, this class currently differs from |std::vector| in that +// |T| must be efficiently default-constructible. Allocated elements beyond the +// end of the array are constructed and destructed. +template +class GrowableArray { + public: + GrowableArray() = default; + GrowableArray(const GrowableArray &) = delete; + GrowableArray(GrowableArray &&other) { *this = std::move(other); } + ~GrowableArray() {} + + GrowableArray &operator=(const GrowableArray &) = delete; + GrowableArray &operator=(GrowableArray &&other) { + size_ = other.size_; + other.size_ = 0; + array_ = std::move(other.array_); + return *this; + } + + size_t size() const { return size_; } + bool empty() const { return size_ == 0; } + + const T &operator[](size_t i) const { return array_[i]; } + T &operator[](size_t i) { return array_[i]; } + + T *begin() { return array_.data(); } + const T *cbegin() const { return array_.data(); } + T *end() { return array_.data() + size_; } + const T *cend() const { return array_.data() + size_; } + + // Push adds |elem| at the end of the internal array, growing if necessary. It + // returns false when allocation fails. + bool Push(T elem) { + if (!MaybeGrow()) { + return false; + } + array_[size_] = std::move(elem); + size_++; + return true; + } + + // CopyFrom replaces the contents of the array with a copy of |in|. It returns + // true on success and false on allocation error. + bool CopyFrom(Span in) { + if (!array_.CopyFrom(in)) { + return false; + } + size_ = in.size(); + return true; + } + + private: + // If there is no room for one more element, creates a new backing array with + // double the size of the old one and copies elements over. + bool MaybeGrow() { + if (array_.size() == 0) { + return array_.Init(kDefaultSize); + } + // No need to grow if we have room for one more T. + if (size_ < array_.size()) { + return true; + } + // Double the array's size if it's safe to do so. + if (array_.size() > std::numeric_limits::max() / 2) { + OPENSSL_PUT_ERROR(SSL, ERR_R_OVERFLOW); + return false; + } + Array new_array; + if (!new_array.Init(array_.size() * 2)) { + return false; + } + for (size_t i = 0; i < array_.size(); i++) { + new_array[i] = std::move(array_[i]); + } + array_ = std::move(new_array); + + return true; + } + + // |size_| is the number of elements stored in this GrowableArray. + size_t size_ = 0; + // |array_| is the backing array. Note that |array_.size()| is this + // GrowableArray's current capacity and that |size_ <= array_.size()|. + Array array_; + // |kDefaultSize| is the default initial size of the backing array. + static constexpr size_t kDefaultSize = 16; +}; + // CBBFinishArray behaves like |CBB_finish| but stores the result in an Array. OPENSSL_EXPORT bool CBBFinishArray(CBB *cbb, Array *out); @@ -2155,8 +2246,6 @@ BSSL_NAMESPACE_END DEFINE_LHASH_OF(SSL_SESSION) -DEFINE_NAMED_STACK_OF(CertCompressionAlg, bssl::CertCompressionAlg) - BSSL_NAMESPACE_BEGIN // An ssl_shutdown_t describes the shutdown state of one end of the connection, @@ -2294,6 +2383,10 @@ struct SSL3_STATE { // alert_dispatch is true there is an alert in |send_alert| to be sent. bool alert_dispatch : 1; + // renegotiate_pending is whether the read half of the channel is blocked on a + // HelloRequest. + bool renegotiate_pending : 1; + // hs_buf is the buffer of handshake data to process. UniquePtr hs_buf; @@ -3137,7 +3230,7 @@ struct ssl_ctx_st { bssl::UniquePtr srtp_profiles; // Defined compression algorithms for certificates. - bssl::UniquePtr cert_compression_algs; + bssl::GrowableArray cert_compression_algs; // Supported group values inherited by SSL structure bssl::Array supported_group_list; diff --git a/Sources/CNIOBoringSSL/ssl/s3_lib.cc b/Sources/CNIOBoringSSL/ssl/s3_lib.cc index 919f6d71..66faf495 100644 --- a/Sources/CNIOBoringSSL/ssl/s3_lib.cc +++ b/Sources/CNIOBoringSSL/ssl/s3_lib.cc @@ -181,7 +181,8 @@ SSL3_STATE::SSL3_STATE() tls13_downgrade(false), token_binding_negotiated(false), pq_experiment_signal_seen(false), - alert_dispatch(false) {} + alert_dispatch(false), + renegotiate_pending(false) {} SSL3_STATE::~SSL3_STATE() {} diff --git a/Sources/CNIOBoringSSL/ssl/ssl_lib.cc b/Sources/CNIOBoringSSL/ssl/ssl_lib.cc index 583ba3f2..bd680ad4 100644 --- a/Sources/CNIOBoringSSL/ssl/ssl_lib.cc +++ b/Sources/CNIOBoringSSL/ssl/ssl_lib.cc @@ -478,6 +478,7 @@ static bool ssl_can_renegotiate(const SSL *ssl) { return false; case ssl_renegotiate_freely: + case ssl_renegotiate_explicit: return true; case ssl_renegotiate_once: return ssl->s3->total_renegotiations == 0; @@ -945,29 +946,16 @@ static int ssl_do_post_handshake(SSL *ssl, const SSLMessage &msg) { return 1; // Ignore the HelloRequest. } - if (!ssl_can_renegotiate(ssl) || - // Renegotiation is only supported at quiescent points in the application - // protocol, namely in HTTPS, just before reading the HTTP response. - // Require the record-layer be idle and avoid complexities of sending a - // handshake record while an application_data record is being written. - !ssl->s3->write_buffer.empty() || - ssl->s3->write_shutdown != ssl_shutdown_none) { - OPENSSL_PUT_ERROR(SSL, SSL_R_NO_RENEGOTIATION); + ssl->s3->renegotiate_pending = true; + if (ssl->renegotiate_mode == ssl_renegotiate_explicit) { + return 1; // Handle it later. + } + + if (!SSL_renegotiate(ssl)) { ssl_send_alert(ssl, SSL3_AL_FATAL, SSL_AD_NO_RENEGOTIATION); return 0; } - // Begin a new handshake. - if (ssl->s3->hs != nullptr) { - OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR); - return 0; - } - ssl->s3->hs = ssl_handshake_new(ssl); - if (ssl->s3->hs == nullptr) { - return 0; - } - - ssl->s3->total_renegotiations++; return 1; } @@ -1012,6 +1000,11 @@ static int ssl_read_impl(SSL *ssl) { } while (ssl->s3->pending_app_data.empty()) { + if (ssl->s3->renegotiate_pending) { + ssl->s3->rwstate = SSL_ERROR_WANT_RENEGOTIATE; + return -1; + } + // Complete the current handshake, if any. False Start will cause // |SSL_do_handshake| to return mid-handshake, so this may require multiple // iterations. @@ -1353,6 +1346,7 @@ int SSL_get_error(const SSL *ssl, int ret_code) { case SSL_ERROR_PENDING_TICKET: case SSL_ERROR_EARLY_DATA_REJECTED: case SSL_ERROR_WANT_CERTIFICATE_VERIFY: + case SSL_ERROR_WANT_RENEGOTIATE: return ssl->s3->rwstate; case SSL_ERROR_WANT_READ: { @@ -1743,8 +1737,39 @@ long SSL_get_default_timeout(const SSL *ssl) { int SSL_renegotiate(SSL *ssl) { // Caller-initiated renegotiation is not supported. - OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); - return 0; + if (!ssl->s3->renegotiate_pending) { + OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } + + if (!ssl_can_renegotiate(ssl)) { + OPENSSL_PUT_ERROR(SSL, SSL_R_NO_RENEGOTIATION); + return 0; + } + + // Renegotiation is only supported at quiescent points in the application + // protocol, namely in HTTPS, just before reading the HTTP response. + // Require the record-layer be idle and avoid complexities of sending a + // handshake record while an application_data record is being written. + if (!ssl->s3->write_buffer.empty() || + ssl->s3->write_shutdown != ssl_shutdown_none) { + OPENSSL_PUT_ERROR(SSL, SSL_R_NO_RENEGOTIATION); + return 0; + } + + // Begin a new handshake. + if (ssl->s3->hs != nullptr) { + OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR); + return 0; + } + ssl->s3->hs = ssl_handshake_new(ssl); + if (ssl->s3->hs == nullptr) { + return 0; + } + + ssl->s3->renegotiate_pending = false; + ssl->s3->total_renegotiations++; + return 1; } int SSL_renegotiate_pending(SSL *ssl) { @@ -2226,36 +2251,17 @@ int SSL_CTX_add_cert_compression_alg(SSL_CTX *ctx, uint16_t alg_id, ssl_cert_decompression_func_t decompress) { assert(compress != nullptr || decompress != nullptr); - for (const auto *alg : ctx->cert_compression_algs.get()) { - if (alg->alg_id == alg_id) { + for (const auto &alg : ctx->cert_compression_algs) { + if (alg.alg_id == alg_id) { return 0; } } - UniquePtr alg = MakeUnique(); - if (alg == nullptr) { - return 0; - } - - alg->alg_id = alg_id; - alg->compress = compress; - alg->decompress = decompress; - - if (ctx->cert_compression_algs == nullptr) { - ctx->cert_compression_algs.reset(sk_CertCompressionAlg_new_null()); - if (ctx->cert_compression_algs == nullptr) { - return 0; - } - } - - if (!PushToStack(ctx->cert_compression_algs.get(), std::move(alg))) { - if (sk_CertCompressionAlg_num(ctx->cert_compression_algs.get()) == 0) { - ctx->cert_compression_algs.reset(); - } - return 0; - } - - return 1; + CertCompressionAlg alg; + alg.alg_id = alg_id; + alg.compress = compress; + alg.decompress = decompress; + return ctx->cert_compression_algs.Push(alg); } void SSL_CTX_set_tls_channel_id_enabled(SSL_CTX *ctx, int enabled) { diff --git a/Sources/CNIOBoringSSL/ssl/t1_lib.cc b/Sources/CNIOBoringSSL/ssl/t1_lib.cc index 19dfe957..0b62a046 100644 --- a/Sources/CNIOBoringSSL/ssl/t1_lib.cc +++ b/Sources/CNIOBoringSSL/ssl/t1_lib.cc @@ -2756,8 +2756,8 @@ static bool cert_compression_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) { bool first = true; CBB contents, algs; - for (const auto *alg : hs->ssl->ctx->cert_compression_algs.get()) { - if (alg->decompress == nullptr) { + for (const auto &alg : hs->ssl->ctx->cert_compression_algs) { + if (alg.decompress == nullptr) { continue; } @@ -2767,7 +2767,7 @@ static bool cert_compression_add_clienthello(SSL_HANDSHAKE *hs, CBB *out) { return false; } first = false; - if (!CBB_add_u16(&algs, alg->alg_id)) { + if (!CBB_add_u16(&algs, alg.alg_id)) { return false; } } @@ -2794,8 +2794,8 @@ static bool cert_compression_parse_clienthello(SSL_HANDSHAKE *hs, return true; } - const size_t num_algs = - sk_CertCompressionAlg_num(hs->ssl->ctx->cert_compression_algs.get()); + const SSL_CTX *ctx = hs->ssl->ctx.get(); + const size_t num_algs = ctx->cert_compression_algs.size(); CBS alg_ids; if (!CBS_get_u8_length_prefixed(contents, &alg_ids) || @@ -2823,9 +2823,8 @@ static bool cert_compression_parse_clienthello(SSL_HANDSHAKE *hs, given_alg_ids[given_alg_idx++] = alg_id; for (size_t i = 0; i < num_algs; i++) { - const auto *alg = sk_CertCompressionAlg_value( - hs->ssl->ctx->cert_compression_algs.get(), i); - if (alg->alg_id == alg_id && alg->compress != nullptr) { + const auto &alg = ctx->cert_compression_algs[i]; + if (alg.alg_id == alg_id && alg.compress != nullptr) { if (i < best_index) { best_index = i; } @@ -2845,10 +2844,7 @@ static bool cert_compression_parse_clienthello(SSL_HANDSHAKE *hs, if (best_index < num_algs && ssl_protocol_version(hs->ssl) >= TLS1_3_VERSION) { hs->cert_compression_negotiated = true; - hs->cert_compression_alg_id = - sk_CertCompressionAlg_value(hs->ssl->ctx->cert_compression_algs.get(), - best_index) - ->alg_id; + hs->cert_compression_alg_id = ctx->cert_compression_algs[best_index].alg_id; } return true; diff --git a/Sources/CNIOBoringSSL/ssl/tls13_both.cc b/Sources/CNIOBoringSSL/ssl/tls13_both.cc index 7cac55c3..f42bc280 100644 --- a/Sources/CNIOBoringSSL/ssl/tls13_both.cc +++ b/Sources/CNIOBoringSSL/ssl/tls13_both.cc @@ -133,9 +133,9 @@ bool tls13_process_certificate(SSL_HANDSHAKE *hs, const SSLMessage &msg, } ssl_cert_decompression_func_t decompress = nullptr; - for (const auto* alg : ssl->ctx->cert_compression_algs.get()) { - if (alg->alg_id == alg_id) { - decompress = alg->decompress; + for (const auto &alg : ssl->ctx->cert_compression_algs) { + if (alg.alg_id == alg_id) { + decompress = alg.decompress; break; } } @@ -517,9 +517,9 @@ bool tls13_add_certificate(SSL_HANDSHAKE *hs) { } const CertCompressionAlg *alg = nullptr; - for (const auto *candidate : ssl->ctx->cert_compression_algs.get()) { - if (candidate->alg_id == hs->cert_compression_alg_id) { - alg = candidate; + for (const auto &candidate : ssl->ctx->cert_compression_algs) { + if (candidate.alg_id == hs->cert_compression_alg_id) { + alg = &candidate; break; } } diff --git a/Sources/CNIOBoringSSL/ssl/tls13_server.cc b/Sources/CNIOBoringSSL/ssl/tls13_server.cc index f0523537..ad30b615 100644 --- a/Sources/CNIOBoringSSL/ssl/tls13_server.cc +++ b/Sources/CNIOBoringSSL/ssl/tls13_server.cc @@ -976,7 +976,7 @@ static enum ssl_hs_wait_t do_send_new_session_ticket(SSL_HANDSHAKE *hs) { // the case of a small server write buffer. Consumers which don't write data // to the client will need to do a zero-byte write if they wish to flush the // tickets. - if (hs->ssl->ctx->quic_method != nullptr && sent_tickets) { + if (hs->ssl->quic_method != nullptr && sent_tickets) { return ssl_hs_flush; } return ssl_hs_ok;