awslabs / aws-c-cal

Aws Crypto Abstraction Layer: Cross-Platform, C99 wrapper for cryptography primitives.
Apache License 2.0
33 stars 36 forks source link

0.6.3+ test fails with openssl3 #166

Closed nunotexbsd closed 9 months ago

nunotexbsd commented 9 months ago

Describe the bug

tests failing on update 0.6.2 -> 0.6.3 (0.6.5 same error):

===>  Performing out-of-source build
/bin/mkdir -p /wrkdirs/usr/ports/security/aws-c-cal/work/.build
-- The C compiler identification is Clang 16.0.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found crypto: /usr/lib/libcrypto.so
-- LibCrypto Include Dir: /usr/include
-- LibCrypto Shared Lib:  /usr/lib/libcrypto.so
-- LibCrypto Static Lib:  /usr/lib/libcrypto.a
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Found Threads: TRUE
-- Performing Test HAS_FPIC_FLAG
-- Performing Test HAS_FPIC_FLAG - Success
-- Performing Test HAS_64BIT_FILE_OFFSET_BY_DEFAULT
-- Performing Test HAS_64BIT_FILE_OFFSET_BY_DEFAULT - Success
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stdbool.h
-- Looking for stdbool.h - found
-- Performing Test HAS_WGNU
-- Performing Test HAS_WGNU - Success
-- Performing Test NO_GNU_EXPR
-- Performing Test NO_GNU_EXPR - Success
-- Performing Test HAVE_SYSCONF
-- Performing Test HAVE_SYSCONF - Success
-- Configuring done (0.5s)
-- Generating done (0.0s)

Test project /wrkdirs/usr/ports/security/aws-c-cal/work/.build
    Start 61: rsa_encryption_roundtrip_pkcs1_from_user
