Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge bssl #94

Merged
merged 115 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
0a6bfa3
Always check the TLS 1.3 downgrade signal.
davidben Nov 18, 2020
5351c8b
Rename the master_key field in SSL_SESSION to secret.
davidben Nov 19, 2020
8846533
Add FIPS self test for the TLS KDF.
Nov 19, 2020
806c505
acvp: add SHA-512/256 support.
Nov 19, 2020
4a265be
Document ASN1_STRING.
davidben Nov 19, 2020
9dae0ac
Add digest.h to self_check.c
Nov 30, 2020
bb6f9c4
util/fipstools/acvp/acvptool: buffer signal channel to avoid losing s…
odeke-em Dec 1, 2020
1bec252
Poly1305: Use |size_t|; assert |poly1305_state| is large enough.
briansmith Nov 30, 2020
f8047e2
Improve sk_dup.
Nov 25, 2020
eb57cc1
aesv8-armx.pl: avoid 32-bit lane assignment in CTR mode
davidben Dec 1, 2020
c3f4612
Only accept little-endian ARM and MIPS variants in base.h.
davidben Dec 1, 2020
5763899
Update FIPS.md to include latest FIPS certificate.
Dec 2, 2020
41a1430
draft-ietf-tls-certificate-compression is now RFC 8879.
davidben Dec 2, 2020
3094902
Get closer to Ed25519 boundary conditions.
davidben Dec 2, 2020
455b78d
PWCT failures should clear the generated key.
Dec 1, 2020
aa4ecb4
Fix EDIPartyName parsing and GENERAL_NAME_cmp.
davidben Oct 29, 2020
225961d
Const-correct GENERAL_NAME_cmp.
davidben Dec 8, 2020
329c0cb
acvp: fix subprocess_test.go
Dec 7, 2020
9ac743e
acvp: tweak config
Dec 7, 2020
f040001
acvp: add TLS KDF support
Dec 7, 2020
1920c6f
Implement GREASE for ECH (draft-ietf-tls-esni-08).
dmcardle Mar 11, 2020
92de0b5
Reject bad ASN.1 templates with implicitly-tagged CHOICEs.
davidben Dec 8, 2020
a6b6b80
Align armv8.pl references to OPENSSL_armcap_P.
davidben Dec 8, 2020
0898b07
acvp: add support for KAS
Dec 8, 2020
66feb2c
Add TLS_KDF to documented break tests.
Dec 10, 2020
4ae71a4
Skip ASN.1 template tests in Windows shared library builds.
davidben Dec 9, 2020
a3a9894
Switch to passive entropy collection for Android FIPS.
Dec 1, 2020
a929e32
Finish switching to NASM.
davidben Dec 11, 2020
49587b2
Remove unused Netware codepaths in x86 perlasm.
davidben Dec 11, 2020
ce7f088
Move DH code into the FIPS module.
Dec 10, 2020
28cab64
acvp: add support for finite-field Diffie–Hellman.
Dec 10, 2020
cd204d8
Include bn.h from bn/internal.h
agl Dec 14, 2020
f2adafe
Fix ChaCha20-Poly1305 x86-64 asm on Windows
vkrasnov Dec 2, 2020
60926d3
Check for trailing data in X509Test.GeneralName.
davidben Dec 15, 2020
061a7f5
Use stdlib.h instead of cstdlib in span.h.
davidben Dec 15, 2020
7ba96a6
Add support for the new QUIC TLS extension codepoint
DavidSchinazi Dec 14, 2020
df75139
Move DH parameter generation out of the FIPS module.
Dec 14, 2020
ca058c0
Revert "Add support for the new QUIC TLS extension codepoint"
Dec 16, 2020
6263426
Use more efficient std::string::find overload.
Dec 16, 2020
bb0cb95
Export tool_sources to GN.
davidben Dec 17, 2020
e56dfcf
Allow some non-minimal lengths in BER.
Dec 16, 2020
8685482
acvp: load config later.
Dec 17, 2020
4ab14ea
acvp: fix silly errors.
Dec 17, 2020
082cd78
Add .text.unlikely.* pattern to fips_shared.lds.
pcc Dec 22, 2020
e02dd70
acvp: better document the subprocess protocol.
Dec 23, 2020
78f15a6
Gerrit ignores <sup>; use Unicode superscript instead.
Dec 23, 2020
92c48be
Update ECH GREASE to draft-ietf-tls-esni-09
dmcardle Dec 21, 2020
bac5544
Fix awkward wording in comment.
Dec 21, 2020
9422ac6
Fix chacha20_poly1305_x86_64.pl comments.
davidben Jan 5, 2021
4f75b76
acvp: add tests
Dec 17, 2020
4df05c5
Update third_party/googletest.
davidben Jan 6, 2021
e484375
delocate: support alternative comment indicators
Dec 22, 2020
c42baf8
delocate: eliminate expression from vpaes assembly.
Dec 22, 2020
76164b1
Add some OpenSSL-compatibility aliases
Jan 7, 2021
ab6a8f4
acvp: drop subprocess_test.go
Dec 17, 2020
7dfb472
Update HPKE to draft-irtf-cfrg-hpke-07.
dmcardle Jan 6, 2021
5dd18d0
A handful more compatibility functions.
agl Jan 7, 2021
13da180
Optimize suffix building in FileTest::ReadNext().
dmcardle Jan 6, 2021
571c3e7
Use gai_strerrorA on Windows.
davidben Jan 8, 2021
afd5dba
Add ASM optimizations for Windows on Arm
anthony-roberts-arm Oct 19, 2020
5d54832
delocate: handle Aarch64 assembly in parser.
Dec 22, 2020
c295935
Send ECH acceptance signal from backend server.
dmcardle Oct 29, 2020
41676bf
Test that ALPS can be deferred to the ALPN callback.
davidben Jan 12, 2021
f4a8829
runner: Allow tokbind without RI/EMS in TLS 1.3.
davidben Jan 12, 2021
71ed9d7
Fix ALPS state machine in QUIC servers.
davidben Jan 12, 2021
7a55c80
Make QUIC work with -async tests.
davidben Jan 12, 2021
47d1274
Make QUIC tests work with early data.
davidben Jan 12, 2021
e606f79
Run extension tests at all protocols.
davidben Jan 12, 2021
c3ee9c8
Replace MockQUICTransport tags with record types.
davidben Jan 12, 2021
f8f35c9
delocate: preprocess perlasm output on Aarch64
Dec 22, 2020
3d8b8c3
Add support for the new QUIC TLS extension codepoint
DavidSchinazi Jan 14, 2021
595cdc2
doc: fix SSL_set0_rbio
lambdai Jan 15, 2021
2f2d27e
acvp: add XTS support.
Jan 18, 2021
a9319d9
Fix client 0-RTT handling with ALPS.
davidben Jan 19, 2021
c1e156a
Add DH_compute_key_padded.
davidben Jan 8, 2021
c5e2cf3
delocate: support Aarch64
Dec 22, 2020
2d691ca
Make BN_clear_free a wrapper around BN_free.
Jan 19, 2021
c47bfce
Define TLSEXT_TYPE_quic_transport_parameters to the old code point fo…
davidben Jan 20, 2021
39093c1
Fix comments that refer to old draft of HPKE.
dmcardle Jan 21, 2021
0f0e2bc
acvp: don't advertise SHA-1 RSA signature generation.
Jan 22, 2021
8dcdcb3
acvp: drop 3DES fields from output when unused.
Jan 22, 2021
b0d71a2
Support cross-compiling AArch64 FIPS to Android.
Jan 17, 2021
1fa6b7f
acvp: update test expectations in light of 8dcdcb39a7
Jan 22, 2021
16c42cc
acvp: check that the payloadLen of cipher tests is correct.
Jan 22, 2021
e133345
Add basic BLAKE2b-256 support.
Jan 21, 2021
d09962d
acvp: update to newer FFDH test.
Jan 25, 2021
5cf0218
Add FFDH FIPS self-test.
Jan 19, 2021
1c91972
Support MOVLPS and MOVHPS in delocate.
davidben Jan 27, 2021
ab5edbe
Benchmark BORINGSSL_self_test in FIPS mode.
davidben Jan 27, 2021
4a196cc
acvp: move CMAC verification into the module wrapper.
Jan 28, 2021
ae2bb64
Use ID instead of Id in Go.
davidben Jan 28, 2021
c5e4538
Fix TLS13SessionID-TLS13 test.
davidben Jan 29, 2021
4251d0d
Revert "Disable check that X.509 extensions implies v3."
Jan 29, 2021
bb43a45
Add missing include to self_check.c.
davidben Feb 2, 2021
48cbd69
Add various function calls to test_fips.
Feb 3, 2021
a2278d4
Include bn/internal.h for non-bcm.c builds.
Feb 5, 2021
4d3e540
acvp: fix CMAC verify
Feb 9, 2021
fc23300
acvp: don't include CMAC-AES in regcap dump.
Feb 9, 2021
f9bd455
Skip runtime NEON checks if __ARM_NEON is defined.
davidben Feb 9, 2021
ce9b002
Align the ARM capability functions.
davidben Feb 9, 2021
3b7029a
acvp: detect header element in JSON.
Feb 11, 2021
c02c19e
Honor SSL_TLSEXT_ERR_ALERT_FATAL in the ALPN callback.
davidben Feb 10, 2021
a99308f
Update Android Bazel build support in BUILD.toplevel.
blueshiftlabs Feb 12, 2021
85bda4b
Specify VS toolchain by command-line argument.
davidben Feb 12, 2021
238a258
Fix Bazel build breakage.
blueshiftlabs Feb 13, 2021
ca2162d
Remove X509_issuer_and_serial_hash.
davidben Feb 16, 2021
e7c0c97
Don't overflow the output length in EVP_CipherUpdate calls.
davidben Feb 16, 2021
f6bd54e
Check for OBJ_nid2obj failures in X509_ATTRIBUTE_create.
davidben Feb 16, 2021
bbd1742
Update Clang and Go on the bots.
davidben Feb 12, 2021
dae88e2
Merge remote-tracking branch 'bssl/master' into merge-bssl
bryce-shang Feb 18, 2021
47c0fe5
Fixed build errors after merging bssl.
bryce-shang Feb 18, 2021
c3e7b34
Merge branch 'main' into merge-bssl
bryce-shang Feb 19, 2021
32577ae
Correct comments.
bryce-shang Feb 19, 2021
77b45e3
Remove unused test data.
bryce-shang Feb 19, 2021
229ed4a
Replace string with token.
bryce-shang Feb 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ StatementMacros:
- "DECLARE_PEM_write_const"
- "DECLARE_PEM_write_fp"
- "DECLARE_PEM_write_fp_const"
- "IMPLEMENT_ASN1_ALLOC_FUNCTIONS"
- "IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname"
- "IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname"
- "IMPLEMENT_ASN1_DUP_FUNCTION"
- "IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname"
- "IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname"
- "IMPLEMENT_ASN1_FUNCTIONS"
- "IMPLEMENT_ASN1_FUNCTIONS_const"
- "IMPLEMENT_ASN1_FUNCTIONS_const_fname"
- "IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name"
- "IMPLEMENT_ASN1_FUNCTIONS_fname"
- "IMPLEMENT_ASN1_FUNCTIONS_name"
- "IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS"
- "IMPLEMENT_PEM_read"
- "IMPLEMENT_PEM_read_bio"
- "IMPLEMENT_PEM_read_fp"
Expand Down
8 changes: 0 additions & 8 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,6 @@ BoringSSL maintainers if making use of it.

