Skip to content

Commit 8ab3eff

Browse files
authored
Merge branch 'main' into x509-name-constraints
2 parents 4878635 + ce76c47 commit 8ab3eff

48 files changed

Lines changed: 1573 additions & 629 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/linux-multi-arch-omnibus.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ jobs:
194194
./tests/ci/run_posix_tests.sh
195195
196196
fips_tests:
197-
name: ${{ matrix.enableASAN && 'asan-' || '' }}fips-tests-${{ matrix.image }}-${{ matrix.compiler }}-${{ matrix.arch }}
197+
name: ${{ matrix.enableASAN && 'asan-' || '' }}${{ matrix.enableMSAN && 'msan-' || '' }}fips-tests-${{ matrix.image }}-${{ matrix.compiler }}-${{ matrix.arch }}
198198
runs-on:
199199
- codebuild-aws-lc-ci-github-actions-${{ github.run_id }}-${{ github.run_attempt }}
200200
image:${{ matrix.arch == 'x86_64' && 'linux-5.0' || matrix.arch == 'aarch64' && 'arm-3.0' }}
@@ -315,6 +315,10 @@ jobs:
315315
- image: ubuntu:22.04
316316
arch: x86_64
317317
compiler: clang-14
318+
- image: amazonlinux:2023
319+
arch: x86_64
320+
compiler: clang-19
321+
enableMSAN: 1
318322
- image: ubuntu:22.04
319323
arch: x86_64
320324
compiler: gcc-10
@@ -349,6 +353,7 @@ jobs:
349353
compiler: gcc-12
350354
env:
351355
AWSLC_ENABLE_FIPS_ASAN: ${{ matrix.enableASAN }}
356+
AWSLC_ENABLE_FIPS_MSAN: ${{ matrix.enableMSAN }}
352357
steps:
353358
- uses: actions/checkout@v5
354359
- name: Login to Amazon ECR
@@ -360,6 +365,7 @@ jobs:
360365
image: ${{ steps.login-ecr.outputs.registry }}/aws-lc/${{ matrix.image }}
361366
env: |
362367
AWSLC_ENABLE_FIPS_ASAN
368+
AWSLC_ENABLE_FIPS_MSAN
363369
run: |
364370
source /opt/compiler-env/setup-${{ matrix.compiler }}.sh
365371
if [[ "${{ matrix.goTestTimeout }}z" != "z" ]]; then

.github/workflows/windows-alt.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,41 @@ jobs:
203203
- name: x86_64-w64-mingw32 Build/Test
204204
run:
205205
./tests/ci/run_cross_mingw_tests.sh x86_64 w64-mingw32 "-DCMAKE_BUILD_TYPE=Release"
206+
cross-clang-cl-ninja:
207+
# Cross-compile from Linux to x86_64-pc-windows-msvc with Ninja + clang-cl,
208+
# mirroring the default aws-lc-rs setup. This catches command-line quoting
209+
# regressions the Windows-native clang-cl-ninja job misses because cmd.exe
210+
# and /bin/sh tokenize arguments differently (see aws/aws-lc-rs#981).
211+
if: github.repository_owner == 'aws'
212+
runs-on: ubuntu-24.04
213+
steps:
214+
- uses: actions/checkout@v4
215+
- name: Setup toolchain
216+
run: |
217+
set -ex
218+
sudo apt-get update -o Acquire::Languages=none -o Acquire::Translation=none
219+
sudo apt-get install --assume-yes --no-install-recommends \
220+
cmake ninja-build nasm \
221+
wget lsb-release software-properties-common gnupg
222+
# Clang 19 (xwin's MSVC STL headers require Clang >= 19; 24.04 ships 18).
223+
wget -qO- https://apt.llvm.org/llvm.sh | sudo bash -s -- 19
224+
sudo ln -sf /usr/bin/clang-19 /usr/local/bin/clang-cl
225+
sudo ln -sf /usr/bin/lld-19 /usr/local/bin/lld-link
226+
sudo ln -sf /usr/bin/llvm-ar-19 /usr/local/bin/llvm-lib
227+
sudo ln -sf /usr/bin/llvm-rc-19 /usr/local/bin/llvm-rc
228+
sudo ln -sf /usr/bin/llvm-mt-19 /usr/local/bin/llvm-mt
229+
# xwin provides the MSVC SDK headers/libs for cross-compiling.
230+
XWIN_VERSION=0.6.5
231+
wget -qO- https://github.com/Jake-Shadle/xwin/releases/download/${XWIN_VERSION}/xwin-${XWIN_VERSION}-x86_64-unknown-linux-musl.tar.gz | tar xz
232+
sudo mv xwin-${XWIN_VERSION}-x86_64-unknown-linux-musl/xwin /usr/local/bin/
233+
xwin --accept-license --arch x86_64 splat --output /tmp/xwin
234+
- name: Build
235+
run: |
236+
set -ex
237+
cmake -B build -G Ninja \
238+
-DCMAKE_BUILD_TYPE=Release \
239+
-DCMAKE_TOOLCHAIN_FILE=util/x86_64-windows-clang-cl-toolchain.cmake
240+
cmake --build build --target all
206241
msys2:
207242
name: msys2 ${{ matrix.sys }} - ${{ matrix.generator }}
208243
if: github.repository_owner == 'aws'

CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_policy(SET CMP0091 NEW)
55
endif()
66

77
set(SOFTWARE_NAME "awslc")
8-
set(SOFTWARE_VERSION "1.72.0")
8+
set(SOFTWARE_VERSION "1.72.1")
99
set(ABI_VERSION 0)
1010
set(CRYPTO_LIB_NAME "crypto")
1111
set(SSL_LIB_NAME "ssl")
@@ -849,9 +849,12 @@ if(WIN32)
849849
# Allow use of fopen.
850850
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
851851
# VS 2017 and higher supports STL-only warning suppressions.
852-
# A bug in CMake < 3.13.0 may cause the space in this value to
853-
# cause issues when building with NASM. In that case, update CMake.
854-
add_definitions("-D_STL_EXTRA_DISABLED_WARNINGS=4774 4987")
852+
# _STL_EXTRA_DISABLED_WARNINGS is only consumed by MSVC STL headers,
853+
# so scope the definition to C++. Using add_compile_options with a
854+
# CMake-escaped space keeps the value as a single argument under
855+
# Ninja + clang-cl, where add_definitions with a space-containing
856+
# value is not quoted robustly (see aws/aws-lc-rs#981).
857+
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-D_STL_EXTRA_DISABLED_WARNINGS=4774\ 4987>)
855858
endif()
856859

857860
add_flag_if_supported(C_CXX_FLAGS "-Wshadow")

