aws-crt 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/VERSION +1 -1
- data/aws-crt-ffi/CMakeLists.txt +49 -41
- data/aws-crt-ffi/crt/aws-c-auth/CMakeLists.txt +0 -10
- data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/credentials.h +3 -2
- data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/private/credentials_utils.h +4 -4
- data/aws-crt-ffi/crt/aws-c-auth/source/auth.c +1 -14
- data/aws-crt-ffi/crt/aws-c-auth/source/aws_imds_client.c +206 -68
- data/aws-crt-ffi/crt/aws-c-auth/source/aws_signing.c +5 -0
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_cached.c +6 -6
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_default_chain.c +16 -1
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_ecs.c +0 -1
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_process.c +0 -1
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_sts_web_identity.c +0 -1
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_x509.c +10 -7
- data/aws-crt-ffi/crt/aws-c-auth/source/credentials_utils.c +35 -26
- data/aws-crt-ffi/crt/aws-c-auth/source/signable_chunk.c +3 -2
- data/aws-crt-ffi/crt/aws-c-auth/tests/CMakeLists.txt +3 -2
- data/aws-crt-ffi/crt/aws-c-auth/tests/aws_imds_client_test.c +1 -0
- data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_provider_ecs_tests.c +3 -0
- data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_provider_process_tests.c +65 -16
- data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_tests.c +125 -0
- data/aws-crt-ffi/crt/aws-c-auth/tests/sigv4_signing_tests.c +68 -46
- data/aws-crt-ffi/crt/aws-c-cal/CMakeLists.txt +8 -3
- data/aws-crt-ffi/crt/aws-c-cal/bin/run_x_platform_fuzz_corpus/main.c +9 -0
- data/aws-crt-ffi/crt/aws-c-cal/builder.json +11 -3
- data/aws-crt-ffi/crt/aws-c-cal/cmake/aws-c-cal-config.cmake +14 -5
- data/aws-crt-ffi/crt/aws-c-cal/source/darwin/securityframework_ecc.c +6 -6
- data/aws-crt-ffi/crt/aws-c-cal/source/windows/bcrypt_ecc.c +12 -12
- data/aws-crt-ffi/crt/aws-c-cal/tests/test_case_helper.h +14 -14
- data/aws-crt-ffi/crt/aws-c-common/CMakeLists.txt +21 -1
- data/aws-crt-ffi/crt/aws-c-common/README.md +8 -0
- data/aws-crt-ffi/crt/aws-c-common/cmake/AwsCFlags.cmake +20 -5
- data/aws-crt-ffi/crt/aws-c-common/cmake/AwsFeatureTests.cmake +7 -1
- data/aws-crt-ffi/crt/aws-c-common/format-check.sh +1 -1
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/byte_buf.h +14 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/config.h.in +1 -0
- data/aws-crt-ffi/crt/{aws-c-auth/include/aws/auth → aws-c-common/include/aws/common}/external/cJSON.h +82 -74
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/json.h +335 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/logging.h +1 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/math.inl +2 -2
- data/aws-crt-ffi/crt/aws-c-common/include/aws/common/private/json_impl.h +22 -0
- data/aws-crt-ffi/crt/aws-c-common/include/aws/testing/aws_test_harness.h +2 -0
- data/aws-crt-ffi/crt/aws-c-common/source/byte_buf.c +36 -0
- data/aws-crt-ffi/crt/aws-c-common/source/common.c +5 -2
- data/aws-crt-ffi/crt/aws-c-common/source/external/cJSON.c +3113 -0
- data/aws-crt-ffi/crt/aws-c-common/source/file.c +9 -0
- data/aws-crt-ffi/crt/aws-c-common/source/json.c +348 -0
- data/aws-crt-ffi/crt/aws-c-common/source/logging.c +7 -2
- data/aws-crt-ffi/crt/aws-c-common/source/posix/system_info.c +8 -0
- data/aws-crt-ffi/crt/aws-c-common/source/ref_count.c +3 -1
- data/aws-crt-ffi/crt/aws-c-common/source/windows/file.c +47 -0
- data/aws-crt-ffi/crt/aws-c-common/source/windows/system_info.c +2 -1
- data/aws-crt-ffi/crt/aws-c-common/tests/CMakeLists.txt +5 -0
- data/aws-crt-ffi/crt/aws-c-common/tests/byte_buf_test.c +69 -0
- data/aws-crt-ffi/crt/aws-c-common/tests/json_test.c +134 -0
- data/aws-crt-ffi/crt/aws-c-common/tests/memtrace_test.c +6 -2
- data/aws-crt-ffi/crt/aws-c-event-stream/README.md +18 -35
- data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream.h +21 -2
- data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream_rpc_client.h +14 -2
- data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream_rpc_server.h +13 -0
- data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/private/event_stream_rpc_priv.h +7 -7
- data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream.c +257 -141
- data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_channel_handler.c +1 -1
- data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_rpc_client.c +31 -8
- data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_rpc_server.c +63 -10
- data/aws-crt-ffi/crt/aws-c-event-stream/tests/CMakeLists.txt +2 -0
- data/aws-crt-ffi/crt/aws-c-event-stream/tests/event_stream_rpc_client_connection_test.c +157 -106
- data/aws-crt-ffi/crt/aws-c-event-stream/tests/event_stream_rpc_server_connection_test.c +168 -1
- data/aws-crt-ffi/crt/aws-c-event-stream/tests/message_deserializer_test.c +4 -2
- data/aws-crt-ffi/crt/aws-c-http/CMakeLists.txt +1 -0
- data/aws-crt-ffi/crt/aws-c-http/README.md +8 -0
- data/aws-crt-ffi/crt/aws-c-http/bin/elasticurl/main.c +1 -1
- data/aws-crt-ffi/crt/aws-c-http/builder.json +4 -3
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/connection.h +8 -1
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/connection_manager.h +45 -1
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/http2_stream_manager.h +63 -12
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/connection_impl.h +2 -1
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_connection.h +20 -2
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_frames.h +1 -0
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_stream.h +42 -13
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/http2_stream_manager_impl.h +17 -0
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/http_impl.h +3 -0
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/random_access_set.h +10 -3
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/request_response_impl.h +3 -17
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/request_response.h +108 -4
- data/aws-crt-ffi/crt/aws-c-http/include/aws/http/statistics.h +22 -0
- data/aws-crt-ffi/crt/aws-c-http/source/connection.c +8 -3
- data/aws-crt-ffi/crt/aws-c-http/source/connection_manager.c +22 -3
- data/aws-crt-ffi/crt/aws-c-http/source/connection_monitor.c +32 -14
- data/aws-crt-ffi/crt/aws-c-http/source/h1_connection.c +14 -0
- data/aws-crt-ffi/crt/aws-c-http/source/h1_encoder.c +7 -4
- data/aws-crt-ffi/crt/aws-c-http/source/h2_connection.c +161 -45
- data/aws-crt-ffi/crt/aws-c-http/source/h2_decoder.c +37 -8
- data/aws-crt-ffi/crt/aws-c-http/source/h2_frames.c +13 -1
- data/aws-crt-ffi/crt/aws-c-http/source/h2_stream.c +345 -87
- data/aws-crt-ffi/crt/aws-c-http/source/hpack.c +3 -0
- data/aws-crt-ffi/crt/aws-c-http/source/http.c +3 -0
- data/aws-crt-ffi/crt/aws-c-http/source/http2_stream_manager.c +266 -39
- data/aws-crt-ffi/crt/aws-c-http/source/random_access_set.c +9 -3
- data/aws-crt-ffi/crt/aws-c-http/source/request_response.c +80 -20
- data/aws-crt-ffi/crt/aws-c-http/source/statistics.c +11 -0
- data/aws-crt-ffi/crt/aws-c-http/tests/CMakeLists.txt +28 -1
- data/aws-crt-ffi/crt/aws-c-http/tests/fuzz/fuzz_h2_decoder_correct.c +5 -3
- data/aws-crt-ffi/crt/aws-c-http/tests/h2_test_helper.c +133 -29
- data/aws-crt-ffi/crt/aws-c-http/tests/h2_test_helper.h +6 -0
- data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/README.md +40 -0
- data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/non_tls_server.py +56 -0
- data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/server.py +329 -0
- data/aws-crt-ffi/crt/aws-c-http/tests/test_connection_manager.c +1 -1
- data/aws-crt-ffi/crt/aws-c-http/tests/test_connection_monitor.c +2 -2
- data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_client.c +47 -34
- data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_encoder.c +4 -4
- data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_server.c +15 -12
- data/aws-crt-ffi/crt/aws-c-http/tests/test_h2_client.c +582 -25
- data/aws-crt-ffi/crt/aws-c-http/tests/test_h2_encoder.c +3 -3
- data/aws-crt-ffi/crt/aws-c-http/tests/test_localhost_integ.c +530 -0
- data/aws-crt-ffi/crt/aws-c-http/tests/test_stream_manager.c +459 -67
- data/aws-crt-ffi/crt/aws-c-io/CMakeLists.txt +4 -0
- data/aws-crt-ffi/crt/aws-c-io/builder.json +3 -2
- data/aws-crt-ffi/crt/aws-c-io/include/aws/io/channel.h +21 -0
- data/aws-crt-ffi/crt/aws-c-io/include/aws/io/io.h +3 -0
- data/aws-crt-ffi/crt/aws-c-io/include/aws/io/socket.h +6 -0
- data/aws-crt-ffi/crt/aws-c-io/include/aws/io/stream.h +35 -5
- data/aws-crt-ffi/crt/aws-c-io/include/aws/io/tls_channel_handler.h +211 -15
- data/aws-crt-ffi/crt/aws-c-io/source/channel.c +56 -30
- data/aws-crt-ffi/crt/aws-c-io/source/darwin/secure_transport_tls_channel_handler.c +0 -24
- data/aws-crt-ffi/crt/aws-c-io/source/io.c +9 -0
- data/aws-crt-ffi/crt/aws-c-io/source/{pkcs11.c → pkcs11_lib.c} +162 -22
- data/aws-crt-ffi/crt/aws-c-io/source/pkcs11_private.h +18 -20
- data/aws-crt-ffi/crt/aws-c-io/source/pkcs11_tls_op_handler.c +221 -0
- data/aws-crt-ffi/crt/aws-c-io/source/posix/socket.c +135 -81
- data/aws-crt-ffi/crt/aws-c-io/source/retry_strategy.c +12 -8
- data/aws-crt-ffi/crt/aws-c-io/source/s2n/s2n_tls_channel_handler.c +252 -215
- data/aws-crt-ffi/crt/aws-c-io/source/stream.c +65 -82
- data/aws-crt-ffi/crt/aws-c-io/source/tls_channel_handler.c +188 -57
- data/aws-crt-ffi/crt/aws-c-io/source/windows/iocp/socket.c +271 -256
- data/aws-crt-ffi/crt/aws-c-io/tests/CMakeLists.txt +21 -12
- data/aws-crt-ffi/crt/aws-c-io/tests/channel_test.c +32 -4
- data/aws-crt-ffi/crt/aws-c-io/tests/io_lib_test.c +37 -0
- data/aws-crt-ffi/crt/aws-c-io/tests/pkcs11_test.c +412 -93
- data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.crt +15 -0
- data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.key +5 -0
- data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.p12 +0 -0
- data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.p8 +5 -0
- data/aws-crt-ffi/crt/aws-c-io/tests/resources/generateCerts.sh +24 -15
- data/aws-crt-ffi/crt/aws-c-io/tests/socket_test.c +72 -1
- data/aws-crt-ffi/crt/s2n/CMakeLists.txt +6 -1
- data/aws-crt-ffi/crt/s2n/bindings/rust/Cargo.toml +1 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/generate/src/main.rs +105 -82
- data/aws-crt-ffi/crt/s2n/bindings/rust/generate.sh +1 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/Cargo.toml +2 -2
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/src/raw/config.rs +1 -1
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/Cargo.toml +1 -1
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/build.rs +84 -30
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/src/lib.rs +4 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/Cargo.toml +21 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/certs/cert.pem +14 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/certs/key.pem +8 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/client.rs +45 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/server.rs +60 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/src/lib.rs +150 -0
- data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/tests/handshake.rs +51 -0
- data/aws-crt-ffi/crt/s2n/crypto/s2n_drbg.c +98 -77
- data/aws-crt-ffi/crt/s2n/crypto/s2n_drbg.h +10 -7
- data/aws-crt-ffi/crt/s2n/crypto/s2n_openssl.h +2 -0
- data/aws-crt-ffi/crt/s2n/error/s2n_errno.c +1 -1
- data/aws-crt-ffi/crt/s2n/error/s2n_errno.h +1 -0
- data/aws-crt-ffi/crt/s2n/s2n.mk +7 -0
- data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/repository.py +233 -0
- data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/setup-proof.py +8 -7
- data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/setup.py +17 -18
- data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/util.py +41 -23
- data/aws-crt-ffi/crt/s2n/tests/fuzz/LD_PRELOAD/global_overrides.c +3 -3
- data/aws-crt-ffi/crt/s2n/tests/integration/s2n_client_endpoint_handshake_test.py +2 -2
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/Makefile +13 -42
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/README.md +6 -1
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/common.py +118 -53
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/configuration.py +108 -88
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/conftest.py +6 -3
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/constants.py +6 -4
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/fixtures.py +21 -12
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/global_flags.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/processes.py +62 -19
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/providers.py +304 -48
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_client_authentication.py +20 -11
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_cross_compatibility.py +41 -17
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_dynamic_record_sizes.py +6 -3
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_early_data.py +105 -48
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_external_psk.py +160 -76
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_fragmentation.py +59 -26
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_happy_path.py +42 -28
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_hello_retry_requests.py +33 -13
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_key_update.py +29 -11
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_ocsp.py +138 -0
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_pq_handshake.py +103 -36
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_session_resumption.py +52 -25
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_signature_algorithms.py +47 -21
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_sni_match.py +13 -9
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_sslyze.py +88 -17
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_version_negotiation.py +71 -22
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_well_known_endpoints.py +4 -3
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/tox.ini +1 -0
- data/aws-crt-ffi/crt/s2n/tests/integrationv2/utils.py +50 -15
- data/aws-crt-ffi/crt/s2n/tests/litani/CHANGELOG +131 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/CONTRIBUTING.md +16 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/README.md +36 -14
- data/aws-crt-ffi/crt/s2n/tests/litani/THIRD-PARTY +205 -41
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/bin/build-html-doc +7 -7
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/configure +27 -23
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-add-job.scdoc +7 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-dump-run.scdoc +7 -5
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-transform-jobs.scdoc +248 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani.scdoc +2 -2
- data/aws-crt-ffi/crt/s2n/tests/litani/doc/templates/index.jinja.html +4 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/README +12 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/original-run.sh +52 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/run-all.py +71 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/README +13 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-1.sh +34 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-2.sh +35 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-3.sh +34 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-all.py +60 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/README.md +10 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/assumptions.html +42 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/file.dat +7 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/histogram.dat +7 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-1.sh +41 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-2.sh +47 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-3.sh +41 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-all.py +34 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib-table.py +40 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib.plt +5 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib.py +32 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin-output.py +40 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin.plt +5 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin.py +30 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/templates/fib-table.jinja.html +45 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/templates/sin-output.jinja.html +30 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/add_job.py +55 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/graph.py +2 -2
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/litani.py +6 -1
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/litani_report.py +18 -21
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/ninja.py +2 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/run_printer.py +26 -7
- data/aws-crt-ffi/crt/s2n/tests/litani/lib/transform_jobs.py +84 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/litani +28 -33
- data/aws-crt-ffi/crt/s2n/tests/litani/script/release +220 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/templates/dashboard.jinja.html +78 -15
- data/aws-crt-ffi/crt/s2n/tests/litani/templates/pipeline.jinja.html +21 -5
- data/aws-crt-ffi/crt/s2n/tests/litani/test/README +15 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/run +56 -33
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/custom_stages.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/cwd.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/dump_run.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/graph_line_break.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/html_node.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/job_id_env.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/multiproc_dump_run.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_pool_serialize.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_pool_serialize_graph.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out_timeout_ignored.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out_timeout_ok.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pipeline_order.py +53 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pool_serialize.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pool_serialize_graph.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/single_pool.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess_multi_shell.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess_shell.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_timeout_ignored.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_timeout_ok.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_delete_job.py +54 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_modify_job.py +46 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_no_change_job.py +44 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/zero_pool.py +1 -0
- data/aws-crt-ffi/crt/s2n/tests/litani/test/run +82 -12
- data/aws-crt-ffi/crt/s2n/tests/s2n_test.h +58 -33
- data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_key_schedule_testlib.c +18 -6
- data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_pq_kat_test_utils.c +4 -4
- data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_testlib.h +2 -0
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_client_hello_retry_test.c +66 -2
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_connection_test.c +1 -1
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_drbg_test.c +34 -14
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_fork_generation_number_test.c +28 -5
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_mem_usage_test.c +6 -0
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_override_openssl_random_test.c +1 -1
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_random_test.c +60 -41
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_self_talk_broken_pipe_test.c +2 -2
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_handshake_early_data_test.c +3 -1
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_hybrid_shared_secret_test.c +9 -1
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_key_schedule_rfc8448_test.c +31 -130
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_key_schedule_test.c +2 -4
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_pq_handshake_test.c +11 -6
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_secrets_rfc8448_test.c +19 -21
- data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_secrets_test.c +109 -60
- data/aws-crt-ffi/crt/s2n/tls/s2n_config.c +1 -0
- data/aws-crt-ffi/crt/s2n/tls/s2n_config.h +1 -1
- data/aws-crt-ffi/crt/s2n/tls/s2n_connection.c +29 -24
- data/aws-crt-ffi/crt/s2n/tls/s2n_connection.h +5 -5
- data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_hashes.h +1 -7
- data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_io.c +2 -0
- data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_transcript.c +0 -44
- data/aws-crt-ffi/crt/s2n/tls/s2n_internal.h +0 -1
- data/aws-crt-ffi/crt/s2n/tls/s2n_quic_support.h +1 -1
- data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_key_schedule.c +1 -2
- data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_secrets.c +84 -44
- data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_secrets.h +3 -9
- data/aws-crt-ffi/crt/s2n/utils/s2n_blob.h +15 -8
- data/aws-crt-ffi/crt/s2n/utils/s2n_fork_detection.c +2 -6
- data/aws-crt-ffi/crt/s2n/utils/s2n_random.c +9 -9
- data/aws-crt-ffi/src/input_stream.c +32 -15
- data/ext/compile.rb +13 -5
- data/lib/aws-crt/platforms.rb +14 -5
- data/lib/aws-crt/string_blob.rb +3 -3
- metadata +61 -7
- data/aws-crt-ffi/crt/aws-c-auth/source/external/cJSON.c +0 -2987
- data/aws-crt-ffi/crt/aws-c-auth/tests/external/cJSON.c +0 -2986
- data/aws-crt-ffi/crt/aws-c-io/tests/error_test.c +0 -20
@@ -11,13 +11,10 @@
|
|
11
11
|
#include <aws/io/event_loop.h>
|
12
12
|
#include <aws/io/file_utils.h>
|
13
13
|
#include <aws/io/logging.h>
|
14
|
-
#include <aws/io/pkcs11.h>
|
15
14
|
#include <aws/io/private/pki_utils.h>
|
16
15
|
#include <aws/io/private/tls_channel_handler_shared.h>
|
17
16
|
#include <aws/io/statistics.h>
|
18
17
|
|
19
|
-
#include "../pkcs11_private.h"
|
20
|
-
|
21
18
|
#include <aws/common/encoding.h>
|
22
19
|
#include <aws/common/string.h>
|
23
20
|
#include <aws/common/task_scheduler.h>
|
@@ -67,7 +64,6 @@ struct s2n_handler {
|
|
67
64
|
NEGOTIATION_SUCCEEDED,
|
68
65
|
} state;
|
69
66
|
struct s2n_delayed_shutdown_task delayed_shutdown_task;
|
70
|
-
struct aws_channel_task async_pkey_task;
|
71
67
|
};
|
72
68
|
|
73
69
|
struct s2n_ctx {
|
@@ -77,25 +73,29 @@ struct s2n_ctx {
|
|
77
73
|
/* Only used in special circumstances (ex: have cert but no key, because key is in PKCS#11) */
|
78
74
|
struct s2n_cert_chain_and_key *custom_cert_chain_and_key;
|
79
75
|
|
80
|
-
|
81
|
-
*
|
82
|
-
*
|
83
|
-
*
|
84
|
-
*
|
85
|
-
* 1 session per event-loop, 1 session per connection, etc).
|
76
|
+
/**
|
77
|
+
* Custom key operations to perform when a private key operation is required in the TLS handshake.
|
78
|
+
* Only will be used if non-NULL, otherwise this is ignored and the standard private key operations
|
79
|
+
* are performed instead.
|
80
|
+
* NOTE: PKCS11 also is done via this custom_key_handler.
|
86
81
|
*
|
87
|
-
*
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
82
|
+
* See aws_custom_key_op_handler in tls_channel_handler.h for more details.
|
83
|
+
*/
|
84
|
+
struct aws_custom_key_op_handler *custom_key_handler;
|
85
|
+
};
|
86
|
+
|
87
|
+
struct aws_tls_key_operation {
|
88
|
+
struct aws_allocator *alloc;
|
89
|
+
struct s2n_async_pkey_op *s2n_op;
|
90
|
+
struct s2n_handler *s2n_handler;
|
91
|
+
enum aws_tls_key_operation_type operation_type;
|
92
|
+
enum aws_tls_signature_algorithm signature_algorithm;
|
93
|
+
enum aws_tls_hash_algorithm digest_algorithm;
|
94
|
+
struct aws_byte_buf input_data;
|
95
|
+
struct aws_channel_task completion_task;
|
96
|
+
int completion_error_code;
|
97
|
+
|
98
|
+
struct aws_atomic_var complete_count;
|
99
99
|
};
|
100
100
|
|
101
101
|
AWS_STATIC_STRING_FROM_LITERAL(s_debian_path, "/etc/ssl/certs");
|
@@ -174,15 +174,34 @@ void aws_tls_init_static_state(struct aws_allocator *alloc) {
|
|
174
174
|
|
175
175
|
setenv("S2N_ENABLE_CLIENT_MODE", "1", 1);
|
176
176
|
setenv("S2N_DONT_MLOCK", "1", 1);
|
177
|
-
|
177
|
+
|
178
|
+
/* Disable atexit behavior, so that s2n_cleanup() fully cleans things up.
|
179
|
+
*
|
180
|
+
* By default, s2n uses an ataexit handler and doesn't fully clean up until the program exits.
|
181
|
+
* This can cause a crash if s2n is compiled into a shared library and
|
182
|
+
* that library is unloaded before the appexit handler runs. */
|
183
|
+
s2n_disable_atexit();
|
184
|
+
|
185
|
+
if (s2n_init() != S2N_SUCCESS) {
|
186
|
+
fprintf(stderr, "s2n_init() failed: %d (%s)\n", s2n_errno, s2n_strerror(s2n_errno, "EN"));
|
187
|
+
AWS_FATAL_ASSERT(0 && "s2n_init() failed");
|
188
|
+
}
|
178
189
|
|
179
190
|
s_default_ca_dir = s_determine_default_pki_dir();
|
180
191
|
s_default_ca_file = s_determine_default_pki_ca_file();
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
192
|
+
if (s_default_ca_dir || s_default_ca_file) {
|
193
|
+
AWS_LOGF_DEBUG(
|
194
|
+
AWS_LS_IO_TLS,
|
195
|
+
"ctx: Based on OS, we detected the default PKI path as %s, and ca file as %s",
|
196
|
+
s_default_ca_dir,
|
197
|
+
s_default_ca_file);
|
198
|
+
} else {
|
199
|
+
AWS_LOGF_WARN(
|
200
|
+
AWS_LS_IO_TLS,
|
201
|
+
"Default TLS trust store not found on this system."
|
202
|
+
" TLS connections will fail unless trusted CA certificates are installed,"
|
203
|
+
" or \"override default trust store\" is used while creating the TLS context.");
|
204
|
+
}
|
186
205
|
}
|
187
206
|
|
188
207
|
void aws_tls_clean_up_static_state(void) {
|
@@ -199,11 +218,6 @@ bool aws_tls_is_cipher_pref_supported(enum aws_tls_cipher_pref cipher_pref) {
|
|
199
218
|
return true;
|
200
219
|
/* PQ Crypto no-ops on android for now */
|
201
220
|
#ifndef ANDROID
|
202
|
-
case AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2019_06:
|
203
|
-
case AWS_IO_TLS_CIPHER_PREF_KMS_PQ_SIKE_TLSv1_0_2019_11:
|
204
|
-
case AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2020_02:
|
205
|
-
case AWS_IO_TLS_CIPHER_PREF_KMS_PQ_SIKE_TLSv1_0_2020_02:
|
206
|
-
case AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2020_07:
|
207
221
|
case AWS_IO_TLS_CIPHER_PREF_PQ_TLSv1_0_2021_05:
|
208
222
|
return true;
|
209
223
|
#endif
|
@@ -604,6 +618,8 @@ static enum aws_tls_signature_algorithm s_s2n_to_aws_signature_algorithm(s2n_tls
|
|
604
618
|
switch (s2n_alg) {
|
605
619
|
case S2N_TLS_SIGNATURE_RSA:
|
606
620
|
return AWS_TLS_SIGNATURE_RSA;
|
621
|
+
case S2N_TLS_SIGNATURE_ECDSA:
|
622
|
+
return AWS_TLS_SIGNATURE_ECDSA;
|
607
623
|
default:
|
608
624
|
return AWS_TLS_SIGNATURE_UNKNOWN;
|
609
625
|
}
|
@@ -626,59 +642,169 @@ static enum aws_tls_hash_algorithm s_s2n_to_aws_hash_algorithm(s2n_tls_hash_algo
|
|
626
642
|
}
|
627
643
|
}
|
628
644
|
|
629
|
-
|
630
|
-
|
631
|
-
|
645
|
+
static void s_tls_key_operation_destroy(struct aws_tls_key_operation *operation) {
|
646
|
+
if (operation->s2n_op) {
|
647
|
+
s2n_async_pkey_op_free(operation->s2n_op);
|
648
|
+
}
|
649
|
+
if (operation->s2n_handler) {
|
650
|
+
aws_channel_release_hold(operation->s2n_handler->slot->channel);
|
651
|
+
}
|
652
|
+
aws_byte_buf_clean_up(&operation->input_data);
|
653
|
+
aws_mem_release(operation->alloc, operation);
|
654
|
+
}
|
655
|
+
|
656
|
+
/* This task finishes a private key operation on the event-loop thread.
|
657
|
+
* If the operation was successful, TLS negotiation is resumed.
|
658
|
+
* If the operation failed, the channel is shut down */
|
659
|
+
static void s_tls_key_operation_completion_task(
|
632
660
|
struct aws_channel_task *channel_task,
|
633
661
|
void *arg,
|
634
662
|
enum aws_task_status status) {
|
635
663
|
|
636
|
-
|
664
|
+
(void)channel_task;
|
665
|
+
struct aws_tls_key_operation *operation = arg;
|
666
|
+
struct s2n_handler *s2n_handler = operation->s2n_handler;
|
637
667
|
struct aws_channel_handler *handler = &s2n_handler->handler;
|
638
|
-
struct s2n_async_pkey_op *op = arg;
|
639
|
-
bool success = false;
|
640
|
-
|
641
|
-
uint8_t *input_data = NULL; /* allocated later */
|
642
|
-
struct aws_byte_buf output_buf; /* initialized later */
|
643
|
-
AWS_ZERO_STRUCT(output_buf);
|
644
668
|
|
645
669
|
/* if things started failing since this task was scheduled, just clean up and bail out */
|
646
670
|
if (status != AWS_TASK_STATUS_RUN_READY || s2n_handler->state != NEGOTIATION_ONGOING) {
|
647
671
|
goto clean_up;
|
648
672
|
}
|
649
673
|
|
650
|
-
|
674
|
+
if (operation->completion_error_code == 0) {
|
675
|
+
if (s2n_async_pkey_op_apply(operation->s2n_op, s2n_handler->connection)) {
|
676
|
+
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "id=%p: Failed applying s2n async pkey op", (void *)handler);
|
677
|
+
operation->completion_error_code = AWS_ERROR_INVALID_STATE;
|
678
|
+
}
|
679
|
+
}
|
680
|
+
|
681
|
+
if (operation->completion_error_code == 0) {
|
682
|
+
s_drive_negotiation(handler);
|
683
|
+
} else {
|
684
|
+
aws_channel_shutdown(s2n_handler->slot->channel, operation->completion_error_code);
|
685
|
+
}
|
686
|
+
|
687
|
+
clean_up:
|
688
|
+
s_tls_key_operation_destroy(operation);
|
689
|
+
}
|
651
690
|
|
652
|
-
|
653
|
-
|
654
|
-
|
691
|
+
/* Common implementation for aws_tls_key_operation_complete() and aws_tls_key_operation_complete_with_error()
|
692
|
+
* This is called exactly once. Schedules a task to actually finish things up on the event-loop thread. */
|
693
|
+
static void s_tls_key_operation_complete_common(
|
694
|
+
struct aws_tls_key_operation *operation,
|
695
|
+
int error_code,
|
696
|
+
const struct aws_byte_cursor *output) {
|
697
|
+
|
698
|
+
AWS_ASSERT((error_code != 0) ^ (output != NULL)); /* error_code XOR output must be set */
|
699
|
+
|
700
|
+
/* Ensure this can only be called once and exactly once. */
|
701
|
+
size_t complete_count = aws_atomic_fetch_add(&operation->complete_count, 1);
|
702
|
+
AWS_FATAL_ASSERT(complete_count == 0 && "TLS key operation marked complete multiple times");
|
703
|
+
|
704
|
+
struct s2n_handler *s2n_handler = operation->s2n_handler;
|
705
|
+
struct aws_channel_handler *handler = &s2n_handler->handler;
|
655
706
|
|
707
|
+
if (output != NULL) {
|
708
|
+
/* Immediately pass output through to s2n_op. */
|
709
|
+
if (s2n_async_pkey_op_set_output(operation->s2n_op, output->ptr, output->len)) {
|
710
|
+
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "id=%p: Failed setting output on s2n async pkey op", (void *)handler);
|
711
|
+
error_code = AWS_ERROR_INVALID_STATE;
|
712
|
+
goto done;
|
713
|
+
}
|
714
|
+
}
|
715
|
+
|
716
|
+
done:
|
717
|
+
operation->completion_error_code = error_code;
|
718
|
+
|
719
|
+
/* Schedule a task to finish the operation.
|
720
|
+
* We schedule a task because the user might
|
721
|
+
* have completed the operation asynchronously,
|
722
|
+
* but we need to be on the event-loop thread to
|
723
|
+
* resume TLS negotiation. */
|
724
|
+
aws_channel_task_init(
|
725
|
+
&operation->completion_task,
|
726
|
+
s_tls_key_operation_completion_task,
|
727
|
+
operation,
|
728
|
+
"tls_key_operation_completion_task");
|
729
|
+
aws_channel_schedule_task_now(s2n_handler->slot->channel, &operation->completion_task);
|
730
|
+
}
|
731
|
+
|
732
|
+
void aws_tls_key_operation_complete(struct aws_tls_key_operation *operation, struct aws_byte_cursor output) {
|
733
|
+
if (operation == NULL) {
|
734
|
+
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "Operation complete: operation is null and therefore cannot be set to complete!");
|
735
|
+
return;
|
736
|
+
}
|
737
|
+
|
738
|
+
AWS_LOGF_DEBUG(
|
739
|
+
AWS_LS_IO_TLS,
|
740
|
+
"id=%p: TLS key operation complete with %zu bytes of output data",
|
741
|
+
(void *)operation->s2n_handler,
|
742
|
+
output.len);
|
743
|
+
s_tls_key_operation_complete_common(operation, 0, &output);
|
744
|
+
}
|
745
|
+
|
746
|
+
void aws_tls_key_operation_complete_with_error(struct aws_tls_key_operation *operation, int error_code) {
|
747
|
+
if (operation == NULL) {
|
748
|
+
AWS_LOGF_ERROR(
|
749
|
+
AWS_LS_IO_TLS, "Operation complete with error: operation is null and therefore cannot be set to complete!");
|
750
|
+
return;
|
751
|
+
}
|
752
|
+
|
753
|
+
if (error_code == 0) {
|
754
|
+
error_code = AWS_ERROR_UNKNOWN;
|
755
|
+
AWS_LOGF_ERROR(
|
756
|
+
AWS_LS_IO_TLS,
|
757
|
+
"id=%p: TLS key operation completed with error, but no error-code set. Using %s",
|
758
|
+
(void *)operation->s2n_handler,
|
759
|
+
aws_error_name(error_code));
|
760
|
+
}
|
761
|
+
|
762
|
+
AWS_LOGF_ERROR(
|
763
|
+
AWS_LS_IO_TLS,
|
764
|
+
"id=%p: TLS key operation complete with error %s",
|
765
|
+
(void *)operation->s2n_handler,
|
766
|
+
aws_error_name(error_code));
|
767
|
+
|
768
|
+
s_tls_key_operation_complete_common(operation, error_code, NULL);
|
769
|
+
}
|
770
|
+
|
771
|
+
static struct aws_tls_key_operation *s_tls_key_operation_new(
|
772
|
+
struct aws_channel_handler *handler,
|
773
|
+
struct s2n_async_pkey_op *s2n_op) {
|
774
|
+
|
775
|
+
struct s2n_handler *s2n_handler = handler->impl;
|
776
|
+
|
777
|
+
struct aws_tls_key_operation *operation = aws_mem_calloc(handler->alloc, 1, sizeof(struct aws_tls_key_operation));
|
778
|
+
operation->alloc = handler->alloc;
|
779
|
+
|
780
|
+
/* Copy input data */
|
656
781
|
uint32_t input_size = 0;
|
657
|
-
if (s2n_async_pkey_op_get_input_size(
|
782
|
+
if (s2n_async_pkey_op_get_input_size(s2n_op, &input_size)) {
|
658
783
|
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "id=%p: Failed querying s2n async pkey op size", (void *)handler);
|
659
784
|
aws_raise_error(AWS_ERROR_INVALID_STATE);
|
660
785
|
goto error;
|
661
786
|
}
|
662
787
|
|
663
|
-
input_data
|
664
|
-
if (s2n_async_pkey_op_get_input(
|
788
|
+
aws_byte_buf_init(&operation->input_data, operation->alloc, input_size); /* cannot fail */
|
789
|
+
if (s2n_async_pkey_op_get_input(s2n_op, operation->input_data.buffer, input_size)) {
|
665
790
|
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "id=%p: Failed querying s2n async pkey input", (void *)handler);
|
666
791
|
aws_raise_error(AWS_ERROR_INVALID_STATE);
|
667
792
|
goto error;
|
668
793
|
}
|
669
|
-
|
794
|
+
operation->input_data.len = input_size;
|
670
795
|
|
671
|
-
|
672
|
-
|
796
|
+
/* Get operation type */
|
797
|
+
s2n_async_pkey_op_type s2n_op_type = 0;
|
798
|
+
if (s2n_async_pkey_op_get_op_type(s2n_op, &s2n_op_type)) {
|
673
799
|
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "id=%p: Failed querying s2n async pkey op type", (void *)handler);
|
674
800
|
aws_raise_error(AWS_ERROR_INVALID_STATE);
|
675
801
|
goto error;
|
676
802
|
}
|
677
803
|
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
804
|
+
if (s2n_op_type == S2N_ASYNC_SIGN) {
|
805
|
+
operation->operation_type = AWS_TLS_KEY_OPERATION_SIGN;
|
806
|
+
|
807
|
+
/* Gather additional information if this is a SIGN operation */
|
682
808
|
s2n_tls_signature_algorithm s2n_sign_alg = 0;
|
683
809
|
if (s2n_connection_get_selected_client_cert_signature_algorithm(s2n_handler->connection, &s2n_sign_alg)) {
|
684
810
|
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "id=%p: Failed getting s2n client cert signature algorithm", (void *)handler);
|
@@ -686,8 +812,8 @@ static void s_s2n_pkcs11_async_pkey_task(
|
|
686
812
|
goto error;
|
687
813
|
}
|
688
814
|
|
689
|
-
|
690
|
-
if (
|
815
|
+
operation->signature_algorithm = s_s2n_to_aws_signature_algorithm(s2n_sign_alg);
|
816
|
+
if (operation->signature_algorithm == AWS_TLS_SIGNATURE_UNKNOWN) {
|
691
817
|
AWS_LOGF_ERROR(
|
692
818
|
AWS_LS_IO_TLS,
|
693
819
|
"id=%p: Cannot sign with s2n_tls_signature_algorithm=%d. Algorithm currently unsupported",
|
@@ -704,8 +830,8 @@ static void s_s2n_pkcs11_async_pkey_task(
|
|
704
830
|
goto error;
|
705
831
|
}
|
706
832
|
|
707
|
-
|
708
|
-
if (
|
833
|
+
operation->digest_algorithm = s_s2n_to_aws_hash_algorithm(s2n_digest_alg);
|
834
|
+
if (operation->digest_algorithm == AWS_TLS_HASH_UNKNOWN) {
|
709
835
|
AWS_LOGF_ERROR(
|
710
836
|
AWS_LS_IO_TLS,
|
711
837
|
"id=%p: Cannot sign digest created with s2n_tls_hash_algorithm=%d. Algorithm currently unsupported",
|
@@ -714,113 +840,75 @@ static void s_s2n_pkcs11_async_pkey_task(
|
|
714
840
|
aws_raise_error(AWS_IO_TLS_DIGEST_ALGORITHM_UNSUPPORTED);
|
715
841
|
goto error;
|
716
842
|
}
|
717
|
-
}
|
718
|
-
|
719
|
-
/*********** BEGIN CRITICAL SECTION ***********/
|
720
|
-
aws_mutex_lock(&s2n_handler->s2n_ctx->pkcs11.session_lock);
|
721
|
-
bool success_while_locked = false;
|
722
|
-
|
723
|
-
switch (op_type) {
|
724
|
-
case S2N_ASYNC_DECRYPT:
|
725
|
-
if (aws_pkcs11_lib_decrypt(
|
726
|
-
s2n_handler->s2n_ctx->pkcs11.lib,
|
727
|
-
s2n_handler->s2n_ctx->pkcs11.session_handle,
|
728
|
-
s2n_handler->s2n_ctx->pkcs11.private_key_handle,
|
729
|
-
s2n_handler->s2n_ctx->pkcs11.private_key_type,
|
730
|
-
input_cursor,
|
731
|
-
handler->alloc,
|
732
|
-
&output_buf)) {
|
733
|
-
|
734
|
-
AWS_LOGF_ERROR(
|
735
|
-
AWS_LS_IO_TLS,
|
736
|
-
"id=%p: PKCS#11 decrypt failed, error %s",
|
737
|
-
(void *)handler,
|
738
|
-
aws_error_name(aws_last_error()));
|
739
|
-
goto unlock;
|
740
|
-
}
|
741
|
-
break;
|
742
|
-
|
743
|
-
case S2N_ASYNC_SIGN:
|
744
|
-
if (aws_pkcs11_lib_sign(
|
745
|
-
s2n_handler->s2n_ctx->pkcs11.lib,
|
746
|
-
s2n_handler->s2n_ctx->pkcs11.session_handle,
|
747
|
-
s2n_handler->s2n_ctx->pkcs11.private_key_handle,
|
748
|
-
s2n_handler->s2n_ctx->pkcs11.private_key_type,
|
749
|
-
input_cursor,
|
750
|
-
handler->alloc,
|
751
|
-
aws_digest_alg,
|
752
|
-
aws_sign_alg,
|
753
|
-
&output_buf)) {
|
754
|
-
|
755
|
-
AWS_LOGF_ERROR(
|
756
|
-
AWS_LS_IO_TLS,
|
757
|
-
"id=%p: PKCS#11 sign failed, error %s",
|
758
|
-
(void *)handler,
|
759
|
-
aws_error_name(aws_last_error()));
|
760
|
-
goto unlock;
|
761
|
-
}
|
762
|
-
break;
|
763
|
-
|
764
|
-
default:
|
765
|
-
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "id=%p: Unknown s2n_async_pkey_op_type:%d", (void *)handler, (int)op_type);
|
766
|
-
aws_raise_error(AWS_ERROR_INVALID_STATE);
|
767
|
-
goto unlock;
|
768
|
-
}
|
769
|
-
|
770
|
-
success_while_locked = true;
|
771
|
-
unlock:
|
772
|
-
aws_mutex_unlock(&s2n_handler->s2n_ctx->pkcs11.session_lock);
|
773
|
-
/*********** END CRITICAL SECTION ***********/
|
774
|
-
|
775
|
-
if (!success_while_locked) {
|
776
|
-
goto error;
|
777
|
-
}
|
778
843
|
|
779
|
-
|
780
|
-
|
844
|
+
} else if (s2n_op_type == S2N_ASYNC_DECRYPT) {
|
845
|
+
operation->operation_type = AWS_TLS_KEY_OPERATION_DECRYPT;
|
781
846
|
|
782
|
-
|
783
|
-
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "id=%p:
|
847
|
+
} else {
|
848
|
+
AWS_LOGF_ERROR(AWS_LS_IO_TLS, "id=%p: Unknown s2n async pkey op type:%d", (void *)handler, (int)s2n_op_type);
|
784
849
|
aws_raise_error(AWS_ERROR_INVALID_STATE);
|
785
850
|
goto error;
|
786
851
|
}
|
787
852
|
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
goto error;
|
792
|
-
}
|
853
|
+
/* Keep channel alive until operation completes */
|
854
|
+
operation->s2n_handler = s2n_handler;
|
855
|
+
aws_channel_acquire_hold(s2n_handler->slot->channel);
|
793
856
|
|
794
|
-
/*
|
795
|
-
|
796
|
-
goto clean_up;
|
857
|
+
/* Set this to zero so we can track how many times complete has been called */
|
858
|
+
aws_atomic_init_int(&operation->complete_count, 0);
|
797
859
|
|
860
|
+
/* Set this last. We don't want to take ownership of s2n_op until we know setup was 100% successful */
|
861
|
+
operation->s2n_op = s2n_op;
|
862
|
+
|
863
|
+
return operation;
|
798
864
|
error:
|
799
|
-
|
865
|
+
s_tls_key_operation_destroy(operation);
|
866
|
+
return NULL;
|
867
|
+
}
|
800
868
|
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
aws_byte_buf_clean_up(&output_buf);
|
869
|
+
struct aws_byte_cursor aws_tls_key_operation_get_input(const struct aws_tls_key_operation *operation) {
|
870
|
+
return aws_byte_cursor_from_buf(&operation->input_data);
|
871
|
+
}
|
805
872
|
|
806
|
-
|
807
|
-
|
808
|
-
|
873
|
+
enum aws_tls_key_operation_type aws_tls_key_operation_get_type(const struct aws_tls_key_operation *operation) {
|
874
|
+
return operation->operation_type;
|
875
|
+
}
|
876
|
+
|
877
|
+
enum aws_tls_signature_algorithm aws_tls_key_operation_get_signature_algorithm(
|
878
|
+
const struct aws_tls_key_operation *operation) {
|
879
|
+
return operation->signature_algorithm;
|
809
880
|
}
|
810
881
|
|
811
|
-
|
882
|
+
enum aws_tls_hash_algorithm aws_tls_key_operation_get_digest_algorithm(const struct aws_tls_key_operation *operation) {
|
883
|
+
return operation->digest_algorithm;
|
884
|
+
}
|
885
|
+
|
886
|
+
static int s_s2n_async_pkey_callback(struct s2n_connection *conn, struct s2n_async_pkey_op *s2n_op) {
|
812
887
|
struct s2n_handler *s2n_handler = s2n_connection_get_ctx(conn);
|
813
888
|
struct aws_channel_handler *handler = &s2n_handler->handler;
|
814
889
|
|
815
890
|
AWS_ASSERT(conn == s2n_handler->connection);
|
816
891
|
(void)conn;
|
817
892
|
|
818
|
-
|
819
|
-
* s2n can't deal with the async private key operation completing synchronously, so we can't just do it now */
|
820
|
-
AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: async pkey callback received, scheduling PKCS#11 task", (void *)handler);
|
893
|
+
AWS_LOGF_TRACE(AWS_LS_IO_TLS, "id=%p: s2n async pkey callback received", (void *)handler);
|
821
894
|
|
822
|
-
|
823
|
-
|
895
|
+
/* Create the AWS wrapper around s2n_async_pkey_op */
|
896
|
+
struct aws_tls_key_operation *operation = s_tls_key_operation_new(handler, s2n_op);
|
897
|
+
if (operation == NULL) {
|
898
|
+
s2n_async_pkey_op_free(s2n_op);
|
899
|
+
return S2N_FAILURE;
|
900
|
+
}
|
901
|
+
|
902
|
+
AWS_LOGF_DEBUG(
|
903
|
+
AWS_LS_IO_TLS,
|
904
|
+
"id=%p: Begin TLS key operation. type=%s input_data.len=%zu signature=%s digest=%s",
|
905
|
+
(void *)operation,
|
906
|
+
aws_tls_key_operation_type_str(operation->operation_type),
|
907
|
+
operation->input_data.len,
|
908
|
+
aws_tls_signature_algorithm_str(operation->signature_algorithm),
|
909
|
+
aws_tls_hash_algorithm_str(operation->digest_algorithm));
|
910
|
+
|
911
|
+
aws_custom_key_op_handler_perform_operation(s2n_handler->s2n_ctx->custom_key_handler, operation);
|
824
912
|
|
825
913
|
return S2N_SUCCESS;
|
826
914
|
}
|
@@ -1189,16 +1277,12 @@ struct aws_channel_handler *aws_tls_server_handler_new(
|
|
1189
1277
|
|
1190
1278
|
static void s_s2n_ctx_destroy(struct s2n_ctx *s2n_ctx) {
|
1191
1279
|
if (s2n_ctx != NULL) {
|
1192
|
-
if (s2n_ctx->pkcs11.session_handle != 0) {
|
1193
|
-
aws_pkcs11_lib_close_session(s2n_ctx->pkcs11.lib, s2n_ctx->pkcs11.session_handle);
|
1194
|
-
}
|
1195
|
-
aws_mutex_clean_up(&s2n_ctx->pkcs11.session_lock);
|
1196
|
-
aws_pkcs11_lib_release(s2n_ctx->pkcs11.lib);
|
1197
1280
|
s2n_config_free(s2n_ctx->s2n_config);
|
1198
1281
|
|
1199
1282
|
if (s2n_ctx->custom_cert_chain_and_key) {
|
1200
1283
|
s2n_cert_chain_and_key_free(s2n_ctx->custom_cert_chain_and_key);
|
1201
1284
|
}
|
1285
|
+
s2n_ctx->custom_key_handler = aws_custom_key_op_handler_release(s2n_ctx->custom_key_handler);
|
1202
1286
|
|
1203
1287
|
aws_mem_release(s2n_ctx->ctx.alloc, s2n_ctx);
|
1204
1288
|
}
|
@@ -1224,44 +1308,6 @@ static int s2n_monotonic_clock_time_nanoseconds(void *context, uint64_t *time_in
|
|
1224
1308
|
return 0;
|
1225
1309
|
}
|
1226
1310
|
|
1227
|
-
static int s_tls_ctx_pkcs11_setup(struct s2n_ctx *s2n_ctx, const struct aws_tls_ctx_options *options) {
|
1228
|
-
/* PKCS#11 options were already sanitized (ie: check for required args) in tls_channel_handler.c */
|
1229
|
-
|
1230
|
-
/* anything initialized in this function is cleaned up during s_s2n_ctx_destroy()
|
1231
|
-
* so don't worry about cleaning up unless it's some tmp heap allocation */
|
1232
|
-
|
1233
|
-
s2n_ctx->pkcs11.lib = aws_pkcs11_lib_acquire(options->pkcs11.lib); /* cannot fail */
|
1234
|
-
aws_mutex_init(&s2n_ctx->pkcs11.session_lock);
|
1235
|
-
|
1236
|
-
CK_SLOT_ID slot_id = 0;
|
1237
|
-
if (aws_pkcs11_lib_find_slot_with_token(
|
1238
|
-
s2n_ctx->pkcs11.lib,
|
1239
|
-
options->pkcs11.has_slot_id ? &options->pkcs11.slot_id : NULL,
|
1240
|
-
options->pkcs11.token_label,
|
1241
|
-
&slot_id /*out*/)) {
|
1242
|
-
return AWS_OP_ERR;
|
1243
|
-
}
|
1244
|
-
|
1245
|
-
if (aws_pkcs11_lib_open_session(s2n_ctx->pkcs11.lib, slot_id, &s2n_ctx->pkcs11.session_handle)) {
|
1246
|
-
return AWS_OP_ERR;
|
1247
|
-
}
|
1248
|
-
|
1249
|
-
if (aws_pkcs11_lib_login_user(s2n_ctx->pkcs11.lib, s2n_ctx->pkcs11.session_handle, options->pkcs11.user_pin)) {
|
1250
|
-
return AWS_OP_ERR;
|
1251
|
-
}
|
1252
|
-
|
1253
|
-
if (aws_pkcs11_lib_find_private_key(
|
1254
|
-
s2n_ctx->pkcs11.lib,
|
1255
|
-
s2n_ctx->pkcs11.session_handle,
|
1256
|
-
options->pkcs11.private_key_object_label,
|
1257
|
-
&s2n_ctx->pkcs11.private_key_handle /*out*/,
|
1258
|
-
&s2n_ctx->pkcs11.private_key_type /*out*/)) {
|
1259
|
-
return AWS_OP_ERR;
|
1260
|
-
}
|
1261
|
-
|
1262
|
-
return AWS_OP_SUCCESS;
|
1263
|
-
}
|
1264
|
-
|
1265
1311
|
static void s_log_and_raise_s2n_errno(const char *msg) {
|
1266
1312
|
AWS_LOGF_ERROR(
|
1267
1313
|
AWS_LS_IO_TLS, "%s: %s (%s)", msg, s2n_strerror(s2n_errno, "EN"), s2n_strerror_debug(s2n_errno, "EN"));
|
@@ -1306,7 +1352,7 @@ static struct aws_tls_ctx *s_tls_ctx_new(
|
|
1306
1352
|
goto cleanup_s2n_config;
|
1307
1353
|
}
|
1308
1354
|
|
1309
|
-
if (options->
|
1355
|
+
if (options->custom_key_op_handler != NULL) {
|
1310
1356
|
/* PKCS#11 integration hasn't been tested with TLS 1.3, so don't use cipher preferences that allow 1.3 */
|
1311
1357
|
switch (options->minimum_tls_version) {
|
1312
1358
|
case AWS_IO_SSLv3:
|
@@ -1356,21 +1402,6 @@ static struct aws_tls_ctx *s_tls_ctx_new(
|
|
1356
1402
|
case AWS_IO_TLS_CIPHER_PREF_SYSTEM_DEFAULT:
|
1357
1403
|
/* No-Op, if the user configured a minimum_tls_version then a version-specific Cipher Preference was set */
|
1358
1404
|
break;
|
1359
|
-
case AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2019_06:
|
1360
|
-
s2n_config_set_cipher_preferences(s2n_ctx->s2n_config, "KMS-PQ-TLS-1-0-2019-06");
|
1361
|
-
break;
|
1362
|
-
case AWS_IO_TLS_CIPHER_PREF_KMS_PQ_SIKE_TLSv1_0_2019_11:
|
1363
|
-
s2n_config_set_cipher_preferences(s2n_ctx->s2n_config, "PQ-SIKE-TEST-TLS-1-0-2019-11");
|
1364
|
-
break;
|
1365
|
-
case AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2020_02:
|
1366
|
-
s2n_config_set_cipher_preferences(s2n_ctx->s2n_config, "KMS-PQ-TLS-1-0-2020-02");
|
1367
|
-
break;
|
1368
|
-
case AWS_IO_TLS_CIPHER_PREF_KMS_PQ_SIKE_TLSv1_0_2020_02:
|
1369
|
-
s2n_config_set_cipher_preferences(s2n_ctx->s2n_config, "PQ-SIKE-TEST-TLS-1-0-2020-02");
|
1370
|
-
break;
|
1371
|
-
case AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2020_07:
|
1372
|
-
s2n_config_set_cipher_preferences(s2n_ctx->s2n_config, "KMS-PQ-TLS-1-0-2020-07");
|
1373
|
-
break;
|
1374
1405
|
case AWS_IO_TLS_CIPHER_PREF_PQ_TLSv1_0_2021_05:
|
1375
1406
|
s2n_config_set_cipher_preferences(s2n_ctx->s2n_config, "PQ-TLS-1-0-2021-05-26");
|
1376
1407
|
break;
|
@@ -1413,14 +1444,12 @@ static struct aws_tls_ctx *s_tls_ctx_new(
|
|
1413
1444
|
s_log_and_raise_s2n_errno("ctx: Failed to add certificate and private key");
|
1414
1445
|
goto cleanup_s2n_config;
|
1415
1446
|
}
|
1416
|
-
} else if (options->
|
1417
|
-
AWS_LOGF_DEBUG(AWS_LS_IO_TLS, "ctx: PKCS#11 has been set, setting it up now.");
|
1418
|
-
if (s_tls_ctx_pkcs11_setup(s2n_ctx, options)) {
|
1419
|
-
goto cleanup_s2n_config;
|
1420
|
-
}
|
1447
|
+
} else if (options->custom_key_op_handler != NULL) {
|
1421
1448
|
|
1422
|
-
|
1423
|
-
|
1449
|
+
s2n_ctx->custom_key_handler = aws_custom_key_op_handler_acquire(options->custom_key_op_handler);
|
1450
|
+
|
1451
|
+
/* set callback so that we can do custom private key operations */
|
1452
|
+
if (s2n_config_set_async_pkey_callback(s2n_ctx->s2n_config, s_s2n_async_pkey_callback)) {
|
1424
1453
|
s_log_and_raise_s2n_errno("ctx: failed to set private key callback");
|
1425
1454
|
goto cleanup_s2n_config;
|
1426
1455
|
}
|
@@ -1494,7 +1523,7 @@ static struct aws_tls_ctx *s_tls_ctx_new(
|
|
1494
1523
|
goto cleanup_s2n_config;
|
1495
1524
|
}
|
1496
1525
|
}
|
1497
|
-
} else {
|
1526
|
+
} else if (s_default_ca_file || s_default_ca_dir) {
|
1498
1527
|
/* User wants to use the system's default trust store.
|
1499
1528
|
*
|
1500
1529
|
* Note that s2n's trust store always starts with libcrypto's default locations.
|
@@ -1509,6 +1538,14 @@ static struct aws_tls_ctx *s_tls_ctx_new(
|
|
1509
1538
|
AWS_LS_IO_TLS, "Failed to set ca_path: %s and ca_file %s\n", s_default_ca_dir, s_default_ca_file);
|
1510
1539
|
goto cleanup_s2n_config;
|
1511
1540
|
}
|
1541
|
+
} else {
|
1542
|
+
/* Cannot find system's trust store */
|
1543
|
+
aws_raise_error(AWS_IO_TLS_ERROR_DEFAULT_TRUST_STORE_NOT_FOUND);
|
1544
|
+
AWS_LOGF_ERROR(
|
1545
|
+
AWS_LS_IO_TLS,
|
1546
|
+
"Default TLS trust store not found on this system."
|
1547
|
+
" Install CA certificates, or \"override default trust store\".");
|
1548
|
+
goto cleanup_s2n_config;
|
1512
1549
|
}
|
1513
1550
|
|
1514
1551
|
if (mode == S2N_SERVER && s2n_config_set_client_auth_type(s2n_ctx->s2n_config, S2N_CERT_AUTH_REQUIRED)) {
|