## Known Limitations on Windows

* Versions of CMake since 3.0.2 have a bug in its Ninja generator that causes
yasm to output warnings

yasm: warning: can open only one input file, only the last file will be processed

These warnings can be safely ignored. The cmake bug is
http://www.cmake.org/Bug/view.php?id=15253.

* CMake can generate Visual Studio projects, but the generated project files
don't have steps for assembling the assembly language source files, so they
currently cannot be used to build BoringSSL.
Expand Down
29 changes: 28 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
set(ARCH "x86")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(ARCH "aarch64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ARM64")
set(ARCH "aarch64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
set(ARCH "aarch64")
# Apple A12 Bionic chipset which is added in iPhone XS/XS Max/XR uses arm64e architecture.
Expand Down Expand Up @@ -696,6 +698,30 @@ if (NOT ${CMAKE_VERSION} VERSION_LESS "3.2")
endif()

if(GO_EXECUTABLE)
if(FIPS)
add_custom_target(
acvp_tests
COMMAND ${GO_EXECUTABLE} build -o ${CMAKE_BINARY_DIR}/acvptool
boringssl.googlesource.com/boringssl/util/fipstools/acvp/acvptool
COMMAND ${GO_EXECUTABLE} build -o ${CMAKE_BINARY_DIR}/testmodulewrapper
boringssl.googlesource.com/boringssl/util/fipstools/acvp/acvptool/testmodulewrapper
COMMAND cd util/fipstools/acvp/acvptool/test &&
${GO_EXECUTABLE} run check_expected.go
-tool ${CMAKE_BINARY_DIR}/acvptool
-module-wrappers modulewrapper:$<TARGET_FILE:modulewrapper>,testmodulewrapper:${CMAKE_BINARY_DIR}/testmodulewrapper
-tests tests.json
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS modulewrapper
USES_TERMINAL)

add_custom_target(
fips_specific_tests_if_any
DEPENDS acvp_tests
)
else()
add_custom_target(fips_specific_tests_if_any)
endif()

add_custom_target(
run_tests
COMMAND ${GO_EXECUTABLE} run util/all_tests.go -build-dir
Expand All @@ -704,7 +730,7 @@ if(GO_EXECUTABLE)
${GO_EXECUTABLE} test -timeout ${GO_TEST_TIMEOUT} -shim-path $<TARGET_FILE:bssl_shim>
${HANDSHAKER_ARGS} ${RUNNER_ARGS}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS all_tests bssl_shim handshaker
DEPENDS all_tests bssl_shim handshaker fips_specific_tests_if_any
${MAYBE_USES_TERMINAL})

add_custom_target(
Expand Down Expand Up @@ -733,6 +759,7 @@ else()
DEPENDS all_tests
${MAYBE_USES_TERMINAL})
endif()

# Copy awslc-config.cmake to build artifacts.
configure_file("cmake/awslc-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/awslc-config.cmake"
Expand Down
2 changes: 1 addition & 1 deletion cmake/awslc-config.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Copied from s2n https://github.com/awslabs/s2n/tree/main/cmake/modules
# Copied from s2n https://github.com/aws/s2n-tls/tree/main/cmake/modules
#
# - Try to find LibCrypto include dirs and libraries
#
Expand Down
38 changes: 23 additions & 15 deletions crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,23 @@ if(NOT OPENSSL_NO_ASM)
endforeach()
endif()
else()
if(${ARCH} STREQUAL "x86_64")
set(PERLASM_STYLE nasm)
if(${ARCH} STREQUAL "aarch64")
set(PERLASM_STYLE win64)
set(ASM_EXT S)
enable_language(ASM)
else()
set(PERLASM_STYLE win32n)
set(PERLASM_FLAGS "-DOPENSSL_IA32_SSE2")
endif()
set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -gcv8")
if(${ARCH} STREQUAL "x86_64")
set(PERLASM_STYLE nasm)
else()
set(PERLASM_STYLE win32n)
set(PERLASM_FLAGS "-DOPENSSL_IA32_SSE2")
endif()
set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -gcv8")

# On Windows, we use the NASM output, specifically built with Yasm.
set(ASM_EXT asm)
enable_language(ASM_NASM)
# On Windows, we use the NASM output.
set(ASM_EXT asm)
enable_language(ASM_NASM)
endif()
endif()
endif()

Expand Down Expand Up @@ -254,6 +260,7 @@ add_library(
bio/printf.c
bio/socket.c
bio/socket_helper.c
blake2/blake2.c
bn_extra/bn_asn1.c
bn_extra/convert.c
buf/buf.c
Expand All @@ -278,17 +285,16 @@ add_library(
conf/conf.c
cpu-aarch64-fuchsia.c
cpu-aarch64-linux.c
cpu-aarch64-win.c
cpu-arm-linux.c
cpu-arm.c
cpu-intel.c
cpu-ppc64le.c
crypto.c
curve25519/curve25519.c
curve25519/spake25519.c
dh/dh.c
dh/params.c
dh/check.c
dh/dh_asn1.c
dh_extra/params.c
dh_extra/dh_asn1.c
digest_extra/digest_extra.c
dsa/dsa.c
dsa/dsa_asn1.c
Expand Down Expand Up @@ -345,6 +351,7 @@ add_library(
rand_extra/deterministic.c
rand_extra/forkunsafe.c
rand_extra/fuchsia.c
rand_extra/passive.c
rand_extra/rand_extra.c
rand_extra/windows.c
rc4/rc4.c
Expand Down Expand Up @@ -506,8 +513,9 @@ add_executable(
abi_self_test.cc
asn1/asn1_test.cc
base64/base64_test.cc
buf/buf_test.cc
bio/bio_test.cc
blake2/blake2_test.cc
buf/buf_test.cc
bytestring/bytestring_test.cc
chacha/chacha_test.cc
cipher_extra/aead_test.cc
Expand All @@ -521,7 +529,7 @@ add_executable(
curve25519/spake25519_test.cc
curve25519/x25519_test.cc
ecdh_extra/ecdh_test.cc
dh/dh_test.cc
dh_extra/dh_test.cc
digest_extra/digest_test.cc
dsa/dsa_test.cc
err/err_test.cc
Expand Down
103 changes: 73 additions & 30 deletions crypto/asn1/asn1_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,44 @@ TEST(ASN1Test, IntegerSetting) {
}
}

template <typename T>
void TestSerialize(T obj, int (*i2d_func)(T a, uint8_t **pp),
bssl::Span<const uint8_t> expected) {
int len = static_cast<int>(expected.size());
ASSERT_EQ(i2d_func(obj, nullptr), len);

std::vector<uint8_t> buf(expected.size());
uint8_t *ptr = buf.data();
ASSERT_EQ(i2d_func(obj, &ptr), len);
EXPECT_EQ(ptr, buf.data() + buf.size());
EXPECT_EQ(Bytes(expected), Bytes(buf));

// Test the allocating version.
ptr = nullptr;
ASSERT_EQ(i2d_func(obj, &ptr), len);
EXPECT_EQ(Bytes(expected), Bytes(ptr, expected.size()));
OPENSSL_free(ptr);
}

TEST(ASN1Test, SerializeObject) {
static const uint8_t kDER[] = {0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
0xf7, 0x0d, 0x01, 0x01, 0x01};
const ASN1_OBJECT *obj = OBJ_nid2obj(NID_rsaEncryption);
TestSerialize(obj, i2d_ASN1_OBJECT, kDER);
}

TEST(ASN1Test, SerializeBoolean) {
static const uint8_t kTrue[] = {0x01, 0x01, 0xff};
TestSerialize(0xff, i2d_ASN1_BOOLEAN, kTrue);

static const uint8_t kFalse[] = {0x01, 0x01, 0x00};
TestSerialize(0x00, i2d_ASN1_BOOLEAN, kFalse);
}

// The ASN.1 macros do not work on Windows shared library builds, where usage of
// |OPENSSL_EXPORT| is a bit stricter.
#if !defined(OPENSSL_WINDOWS) || !defined(BORINGSSL_SHARED_LIBRARY)

typedef struct asn1_linked_list_st {
struct asn1_linked_list_st *next;
} ASN1_LINKED_LIST;
Expand Down Expand Up @@ -151,36 +189,41 @@ TEST(ASN1Test, Recursive) {
ASN1_LINKED_LIST_free(list);
}

template <typename T>
void TestSerialize(T obj, int (*i2d_func)(T a, uint8_t **pp),
bssl::Span<const uint8_t> expected) {
int len = static_cast<int>(expected.size());
ASSERT_EQ(i2d_func(obj, nullptr), len);

std::vector<uint8_t> buf(expected.size());
uint8_t *ptr = buf.data();
ASSERT_EQ(i2d_func(obj, &ptr), len);
EXPECT_EQ(ptr, buf.data() + buf.size());
EXPECT_EQ(Bytes(expected), Bytes(buf));

// Test the allocating version.
ptr = nullptr;
ASSERT_EQ(i2d_func(obj, &ptr), len);
EXPECT_EQ(Bytes(expected), Bytes(ptr, expected.size()));
OPENSSL_free(ptr);
}
struct IMPLICIT_CHOICE {
ASN1_STRING *string;
};

TEST(ASN1Test, SerializeObject) {
static const uint8_t kDER[] = {0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
0xf7, 0x0d, 0x01, 0x01, 0x01};
const ASN1_OBJECT *obj = OBJ_nid2obj(NID_rsaEncryption);
TestSerialize(obj, i2d_ASN1_OBJECT, kDER);
// clang-format off
DECLARE_ASN1_FUNCTIONS(IMPLICIT_CHOICE)

ASN1_SEQUENCE(IMPLICIT_CHOICE) = {
ASN1_IMP(IMPLICIT_CHOICE, string, DIRECTORYSTRING, 0)
} ASN1_SEQUENCE_END(IMPLICIT_CHOICE)

IMPLEMENT_ASN1_FUNCTIONS(IMPLICIT_CHOICE)
// clang-format on

// Test that the ASN.1 templates reject types with implicitly-tagged CHOICE
// types.
TEST(ASN1Test, ImplicitChoice) {
// Serializing a type with an implicitly tagged CHOICE should fail.
std::unique_ptr<IMPLICIT_CHOICE, decltype(&IMPLICIT_CHOICE_free)> obj(
IMPLICIT_CHOICE_new(), IMPLICIT_CHOICE_free);
EXPECT_EQ(-1, i2d_IMPLICIT_CHOICE(obj.get(), nullptr));

// An implicitly-tagged CHOICE is an error. Depending on the implementation,
// it may be misinterpreted as without the tag, or as clobbering the CHOICE
// tag. Test both inputs and ensure they fail.

// SEQUENCE { UTF8String {} }
static const uint8_t kInput1[] = {0x30, 0x02, 0x0c, 0x00};
const uint8_t *ptr = kInput1;
EXPECT_EQ(nullptr, d2i_IMPLICIT_CHOICE(nullptr, &ptr, sizeof(kInput1)));

// SEQUENCE { [0 PRIMITIVE] {} }
static const uint8_t kInput2[] = {0x30, 0x02, 0x80, 0x00};
ptr = kInput2;
EXPECT_EQ(nullptr, d2i_IMPLICIT_CHOICE(nullptr, &ptr, sizeof(kInput2)));
}

TEST(ASN1Test, SerializeBoolean) {
static const uint8_t kTrue[] = {0x01, 0x01, 0xff};
TestSerialize(0xff, i2d_ASN1_BOOLEAN, kTrue);

static const uint8_t kFalse[] = {0x01, 0x01, 0x00};
TestSerialize(0x00, i2d_ASN1_BOOLEAN, kFalse);
}
#endif // !WINDOWS || !SHARED_LIBRARY
4 changes: 2 additions & 2 deletions crypto/asn1/tasn_dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ static int asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,

case ASN1_ITYPE_CHOICE:
/*
* It never makes sense for CHOICE types to have implicit tagging, so
* if tag != -1, then this looks like an error in the template.
* It never makes sense for CHOICE types to have implicit tagging, so if
* tag != -1, then this looks like an error in the template.
*/
if (tag != -1) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
Expand Down
4 changes: 2 additions & 2 deletions crypto/asn1/tasn_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,

case ASN1_ITYPE_CHOICE:
/*
* It never makes sense for CHOICE types to have implicit tagging, so
* if tag != -1, then this looks like an error in the template.
* It never makes sense for CHOICE types to have implicit tagging, so if
* tag != -1, then this looks like an error in the template.
*/
if (tag != -1) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BAD_TEMPLATE);
Expand Down
4 changes: 4 additions & 0 deletions crypto/bio/socket_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ int bio_ip_and_port_to_socket_and_addr(int *out_sock,
ret = getaddrinfo(hostname, port_str, &hint, &result);
if (ret != 0) {
OPENSSL_PUT_ERROR(SYS, 0);
#if defined(OPENSSL_WINDOWS)
ERR_add_error_data(1, gai_strerrorA(ret));
#else
ERR_add_error_data(1, gai_strerror(ret));
#endif
return 0;
}

Expand Down
Loading