Skip to content

Commit 321c039

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 3831437 + f4f1f53 commit 321c039

File tree

424 files changed

+1596
-388
lines changed

Some content is hidden

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

424 files changed

+1596
-388
lines changed

.github/workflows/actions-ci.yml

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -103,67 +103,6 @@ jobs:
103103
run: |
104104
./tests/ci/run_fips_tests.sh
105105
106-
107-
MSVC-2019:
108-
if: github.repository_owner == 'aws'
109-
needs: [sanity-test-run]
110-
runs-on: aws-lc_windows-2019_8-core
111-
steps:
112-
- name: Git clone the repository
113-
uses: actions/checkout@v3
114-
- name: Build Windows Dependencies
115-
run: |
116-
choco install ninja -y &&
117-
choco install nasm -y
118-
- name: Run Windows Tests on MSVC-2019
119-
run: |
120-
.\tests\ci\run_windows_tests.bat "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
121-
122-
MSVC-2022:
123-
if: github.repository_owner == 'aws'
124-
needs: [sanity-test-run]
125-
runs-on: aws-lc_windows-latest_8-core
126-
steps:
127-
- name: Git clone the repository
128-
uses: actions/checkout@v3
129-
- name: Build Windows Dependencies
130-
run: |
131-
choco install ninja -y &&
132-
choco install nasm -y
133-
- name: Run Windows Tests on MSVC-2022
134-
run: |
135-
.\tests\ci\run_windows_tests.bat "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
136-
137-
MSVC-SDE-64-bit:
138-
if: github.repository_owner == 'aws'
139-
needs: [sanity-test-run]
140-
# TODO: Update this to run on windows-2022. windows-2022 (Windows 11) has phased out support for older processors.
141-
# https://learn.microsoft.com/en-us/windows-hardware/design/minimum/supported/windows-11-supported-intel-processors
142-
runs-on: aws-lc_windows-2019_64-core
143-
steps:
144-
- name: Git clone the repository
145-
uses: actions/checkout@v3
146-
147-
- name: Build Windows Dependencies
148-
run: |
149-
choco install ninja -y &&
150-
choco install nasm -y
151-
152-
- name: Install SDE simulator
153-
run: |
154-
curl -SL --output temp.tar.xz ${{ env.SDE_MIRROR_URL }}
155-
7z x temp.tar.xz
156-
7z x temp.tar
157-
ren ${{ env.SDE_VERSION_TAG }} windows-sde
158-
del temp.tar.xz
159-
del temp.tar
160-
161-
- name: Run Windows SDE Tests for 64 bit
162-
run: |
163-
$env:SDEROOT = "${PWD}\windows-sde"
164-
echo ${env:SDEROOT}
165-
.\tests\ci\run_windows_tests.bat "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 true
166-
167106
clang-ubuntu-2004-sanity:
168107
if: github.repository_owner == 'aws'
169108
needs: [sanity-test-run]

CMakeLists.txt

Lines changed: 4 additions & 2 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.57.1")
8+
set(SOFTWARE_VERSION "1.58.1")
99
set(ABI_VERSION 0)
1010
set(CRYPTO_LIB_NAME "crypto")
1111
set(SSL_LIB_NAME "ssl")
@@ -1342,4 +1342,6 @@ endforeach()
13421342

13431343
configure_file(include/openssl/base.h.in ${AWSLC_SOURCE_DIR}/include/openssl/base.h @ONLY)
13441344
configure_file(include/openssl/opensslv.h.in ${AWSLC_SOURCE_DIR}/include/openssl/opensslv.h @ONLY)
1345-
configure_file(tests/ci/check-linkage.sh.in check-linkage.sh @ONLY)
1345+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/util/check-linkage.sh.in")
1346+
configure_file(util/check-linkage.sh.in check-linkage.sh @ONLY)
1347+
endif()

