Skip to content

Commit 3008821

Browse files
authored
Merge branch 'aws:main' into sha3_absorb_squeeze
2 parents e61be0d + 71809b1 commit 3008821

File tree

16 files changed

+50
-23
lines changed

16 files changed

+50
-23
lines changed

CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "GNU")
118118
set(GCC 1)
119119
endif()
120120

121-
if (UNIX AND NOT APPLE)
121+
if (NOT WIN32 AND NOT APPLE)
122122
include(GNUInstallDirs)
123123
elseif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
124124
set(CMAKE_INSTALL_LIBDIR "lib")
@@ -145,7 +145,7 @@ if(NOT DISABLE_PERL)
145145
find_package(Perl REQUIRED)
146146
endif()
147147

148-
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND NOT CMAKE_CROSSCOMPILING)
148+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
149149
find_package(PkgConfig QUIET)
150150
if (PkgConfig_FOUND)
151151
pkg_check_modules(LIBUNWIND libunwind-generic)
@@ -737,7 +737,7 @@ if(FIPS)
737737
message(FATAL_ERROR "Building AWS-LC for FIPS requires Go and Perl")
738738
endif()
739739

740-
if(NOT BUILD_SHARED_LIBS AND NOT (UNIX AND NOT APPLE))
740+
if(NOT BUILD_SHARED_LIBS AND NOT (NOT WIN32 AND NOT APPLE))
741741
message(FATAL_ERROR "Static FIPS build of AWS-LC is suported only on Linux")
742742
endif()
743743

crypto/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function(msbuild_aarch64_asm)
4444
endfunction()
4545

4646
if(NOT OPENSSL_NO_ASM)
47-
if(UNIX)
47+
if(NOT WIN32)
4848
if(ARCH STREQUAL "aarch64")
4949
# The "armx" Perl scripts look for "64" in the style argument
5050
# in order to decide whether to generate 32- or 64-bit asm.
@@ -186,7 +186,7 @@ else()
186186
set(ASSEMBLY_SOURCE ${GENERATE_CODE_ROOT}/ios-arm/crypto/)
187187
elseif(APPLE)
188188
set(ASSEMBLY_SOURCE ${GENERATE_CODE_ROOT}/mac-${ARCH}/crypto/)
189-
elseif(UNIX)
189+
elseif(NOT WIN32)
190190
if(${ARCH} STREQUAL "generic")
191191
message(STATUS "Detected generic linux platform. No assembly files will be included.")
192192
else()

crypto/crypto_test.cc

+8
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ TEST(CryptoTest, Strndup) {
7373
EXPECT_STREQ("", str.get());
7474
}
7575