1/5 Test #61: rsa_encryption_roundtrip_pkcs1_from_user .........***Exception: SegFault  0.01 sec
[DEBUG] [2023-10-13T09:42:32Z] [00002a3595012000] [libcrypto_resolve] - searching process and loaded modules
[DEBUG] [2023-10-13T09:42:32Z] [00002a3595012000] [libcrypto_resolve] - did not find aws-lc symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [00002a3595012000] [libcrypto_resolve] - did not find boringssl symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [00002a3595012000] [libcrypto_resolve] - did not find libcrypto 1.0.2 symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [00002a3595012000] [libcrypto_resolve] - found static libcrypto 1.1.1 HMAC symbols
[DEBUG] [2023-10-13T09:42:32Z] [00002a3595012000] [libcrypto_resolve] - found static libcrypto 1.1.1 EVP_MD symbols
***FAILURE*** Expected error but no error occurred; rv=0, aws_last_error=0000 (expected 0004): ***FAILURE*** aws_rsa_key_pair_encrypt(key_pair, algo, plaintext_cur, &ciphertext_short) [s_rsa_encryption_roundtrip_
helper(): /wrkdirs/usr/ports/security/aws-c-cal/work/aws-c-cal-0.6.3/tests/rsa_test.c:40]
[TRACE] [2023-10-13T09:42:32Z] [00002a3595012000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [00002a3595012000] [Unknown] - #  BEGIN MEMTRACE DUMP                                                         #
[TRACE] [2023-10-13T09:42:32Z] [00002a3595012000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [00002a3595012000] [Unknown] - tracer: 5 bytes still allocated in 1 allocations
[TRACE] [2023-10-13T09:42:32Z] [00002a3595012000] [Unknown] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[TRACE] [2023-10-13T09:42:32Z] [00002a3595012000] [Unknown] - Leaks in order of allocation:
[TRACE] [2023-10-13T09:42:32Z] [00002a3595012000] [Unknown] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[TRACE] [2023-10-13T09:42:32Z] [00002a3595012000] [Unknown] - ALLOC 5 bytes
[TRACE] [2023-10-13T09:42:32Z] [00002a3595012000] [Unknown] - ################################################################################
***FAILURE*** Test leaked memory: 1 bytes [s_aws_run_test_case(): /usr/local/include/aws/testing/aws_test_harness.h:480]
***FAILURE*** rsa_encryption_roundtrip_pkcs1_from_user [ ^[[31mFAILED^[[0m ] [s_aws_run_test_case(): /usr/local/include/aws/testing/aws_test_harness.h:497]
[TRACE] [2023-10-13T09:42:32Z] [00002a3595012000] [Unknown] - #  END MEMTRACE DUMP                                                           #
[TRACE] [2023-10-13T09:42:32Z] [00002a3595012000] [Unknown] - ################################################################################

    Start 62: rsa_encryption_roundtrip_oaep_sha256_from_user
2/5 Test #62: rsa_encryption_roundtrip_oaep_sha256_from_user ...***Exception: SegFault  0.01 sec
[DEBUG] [2023-10-13T09:42:32Z] [0000356782612000] [libcrypto_resolve] - searching process and loaded modules
[DEBUG] [2023-10-13T09:42:32Z] [0000356782612000] [libcrypto_resolve] - did not find aws-lc symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [0000356782612000] [libcrypto_resolve] - did not find boringssl symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [0000356782612000] [libcrypto_resolve] - did not find libcrypto 1.0.2 symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [0000356782612000] [libcrypto_resolve] - found static libcrypto 1.1.1 HMAC symbols
[DEBUG] [2023-10-13T09:42:32Z] [0000356782612000] [libcrypto_resolve] - found static libcrypto 1.1.1 EVP_MD symbols
***FAILURE*** Expected error but no error occurred; rv=0, aws_last_error=0000 (expected 0004): ***FAILURE*** aws_rsa_key_pair_encrypt(key_pair, algo, plaintext_cur, &ciphertext_short) [s_rsa_encryption_roundtrip_
helper(): /wrkdirs/usr/ports/security/aws-c-cal/work/aws-c-cal-0.6.3/tests/rsa_test.c:40]
[TRACE] [2023-10-13T09:42:32Z] [0000356782612000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [0000356782612000] [Unknown] - #  BEGIN MEMTRACE DUMP                                                         #
[TRACE] [2023-10-13T09:42:32Z] [0000356782612000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [0000356782612000] [Unknown] - tracer: 5 bytes still allocated in 1 allocations
[TRACE] [2023-10-13T09:42:32Z] [0000356782612000] [Unknown] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[TRACE] [2023-10-13T09:42:32Z] [0000356782612000] [Unknown] - Leaks in order of allocation:
[TRACE] [2023-10-13T09:42:32Z] [0000356782612000] [Unknown] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[TRACE] [2023-10-13T09:42:32Z] [0000356782612000] [Unknown] - ALLOC 5 bytes
[TRACE] [2023-10-13T09:42:32Z] [0000356782612000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [0000356782612000] [Unknown] - #  END MEMTRACE DUMP                                                           #
***FAILURE*** Test leaked memory: 1 bytes [s_aws_run_test_case(): /usr/local/include/aws/testing/aws_test_harness.h:480]
***FAILURE*** rsa_encryption_roundtrip_oaep_sha256_from_user [ ^[[31mFAILED^[[0m ] [s_aws_run_test_case(): /usr/local/include/aws/testing/aws_test_harness.h:497]
[TRACE] [2023-10-13T09:42:32Z] [0000356782612000] [Unknown] - ################################################################################

    Start 63: rsa_encryption_roundtrip_oaep_sha512_from_user
3/5 Test #63: rsa_encryption_roundtrip_oaep_sha512_from_user ...***Exception: SegFault  0.01 sec
[DEBUG] [2023-10-13T09:42:32Z] [0000147209212000] [libcrypto_resolve] - searching process and loaded modules
[DEBUG] [2023-10-13T09:42:32Z] [0000147209212000] [libcrypto_resolve] - did not find aws-lc symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [0000147209212000] [libcrypto_resolve] - did not find boringssl symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [0000147209212000] [libcrypto_resolve] - did not find libcrypto 1.0.2 symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [0000147209212000] [libcrypto_resolve] - found static libcrypto 1.1.1 HMAC symbols
[DEBUG] [2023-10-13T09:42:32Z] [0000147209212000] [libcrypto_resolve] - found static libcrypto 1.1.1 EVP_MD symbols
***FAILURE*** Expected error but no error occurred; rv=0, aws_last_error=0000 (expected 0004): ***FAILURE*** aws_rsa_key_pair_encrypt(key_pair, algo, plaintext_cur, &ciphertext_short) [s_rsa_encryption_roundtrip_
helper(): /wrkdirs/usr/ports/security/aws-c-cal/work/aws-c-cal-0.6.3/tests/rsa_test.c:40]
[TRACE] [2023-10-13T09:42:32Z] [0000147209212000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [0000147209212000] [Unknown] - #  BEGIN MEMTRACE DUMP                                                         #
[TRACE] [2023-10-13T09:42:32Z] [0000147209212000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [0000147209212000] [Unknown] - tracer: 5 bytes still allocated in 1 allocations
[TRACE] [2023-10-13T09:42:32Z] [0000147209212000] [Unknown] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[TRACE] [2023-10-13T09:42:32Z] [0000147209212000] [Unknown] - Leaks in order of allocation:
[TRACE] [2023-10-13T09:42:32Z] [0000147209212000] [Unknown] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[TRACE] [2023-10-13T09:42:32Z] [0000147209212000] [Unknown] - ALLOC 5 bytes
[TRACE] [2023-10-13T09:42:32Z] [0000147209212000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [0000147209212000] [Unknown] - #  END MEMTRACE DUMP                                                           #
***FAILURE*** Test leaked memory: 1 bytes [s_aws_run_test_case(): /usr/local/include/aws/testing/aws_test_harness.h:480]
***FAILURE*** rsa_encryption_roundtrip_oaep_sha512_from_user [ ^[[31mFAILED^[[0m ] [s_aws_run_test_case(): /usr/local/include/aws/testing/aws_test_harness.h:497]
[TRACE] [2023-10-13T09:42:32Z] [0000147209212000] [Unknown] - ################################################################################

    Start 64: rsa_signing_roundtrip_pkcs1_sha256_from_user
4/5 Test #64: rsa_signing_roundtrip_pkcs1_sha256_from_user .....***Failed    0.00 sec
[DEBUG] [2023-10-13T09:42:32Z] [00002a4f52812000] [libcrypto_resolve] - searching process and loaded modules
[DEBUG] [2023-10-13T09:42:32Z] [00002a4f52812000] [libcrypto_resolve] - did not find aws-lc symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [00002a4f52812000] [libcrypto_resolve] - did not find boringssl symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [00002a4f52812000] [libcrypto_resolve] - did not find libcrypto 1.0.2 symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [00002a4f52812000] [libcrypto_resolve] - found static libcrypto 1.1.1 HMAC symbols
[DEBUG] [2023-10-13T09:42:32Z] [00002a4f52812000] [libcrypto_resolve] - found static libcrypto 1.1.1 EVP_MD symbols
***FAILURE*** Incorrect error code; aws_last_error=1c0b (expected 0004): ***FAILURE*** aws_rsa_key_pair_sign_message(key_pair_private, algo, hash_cur, &signature_short) [s_rsa_signing_roundtrip_helper(): /wrkdirs
/usr/ports/security/aws-c-cal/work/aws-c-cal-0.6.3/tests/rsa_test.c:427]
[ERROR] [2023-10-13T09:42:32Z] [00002a4f52812000] [rsa] - EVP_PKEY_sign() failed. returned: 0 extended error:478150835(invalid signature size) aws_error:AWS_ERROR_CAL_CRYPTO_OPERATION_FAILED
[TRACE] [2023-10-13T09:42:32Z] [00002a4f52812000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [00002a4f52812000] [Unknown] - #  BEGIN MEMTRACE DUMP                                                         #
[TRACE] [2023-10-13T09:42:32Z] [00002a4f52812000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [00002a4f52812000] [Unknown] - tracer: 146 bytes still allocated in 2 allocations
[TRACE] [2023-10-13T09:42:32Z] [00002a4f52812000] [Unknown] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[TRACE] [2023-10-13T09:42:32Z] [00002a4f52812000] [Unknown] - Leaks in order of allocation:
[TRACE] [2023-10-13T09:42:32Z] [00002a4f52812000] [Unknown] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[TRACE] [2023-10-13T09:42:32Z] [00002a4f52812000] [Unknown] - ALLOC 141 bytes
[TRACE] [2023-10-13T09:42:32Z] [00002a4f52812000] [Unknown] - ALLOC 5 bytes
[TRACE] [2023-10-13T09:42:32Z] [00002a4f52812000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [00002a4f52812000] [Unknown] - #  END MEMTRACE DUMP                                                           #
***FAILURE*** Test leaked memory: 2 bytes [s_aws_run_test_case(): /usr/local/include/aws/testing/aws_test_harness.h:480]
***FAILURE*** rsa_signing_roundtrip_pkcs1_sha256_from_user [ ^[[31mFAILED^[[0m ] [s_aws_run_test_case(): /usr/local/include/aws/testing/aws_test_harness.h:497]
[TRACE] [2023-10-13T09:42:32Z] [00002a4f52812000] [Unknown] - ################################################################################

    Start 65: rsa_signing_roundtrip_pss_sha256_from_user
5/5 Test #65: rsa_signing_roundtrip_pss_sha256_from_user .......***Failed    0.00 sec
[DEBUG] [2023-10-13T09:42:32Z] [0000236af4c12000] [libcrypto_resolve] - searching process and loaded modules
[DEBUG] [2023-10-13T09:42:32Z] [0000236af4c12000] [libcrypto_resolve] - did not find aws-lc symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [0000236af4c12000] [libcrypto_resolve] - did not find boringssl symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [0000236af4c12000] [libcrypto_resolve] - did not find libcrypto 1.0.2 symbols linked
[DEBUG] [2023-10-13T09:42:32Z] [0000236af4c12000] [libcrypto_resolve] - found static libcrypto 1.1.1 HMAC symbols
[DEBUG] [2023-10-13T09:42:32Z] [0000236af4c12000] [libcrypto_resolve] - found static libcrypto 1.1.1 EVP_MD symbols
***FAILURE*** Incorrect error code; aws_last_error=1c0b (expected 0004): ***FAILURE*** aws_rsa_key_pair_sign_message(key_pair_private, algo, hash_cur, &signature_short) [s_rsa_signing_roundtrip_helper(): /wrkdirs
/usr/ports/security/aws-c-cal/work/aws-c-cal-0.6.3/tests/rsa_test.c:427]
[ERROR] [2023-10-13T09:42:32Z] [0000236af4c12000] [rsa] - EVP_PKEY_sign() failed. returned: 0 extended error:478150835(invalid signature size) aws_error:AWS_ERROR_CAL_CRYPTO_OPERATION_FAILED
[TRACE] [2023-10-13T09:42:32Z] [0000236af4c12000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [0000236af4c12000] [Unknown] - #  BEGIN MEMTRACE DUMP                                                         #
[TRACE] [2023-10-13T09:42:32Z] [0000236af4c12000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [0000236af4c12000] [Unknown] - tracer: 146 bytes still allocated in 2 allocations
[TRACE] [2023-10-13T09:42:32Z] [0000236af4c12000] [Unknown] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[TRACE] [2023-10-13T09:42:32Z] [0000236af4c12000] [Unknown] - Leaks in order of allocation:
[TRACE] [2023-10-13T09:42:32Z] [0000236af4c12000] [Unknown] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[TRACE] [2023-10-13T09:42:32Z] [0000236af4c12000] [Unknown] - ALLOC 141 bytes
[TRACE] [2023-10-13T09:42:32Z] [0000236af4c12000] [Unknown] - ALLOC 5 bytes
[TRACE] [2023-10-13T09:42:32Z] [0000236af4c12000] [Unknown] - ################################################################################
[TRACE] [2023-10-13T09:42:32Z] [0000236af4c12000] [Unknown] - #  END MEMTRACE DUMP                                                           #
***FAILURE*** Test leaked memory: 2 bytes [s_aws_run_test_case(): /usr/local/include/aws/testing/aws_test_harness.h:480]
***FAILURE*** rsa_signing_roundtrip_pss_sha256_from_user [ ^[[31mFAILED^[[0m ] [s_aws_run_test_case(): /usr/local/include/aws/testing/aws_test_harness.h:497]
[TRACE] [2023-10-13T09:42:32Z] [0000236af4c12000] [Unknown] - ################################################################################

0% tests passed, 5 tests failed out of 5

Total Test time (real) =   0.05 sec

The following tests FAILED:
         61 - rsa_encryption_roundtrip_pkcs1_from_user (SEGFAULT)
         62 - rsa_encryption_roundtrip_oaep_sha256_from_user (SEGFAULT)
         63 - rsa_encryption_roundtrip_oaep_sha512_from_user (SEGFAULT)
         64 - rsa_signing_roundtrip_pkcs1_sha256_from_user (Failed)
         65 - rsa_signing_roundtrip_pss_sha256_from_user (Failed)

Expected Behavior

tests ok

Current Behavior

tests fail

Reproduction Steps

ctest --force-new-ctest-process ctest --rerun-failed --output-on-failure

Possible Solution

No response

Additional Information/Context

No response

aws-c-cal version used

0.6.3, 0.6.4, 0.6.5

Compiler and version used

clang 16

Operating System and version

FreeBSD 14.0-BETA5 and CURRENT

DmitriyMusatkin commented 9 months ago

Will look into it. We currently dont support openssl 3 well and dont run CI for it. As you can see from the logs above its missdetecting it as openssl 1.1.1. My initial guess is that its either not picking up md symbols correctly or there are some buffer size handling changes in 3.0.

DmitriyMusatkin commented 9 months ago

Should get resolved by https://github.com/awslabs/aws-c-cal/pull/169.

nunotexbsd commented 9 months ago

@DmitriyMusatkin ,

Fixed. Thanks!