crypto/chacha/asm/chacha-x86_64.pl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2718,33 +2718,38 @@ sub AVX512_lane_ROUND {
27182718
___
27192719
$code.=<<___;
27202720
.section .xdata
2721-
.align 8
2721+
.align 4
27222722
.LSEH_info_ChaCha20_ctr32_nohw:
27232723
.byte 9,0,0,0
27242724
.rva se_handler
27252725
2726+
.align 4
27262727
.LSEH_info_ChaCha20_ctr32_ssse3:
27272728
.byte 9,0,0,0
27282729
.rva ssse3_handler
27292730
.rva .Lssse3_body,.Lssse3_epilogue
27302731
2732+
.align 4
27312733
.LSEH_info_ChaCha20_ctr32_ssse3_4x:
27322734
.byte 9,0,0,0
27332735
.rva full_handler
27342736
.rva .L4x_body,.L4x_epilogue
27352737
___
27362738
$code.=<<___ if ($avx>1);
2739+
.align 4
27372740
.LSEH_info_ChaCha20_ctr32_avx2:
27382741
.byte 9,0,0,0
27392742
.rva full_handler
27402743
.rva .L8x_body,.L8x_epilogue # HandlerData[]
27412744
___
27422745
$code.=<<___ if ($avx>2);
2746+
.align 4
27432747
.LSEH_info_ChaCha20_avx512:
27442748
.byte 9,0,0,0
27452749
.rva ssse3_handler
27462750
.rva .Lavx512_body,.Lavx512_epilogue # HandlerData[]
27472751
2752+
.align 4
27482753
.LSEH_info_ChaCha20_16x:
27492754
.byte 9,0,0,0
27502755
.rva full_handler

crypto/cipher_extra/asm/aesni-sha1-x86_64.pl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,19 +1530,21 @@ ()
15301530
___
15311531
$code.=<<___;
15321532
.section .xdata
1533-
.align 8
1533+
.align 4
15341534
.LSEH_info_aesni_cbc_sha1_enc_ssse3:
15351535
.byte 9,0,0,0
15361536
.rva ssse3_handler
15371537
.rva .Lprologue_ssse3,.Lepilogue_ssse3 # HandlerData[]
15381538
___
15391539
$code.=<<___ if ($avx);
1540+
.align 4
15401541
.LSEH_info_aesni_cbc_sha1_enc_avx:
15411542
.byte 9,0,0,0
15421543
.rva ssse3_handler
15431544
.rva .Lprologue_avx,.Lepilogue_avx # HandlerData[]
15441545
___
15451546
$code.=<<___ if ($shaext);
1547+
.align 4
15461548
.LSEH_info_aesni_cbc_sha1_enc_shaext:
15471549
.byte 9,0,0,0
15481550
.rva ssse3_handler

crypto/cipher_extra/asm/aesni-sha256-x86_64.pl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,7 @@ ()
17071707
.size se_handler,.-se_handler
17081708
17091709
.section .pdata
1710+
.align 4
17101711
.rva .LSEH_begin_${func}_xop
17111712
.rva .LSEH_end_${func}_xop
17121713
.rva .LSEH_info_${func}_xop
@@ -1727,24 +1728,27 @@ ()
17271728
___
17281729
$code.=<<___;
17291730
.section .xdata
1730-
.align 8
1731+
.align 4
17311732
.LSEH_info_${func}_xop:
17321733
.byte 9,0,0,0
17331734
.rva se_handler
17341735
.rva .Lprologue_xop,.Lepilogue_xop # HandlerData[]
17351736
1737+
.align 4
17361738
.LSEH_info_${func}_avx:
17371739
.byte 9,0,0,0
17381740
.rva se_handler
17391741
.rva .Lprologue_avx,.Lepilogue_avx # HandlerData[]
17401742
___
17411743
$code.=<<___ if ($avx>1);
1744+
.align 4
17421745
.LSEH_info_${func}_avx2:
17431746
.byte 9,0,0,0
17441747
.rva se_handler
17451748
.rva .Lprologue_avx2,.Lepilogue_avx2 # HandlerData[]
17461749
___
17471750
$code.=<<___ if ($shaext);
1751+
.align 4
17481752
.LSEH_info_${func}_shaext:
17491753
.byte 9,0,0,0
17501754
.rva se_handler

crypto/ecdh_extra/ecdh_test.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ TEST(ECDHTest, TestVectors) {
104104
ASSERT_TRUE(EC_KEY_set_public_key(key.get(), pub_key.get()));
105105
ASSERT_TRUE(EC_KEY_check_key(key.get()));
106106

107+
// Check EVP_PKEY_check and EVP_PKEY_public_check
108+
bssl::UniquePtr<EVP_PKEY> ec_pkey(EVP_PKEY_new());
109+
ASSERT_TRUE(ec_pkey);
110+
ASSERT_TRUE(EVP_PKEY_set1_EC_KEY(ec_pkey.get(), key.get()));
111+
bssl::UniquePtr<EVP_PKEY_CTX> ec_key_ctx(
112+
EVP_PKEY_CTX_new(ec_pkey.get(), NULL));
113+
ASSERT_TRUE(ec_key_ctx);
114+
ASSERT_TRUE(EVP_PKEY_check(ec_key_ctx.get()));
115+
ASSERT_TRUE(EVP_PKEY_public_check((ec_key_ctx.get())));
116+
107117
std::vector<uint8_t> actual_z;
108118
// Make |actual_z| larger than expected to ensure |ECDH_compute_key| returns
109119
// the right amount of data.

crypto/evp_extra/evp_asn1.c

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,18 @@
5959
#include <string.h>
6060

6161
#include <openssl/bytestring.h>
62+
#include <openssl/dh.h>
6263
#include <openssl/dsa.h>
6364
#include <openssl/ec_key.h>
6465
#include <openssl/err.h>
6566
#include <openssl/rsa.h>
6667

67-
#include "../fipsmodule/evp/internal.h"
6868
#include "../bytestring/internal.h"
69+
#include "../fipsmodule/dh/internal.h"
70+
#include "../fipsmodule/evp/internal.h"
71+
#include "../fipsmodule/pqdsa/internal.h"
6972
#include "../internal.h"
7073
#include "internal.h"
71-
#include "../fipsmodule/pqdsa/internal.h"
7274

7375
// parse_key_type takes the algorithm cbs sequence |cbs| and extracts the OID.
7476
// The extracted OID will be set on |out_oid| so that it may be used later in
@@ -301,6 +303,82 @@ static EVP_PKEY *old_priv_decode(CBS *cbs, int type) {
301303
return NULL;
302304
}
303305

306+
int EVP_PKEY_check(EVP_PKEY_CTX *ctx) {
307+
if (ctx == NULL) {
308+
OPENSSL_PUT_ERROR(EVP, ERR_R_PASSED_NULL_PARAMETER);
309+
return 0;
310+
}
311+
312+
EVP_PKEY *pkey = ctx->pkey;
313+
314+
if (pkey == NULL) {
315+
OPENSSL_PUT_ERROR(EVP, EVP_R_NO_KEY_SET);
316+
return 0;
317+
}
318+
319+
switch (pkey->type) {
320+
case EVP_PKEY_EC: {
321+
EC_KEY *ec = pkey->pkey.ec;
322+
// For EVP_PKEY_check, ensure the private key exists for EC keys
323+
if (EC_KEY_get0_private_key(ec) == NULL) {
324+
OPENSSL_PUT_ERROR(EVP, EC_R_MISSING_PRIVATE_KEY);
325+
return 0;
326+
}
327+
return EC_KEY_check_key(ec);
328+
}
329+
case EVP_PKEY_RSA:
330+
return RSA_check_key(pkey->pkey.rsa);
331+
default:
332+
OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
333+
return 0;
334+
}
335+
}
336+
337+
int EVP_PKEY_public_check(EVP_PKEY_CTX *ctx) {
338+
if (ctx == NULL) {
339+
OPENSSL_PUT_ERROR(EVP, ERR_R_PASSED_NULL_PARAMETER);
340+
return 0;
341+
}
342+
343+
EVP_PKEY *pkey = ctx->pkey;
344+
345+
if (pkey == NULL) {
346+
OPENSSL_PUT_ERROR(EVP, EVP_R_NO_KEY_SET);
347+
return 0;
348+
}
349+
switch (pkey->type) {
350+
case EVP_PKEY_EC:
351+
return EC_KEY_check_key(pkey->pkey.ec);
352+
case EVP_PKEY_RSA:
353+
return RSA_check_key(pkey->pkey.rsa);
354+
default:
355+
OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
356+
return 0;
357+
}
358+
}
359+
360+
int EVP_PKEY_param_check(EVP_PKEY_CTX *ctx) {
361+
if (ctx == NULL) {
362+
OPENSSL_PUT_ERROR(EVP, ERR_R_PASSED_NULL_PARAMETER);
363+
return 0;
364+
}
365+
366+
EVP_PKEY *pkey = ctx->pkey;
367+
if (pkey == NULL) {
368+
OPENSSL_PUT_ERROR(EVP, EVP_R_NO_KEY_SET);
369+
return 0;
370+
}
371+
372+
int err_flags = 0;
373+
switch (pkey->type) {
374+
case EVP_PKEY_DH:
375+
return DH_check(pkey->pkey.dh, &err_flags) && err_flags == 0;
376+
default:
377+
OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
378+
return 0;
379+
}
380+
}
381+
304382
EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **out, const uint8_t **inp,
305383
long len) {
306384
if (len < 0) {

crypto/evp_extra/evp_extra_test.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,6 +1737,8 @@ TEST(EVPExtraTest, ECKeygen) {
17371737
ASSERT_TRUE(maybe_copy(&ctx));
17381738
EVP_PKEY *raw = nullptr;
17391739
ASSERT_TRUE(EVP_PKEY_paramgen(ctx.get(), &raw));
1740+
// |EVP_PKEY_param_check| does not support EC keys yet.
1741+
ASSERT_FALSE(EVP_PKEY_param_check(ctx.get()));
17401742
bssl::UniquePtr<EVP_PKEY> pkey(raw);
17411743
raw = nullptr;
17421744
ExpectECGroupOnly(pkey.get(), NID_X9_62_prime256v1);
@@ -1801,6 +1803,7 @@ TEST(EVPExtraTest, DHKeygen) {
18011803
ASSERT_TRUE(ctx);
18021804
ASSERT_TRUE(maybe_copy(&ctx));
18031805
ASSERT_TRUE(EVP_PKEY_keygen_init(ctx.get()));
1806+
ASSERT_TRUE(EVP_PKEY_param_check(ctx.get()));
18041807
ASSERT_TRUE(maybe_copy(&ctx));
18051808
EVP_PKEY *raw = nullptr;
18061809
ASSERT_TRUE(EVP_PKEY_keygen(ctx.get(), &raw));
@@ -1853,6 +1856,8 @@ TEST(EVPExtraTest, DHParamgen) {
18531856
EVP_PKEY *raw_pkey = NULL;
18541857
// Generate the parameters
18551858
ASSERT_TRUE(EVP_PKEY_paramgen(ctx.get(), &raw_pkey));
1859+
// Only parameters have been generated, but no key has actually been set.
1860+
EXPECT_FALSE(EVP_PKEY_param_check(ctx.get()));
18561861
bssl::UniquePtr<EVP_PKEY> pkey(raw_pkey);
18571862
ASSERT_TRUE(raw_pkey);
18581863

@@ -1876,6 +1881,7 @@ TEST(EVPExtraTest, DHParamgen) {
18761881
ASSERT_NE(EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx.get(), prime_len), 1);
18771882
// Set the generator
18781883
ASSERT_NE(EVP_PKEY_CTX_set_dh_paramgen_generator(ctx.get(), generator), 1);
1884+
ASSERT_FALSE(EVP_PKEY_param_check(ctx.get()));
18791885
}
18801886

18811887
// Test that |EVP_PKEY_keygen| works for Ed25519.
@@ -2578,6 +2584,16 @@ TEST_P(PerKEMTest, RawKeyOperations) {
25782584
ASSERT_TRUE(pkey_new);
25792585
ASSERT_TRUE(EVP_PKEY_kem_check_key(pkey_new.get()));
25802586

2587+
// Not supported for anything but EC and RSA keys
2588+
bssl::UniquePtr<EVP_PKEY_CTX> kem_key_ctx(
2589+
EVP_PKEY_CTX_new(pkey_new.get(), NULL));
2590+
ASSERT_TRUE(kem_key_ctx);
2591+
EXPECT_FALSE(EVP_PKEY_check(kem_key_ctx.get()));
2592+
EXPECT_FALSE(EVP_PKEY_public_check((kem_key_ctx.get())));
2593+
ASSERT_EQ((uint16_t)ERR_get_error(),
2594+
(uint16_t)EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
2595+
ERR_clear_error();
2596+
25812597
// ---- 5. Test encaps/decaps with new keys ----
25822598
// Create Alice's context with the new key that has both
25832599
// the public and the secret part of the key.

crypto/fipsmodule/CMakeLists.txt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,30 @@ if((((ARCH STREQUAL "x86_64") AND NOT MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) OR
300300
# (gcc supports it since gcc8, clang supports it since clang7)
301301
check_compiler("neon_sha3_check.c" MY_ASSEMBLER_SUPPORTS_NEON_SHA3_EXTENSION "-march=armv8.4-a+sha3")
302302

303-
# Scalar Keccak-x1 assembly from s2n-bignum/mlkem-native
304303
list(APPEND BCM_ASM_SOURCES
304+
# Scalar Keccak-x1 assembly from s2n-bignum/mlkem-native
305305
${S2N_BIGNUM_DIR}/sha3/sha3_keccak_f1600.S
306+
307+
# Batched Keccak-x4 assembly from s2n-bignum
308+
# Scalar version for Neoverse N1
309+
${S2N_BIGNUM_DIR}/sha3/sha3_keccak4_f1600_alt.S
306310
)
307311

308-
# SIMD Keccak-x1 assembly from s2n-bignum/mlkem-native, using SHA3 extension
309312
if(MY_ASSEMBLER_SUPPORTS_NEON_SHA3_EXTENSION)
310-
list(APPEND BCM_ASM_SOURCES ${S2N_BIGNUM_DIR}/sha3/sha3_keccak_f1600_alt.S)
313+
list(APPEND BCM_ASM_SOURCES
314+
# Scalar Keccak-x1 assembly from s2n-bignum/mlkem-native, using SHA3 extension
315+
${S2N_BIGNUM_DIR}/sha3/sha3_keccak_f1600_alt.S
316+
317+
# SIMD versions using SHA3 extension
318+
${S2N_BIGNUM_DIR}/sha3/sha3_keccak2_f1600.S
319+
${S2N_BIGNUM_DIR}/sha3/sha3_keccak4_f1600_alt2.S)
320+
311321
set_source_files_properties(${S2N_BIGNUM_DIR}/sha3/sha3_keccak_f1600_alt.S
312322
PROPERTIES COMPILE_FLAGS "-march=armv8.4-a+sha3")
323+
set_source_files_properties(${S2N_BIGNUM_DIR}/sha3/sha3_keccak2_f1600.S
324+
PROPERTIES COMPILE_FLAGS "-march=armv8.4-a+sha3")
325+
set_source_files_properties(${S2N_BIGNUM_DIR}/sha3/sha3_keccak4_f1600_alt2.S
326+
PROPERTIES COMPILE_FLAGS "-march=armv8.4-a+sha3")
313327
endif()
314328
endif()
315329

0 commit comments

Comments
 (0)