76+
TEST(CryptoTest, aws_lc_assert_entropy_cpu_jitter) {
77+
#if defined(FIPS_ENTROPY_SOURCE_JITTER_CPU)
78+
ASSERT_EQ(1, FIPS_is_entropy_cpu_jitter());
79+
#else
80+
ASSERT_EQ(0, FIPS_is_entropy_cpu_jitter());
81+
#endif
82+
}
83+
7684
TEST(CryptoTest, OPENSSL_hexstr2buf) {
7785
const char *test_cases[][2] = {{"a2", "\xa2"},
7886
{"a213", "\xa2\x13"},

crypto/fipsmodule/ml_kem/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ that initialize a given structure with values corresponding to a parameter set.
1212
- `symmetric-shake.c`: unnecessary include of fips202.h is removed.
1313
- `api.h`: `pqcrystals` prefix substituted with `ml_kem` (to be able to build alongside `crypto/kyber`).
1414
- `poly.c`: the `poly_frommsg` function was modified to address the constant-time issue described [here](https://github.com/pq-crystals/kyber/commit/9b8d30698a3e7449aeb34e62339d4176f11e3c6c).
15+
- All internal header files were updated with unique `ML_KEM_*` include guards.
1516

1617
**Testing.** The KATs were obtained from an independent implementation of ML-KEM written in SPARK Ada subset: https://github.com/awslabs/LibMLKEM.

crypto/fipsmodule/ml_kem/ml_kem_ref/cbd.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef CBD_H
2-
#define CBD_H
1+
#ifndef ML_KEM_CBD_H
2+
#define ML_KEM_CBD_H
33

44
#include <stdint.h>
55
#include "params.h"

crypto/fipsmodule/ml_kem/ml_kem_ref/indcpa.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef INDCPA_H
2-
#define INDCPA_H
1+
#ifndef ML_KEM_INDCPA_H
2+
#define ML_KEM_INDCPA_H
33

44
#include <stdint.h>
55
#include "params.h"

crypto/fipsmodule/ml_kem/ml_kem_ref/ntt.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef NTT_H
2-
#define NTT_H
1+
#ifndef ML_KEM_NTT_H
2+
#define ML_KEM_NTT_H
33

44
#include <stdint.h>
55
#include "params.h"

crypto/fipsmodule/ml_kem/ml_kem_ref/params.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef PARAMS_H
2-
#define PARAMS_H
1+
#ifndef ML_KEM_PARAMS_H
2+
#define ML_KEM_PARAMS_H
33

44
#include <openssl/base.h>
55

crypto/fipsmodule/ml_kem/ml_kem_ref/poly.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef POLY_H
2-
#define POLY_H
1+
#ifndef ML_KEM_POLY_H
2+
#define ML_KEM_POLY_H
33

44
#include <stdint.h>
55
#include "params.h"

crypto/fipsmodule/ml_kem/ml_kem_ref/polyvec.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef POLYVEC_H
2-
#define POLYVEC_H
1+
#ifndef ML_KEM_POLYVEC_H
2+
#define ML_KEM_POLYVEC_H
33

44
#include <stdint.h>
55
#include "params.h"

crypto/fipsmodule/ml_kem/ml_kem_ref/reduce.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef REDUCE_H
2-
#define REDUCE_H
1+
#ifndef ML_KEM_REDUCE_H
2+
#define ML_KEM_REDUCE_H
33

44
#include <stdint.h>
55
#include "params.h"

crypto/fipsmodule/ml_kem/ml_kem_ref/symmetric.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef SYMMETRIC_H
2-
#define SYMMETRIC_H
1+
#ifndef ML_KEM_SYMMETRIC_H
2+
#define ML_KEM_SYMMETRIC_H
33

44
#include <stddef.h>
55
#include <stdint.h>

crypto/fipsmodule/ml_kem/ml_kem_ref/verify.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef VERIFY_H
2-
#define VERIFY_H
1+
#ifndef ML_KEM_VERIFY_H
2+
#define ML_KEM_VERIFY_H
33

44
#include <stddef.h>
55
#include <stdint.h>

crypto/fipsmodule/self_check/fips.c

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ int FIPS_mode(void) {
2828
#endif
2929
}
3030

31+
int FIPS_is_entropy_cpu_jitter(void) {
32+
#if defined(FIPS_ENTROPY_SOURCE_JITTER_CPU)
33+
return 1;
34+
#else
35+
return 0;
36+
#endif
37+
}
38+
3139
int FIPS_mode_set(int on) { return on == FIPS_mode(); }
3240

3341
#if defined(BORINGSSL_FIPS_140_3)

include/openssl/crypto.h

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ OPENSSL_EXPORT void armv8_enable_dit(void);
117117
// which case it returns one.
118118
OPENSSL_EXPORT int FIPS_mode(void);
119119

120+
// FIPS_is_entropy_cpu_jitter returns 1 if CPU jitter is used as the entropy source
121+
// for AWS-LC. Otherwise, returns 0;
122+
OPENSSL_EXPORT int FIPS_is_entropy_cpu_jitter(void);
123+
120124
// fips_counter_t denotes specific APIs/algorithms. A counter is maintained for
121125
// each in FIPS mode so that tests can be written to assert that the expected,
122126
// FIPS functions are being called by a certain peice of code.

ssl/test/bssl_shim.cc

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ OPENSSL_MSVC_PRAGMA(warning(pop))
3131
#endif
3232

3333
#include <assert.h>
34+
#include <errno.h>
3435

3536
#ifndef __STDC_FORMAT_MACROS
3637
#define __STDC_FORMAT_MACROS
@@ -986,6 +987,11 @@ static bool DoConnection(bssl::UniquePtr<SSL_SESSION> *out_session,
986987
int ssl_err = SSL_get_error(ssl.get(), -1);
987988
if (ssl_err != SSL_ERROR_NONE) {
988989
fprintf(stderr, "SSL error: %s\n", SSL_error_description(ssl_err));
990+
if (ssl_err == SSL_ERROR_SYSCALL) {
991+
int err = errno;
992+
fprintf(stderr, "Error occurred: errno = %d, description = %s\n", err, strerror(err));
993+
994+
}
989995
}
990996
return false;
991997
}

0 commit comments

Comments
 (0)