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
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
#include <aws/checksums/crc.h>
|
9
9
|
|
10
|
+
#include <aws/common/byte_buf.h>
|
10
11
|
#include <aws/common/encoding.h>
|
11
12
|
#include <aws/io/io.h>
|
12
13
|
|
@@ -128,81 +129,100 @@ uint32_t aws_event_stream_compute_headers_required_buffer_len(const struct aws_a
|
|
128
129
|
struct aws_event_stream_header_value_pair *header = NULL;
|
129
130
|
|
130
131
|
aws_array_list_get_at_ptr(headers, (void **)&header, i);
|
131
|
-
|
132
|
-
|
132
|
+
AWS_FATAL_ASSERT(
|
133
|
+
!aws_add_size_checked(headers_len, sizeof(header->header_name_len), &headers_len) &&
|
134
|
+
"integer overflow occurred computing total headers length.");
|
135
|
+
AWS_FATAL_ASSERT(
|
136
|
+
!aws_add_size_checked(headers_len, header->header_name_len + 1, &headers_len) &&
|
137
|
+
"integer overflow occurred computing total headers length.");
|
133
138
|
|
134
139
|
if (header->header_value_type == AWS_EVENT_STREAM_HEADER_STRING ||
|
135
140
|
header->header_value_type == AWS_EVENT_STREAM_HEADER_BYTE_BUF) {
|
136
|
-
|
141
|
+
AWS_FATAL_ASSERT(
|
142
|
+
!aws_add_size_checked(headers_len, sizeof(header->header_value_len), &headers_len) &&
|
143
|
+
"integer overflow occurred computing total headers length.");
|
137
144
|
}
|
138
145
|
|
139
146
|
if (header->header_value_type != AWS_EVENT_STREAM_HEADER_BOOL_FALSE &&
|
140
147
|
header->header_value_type != AWS_EVENT_STREAM_HEADER_BOOL_TRUE) {
|
141
|
-
|
148
|
+
AWS_FATAL_ASSERT(
|
149
|
+
!aws_add_size_checked(headers_len, header->header_value_len, &headers_len) &&
|
150
|
+
"integer overflow occurred computing total headers length.");
|
142
151
|
}
|
143
152
|
}
|
144
153
|
|
145
154
|
return (uint32_t)headers_len;
|
146
155
|
}
|
147
156
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
size_t aws_event_stream_write_headers_to_buffer(const struct aws_array_list *headers, uint8_t *buffer) {
|
157
|
+
int aws_event_stream_write_headers_to_buffer_safe(const struct aws_array_list *headers, struct aws_byte_buf *buf) {
|
158
|
+
AWS_FATAL_PRECONDITION(buf);
|
159
|
+
|
152
160
|
if (!headers || !aws_array_list_length(headers)) {
|
153
|
-
return
|
161
|
+
return AWS_OP_SUCCESS;
|
154
162
|
}
|
155
163
|
|
156
164
|
size_t headers_count = aws_array_list_length(headers);
|
157
|
-
uint8_t *buffer_alias = buffer;
|
158
165
|
|
159
166
|
for (size_t i = 0; i < headers_count; ++i) {
|
160
167
|
struct aws_event_stream_header_value_pair *header = NULL;
|
161
168
|
|
162
169
|
aws_array_list_get_at_ptr(headers, (void **)&header, i);
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
170
|
+
AWS_RETURN_ERROR_IF(
|
171
|
+
aws_byte_buf_write_u8(buf, header->header_name_len), AWS_ERROR_EVENT_STREAM_INSUFFICIENT_BUFFER_LEN);
|
172
|
+
AWS_RETURN_ERROR_IF(
|
173
|
+
aws_byte_buf_write(buf, (uint8_t *)header->header_name, (size_t)header->header_name_len),
|
174
|
+
AWS_ERROR_EVENT_STREAM_INSUFFICIENT_BUFFER_LEN);
|
175
|
+
AWS_RETURN_ERROR_IF(
|
176
|
+
aws_byte_buf_write_u8(buf, (uint8_t)header->header_value_type),
|
177
|
+
AWS_ERROR_EVENT_STREAM_INSUFFICIENT_BUFFER_LEN);
|
178
|
+
|
169
179
|
switch (header->header_value_type) {
|
170
180
|
case AWS_EVENT_STREAM_HEADER_BOOL_FALSE:
|
171
181
|
case AWS_EVENT_STREAM_HEADER_BOOL_TRUE:
|
172
182
|
break;
|
183
|
+
/* additions of integers here assume the endianness conversion has already happened */
|
173
184
|
case AWS_EVENT_STREAM_HEADER_BYTE:
|
174
|
-
*buffer_alias = header->header_value.static_val[0];
|
175
|
-
buffer_alias++;
|
176
|
-
break;
|
177
|
-
/* additions of integers here assume the endianness conversion has already happened */
|
178
185
|
case AWS_EVENT_STREAM_HEADER_INT16:
|
179
|
-
memcpy(buffer_alias, header->header_value.static_val, sizeof(uint16_t));
|
180
|
-
buffer_alias += sizeof(uint16_t);
|
181
|
-
break;
|
182
186
|
case AWS_EVENT_STREAM_HEADER_INT32:
|
183
|
-
memcpy(buffer_alias, header->header_value.static_val, sizeof(uint32_t));
|
184
|
-
buffer_alias += sizeof(uint32_t);
|
185
|
-
break;
|
186
187
|
case AWS_EVENT_STREAM_HEADER_INT64:
|
187
188
|
case AWS_EVENT_STREAM_HEADER_TIMESTAMP:
|
188
|
-
|
189
|
-
|
189
|
+
case AWS_EVENT_STREAM_HEADER_UUID:
|
190
|
+
AWS_RETURN_ERROR_IF(
|
191
|
+
aws_byte_buf_write(buf, header->header_value.static_val, header->header_value_len),
|
192
|
+
AWS_ERROR_EVENT_STREAM_INSUFFICIENT_BUFFER_LEN);
|
190
193
|
break;
|
191
194
|
case AWS_EVENT_STREAM_HEADER_BYTE_BUF:
|
192
195
|
case AWS_EVENT_STREAM_HEADER_STRING:
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
196
|
+
AWS_RETURN_ERROR_IF(
|
197
|
+
aws_byte_buf_write_be16(buf, header->header_value_len),
|
198
|
+
AWS_ERROR_EVENT_STREAM_INSUFFICIENT_BUFFER_LEN);
|
199
|
+
AWS_RETURN_ERROR_IF(
|
200
|
+
aws_byte_buf_write(buf, header->header_value.variable_len_val, header->header_value_len),
|
201
|
+
AWS_ERROR_EVENT_STREAM_INSUFFICIENT_BUFFER_LEN);
|
197
202
|
break;
|
198
|
-
|
199
|
-
|
200
|
-
buffer_alias += header->header_value_len;
|
203
|
+
default:
|
204
|
+
AWS_FATAL_ASSERT(false && !"Unknown header type!");
|
201
205
|
break;
|
202
206
|
}
|
203
207
|
}
|
204
208
|
|
205
|
-
return
|
209
|
+
return AWS_OP_SUCCESS;
|
210
|
+
}
|
211
|
+
|
212
|
+
/* adds the headers represented in the headers list to the buffer.
|
213
|
+
returns the new buffer offset for use elsewhere. Assumes buffer length is at least the length of the return value
|
214
|
+
from compute_headers_length() */
|
215
|
+
size_t aws_event_stream_write_headers_to_buffer(const struct aws_array_list *headers, uint8_t *buffer) {
|
216
|
+
AWS_FATAL_PRECONDITION(buffer);
|
217
|
+
|
218
|
+
uint32_t min_buffer_len_assumption = aws_event_stream_compute_headers_required_buffer_len(headers);
|
219
|
+
struct aws_byte_buf safer_buf = aws_byte_buf_from_empty_array(buffer, min_buffer_len_assumption);
|
220
|
+
|
221
|
+
if (aws_event_stream_write_headers_to_buffer_safe(headers, &safer_buf)) {
|
222
|
+
return 0;
|
223
|
+
}
|
224
|
+
|
225
|
+
return safer_buf.len;
|
206
226
|
}
|
207
227
|
|
208
228
|
int aws_event_stream_read_headers_from_buffer(
|
@@ -210,23 +230,28 @@ int aws_event_stream_read_headers_from_buffer(
|
|
210
230
|
const uint8_t *buffer,
|
211
231
|
size_t headers_len) {
|
212
232
|
|
213
|
-
|
233
|
+
AWS_FATAL_PRECONDITION(headers);
|
234
|
+
AWS_FATAL_PRECONDITION(buffer);
|
235
|
+
|
236
|
+
if (AWS_UNLIKELY(headers_len > (size_t)AWS_EVENT_STREAM_MAX_HEADERS_SIZE)) {
|
214
237
|
return aws_raise_error(AWS_ERROR_EVENT_STREAM_MESSAGE_FIELD_SIZE_EXCEEDED);
|
215
238
|
}
|
216
239
|
|
240
|
+
struct aws_byte_cursor buffer_cur = aws_byte_cursor_from_array(buffer, headers_len);
|
217
241
|
/* iterate the buffer per header. */
|
218
|
-
|
219
|
-
while ((size_t)(buffer - buffer_start) < headers_len) {
|
242
|
+
while (buffer_cur.len) {
|
220
243
|
struct aws_event_stream_header_value_pair header;
|
221
244
|
AWS_ZERO_STRUCT(header);
|
222
245
|
|
223
246
|
/* get the header info from the buffer, make sure to increment buffer offset. */
|
224
|
-
header.header_name_len
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
247
|
+
aws_byte_cursor_read_u8(&buffer_cur, &header.header_name_len);
|
248
|
+
AWS_RETURN_ERROR_IF(header.header_name_len <= INT8_MAX, AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
249
|
+
AWS_RETURN_ERROR_IF(
|
250
|
+
aws_byte_cursor_read(&buffer_cur, header.header_name, (size_t)header.header_name_len),
|
251
|
+
AWS_ERROR_EVENT_STREAM_BUFFER_LENGTH_MISMATCH);
|
252
|
+
AWS_RETURN_ERROR_IF(
|
253
|
+
aws_byte_cursor_read_u8(&buffer_cur, (uint8_t *)&header.header_value_type),
|
254
|
+
AWS_ERROR_EVENT_STREAM_BUFFER_LENGTH_MISMATCH);
|
230
255
|
|
231
256
|
switch (header.header_value_type) {
|
232
257
|
case AWS_EVENT_STREAM_HEADER_BOOL_FALSE:
|
@@ -239,36 +264,46 @@ int aws_event_stream_read_headers_from_buffer(
|
|
239
264
|
break;
|
240
265
|
case AWS_EVENT_STREAM_HEADER_BYTE:
|
241
266
|
header.header_value_len = sizeof(uint8_t);
|
242
|
-
|
243
|
-
|
267
|
+
AWS_RETURN_ERROR_IF(
|
268
|
+
aws_byte_cursor_read(&buffer_cur, header.header_value.static_val, header.header_value_len),
|
269
|
+
AWS_ERROR_EVENT_STREAM_BUFFER_LENGTH_MISMATCH);
|
244
270
|
break;
|
245
271
|
case AWS_EVENT_STREAM_HEADER_INT16:
|
246
272
|
header.header_value_len = sizeof(uint16_t);
|
247
|
-
|
248
|
-
|
273
|
+
AWS_RETURN_ERROR_IF(
|
274
|
+
aws_byte_cursor_read(&buffer_cur, header.header_value.static_val, header.header_value_len),
|
275
|
+
AWS_ERROR_EVENT_STREAM_BUFFER_LENGTH_MISMATCH);
|
249
276
|
break;
|
250
277
|
case AWS_EVENT_STREAM_HEADER_INT32:
|
251
278
|
header.header_value_len = sizeof(uint32_t);
|
252
|
-
|
253
|
-
|
279
|
+
AWS_RETURN_ERROR_IF(
|
280
|
+
aws_byte_cursor_read(&buffer_cur, header.header_value.static_val, header.header_value_len),
|
281
|
+
AWS_ERROR_EVENT_STREAM_BUFFER_LENGTH_MISMATCH);
|
254
282
|
break;
|
255
283
|
case AWS_EVENT_STREAM_HEADER_INT64:
|
256
284
|
case AWS_EVENT_STREAM_HEADER_TIMESTAMP:
|
257
285
|
header.header_value_len = sizeof(uint64_t);
|
258
|
-
|
259
|
-
|
286
|
+
AWS_RETURN_ERROR_IF(
|
287
|
+
aws_byte_cursor_read(&buffer_cur, header.header_value.static_val, header.header_value_len),
|
288
|
+
AWS_ERROR_EVENT_STREAM_BUFFER_LENGTH_MISMATCH);
|
260
289
|
break;
|
261
290
|
case AWS_EVENT_STREAM_HEADER_BYTE_BUF:
|
262
291
|
case AWS_EVENT_STREAM_HEADER_STRING:
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
292
|
+
AWS_RETURN_ERROR_IF(
|
293
|
+
aws_byte_cursor_read_be16(&buffer_cur, &header.header_value_len),
|
294
|
+
AWS_ERROR_EVENT_STREAM_BUFFER_LENGTH_MISMATCH);
|
295
|
+
AWS_RETURN_ERROR_IF(
|
296
|
+
header.header_value_len <= INT16_MAX, AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
297
|
+
AWS_RETURN_ERROR_IF(
|
298
|
+
buffer_cur.len >= header.header_value_len, AWS_ERROR_EVENT_STREAM_BUFFER_LENGTH_MISMATCH);
|
299
|
+
header.header_value.variable_len_val = (uint8_t *)buffer_cur.ptr;
|
300
|
+
aws_byte_cursor_advance(&buffer_cur, header.header_value_len);
|
267
301
|
break;
|
268
302
|
case AWS_EVENT_STREAM_HEADER_UUID:
|
269
|
-
header.header_value_len =
|
270
|
-
|
271
|
-
|
303
|
+
header.header_value_len = UUID_LEN;
|
304
|
+
AWS_RETURN_ERROR_IF(
|
305
|
+
aws_byte_cursor_read(&buffer_cur, header.header_value.static_val, UUID_LEN),
|
306
|
+
AWS_ERROR_EVENT_STREAM_BUFFER_LENGTH_MISMATCH);
|
272
307
|
break;
|
273
308
|
}
|
274
309
|
|
@@ -288,6 +323,8 @@ int aws_event_stream_message_init(
|
|
288
323
|
struct aws_allocator *alloc,
|
289
324
|
struct aws_array_list *headers,
|
290
325
|
struct aws_byte_buf *payload) {
|
326
|
+
AWS_FATAL_PRECONDITION(message);
|
327
|
+
AWS_FATAL_PRECONDITION(alloc);
|
291
328
|
|
292
329
|
size_t payload_len = payload ? payload->len : 0;
|
293
330
|
|
@@ -309,39 +346,33 @@ int aws_event_stream_message_init(
|
|
309
346
|
}
|
310
347
|
|
311
348
|
message->alloc = alloc;
|
312
|
-
message->message_buffer
|
349
|
+
aws_byte_buf_init(&message->message_buffer, message->alloc, total_length);
|
313
350
|
|
314
|
-
|
315
|
-
|
316
|
-
aws_write_u32(total_length, message->message_buffer);
|
317
|
-
uint8_t *buffer_offset = message->message_buffer + sizeof(total_length);
|
318
|
-
aws_write_u32(headers_length, buffer_offset);
|
319
|
-
buffer_offset += sizeof(headers_length);
|
351
|
+
aws_byte_buf_write_be32(&message->message_buffer, total_length);
|
352
|
+
aws_byte_buf_write_be32(&message->message_buffer, headers_length);
|
320
353
|
|
321
|
-
|
322
|
-
aws_checksums_crc32(message->message_buffer, (int)(buffer_offset - message->message_buffer), 0);
|
354
|
+
uint32_t running_crc = aws_checksums_crc32(message->message_buffer.buffer, (int)message->message_buffer.len, 0);
|
323
355
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
if (headers_length) {
|
329
|
-
buffer_offset += aws_event_stream_write_headers_to_buffer(headers, buffer_offset);
|
330
|
-
}
|
356
|
+
const uint8_t *pre_prelude_marker = message->message_buffer.buffer + message->message_buffer.len;
|
357
|
+
size_t pre_prelude_position_marker = message->message_buffer.len;
|
358
|
+
aws_byte_buf_write_be32(&message->message_buffer, running_crc);
|
331
359
|
|
332
|
-
|
333
|
-
|
334
|
-
|
360
|
+
if (headers_length) {
|
361
|
+
if (aws_event_stream_write_headers_to_buffer_safe(headers, &message->message_buffer)) {
|
362
|
+
aws_event_stream_message_clean_up(message);
|
363
|
+
return AWS_OP_ERR;
|
335
364
|
}
|
365
|
+
}
|
336
366
|
|
337
|
-
|
338
|
-
|
339
|
-
aws_write_u32(running_crc, buffer_offset);
|
340
|
-
|
341
|
-
return AWS_OP_SUCCESS;
|
367
|
+
if (payload) {
|
368
|
+
aws_byte_buf_write_from_whole_buffer(&message->message_buffer, *payload);
|
342
369
|
}
|
343
370
|
|
344
|
-
|
371
|
+
running_crc = aws_checksums_crc32(
|
372
|
+
pre_prelude_marker, (int)(message->message_buffer.len - pre_prelude_position_marker), running_crc);
|
373
|
+
aws_byte_buf_write_be32(&message->message_buffer, running_crc);
|
374
|
+
|
375
|
+
return AWS_OP_SUCCESS;
|
345
376
|
}
|
346
377
|
|
347
378
|
/* add buffer to the message (non-owning). Verify buffer crcs and that length fields are reasonable. */
|
@@ -349,16 +380,20 @@ int aws_event_stream_message_from_buffer(
|
|
349
380
|
struct aws_event_stream_message *message,
|
350
381
|
struct aws_allocator *alloc,
|
351
382
|
struct aws_byte_buf *buffer) {
|
352
|
-
|
383
|
+
AWS_FATAL_PRECONDITION(message);
|
384
|
+
AWS_FATAL_PRECONDITION(alloc);
|
385
|
+
AWS_FATAL_PRECONDITION(buffer);
|
353
386
|
|
354
387
|
message->alloc = alloc;
|
355
|
-
message->owns_buffer = 0;
|
356
388
|
|
357
389
|
if (AWS_UNLIKELY(buffer->len < AWS_EVENT_STREAM_PRELUDE_LENGTH + AWS_EVENT_STREAM_TRAILER_LENGTH)) {
|
358
390
|
return aws_raise_error(AWS_ERROR_EVENT_STREAM_BUFFER_LENGTH_MISMATCH);
|
359
391
|
}
|
360
392
|
|
361
|
-
|
393
|
+
struct aws_byte_cursor parsing_cur = aws_byte_cursor_from_buf(buffer);
|
394
|
+
|
395
|
+
uint32_t message_length = 0;
|
396
|
+
aws_byte_cursor_read_be32(&parsing_cur, &message_length);
|
362
397
|
|
363
398
|
if (AWS_UNLIKELY(message_length != buffer->len)) {
|
364
399
|
return aws_raise_error(AWS_ERROR_EVENT_STREAM_BUFFER_LENGTH_MISMATCH);
|
@@ -367,17 +402,21 @@ int aws_event_stream_message_from_buffer(
|
|
367
402
|
if (AWS_UNLIKELY(message_length > AWS_EVENT_STREAM_MAX_MESSAGE_SIZE)) {
|
368
403
|
return aws_raise_error(AWS_ERROR_EVENT_STREAM_MESSAGE_FIELD_SIZE_EXCEEDED);
|
369
404
|
}
|
370
|
-
|
405
|
+
/* skip the headers for the moment, we'll handle those later. */
|
406
|
+
aws_byte_cursor_advance(&parsing_cur, sizeof(uint32_t));
|
371
407
|
uint32_t running_crc = aws_checksums_crc32(buffer->buffer, (int)PRELUDE_CRC_OFFSET, 0);
|
372
|
-
uint32_t prelude_crc =
|
408
|
+
uint32_t prelude_crc = 0;
|
409
|
+
const uint8_t *start_of_payload_checksum = parsing_cur.ptr;
|
410
|
+
size_t start_of_payload_checksum_pos = PRELUDE_CRC_OFFSET;
|
411
|
+
aws_byte_cursor_read_be32(&parsing_cur, &prelude_crc);
|
373
412
|
|
374
413
|
if (running_crc != prelude_crc) {
|
375
414
|
return aws_raise_error(AWS_ERROR_EVENT_STREAM_PRELUDE_CHECKSUM_FAILURE);
|
376
415
|
}
|
377
416
|
|
378
417
|
running_crc = aws_checksums_crc32(
|
379
|
-
|
380
|
-
(int)(message_length -
|
418
|
+
start_of_payload_checksum,
|
419
|
+
(int)(message_length - start_of_payload_checksum_pos - AWS_EVENT_STREAM_TRAILER_LENGTH),
|
381
420
|
running_crc);
|
382
421
|
uint32_t message_crc = aws_read_u32(buffer->buffer + message_length - AWS_EVENT_STREAM_TRAILER_LENGTH);
|
383
422
|
|
@@ -385,11 +424,14 @@ int aws_event_stream_message_from_buffer(
|
|
385
424
|
return aws_raise_error(AWS_ERROR_EVENT_STREAM_MESSAGE_CHECKSUM_FAILURE);
|
386
425
|
}
|
387
426
|
|
388
|
-
message->message_buffer = buffer
|
427
|
+
message->message_buffer = *buffer;
|
428
|
+
/* we don't own this buffer, this is a zero allocation/copy path. Setting allocator to null will prevent the
|
429
|
+
* clean_up from attempting to free it */
|
430
|
+
message->message_buffer.allocator = NULL;
|
389
431
|
|
390
432
|
if (aws_event_stream_message_headers_len(message) >
|
391
433
|
message_length - AWS_EVENT_STREAM_PRELUDE_LENGTH - AWS_EVENT_STREAM_TRAILER_LENGTH) {
|
392
|
-
message->message_buffer
|
434
|
+
AWS_ZERO_STRUCT(message->message_buffer);
|
393
435
|
return aws_raise_error(AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
394
436
|
}
|
395
437
|
|
@@ -404,17 +446,9 @@ int aws_event_stream_message_from_buffer_copy(
|
|
404
446
|
int parse_value = aws_event_stream_message_from_buffer(message, alloc, (struct aws_byte_buf *)buffer);
|
405
447
|
|
406
448
|
if (!parse_value) {
|
407
|
-
message->message_buffer
|
408
|
-
|
409
|
-
|
410
|
-
memcpy(message->message_buffer, buffer->buffer, buffer->len);
|
411
|
-
message->alloc = alloc;
|
412
|
-
message->owns_buffer = 1;
|
413
|
-
|
414
|
-
return AWS_OP_SUCCESS;
|
415
|
-
}
|
416
|
-
|
417
|
-
return aws_raise_error(AWS_ERROR_OOM);
|
449
|
+
aws_byte_buf_init_copy(&message->message_buffer, alloc, buffer);
|
450
|
+
message->alloc = alloc;
|
451
|
+
return AWS_OP_SUCCESS;
|
418
452
|
}
|
419
453
|
|
420
454
|
return parse_value;
|
@@ -422,47 +456,75 @@ int aws_event_stream_message_from_buffer_copy(
|
|
422
456
|
|
423
457
|
/* if buffer is owned, release the memory. */
|
424
458
|
void aws_event_stream_message_clean_up(struct aws_event_stream_message *message) {
|
425
|
-
|
426
|
-
aws_mem_release(message->alloc, message->message_buffer);
|
427
|
-
}
|
459
|
+
aws_byte_buf_clean_up(&message->message_buffer);
|
428
460
|
}
|
429
461
|
|
430
462
|
uint32_t aws_event_stream_message_total_length(const struct aws_event_stream_message *message) {
|
431
|
-
|
463
|
+
struct aws_byte_cursor read_cur = aws_byte_cursor_from_buf(&message->message_buffer);
|
464
|
+
aws_byte_cursor_advance(&read_cur, TOTAL_LEN_OFFSET);
|
465
|
+
uint32_t total_len = 0;
|
466
|
+
aws_byte_cursor_read_be32(&read_cur, &total_len);
|
467
|
+
|
468
|
+
return total_len;
|
432
469
|
}
|
433
470
|
|
434
471
|
uint32_t aws_event_stream_message_headers_len(const struct aws_event_stream_message *message) {
|
435
|
-
|
472
|
+
struct aws_byte_cursor read_cur = aws_byte_cursor_from_buf(&message->message_buffer);
|
473
|
+
aws_byte_cursor_advance(&read_cur, HEADER_LEN_OFFSET);
|
474
|
+
|
475
|
+
uint32_t headers_len = 0;
|
476
|
+
aws_byte_cursor_read_be32(&read_cur, &headers_len);
|
477
|
+
|
478
|
+
return headers_len;
|
436
479
|
}
|
437
480
|
|
438
481
|
uint32_t aws_event_stream_message_prelude_crc(const struct aws_event_stream_message *message) {
|
439
|
-
|
482
|
+
struct aws_byte_cursor read_cur = aws_byte_cursor_from_buf(&message->message_buffer);
|
483
|
+
aws_byte_cursor_advance(&read_cur, PRELUDE_CRC_OFFSET);
|
484
|
+
|
485
|
+
uint32_t prelude_crc = 0;
|
486
|
+
aws_byte_cursor_read_be32(&read_cur, &prelude_crc);
|
487
|
+
|
488
|
+
return prelude_crc;
|
440
489
|
}
|
441
490
|
|
442
491
|
int aws_event_stream_message_headers(const struct aws_event_stream_message *message, struct aws_array_list *headers) {
|
492
|
+
struct aws_byte_cursor read_cur = aws_byte_cursor_from_buf(&message->message_buffer);
|
493
|
+
aws_byte_cursor_advance(&read_cur, AWS_EVENT_STREAM_PRELUDE_LENGTH);
|
494
|
+
|
443
495
|
return aws_event_stream_read_headers_from_buffer(
|
444
|
-
headers,
|
445
|
-
message->message_buffer + AWS_EVENT_STREAM_PRELUDE_LENGTH,
|
446
|
-
aws_event_stream_message_headers_len(message));
|
496
|
+
headers, read_cur.ptr, aws_event_stream_message_headers_len(message));
|
447
497
|
}
|
448
498
|
|
449
499
|
const uint8_t *aws_event_stream_message_payload(const struct aws_event_stream_message *message) {
|
450
|
-
|
500
|
+
AWS_FATAL_PRECONDITION(message);
|
501
|
+
struct aws_byte_cursor read_cur = aws_byte_cursor_from_buf(&message->message_buffer);
|
502
|
+
aws_byte_cursor_advance(&read_cur, AWS_EVENT_STREAM_PRELUDE_LENGTH + aws_event_stream_message_headers_len(message));
|
503
|
+
return read_cur.ptr;
|
451
504
|
}
|
452
505
|
|
453
506
|
uint32_t aws_event_stream_message_payload_len(const struct aws_event_stream_message *message) {
|
507
|
+
AWS_FATAL_PRECONDITION(message);
|
454
508
|
return aws_event_stream_message_total_length(message) -
|
455
509
|
(AWS_EVENT_STREAM_PRELUDE_LENGTH + aws_event_stream_message_headers_len(message) +
|
456
510
|
AWS_EVENT_STREAM_TRAILER_LENGTH);
|
457
511
|
}
|
458
512
|
|
459
513
|
uint32_t aws_event_stream_message_message_crc(const struct aws_event_stream_message *message) {
|
460
|
-
|
461
|
-
|
514
|
+
AWS_FATAL_PRECONDITION(message);
|
515
|
+
struct aws_byte_cursor read_cur = aws_byte_cursor_from_buf(&message->message_buffer);
|
516
|
+
aws_byte_cursor_advance(
|
517
|
+
&read_cur, aws_event_stream_message_total_length(message) - AWS_EVENT_STREAM_TRAILER_LENGTH);
|
518
|
+
|
519
|
+
uint32_t message_crc = 0;
|
520
|
+
aws_byte_cursor_read_be32(&read_cur, &message_crc);
|
521
|
+
|
522
|
+
return message_crc;
|
462
523
|
}
|
463
524
|
|
464
525
|
const uint8_t *aws_event_stream_message_buffer(const struct aws_event_stream_message *message) {
|
465
|
-
|
526
|
+
AWS_FATAL_PRECONDITION(message);
|
527
|
+
return message->message_buffer.buffer;
|
466
528
|
}
|
467
529
|
|
468
530
|
#define DEBUG_STR_PRELUDE_TOTAL_LEN "\"total_length\": "
|
@@ -474,6 +536,9 @@ const uint8_t *aws_event_stream_message_buffer(const struct aws_event_stream_mes
|
|
474
536
|
#define DEBUG_STR_HEADER_TYPE "\"type\": "
|
475
537
|
|
476
538
|
int aws_event_stream_message_to_debug_str(FILE *fd, const struct aws_event_stream_message *message) {
|
539
|
+
AWS_FATAL_PRECONDITION(fd);
|
540
|
+
AWS_FATAL_PRECONDITION(message);
|
541
|
+
|
477
542
|
struct aws_array_list headers;
|
478
543
|
aws_event_stream_headers_list_init(&headers, message->alloc);
|
479
544
|
aws_event_stream_message_headers(message, &headers);
|
@@ -527,9 +592,6 @@ int aws_event_stream_message_to_debug_str(FILE *fd, const struct aws_event_strea
|
|
527
592
|
size_t buffer_len = 0;
|
528
593
|
aws_base64_compute_encoded_len(header->header_value_len, &buffer_len);
|
529
594
|
char *encoded_buffer = (char *)aws_mem_acquire(message->alloc, buffer_len);
|
530
|
-
if (!encoded_buffer) {
|
531
|
-
return aws_raise_error(AWS_ERROR_OOM);
|
532
|
-
}
|
533
595
|
|
534
596
|
struct aws_byte_buf encode_output = aws_byte_buf_from_array((uint8_t *)encoded_buffer, buffer_len);
|
535
597
|
|
@@ -565,10 +627,6 @@ int aws_event_stream_message_to_debug_str(FILE *fd, const struct aws_event_strea
|
|
565
627
|
aws_base64_compute_encoded_len(payload_len, &encoded_len);
|
566
628
|
char *encoded_payload = (char *)aws_mem_acquire(message->alloc, encoded_len);
|
567
629
|
|
568
|
-
if (!encoded_payload) {
|
569
|
-
return aws_raise_error(AWS_ERROR_OOM);
|
570
|
-
}
|
571
|
-
|
572
630
|
struct aws_byte_cursor payload_buffer = aws_byte_cursor_from_array(payload, payload_len);
|
573
631
|
struct aws_byte_buf encoded_payload_buffer = aws_byte_buf_from_array((uint8_t *)encoded_payload, encoded_len);
|
574
632
|
|
@@ -580,13 +638,15 @@ int aws_event_stream_message_to_debug_str(FILE *fd, const struct aws_event_strea
|
|
580
638
|
}
|
581
639
|
|
582
640
|
int aws_event_stream_headers_list_init(struct aws_array_list *headers, struct aws_allocator *allocator) {
|
583
|
-
|
584
|
-
|
641
|
+
AWS_FATAL_PRECONDITION(headers);
|
642
|
+
AWS_FATAL_PRECONDITION(allocator);
|
585
643
|
|
586
644
|
return aws_array_list_init_dynamic(headers, allocator, 4, sizeof(struct aws_event_stream_header_value_pair));
|
587
645
|
}
|
588
646
|
|
589
647
|
void aws_event_stream_headers_list_cleanup(struct aws_array_list *headers) {
|
648
|
+
AWS_FATAL_PRECONDITION(headers);
|
649
|
+
|
590
650
|
if (AWS_UNLIKELY(!headers || !aws_array_list_is_valid(headers))) {
|
591
651
|
return;
|
592
652
|
}
|
@@ -616,10 +676,6 @@ static int s_add_variable_len_header(
|
|
616
676
|
|
617
677
|
if (copy) {
|
618
678
|
header->header_value.variable_len_val = aws_mem_acquire(headers->alloc, value_len);
|
619
|
-
if (!header->header_value.variable_len_val) {
|
620
|
-
return aws_raise_error(AWS_ERROR_OOM);
|
621
|
-
}
|
622
|
-
|
623
679
|
header->value_owned = 1;
|
624
680
|
memcpy((void *)header->header_value.variable_len_val, (void *)value, value_len);
|
625
681
|
} else {
|
@@ -644,6 +700,10 @@ int aws_event_stream_add_string_header(
|
|
644
700
|
const char *value,
|
645
701
|
uint16_t value_len,
|
646
702
|
int8_t copy) {
|
703
|
+
AWS_FATAL_PRECONDITION(headers);
|
704
|
+
AWS_RETURN_ERROR_IF(
|
705
|
+
name_len <= AWS_EVENT_STREAM_HEADER_NAME_LEN_MAX, AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
706
|
+
AWS_RETURN_ERROR_IF(value_len <= INT16_MAX, AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
647
707
|
struct aws_event_stream_header_value_pair header = {.header_name_len = name_len,
|
648
708
|
.header_value_len = value_len,
|
649
709
|
.value_owned = copy,
|
@@ -655,8 +715,8 @@ int aws_event_stream_add_string_header(
|
|
655
715
|
struct aws_event_stream_header_value_pair aws_event_stream_create_string_header(
|
656
716
|
struct aws_byte_cursor name,
|
657
717
|
struct aws_byte_cursor value) {
|
658
|
-
|
659
|
-
|
718
|
+
AWS_FATAL_PRECONDITION(name.len <= AWS_EVENT_STREAM_HEADER_NAME_LEN_MAX);
|
719
|
+
AWS_FATAL_PRECONDITION(value.len <= INT16_MAX);
|
660
720
|
|
661
721
|
struct aws_event_stream_header_value_pair header = {
|
662
722
|
.header_value_type = AWS_EVENT_STREAM_HEADER_STRING,
|
@@ -674,7 +734,7 @@ struct aws_event_stream_header_value_pair aws_event_stream_create_string_header(
|
|
674
734
|
struct aws_event_stream_header_value_pair aws_event_stream_create_int32_header(
|
675
735
|
struct aws_byte_cursor name,
|
676
736
|
int32_t value) {
|
677
|
-
|
737
|
+
AWS_FATAL_PRECONDITION(name.len <= AWS_EVENT_STREAM_HEADER_NAME_LEN_MAX);
|
678
738
|
|
679
739
|
struct aws_event_stream_header_value_pair header = {
|
680
740
|
.header_value_type = AWS_EVENT_STREAM_HEADER_INT32,
|
@@ -690,6 +750,11 @@ struct aws_event_stream_header_value_pair aws_event_stream_create_int32_header(
|
|
690
750
|
}
|
691
751
|
|
692
752
|
int aws_event_stream_add_byte_header(struct aws_array_list *headers, const char *name, uint8_t name_len, int8_t value) {
|
753
|
+
AWS_FATAL_PRECONDITION(headers);
|
754
|
+
AWS_FATAL_PRECONDITION(name);
|
755
|
+
AWS_RETURN_ERROR_IF(
|
756
|
+
name_len <= AWS_EVENT_STREAM_HEADER_NAME_LEN_MAX, AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
757
|
+
|
693
758
|
struct aws_event_stream_header_value_pair header = {.header_name_len = name_len,
|
694
759
|
.header_value_len = 1,
|
695
760
|
.value_owned = 0,
|
@@ -702,6 +767,11 @@ int aws_event_stream_add_byte_header(struct aws_array_list *headers, const char
|
|
702
767
|
}
|
703
768
|
|
704
769
|
int aws_event_stream_add_bool_header(struct aws_array_list *headers, const char *name, uint8_t name_len, int8_t value) {
|
770
|
+
AWS_FATAL_PRECONDITION(headers);
|
771
|
+
AWS_FATAL_PRECONDITION(name);
|
772
|
+
AWS_RETURN_ERROR_IF(
|
773
|
+
name_len <= AWS_EVENT_STREAM_HEADER_NAME_LEN_MAX, AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
774
|
+
|
705
775
|
struct aws_event_stream_header_value_pair header = {
|
706
776
|
.header_name_len = name_len,
|
707
777
|
.header_value_len = 0,
|
@@ -719,6 +789,11 @@ int aws_event_stream_add_int16_header(
|
|
719
789
|
const char *name,
|
720
790
|
uint8_t name_len,
|
721
791
|
int16_t value) {
|
792
|
+
AWS_FATAL_PRECONDITION(headers);
|
793
|
+
AWS_FATAL_PRECONDITION(name);
|
794
|
+
AWS_RETURN_ERROR_IF(
|
795
|
+
name_len <= AWS_EVENT_STREAM_HEADER_NAME_LEN_MAX, AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
796
|
+
|
722
797
|
struct aws_event_stream_header_value_pair header = {
|
723
798
|
.header_name_len = name_len,
|
724
799
|
.header_value_len = sizeof(value),
|
@@ -737,6 +812,11 @@ int aws_event_stream_add_int32_header(
|
|
737
812
|
const char *name,
|
738
813
|
uint8_t name_len,
|
739
814
|
int32_t value) {
|
815
|
+
AWS_FATAL_PRECONDITION(headers);
|
816
|
+
AWS_FATAL_PRECONDITION(name);
|
817
|
+
AWS_RETURN_ERROR_IF(
|
818
|
+
name_len <= AWS_EVENT_STREAM_HEADER_NAME_LEN_MAX, AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
819
|
+
|
740
820
|
struct aws_event_stream_header_value_pair header = {
|
741
821
|
.header_name_len = name_len,
|
742
822
|
.header_value_len = sizeof(value),
|
@@ -755,6 +835,12 @@ int aws_event_stream_add_int64_header(
|
|
755
835
|
const char *name,
|
756
836
|
uint8_t name_len,
|
757
837
|
int64_t value) {
|
838
|
+
|
839
|
+
AWS_FATAL_PRECONDITION(headers);
|
840
|
+
AWS_FATAL_PRECONDITION(name);
|
841
|
+
AWS_RETURN_ERROR_IF(
|
842
|
+
name_len <= AWS_EVENT_STREAM_HEADER_NAME_LEN_MAX, AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
843
|
+
|
758
844
|
struct aws_event_stream_header_value_pair header = {
|
759
845
|
.header_name_len = name_len,
|
760
846
|
.header_value_len = sizeof(value),
|
@@ -775,6 +861,12 @@ int aws_event_stream_add_bytebuf_header(
|
|
775
861
|
uint8_t *value,
|
776
862
|
uint16_t value_len,
|
777
863
|
int8_t copy) {
|
864
|
+
AWS_FATAL_PRECONDITION(headers);
|
865
|
+
AWS_FATAL_PRECONDITION(name);
|
866
|
+
AWS_RETURN_ERROR_IF(
|
867
|
+
name_len <= AWS_EVENT_STREAM_HEADER_NAME_LEN_MAX, AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
868
|
+
AWS_RETURN_ERROR_IF(value_len <= INT16_MAX, AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
869
|
+
|
778
870
|
struct aws_event_stream_header_value_pair header = {.header_name_len = name_len,
|
779
871
|
.header_value_len = value_len,
|
780
872
|
.value_owned = copy,
|
@@ -788,6 +880,11 @@ int aws_event_stream_add_timestamp_header(
|
|
788
880
|
const char *name,
|
789
881
|
uint8_t name_len,
|
790
882
|
int64_t value) {
|
883
|
+
AWS_FATAL_PRECONDITION(headers);
|
884
|
+
AWS_FATAL_PRECONDITION(name);
|
885
|
+
AWS_RETURN_ERROR_IF(
|
886
|
+
name_len <= AWS_EVENT_STREAM_HEADER_NAME_LEN_MAX, AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
887
|
+
|
791
888
|
struct aws_event_stream_header_value_pair header = {
|
792
889
|
.header_name_len = name_len,
|
793
890
|
.header_value_len = sizeof(uint64_t),
|
@@ -806,60 +903,83 @@ int aws_event_stream_add_uuid_header(
|
|
806
903
|
const char *name,
|
807
904
|
uint8_t name_len,
|
808
905
|
const uint8_t *value) {
|
906
|
+
AWS_FATAL_PRECONDITION(headers);
|
907
|
+
AWS_FATAL_PRECONDITION(name);
|
908
|
+
AWS_RETURN_ERROR_IF(
|
909
|
+
name_len <= AWS_EVENT_STREAM_HEADER_NAME_LEN_MAX, AWS_ERROR_EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN);
|
910
|
+
|
809
911
|
struct aws_event_stream_header_value_pair header = {
|
810
912
|
.header_name_len = name_len,
|
811
|
-
.header_value_len =
|
913
|
+
.header_value_len = UUID_LEN,
|
812
914
|
.value_owned = 0,
|
813
915
|
.header_value_type = AWS_EVENT_STREAM_HEADER_UUID,
|
814
916
|
};
|
815
917
|
|
816
918
|
memcpy((void *)header.header_name, (void *)name, (size_t)name_len);
|
817
|
-
memcpy((void *)header.header_value.static_val, value,
|
919
|
+
memcpy((void *)header.header_value.static_val, value, UUID_LEN);
|
818
920
|
|
819
921
|
return aws_array_list_push_back(headers, (void *)&header);
|
820
922
|
}
|
821
923
|
|
822
924
|
struct aws_byte_buf aws_event_stream_header_name(struct aws_event_stream_header_value_pair *header) {
|
925
|
+
AWS_FATAL_PRECONDITION(header);
|
926
|
+
|
823
927
|
return aws_byte_buf_from_array((uint8_t *)header->header_name, header->header_name_len);
|
824
928
|
}
|
825
929
|
|
826
930
|
int8_t aws_event_stream_header_value_as_byte(struct aws_event_stream_header_value_pair *header) {
|
931
|
+
AWS_FATAL_PRECONDITION(header);
|
932
|
+
|
827
933
|
return (int8_t)header->header_value.static_val[0];
|
828
934
|
}
|
829
935
|
|
830
936
|
struct aws_byte_buf aws_event_stream_header_value_as_string(struct aws_event_stream_header_value_pair *header) {
|
937
|
+
AWS_FATAL_PRECONDITION(header);
|
938
|
+
|
831
939
|
return aws_event_stream_header_value_as_bytebuf(header);
|
832
940
|
}
|
833
941
|
|
834
942
|
int8_t aws_event_stream_header_value_as_bool(struct aws_event_stream_header_value_pair *header) {
|
943
|
+
AWS_FATAL_PRECONDITION(header);
|
944
|
+
|
835
945
|
return header->header_value_type == AWS_EVENT_STREAM_HEADER_BOOL_TRUE ? (int8_t)1 : (int8_t)0;
|
836
946
|
}
|
837
947
|
|
838
948
|
int16_t aws_event_stream_header_value_as_int16(struct aws_event_stream_header_value_pair *header) {
|
949
|
+
AWS_FATAL_PRECONDITION(header);
|
950
|
+
|
839
951
|
return (int16_t)aws_read_u16(header->header_value.static_val);
|
840
952
|
}
|
841
953
|
|
842
954
|
int32_t aws_event_stream_header_value_as_int32(struct aws_event_stream_header_value_pair *header) {
|
955
|
+
AWS_FATAL_PRECONDITION(header);
|
956
|
+
|
843
957
|
return (int32_t)aws_read_u32(header->header_value.static_val);
|
844
958
|
}
|
845
959
|
|
846
960
|
int64_t aws_event_stream_header_value_as_int64(struct aws_event_stream_header_value_pair *header) {
|
961
|
+
AWS_FATAL_PRECONDITION(header);
|
847
962
|
return (int64_t)aws_read_u64(header->header_value.static_val);
|
848
963
|
}
|
849
964
|
|
850
965
|
struct aws_byte_buf aws_event_stream_header_value_as_bytebuf(struct aws_event_stream_header_value_pair *header) {
|
966
|
+
AWS_FATAL_PRECONDITION(header);
|
851
967
|
return aws_byte_buf_from_array(header->header_value.variable_len_val, header->header_value_len);
|
852
968
|
}
|
853
969
|
|
854
970
|
int64_t aws_event_stream_header_value_as_timestamp(struct aws_event_stream_header_value_pair *header) {
|
971
|
+
AWS_FATAL_PRECONDITION(header);
|
855
972
|
return aws_event_stream_header_value_as_int64(header);
|
856
973
|
}
|
857
974
|
|
858
975
|
struct aws_byte_buf aws_event_stream_header_value_as_uuid(struct aws_event_stream_header_value_pair *header) {
|
859
|
-
|
976
|
+
AWS_FATAL_PRECONDITION(header);
|
977
|
+
return aws_byte_buf_from_array(header->header_value.static_val, UUID_LEN);
|
860
978
|
}
|
861
979
|
|
862
980
|
uint16_t aws_event_stream_header_value_length(struct aws_event_stream_header_value_pair *header) {
|
981
|
+
AWS_FATAL_PRECONDITION(header);
|
982
|
+
|
863
983
|
return header->header_value_len;
|
864
984
|
}
|
865
985
|
|
@@ -920,10 +1040,6 @@ static int s_read_header_value(
|
|
920
1040
|
current_header->header_value.variable_len_val =
|
921
1041
|
aws_mem_acquire(decoder->alloc, decoder->current_header.header_value_len);
|
922
1042
|
|
923
|
-
if (!current_header->header_value.variable_len_val) {
|
924
|
-
return aws_raise_error(AWS_ERROR_OOM);
|
925
|
-
}
|
926
|
-
|
927
1043
|
current_header->value_owned = 1;
|
928
1044
|
}
|
929
1045
|
}
|