Skip to content

Commit

Permalink
Merge branch 'main' into user/ashdhin/IssueTemplateRegressionCheckbox
Browse files Browse the repository at this point in the history
  • Loading branch information
jmklix authored Oct 25, 2024
2 parents 1cc4853 + fbd5310 commit 4429d6d
Show file tree
Hide file tree
Showing 20 changed files with 172 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
linux-compat:
runs-on: ubuntu-22.04 # latest
strategy:
fail-fast: false
matrix:
image:
- manylinux2014-x64
Expand Down
57 changes: 39 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9)

if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
Expand Down Expand Up @@ -83,40 +83,47 @@ if(BUILD_DEPS)
add_subdirectory(crt/aws-c-common)

if(UNIX AND NOT APPLE AND NOT BYO_CRYPTO)
include(AwsPrebuildDependency)
if(NOT USE_OPENSSL)
set(DISABLE_PERL ON CACHE BOOL "Disable Perl for AWS-LC.")
set(DISABLE_GO ON CACHE BOOL "Disable Go for AWS-LC.")
set(BUILD_LIBSSL OFF CACHE BOOL "Build libssl for AWS-LC.")

# temporarily disable certain warnings as errors for the aws-lc build
set(OLD_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(AWSLC_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")

# temporarily disable certain warnings as errors for the aws-lc build
if(NOT MSVC)
check_c_compiler_flag(-Wno-stringop-overflow HAS_WNO_STRINGOP_OVERFLOW)

if(HAS_WNO_STRINGOP_OVERFLOW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-stringop-overflow")
set(AWSLC_CMAKE_C_FLAGS "${AWSLC_CMAKE_C_FLAGS} -Wno-stringop-overflow")
endif()

check_c_compiler_flag(-Wno-array-parameter HAS_WNO_ARRAY_PARAMETER)

if(HAS_WNO_ARRAY_PARAMETER)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-array-parameter")
set(AWSLC_CMAKE_C_FLAGS "${AWSLC_CMAKE_C_FLAGS} -Wno-array-parameter")
endif()
endif()

add_subdirectory(crt/aws-lc)

# restore previous build flags
set(CMAKE_C_FLAGS "${OLD_CMAKE_C_FLAGS}")

set(SEARCH_LIBCRYPTO OFF CACHE BOOL "Let S2N use libcrypto from AWS-LC.")
else()
set(SEARCH_LIBCRYPTO ON CACHE BOOL "Let S2N search libcrypto in the system.")
# s2n-tls uses libcrypto during its configuration, so we need to prebuild aws-lc.
aws_prebuild_dependency(
DEPENDENCY_NAME AWSLC
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/crt/aws-lc
CMAKE_ARGUMENTS
-DDISABLE_GO=ON
-DDISABLE_PERL=ON
-DBUILD_LIBSSL=OFF
-DBUILD_TESTING=OFF
-DCMAKE_C_FLAGS=${AWSLC_CMAKE_C_FLAGS}
)
endif()

set(UNSAFE_TREAT_WARNINGS_AS_ERRORS OFF CACHE BOOL "Disable warnings-as-errors when building S2N")
add_subdirectory(crt/s2n)
# prebuild s2n-tls.
aws_prebuild_dependency(
DEPENDENCY_NAME S2N
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/crt/s2n
CMAKE_ARGUMENTS
-DUNSAFE_TREAT_WARNINGS_AS_ERRORS=OFF
-DBUILD_TESTING=OFF
)
endif()

add_subdirectory(crt/aws-c-sdkutils)
Expand Down Expand Up @@ -147,6 +154,10 @@ file(GLOB AWS_CRT_AUTH_HEADERS
"include/aws/crt/auth/*.h"
)

file(GLOB AWS_CRT_CHECKSUM_HEADERS
"include/aws/crt/checksum/*.h"
)

file(GLOB AWS_CRT_CRYPTO_HEADERS
"include/aws/crt/crypto/*.h"
)
Expand Down Expand Up @@ -178,6 +189,7 @@ file(GLOB AWS_CRT_CBOR_HEADERS
file(GLOB AWS_CRT_PUBLIC_HEADERS
${AWS_CRT_HEADERS}
${AWS_CRT_AUTH_HEADERS}
${AWS_CRT_CHECKSUM_HEADERS}
${AWS_CRT_CRYPTO_HEADERS}
${AWS_CRT_IO_HEADERS}
${AWS_CRT_IOT_HEADERS}
Expand All @@ -204,6 +216,10 @@ file(GLOB AWS_CRT_AUTH_SRC
"source/auth/*.cpp"
)

file(GLOB AWS_CRT_CHECKSUM_SRC
"source/checksum/*.cpp"
)

file(GLOB AWS_CRT_CRYPTO_SRC
"source/crypto/*.cpp"
)
Expand Down Expand Up @@ -235,6 +251,7 @@ file(GLOB AWS_CRT_CBOR_SRC
file(GLOB AWS_CRT_CPP_SRC
${AWS_CRT_SRC}
${AWS_CRT_AUTH_SRC}
${AWS_CRT_CHECKSUM_SRC}
${AWS_CRT_CRYPTO_SRC}
${AWS_CRT_IO_SRC}
${AWS_CRT_IOT_SRC}
Expand All @@ -248,6 +265,7 @@ if(WIN32)
if(MSVC)
source_group("Header Files\\aws\\crt" FILES ${AWS_CRT_HEADERS})
source_group("Header Files\\aws\\crt\\auth" FILES ${AWS_CRT_AUTH_HEADERS})
source_group("Header Files\\aws\\crt\\checksum" FILES ${AWS_CRT_CHECKSUM_HEADERS})
source_group("Header Files\\aws\\crt\\crypto" FILES ${AWS_CRT_CRYPTO_HEADERS})
source_group("Header Files\\aws\\crt\\io" FILES ${AWS_CRT_IO_HEADERS})
source_group("Header Files\\aws\\iot" FILES ${AWS_CRT_IOT_HEADERS})
Expand All @@ -258,6 +276,7 @@ if(WIN32)

source_group("Source Files" FILES ${AWS_CRT_SRC})
source_group("Source Files\\auth" FILES ${AWS_CRT_AUTH_SRC})
source_group("Source Files\\checksum" FILES ${AWS_CRT_CHECKSUM_SRC})
source_group("Source Files\\crypto" FILES ${AWS_CRT_CRYPTO_SRC})
source_group("Source Files\\io" FILES ${AWS_CRT_IO_SRC})
source_group("Source Files\\iot" FILES ${AWS_CRT_IOT_SRC})
Expand All @@ -283,6 +302,7 @@ endif()

set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD ${CMAKE_CXX_STANDARD})
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON)

aws_prepare_symbol_visibility_args(${PROJECT_NAME} "AWS_CRT_CPP")

Expand Down Expand Up @@ -328,6 +348,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC ${DEP_AWS_LIBS})

install(FILES ${AWS_CRT_HEADERS} DESTINATION "include/aws/crt" COMPONENT Development)
install(FILES ${AWS_CRT_AUTH_HEADERS} DESTINATION "include/aws/crt/auth" COMPONENT Development)
install(FILES ${AWS_CRT_CHECKSUM_HEADERS} DESTINATION "include/aws/crt/crypto" COMPONENT Development)
install(FILES ${AWS_CRT_CRYPTO_HEADERS} DESTINATION "include/aws/crt/crypto" COMPONENT Development)
install(FILES ${AWS_CRT_IO_HEADERS} DESTINATION "include/aws/crt/io" COMPONENT Development)
install(FILES ${AWS_CRT_IOT_HEADERS} DESTINATION "include/aws/iot" COMPONENT Development)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.28.2
0.29.0
2 changes: 1 addition & 1 deletion crt/aws-c-cal
Submodule aws-c-cal updated 2 files
+2 −6 CMakeLists.txt
+1 −1 README.md
2 changes: 1 addition & 1 deletion crt/aws-c-compression
2 changes: 1 addition & 1 deletion crt/aws-c-event-stream
2 changes: 1 addition & 1 deletion crt/aws-c-mqtt
Submodule aws-c-mqtt updated 46 files
+12 −3 .github/workflows/ci.yml
+4 −6 .github/workflows/clang-format.yml
+19 −15 CMakeLists.txt
+3 −3 README.md
+29 −0 bin/elastishadow/CMakeLists.txt
+1,272 −0 bin/elastishadow/main.c
+47 −0 format-check.py
+0 −24 format-check.sh
+12 −0 include/aws/mqtt/mqtt.h
+54 −0 include/aws/mqtt/private/client_impl.h
+24 −0 include/aws/mqtt/private/client_impl_shared.h
+204 −0 include/aws/mqtt/private/mqtt311_listener.h
+220 −0 include/aws/mqtt/private/request-response/protocol_adapter.h
+23 −0 include/aws/mqtt/private/request-response/request_response_client.h
+264 −0 include/aws/mqtt/private/request-response/subscription_manager.h
+2 −0 include/aws/mqtt/private/shared.h
+274 −0 include/aws/mqtt/request-response/request_response_client.h
+3 −0 include/aws/mqtt/v5/mqtt5_client.h
+176 −58 source/client.c
+6 −0 source/client_channel_handler.c
+9 −0 source/client_impl_shared.c
+34 −0 source/mqtt.c
+329 −0 source/mqtt311_listener.c
+2 −3 source/packets.c
+964 −0 source/request-response/protocol_adapter.c
+2,276 −0 source/request-response/request_response_client.c
+822 −0 source/request-response/subscription_manager.c
+1 −1 source/shared.c
+1 −1 source/v5/mqtt5_client.c
+1 −0 source/v5/mqtt5_listener.c
+14 −0 source/v5/mqtt5_to_mqtt3_adapter.c
+135 −3 tests/CMakeLists.txt
+1,784 −0 tests/request-response/protocol_adapter_tests.c
+3,151 −0 tests/request-response/request_response_client_tests.c
+2,877 −0 tests/request-response/subscription_manager_tests.c
+739 −998 tests/v3/connection_state_test.c
+488 −0 tests/v3/mqtt311_listener_test.c
+582 −0 tests/v3/mqtt311_testing_utils.c
+155 −0 tests/v3/mqtt311_testing_utils.h
+51 −2 tests/v3/mqtt_mock_server_handler.c
+18 −0 tests/v3/mqtt_mock_server_handler.h
+22 −42 tests/v5/mqtt5_client_tests.c
+26 −0 tests/v5/mqtt5_testing_utils.c
+20 −0 tests/v5/mqtt5_testing_utils.h
+0 −4 tests/v5/mqtt5_to_mqtt3_adapter_tests.c
+2 −1 tests/v5/mqtt5_topic_alias_tests.c
2 changes: 1 addition & 1 deletion crt/aws-c-sdkutils
2 changes: 1 addition & 1 deletion crt/aws-lc
2 changes: 1 addition & 1 deletion crt/s2n
Submodule s2n updated from 87f4a0 to ffe0bf
39 changes: 39 additions & 0 deletions include/aws/crt/checksum/CRC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/crt/Exports.h>
#include <aws/crt/Types.h>

namespace Aws
{
namespace Crt
{
namespace Checksum
{
/**
* The entry point function to perform a CRC32 (Ethernet, gzip) computation.
* Selects a suitable implementation based on hardware capabilities.
* Pass previousCRC32 if updating a running checksum.
*/
uint32_t AWS_CRT_CPP_API ComputeCRC32(ByteCursor input, uint32_t previousCRC32 = 0) noexcept;

/**
* The entry point function to perform a Castagnoli CRC32c (iSCSI) computation.
* Selects a suitable implementation based on hardware capabilities.
* Pass previousCRC32C if updating a running checksum.
*/
uint32_t AWS_CRT_CPP_API ComputeCRC32C(ByteCursor input, uint32_t previousCRC32C = 0) noexcept;

/**
* The entry point function to perform a CRC64-NVME (a.k.a. CRC64-Rocksoft) computation.
* Selects a suitable implementation based on hardware capabilities.
* Pass previousCRC64NVME if updating a running checksum.
* There are many variants of CRC64 algorithms. This CRC64 variant is bit-reflected (based on
* the non bit-reflected polynomial 0xad93d23594c93659) and inverts the CRC input and output bits.
*/
uint64_t AWS_CRT_CPP_API ComputeCRC64NVME(ByteCursor input, uint64_t previousCRC64NVME = 0) noexcept;
} // namespace Checksum
} // namespace Crt
} // namespace Aws
2 changes: 1 addition & 1 deletion include/aws/crt/crypto/Hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ namespace Aws

/**
* Complete the hash computation and write the final digest to output.
* This cannote be called more than once.
* This cannot be called more than once.
* If truncate_to is something other than 0, the output must be truncated to that number of bytes.
* Raise an AWS error and return false to indicate failure.
*/
Expand Down
32 changes: 32 additions & 0 deletions source/checksum/CRC.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/crt/checksum/CRC.h>

#include <aws/checksums/crc.h>

namespace Aws
{
namespace Crt
{
namespace Checksum
{
uint32_t ComputeCRC32(ByteCursor input, uint32_t previousCRC32) noexcept
{
return aws_checksums_crc32_ex(input.ptr, input.len, previousCRC32);
}

uint32_t ComputeCRC32C(ByteCursor input, uint32_t previousCRC32C) noexcept
{
return aws_checksums_crc32c_ex(input.ptr, input.len, previousCRC32C);
}

uint64_t ComputeCRC64NVME(ByteCursor input, uint64_t previousCRC64NVME) noexcept
{
return aws_checksums_crc64nvme_ex(input.ptr, input.len, previousCRC64NVME);
}

} // namespace Checksum
} // namespace Crt
} // namespace Aws
46 changes: 46 additions & 0 deletions tests/CRCTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/crt/Api.h>
#include <aws/crt/checksum/CRC.h>
#include <aws/testing/aws_test_harness.h>

static int s_TestCRC32Piping(struct aws_allocator *allocator, void *)
{
Aws::Crt::ApiHandle apiHandle(allocator);
uint8_t data[32] = {0};

Aws::Crt::ByteCursor dataCur = aws_byte_cursor_from_array(data, sizeof(data));

ASSERT_UINT_EQUALS(0x190A55AD, Aws::Crt::Checksum::ComputeCRC32(dataCur));

return AWS_OP_SUCCESS;
}
AWS_TEST_CASE(CRC32Piping, s_TestCRC32Piping)

static int s_TestCRC32CPiping(struct aws_allocator *allocator, void *)
{
Aws::Crt::ApiHandle apiHandle(allocator);
uint8_t data[32] = {0};

Aws::Crt::ByteCursor dataCur = aws_byte_cursor_from_array(data, sizeof(data));

ASSERT_UINT_EQUALS(0x8A9136AA, Aws::Crt::Checksum::ComputeCRC32C(dataCur));

return AWS_OP_SUCCESS;
}
AWS_TEST_CASE(CRC32CPiping, s_TestCRC32CPiping)

static int s_TestCRC64NVMEPiping(struct aws_allocator *allocator, void *)
{
Aws::Crt::ApiHandle apiHandle(allocator);
uint8_t data[32] = {0};

Aws::Crt::ByteCursor dataCur = aws_byte_cursor_from_array(data, sizeof(data));

ASSERT_UINT_EQUALS(0xCF3473434D4ECF3B, Aws::Crt::Checksum::ComputeCRC64NVME(dataCur));

return AWS_OP_SUCCESS;
}
AWS_TEST_CASE(CRC64NVMEPiping, s_TestCRC64NVMEPiping)

0 comments on commit 4429d6d

Please sign in to comment.