crypto/cipher_extra/aead_test.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,19 @@ TEST(AEADTest, TestGCMSIV128Change16Alignment) {
13021302
GTEST_LOG_(INFO) << "Orig. Ctx.State Location: " << &encrypt_ctx_128->state;
13031303
EVP_AEAD_CTX *moved_encrypt_ctx_128 =
13041304
(EVP_AEAD_CTX *)(((uint8_t *)encrypt_ctx_128) + 8);
1305+
// The destination pointer is offset into the allocation so that it aliases
1306+
// the |state| subobject; GCC / fortify-headers infer the subobject size and
1307+
// report a `stringop-overflow` false positive (see aws-lc#3083).
1308+
// -Wstringop-overflow was introduced in GCC 7; older GCC versions reject
1309+
// the pragma with -Werror=pragmas.
1310+
#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ >= 7)
1311+
#pragma GCC diagnostic push
1312+
#pragma GCC diagnostic ignored "-Wstringop-overflow"
1313+
#endif
13051314
memmove(moved_encrypt_ctx_128, encrypt_ctx_128, sizeof(EVP_AEAD_CTX));
1315+
#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ >= 7)
1316+
#pragma GCC diagnostic pop
1317+
#endif
13061318
GTEST_LOG_(INFO) << "Moved Ctx.State Location: "
13071319
<< &moved_encrypt_ctx_128->state;
13081320

@@ -1343,7 +1355,15 @@ TEST(AEADTest, TestGCMSIV256Change16Alignment) {
13431355
GTEST_LOG_(INFO) << "Orig. Ctx.State Location: " << &encrypt_ctx_256->state;
13441356
EVP_AEAD_CTX *moved_encrypt_ctx_256 =
13451357
(EVP_AEAD_CTX *)(((uint8_t *)encrypt_ctx_256) + 8);
1358+
// See TestGCMSIV128Change16Alignment for why this pragma is needed.
1359+
#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ >= 7)
1360+
#pragma GCC diagnostic push
1361+
#pragma GCC diagnostic ignored "-Wstringop-overflow"
1362+
#endif
13461363
memmove(moved_encrypt_ctx_256, encrypt_ctx_256, sizeof(EVP_AEAD_CTX));
1364+
#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ >= 7)
1365+
#pragma GCC diagnostic pop
1366+
#endif
13471367
GTEST_LOG_(INFO) << "Moved Ctx.State Location: "
13481368
<< &moved_encrypt_ctx_256->state;
13491369

crypto/conf/conf.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,20 @@ static int add_string(const CONF *conf, CONF_VALUE *section,
326326
CONF_VALUE *old_value;
327327

328328
value->section = OPENSSL_strdup(section->section);
329+
if (value->section == NULL) {
330+
return 0;
331+
}
332+
329333
if (!sk_CONF_VALUE_push(section_stack, value)) {
334+
OPENSSL_free(value->section);
335+
value->section = NULL;
330336
return 0;
331337
}
332338

333339
if (!lh_CONF_VALUE_insert(conf->data, &old_value, value)) {
340+
(void)sk_CONF_VALUE_delete_ptr(section_stack, value);
341+
OPENSSL_free(value->section);
342+
value->section = NULL;
334343
return 0;
335344
}
336345
if (old_value != NULL) {

crypto/crypto_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ TEST(CryptoTest, FIPSdownstreamPrecompilationFlag) {
106106
}
107107
#endif // defined(BORINGSSL_FIPS)
108108

109-
#if defined(BORINGSSL_FIPS) && !defined(OPENSSL_ASAN)
109+
#if defined(BORINGSSL_FIPS) && !defined(OPENSSL_ASAN) && !defined(OPENSSL_MSAN)
110110
TEST(Crypto, OnDemandIntegrityTest) {
111111
BORINGSSL_integrity_test();
112112
}

crypto/err/evp.errordata

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ EVP,107,EXPECTING_AN_RSA_KEY
1010
EVP,139,EXPECTING_A_DH_KEY
1111
EVP,108,EXPECTING_A_DSA_KEY
1212
EVP,106,EXPECTING_A_EC_KEY_KEY
13+
EVP,141,EXPECTING_A_KEM_KEY
1314
EVP,140,EXPECTING_A_PQDSA_KEY
1415
EVP,109,ILLEGAL_OR_UNSUPPORTED_PADDING_MODE
1516
EVP,137,INVALID_BUFFER_SIZE

crypto/evp_extra/evp_asn1.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@
1919
#include "../internal.h"
2020
#include "internal.h"
2121
#include "../fipsmodule/kem/internal.h"
22+
#include "../fipsmodule/cpucap/internal.h"
2223

2324
// parse_key_type takes the algorithm cbs sequence |cbs| and extracts the OID.
2425
// The extracted OID will be set on |out_oid| so that it may be used later in
2526
// specific key type implementations like PQDSA.
2627
// The OID is then searched against ASN.1 methods for a method with that OID.
2728
// As the |OID| is read from |cbs| the buffer is advanced.
28-
// For the case of |NID_rsa| the method |rsa_asn1_meth| is returned.
29+
// For the case of |NID_rsa| or |NID_rsaesOaep| the method |rsa_asn1_meth| is returned.
2930
// For the case of |EVP_PKEY_PQDSA| the method |pqdsa_asn1.meth| is returned.
3031
// For the case of |EVP_PKEY_KEM| the method |kem_asn1.meth| is returned.
3132
static const EVP_PKEY_ASN1_METHOD *parse_key_type(CBS *cbs, CBS *out_oid) {
@@ -46,20 +47,25 @@ static const EVP_PKEY_ASN1_METHOD *parse_key_type(CBS *cbs, CBS *out_oid) {
4647
}
4748
}
4849

49-
// Special logic to handle the rarer |NID_rsa|.
50+
// Special logic to handle the rarer |NID_rsa| and |NID_rsaesOaep|.
51+
// NID_rsa:
5052
// https://www.itu.int/ITU-T/formal-language/itu-t/x/x509/2008/AlgorithmObjectIdentifiers.html
51-
if (OBJ_cbs2nid(&oid) == NID_rsa) {
53+
// NID_rsaesOaep: underlying key is the same as |NID_rsa|. Used by
54+
// TPM 1.2 Endorsement Key certificates per TCG Credential Profiles
55+
// V1.2, section 3.2.7.
56+
int nid = OBJ_cbs2nid(&oid);
57+
if (nid == NID_rsa || nid == NID_rsaesOaep) {
5258
return &rsa_asn1_meth;
5359
}
5460

5561
// The pkey_id for the pqdsa_asn1_meth is EVP_PKEY_PQDSA, as this holds all
5662
// asn1 functions for pqdsa types. However, the incoming CBS has the OID for
5763
// the specific algorithm. So we must search explicitly for the algorithm.
58-
const EVP_PKEY_ASN1_METHOD *pqdsa_method = PQDSA_find_asn1_by_nid(OBJ_cbs2nid(&oid));
64+
const EVP_PKEY_ASN1_METHOD *pqdsa_method = PQDSA_find_asn1_by_nid(nid);
5965
if (pqdsa_method != NULL) {
6066
return pqdsa_method;
6167
}
62-
return KEM_find_asn1_by_nid(OBJ_cbs2nid(&oid));
68+
return KEM_find_asn1_by_nid(nid);
6369
}
6470

6571
EVP_PKEY *EVP_parse_public_key(CBS *cbs) {
@@ -713,3 +719,17 @@ int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id, int *ppkey_flags,
713719
}
714720
return 1;
715721
}
722+
723+
int EVP_PKEY_get_private_seed(const EVP_PKEY *key, uint8_t *out,
724+
size_t *out_len) {
725+
SET_DIT_AUTO_RESET;
726+
GUARD_PTR(key);
727+
GUARD_PTR(out_len);
728+
729+
if (key->ameth == NULL || key->ameth->get_priv_seed == NULL) {
730+
OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
731+
return 0;
732+
}
733+
734+
return key->ameth->get_priv_seed(key, out, out_len);
735+
}

crypto/evp_extra/evp_extra_test.cc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,49 @@ TEST(EVPExtraTest, Ed25519) {
16831683
ERR_clear_error();
16841684
}
16851685

1686+
// EVP_PKEY_get_private_seed returns an error for key types that don't
1687+
// provide a get_priv_seed method. It must also reject NULL |key| regardless of
1688+
// key type.
1689+
TEST(EVPExtraTest, GetPrivateSeedUnsupportedKeyTypes) {
1690+
// NULL key is rejected.
1691+
size_t seed_len = 0;
1692+
ERR_clear_error();
1693+
EXPECT_FALSE(EVP_PKEY_get_private_seed(nullptr, nullptr, &seed_len));
1694+
1695+
// RSA
1696+
bssl::UniquePtr<EVP_PKEY> rsa_key(ParsePrivateKey(
1697+
EVP_PKEY_RSA, kExampleRSAKeyDER, sizeof(kExampleRSAKeyDER)));
1698+
ASSERT_TRUE(rsa_key);
1699+
ERR_clear_error();
1700+
EXPECT_FALSE(EVP_PKEY_get_private_seed(rsa_key.get(), nullptr, &seed_len));
1701+
EXPECT_TRUE(ErrorEquals(ERR_get_error(), ERR_LIB_EVP,
1702+
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE));
1703+
1704+
// EC
1705+
bssl::UniquePtr<EVP_PKEY> ec_key(ParsePrivateKey(
1706+
EVP_PKEY_EC, kExampleECKeyDER, sizeof(kExampleECKeyDER)));
1707+
ASSERT_TRUE(ec_key);
1708+
ERR_clear_error();
1709+
EXPECT_FALSE(EVP_PKEY_get_private_seed(ec_key.get(), nullptr, &seed_len));
1710+
EXPECT_TRUE(ErrorEquals(ERR_get_error(), ERR_LIB_EVP,
1711+
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE));
1712+
1713+
// Ed25519: has a raw 32-byte private "seed" but does NOT wire up
1714+
// get_priv_seed. EVP_PKEY_get_raw_private_key is the correct accessor.
1715+
static const uint8_t kEd25519Seed[32] = {
1716+
0x9d, 0x61, 0xb1, 0x9d, 0xef, 0xfd, 0x5a, 0x60, 0xba, 0x84, 0x4a,
1717+
0xf4, 0x92, 0xec, 0x2c, 0xc4, 0x44, 0x49, 0xc5, 0x69, 0x7b, 0x32,
1718+
0x69, 0x19, 0x70, 0x3b, 0xac, 0x03, 0x1c, 0xae, 0x7f, 0x60,
1719+
};
1720+
bssl::UniquePtr<EVP_PKEY> ed_key(EVP_PKEY_new_raw_private_key(
1721+
EVP_PKEY_ED25519, nullptr, kEd25519Seed, sizeof(kEd25519Seed)));
1722+
ASSERT_TRUE(ed_key);
1723+
ERR_clear_error();
1724+
EXPECT_FALSE(EVP_PKEY_get_private_seed(ed_key.get(), nullptr, &seed_len));
1725+
EXPECT_TRUE(ErrorEquals(ERR_get_error(), ERR_LIB_EVP,
1726+
EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE));
1727+
}
1728+
16861729
static void ExpectECGroupOnly(const EVP_PKEY *pkey, int nid) {
16871730
EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey);
16881731
ASSERT_TRUE(ec);

crypto/evp_extra/p_dsa_asn1.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ const EVP_PKEY_ASN1_METHOD dsa_asn1_meth = {
217217
NULL /* set_pub_raw */,
218218
NULL /* get_priv_raw */,
219219
NULL /* get_pub_raw */,
220+
NULL /* get_priv_seed */,
220221

221222
NULL /* pkey_opaque */,
222223

0 commit comments

Comments
 (0)