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.
Files changed (322) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/VERSION +1 -1
  4. data/aws-crt-ffi/CMakeLists.txt +49 -41
  5. data/aws-crt-ffi/crt/aws-c-auth/CMakeLists.txt +0 -10
  6. data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/credentials.h +3 -2
  7. data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/private/credentials_utils.h +4 -4
  8. data/aws-crt-ffi/crt/aws-c-auth/source/auth.c +1 -14
  9. data/aws-crt-ffi/crt/aws-c-auth/source/aws_imds_client.c +206 -68
  10. data/aws-crt-ffi/crt/aws-c-auth/source/aws_signing.c +5 -0
  11. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_cached.c +6 -6
  12. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_default_chain.c +16 -1
  13. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_ecs.c +0 -1
  14. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_process.c +0 -1
  15. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_sts_web_identity.c +0 -1
  16. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_x509.c +10 -7
  17. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_utils.c +35 -26
  18. data/aws-crt-ffi/crt/aws-c-auth/source/signable_chunk.c +3 -2
  19. data/aws-crt-ffi/crt/aws-c-auth/tests/CMakeLists.txt +3 -2
  20. data/aws-crt-ffi/crt/aws-c-auth/tests/aws_imds_client_test.c +1 -0
  21. data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_provider_ecs_tests.c +3 -0
  22. data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_provider_process_tests.c +65 -16
  23. data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_tests.c +125 -0
  24. data/aws-crt-ffi/crt/aws-c-auth/tests/sigv4_signing_tests.c +68 -46
  25. data/aws-crt-ffi/crt/aws-c-cal/CMakeLists.txt +8 -3
  26. data/aws-crt-ffi/crt/aws-c-cal/bin/run_x_platform_fuzz_corpus/main.c +9 -0
  27. data/aws-crt-ffi/crt/aws-c-cal/builder.json +11 -3
  28. data/aws-crt-ffi/crt/aws-c-cal/cmake/aws-c-cal-config.cmake +14 -5
  29. data/aws-crt-ffi/crt/aws-c-cal/source/darwin/securityframework_ecc.c +6 -6
  30. data/aws-crt-ffi/crt/aws-c-cal/source/windows/bcrypt_ecc.c +12 -12
  31. data/aws-crt-ffi/crt/aws-c-cal/tests/test_case_helper.h +14 -14
  32. data/aws-crt-ffi/crt/aws-c-common/CMakeLists.txt +21 -1
  33. data/aws-crt-ffi/crt/aws-c-common/README.md +8 -0
  34. data/aws-crt-ffi/crt/aws-c-common/cmake/AwsCFlags.cmake +20 -5
  35. data/aws-crt-ffi/crt/aws-c-common/cmake/AwsFeatureTests.cmake +7 -1
  36. data/aws-crt-ffi/crt/aws-c-common/format-check.sh +1 -1
  37. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/byte_buf.h +14 -0
  38. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/config.h.in +1 -0
  39. data/aws-crt-ffi/crt/{aws-c-auth/include/aws/auth → aws-c-common/include/aws/common}/external/cJSON.h +82 -74
  40. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/json.h +335 -0
  41. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/logging.h +1 -0
  42. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/math.inl +2 -2
  43. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/private/json_impl.h +22 -0
  44. data/aws-crt-ffi/crt/aws-c-common/include/aws/testing/aws_test_harness.h +2 -0
  45. data/aws-crt-ffi/crt/aws-c-common/source/byte_buf.c +36 -0
  46. data/aws-crt-ffi/crt/aws-c-common/source/common.c +5 -2
  47. data/aws-crt-ffi/crt/aws-c-common/source/external/cJSON.c +3113 -0
  48. data/aws-crt-ffi/crt/aws-c-common/source/file.c +9 -0
  49. data/aws-crt-ffi/crt/aws-c-common/source/json.c +348 -0
  50. data/aws-crt-ffi/crt/aws-c-common/source/logging.c +7 -2
  51. data/aws-crt-ffi/crt/aws-c-common/source/posix/system_info.c +8 -0
  52. data/aws-crt-ffi/crt/aws-c-common/source/ref_count.c +3 -1
  53. data/aws-crt-ffi/crt/aws-c-common/source/windows/file.c +47 -0
  54. data/aws-crt-ffi/crt/aws-c-common/source/windows/system_info.c +2 -1
  55. data/aws-crt-ffi/crt/aws-c-common/tests/CMakeLists.txt +5 -0
  56. data/aws-crt-ffi/crt/aws-c-common/tests/byte_buf_test.c +69 -0
  57. data/aws-crt-ffi/crt/aws-c-common/tests/json_test.c +134 -0
  58. data/aws-crt-ffi/crt/aws-c-common/tests/memtrace_test.c +6 -2
  59. data/aws-crt-ffi/crt/aws-c-event-stream/README.md +18 -35
  60. data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream.h +21 -2
  61. data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream_rpc_client.h +14 -2
  62. data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream_rpc_server.h +13 -0
  63. data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/private/event_stream_rpc_priv.h +7 -7
  64. data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream.c +257 -141
  65. data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_channel_handler.c +1 -1
  66. data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_rpc_client.c +31 -8
  67. data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_rpc_server.c +63 -10
  68. data/aws-crt-ffi/crt/aws-c-event-stream/tests/CMakeLists.txt +2 -0
  69. data/aws-crt-ffi/crt/aws-c-event-stream/tests/event_stream_rpc_client_connection_test.c +157 -106
  70. data/aws-crt-ffi/crt/aws-c-event-stream/tests/event_stream_rpc_server_connection_test.c +168 -1
  71. data/aws-crt-ffi/crt/aws-c-event-stream/tests/message_deserializer_test.c +4 -2
  72. data/aws-crt-ffi/crt/aws-c-http/CMakeLists.txt +1 -0
  73. data/aws-crt-ffi/crt/aws-c-http/README.md +8 -0
  74. data/aws-crt-ffi/crt/aws-c-http/bin/elasticurl/main.c +1 -1
  75. data/aws-crt-ffi/crt/aws-c-http/builder.json +4 -3
  76. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/connection.h +8 -1
  77. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/connection_manager.h +45 -1
  78. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/http2_stream_manager.h +63 -12
  79. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/connection_impl.h +2 -1
  80. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_connection.h +20 -2
  81. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_frames.h +1 -0
  82. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_stream.h +42 -13
  83. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/http2_stream_manager_impl.h +17 -0
  84. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/http_impl.h +3 -0
  85. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/random_access_set.h +10 -3
  86. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/request_response_impl.h +3 -17
  87. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/request_response.h +108 -4
  88. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/statistics.h +22 -0
  89. data/aws-crt-ffi/crt/aws-c-http/source/connection.c +8 -3
  90. data/aws-crt-ffi/crt/aws-c-http/source/connection_manager.c +22 -3
  91. data/aws-crt-ffi/crt/aws-c-http/source/connection_monitor.c +32 -14
  92. data/aws-crt-ffi/crt/aws-c-http/source/h1_connection.c +14 -0
  93. data/aws-crt-ffi/crt/aws-c-http/source/h1_encoder.c +7 -4
  94. data/aws-crt-ffi/crt/aws-c-http/source/h2_connection.c +161 -45
  95. data/aws-crt-ffi/crt/aws-c-http/source/h2_decoder.c +37 -8
  96. data/aws-crt-ffi/crt/aws-c-http/source/h2_frames.c +13 -1
  97. data/aws-crt-ffi/crt/aws-c-http/source/h2_stream.c +345 -87
  98. data/aws-crt-ffi/crt/aws-c-http/source/hpack.c +3 -0
  99. data/aws-crt-ffi/crt/aws-c-http/source/http.c +3 -0
  100. data/aws-crt-ffi/crt/aws-c-http/source/http2_stream_manager.c +266 -39
  101. data/aws-crt-ffi/crt/aws-c-http/source/random_access_set.c +9 -3
  102. data/aws-crt-ffi/crt/aws-c-http/source/request_response.c +80 -20
  103. data/aws-crt-ffi/crt/aws-c-http/source/statistics.c +11 -0
  104. data/aws-crt-ffi/crt/aws-c-http/tests/CMakeLists.txt +28 -1
  105. data/aws-crt-ffi/crt/aws-c-http/tests/fuzz/fuzz_h2_decoder_correct.c +5 -3
  106. data/aws-crt-ffi/crt/aws-c-http/tests/h2_test_helper.c +133 -29
  107. data/aws-crt-ffi/crt/aws-c-http/tests/h2_test_helper.h +6 -0
  108. data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/README.md +40 -0
  109. data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/non_tls_server.py +56 -0
  110. data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/server.py +329 -0
  111. data/aws-crt-ffi/crt/aws-c-http/tests/test_connection_manager.c +1 -1
  112. data/aws-crt-ffi/crt/aws-c-http/tests/test_connection_monitor.c +2 -2
  113. data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_client.c +47 -34
  114. data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_encoder.c +4 -4
  115. data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_server.c +15 -12
  116. data/aws-crt-ffi/crt/aws-c-http/tests/test_h2_client.c +582 -25
  117. data/aws-crt-ffi/crt/aws-c-http/tests/test_h2_encoder.c +3 -3
  118. data/aws-crt-ffi/crt/aws-c-http/tests/test_localhost_integ.c +530 -0
  119. data/aws-crt-ffi/crt/aws-c-http/tests/test_stream_manager.c +459 -67
  120. data/aws-crt-ffi/crt/aws-c-io/CMakeLists.txt +4 -0
  121. data/aws-crt-ffi/crt/aws-c-io/builder.json +3 -2
  122. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/channel.h +21 -0
  123. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/io.h +3 -0
  124. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/socket.h +6 -0
  125. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/stream.h +35 -5
  126. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/tls_channel_handler.h +211 -15
  127. data/aws-crt-ffi/crt/aws-c-io/source/channel.c +56 -30
  128. data/aws-crt-ffi/crt/aws-c-io/source/darwin/secure_transport_tls_channel_handler.c +0 -24
  129. data/aws-crt-ffi/crt/aws-c-io/source/io.c +9 -0
  130. data/aws-crt-ffi/crt/aws-c-io/source/{pkcs11.c → pkcs11_lib.c} +162 -22
  131. data/aws-crt-ffi/crt/aws-c-io/source/pkcs11_private.h +18 -20
  132. data/aws-crt-ffi/crt/aws-c-io/source/pkcs11_tls_op_handler.c +221 -0
  133. data/aws-crt-ffi/crt/aws-c-io/source/posix/socket.c +135 -81
  134. data/aws-crt-ffi/crt/aws-c-io/source/retry_strategy.c +12 -8
  135. data/aws-crt-ffi/crt/aws-c-io/source/s2n/s2n_tls_channel_handler.c +252 -215
  136. data/aws-crt-ffi/crt/aws-c-io/source/stream.c +65 -82
  137. data/aws-crt-ffi/crt/aws-c-io/source/tls_channel_handler.c +188 -57
  138. data/aws-crt-ffi/crt/aws-c-io/source/windows/iocp/socket.c +271 -256
  139. data/aws-crt-ffi/crt/aws-c-io/tests/CMakeLists.txt +21 -12
  140. data/aws-crt-ffi/crt/aws-c-io/tests/channel_test.c +32 -4
  141. data/aws-crt-ffi/crt/aws-c-io/tests/io_lib_test.c +37 -0
  142. data/aws-crt-ffi/crt/aws-c-io/tests/pkcs11_test.c +412 -93
  143. data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.crt +15 -0
  144. data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.key +5 -0
  145. data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.p12 +0 -0
  146. data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.p8 +5 -0
  147. data/aws-crt-ffi/crt/aws-c-io/tests/resources/generateCerts.sh +24 -15
  148. data/aws-crt-ffi/crt/aws-c-io/tests/socket_test.c +72 -1
  149. data/aws-crt-ffi/crt/s2n/CMakeLists.txt +6 -1
  150. data/aws-crt-ffi/crt/s2n/bindings/rust/Cargo.toml +1 -0
  151. data/aws-crt-ffi/crt/s2n/bindings/rust/generate/src/main.rs +105 -82
  152. data/aws-crt-ffi/crt/s2n/bindings/rust/generate.sh +1 -0
  153. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/Cargo.toml +2 -2
  154. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/src/raw/config.rs +1 -1
  155. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/Cargo.toml +1 -1
  156. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/build.rs +84 -30
  157. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/src/lib.rs +4 -0
  158. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/Cargo.toml +21 -0
  159. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/certs/cert.pem +14 -0
  160. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/certs/key.pem +8 -0
  161. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/client.rs +45 -0
  162. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/server.rs +60 -0
  163. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/src/lib.rs +150 -0
  164. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/tests/handshake.rs +51 -0
  165. data/aws-crt-ffi/crt/s2n/crypto/s2n_drbg.c +98 -77
  166. data/aws-crt-ffi/crt/s2n/crypto/s2n_drbg.h +10 -7
  167. data/aws-crt-ffi/crt/s2n/crypto/s2n_openssl.h +2 -0
  168. data/aws-crt-ffi/crt/s2n/error/s2n_errno.c +1 -1
  169. data/aws-crt-ffi/crt/s2n/error/s2n_errno.h +1 -0
  170. data/aws-crt-ffi/crt/s2n/s2n.mk +7 -0
  171. data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/repository.py +233 -0
  172. data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/setup-proof.py +8 -7
  173. data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/setup.py +17 -18
  174. data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/util.py +41 -23
  175. data/aws-crt-ffi/crt/s2n/tests/fuzz/LD_PRELOAD/global_overrides.c +3 -3
  176. data/aws-crt-ffi/crt/s2n/tests/integration/s2n_client_endpoint_handshake_test.py +2 -2
  177. data/aws-crt-ffi/crt/s2n/tests/integrationv2/Makefile +13 -42
  178. data/aws-crt-ffi/crt/s2n/tests/integrationv2/README.md +6 -1
  179. data/aws-crt-ffi/crt/s2n/tests/integrationv2/common.py +118 -53
  180. data/aws-crt-ffi/crt/s2n/tests/integrationv2/configuration.py +108 -88
  181. data/aws-crt-ffi/crt/s2n/tests/integrationv2/conftest.py +6 -3
  182. data/aws-crt-ffi/crt/s2n/tests/integrationv2/constants.py +6 -4
  183. data/aws-crt-ffi/crt/s2n/tests/integrationv2/fixtures.py +21 -12
  184. data/aws-crt-ffi/crt/s2n/tests/integrationv2/global_flags.py +1 -0
  185. data/aws-crt-ffi/crt/s2n/tests/integrationv2/processes.py +62 -19
  186. data/aws-crt-ffi/crt/s2n/tests/integrationv2/providers.py +304 -48
  187. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_client_authentication.py +20 -11
  188. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_cross_compatibility.py +41 -17
  189. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_dynamic_record_sizes.py +6 -3
  190. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_early_data.py +105 -48
  191. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_external_psk.py +160 -76
  192. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_fragmentation.py +59 -26
  193. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_happy_path.py +42 -28
  194. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_hello_retry_requests.py +33 -13
  195. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_key_update.py +29 -11
  196. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_ocsp.py +138 -0
  197. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_pq_handshake.py +103 -36
  198. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_session_resumption.py +52 -25
  199. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_signature_algorithms.py +47 -21
  200. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_sni_match.py +13 -9
  201. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_sslyze.py +88 -17
  202. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_version_negotiation.py +71 -22
  203. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_well_known_endpoints.py +4 -3
  204. data/aws-crt-ffi/crt/s2n/tests/integrationv2/tox.ini +1 -0
  205. data/aws-crt-ffi/crt/s2n/tests/integrationv2/utils.py +50 -15
  206. data/aws-crt-ffi/crt/s2n/tests/litani/CHANGELOG +131 -0
  207. data/aws-crt-ffi/crt/s2n/tests/litani/CONTRIBUTING.md +16 -0
  208. data/aws-crt-ffi/crt/s2n/tests/litani/README.md +36 -14
  209. data/aws-crt-ffi/crt/s2n/tests/litani/THIRD-PARTY +205 -41
  210. data/aws-crt-ffi/crt/s2n/tests/litani/doc/bin/build-html-doc +7 -7
  211. data/aws-crt-ffi/crt/s2n/tests/litani/doc/configure +27 -23
  212. data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-add-job.scdoc +7 -0
  213. data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-dump-run.scdoc +7 -5
  214. data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-transform-jobs.scdoc +248 -0
  215. data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani.scdoc +2 -2
  216. data/aws-crt-ffi/crt/s2n/tests/litani/doc/templates/index.jinja.html +4 -0
  217. data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/README +12 -0
  218. data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/original-run.sh +52 -0
  219. data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/run-all.py +71 -0
  220. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/README +13 -0
  221. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-1.sh +34 -0
  222. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-2.sh +35 -0
  223. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-3.sh +34 -0
  224. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-all.py +60 -0
  225. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/README.md +10 -0
  226. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/assumptions.html +42 -0
  227. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/file.dat +7 -0
  228. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/histogram.dat +7 -0
  229. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-1.sh +41 -0
  230. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-2.sh +47 -0
  231. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-3.sh +41 -0
  232. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-all.py +34 -0
  233. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib-table.py +40 -0
  234. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib.plt +5 -0
  235. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib.py +32 -0
  236. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin-output.py +40 -0
  237. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin.plt +5 -0
  238. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin.py +30 -0
  239. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/templates/fib-table.jinja.html +45 -0
  240. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/templates/sin-output.jinja.html +30 -0
  241. data/aws-crt-ffi/crt/s2n/tests/litani/lib/add_job.py +55 -0
  242. data/aws-crt-ffi/crt/s2n/tests/litani/lib/graph.py +2 -2
  243. data/aws-crt-ffi/crt/s2n/tests/litani/lib/litani.py +6 -1
  244. data/aws-crt-ffi/crt/s2n/tests/litani/lib/litani_report.py +18 -21
  245. data/aws-crt-ffi/crt/s2n/tests/litani/lib/ninja.py +2 -0
  246. data/aws-crt-ffi/crt/s2n/tests/litani/lib/run_printer.py +26 -7
  247. data/aws-crt-ffi/crt/s2n/tests/litani/lib/transform_jobs.py +84 -0
  248. data/aws-crt-ffi/crt/s2n/tests/litani/litani +28 -33
  249. data/aws-crt-ffi/crt/s2n/tests/litani/script/release +220 -0
  250. data/aws-crt-ffi/crt/s2n/tests/litani/templates/dashboard.jinja.html +78 -15
  251. data/aws-crt-ffi/crt/s2n/tests/litani/templates/pipeline.jinja.html +21 -5
  252. data/aws-crt-ffi/crt/s2n/tests/litani/test/README +15 -0
  253. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/run +56 -33
  254. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/custom_stages.py +1 -0
  255. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/cwd.py +1 -0
  256. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/dump_run.py +1 -0
  257. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/graph_line_break.py +1 -0
  258. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/html_node.py +1 -0
  259. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/job_id_env.py +1 -0
  260. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/multiproc_dump_run.py +1 -0
  261. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_pool_serialize.py +1 -0
  262. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_pool_serialize_graph.py +1 -0
  263. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out.py +1 -0
  264. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out_timeout_ignored.py +1 -0
  265. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out_timeout_ok.py +1 -0
  266. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pipeline_order.py +53 -0
  267. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pool_serialize.py +1 -0
  268. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pool_serialize_graph.py +1 -0
  269. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/single_pool.py +1 -0
  270. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out.py +1 -0
  271. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess.py +1 -0
  272. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess_multi_shell.py +1 -0
  273. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess_shell.py +1 -0
  274. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_timeout_ignored.py +1 -0
  275. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_timeout_ok.py +1 -0
  276. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_delete_job.py +54 -0
  277. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_modify_job.py +46 -0
  278. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_no_change_job.py +44 -0
  279. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/zero_pool.py +1 -0
  280. data/aws-crt-ffi/crt/s2n/tests/litani/test/run +82 -12
  281. data/aws-crt-ffi/crt/s2n/tests/s2n_test.h +58 -33
  282. data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_key_schedule_testlib.c +18 -6
  283. data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_pq_kat_test_utils.c +4 -4
  284. data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_testlib.h +2 -0
  285. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_client_hello_retry_test.c +66 -2
  286. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_connection_test.c +1 -1
  287. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_drbg_test.c +34 -14
  288. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_fork_generation_number_test.c +28 -5
  289. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_mem_usage_test.c +6 -0
  290. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_override_openssl_random_test.c +1 -1
  291. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_random_test.c +60 -41
  292. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_self_talk_broken_pipe_test.c +2 -2
  293. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_handshake_early_data_test.c +3 -1
  294. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_hybrid_shared_secret_test.c +9 -1
  295. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_key_schedule_rfc8448_test.c +31 -130
  296. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_key_schedule_test.c +2 -4
  297. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_pq_handshake_test.c +11 -6
  298. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_secrets_rfc8448_test.c +19 -21
  299. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_secrets_test.c +109 -60
  300. data/aws-crt-ffi/crt/s2n/tls/s2n_config.c +1 -0
  301. data/aws-crt-ffi/crt/s2n/tls/s2n_config.h +1 -1
  302. data/aws-crt-ffi/crt/s2n/tls/s2n_connection.c +29 -24
  303. data/aws-crt-ffi/crt/s2n/tls/s2n_connection.h +5 -5
  304. data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_hashes.h +1 -7
  305. data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_io.c +2 -0
  306. data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_transcript.c +0 -44
  307. data/aws-crt-ffi/crt/s2n/tls/s2n_internal.h +0 -1
  308. data/aws-crt-ffi/crt/s2n/tls/s2n_quic_support.h +1 -1
  309. data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_key_schedule.c +1 -2
  310. data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_secrets.c +84 -44
  311. data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_secrets.h +3 -9
  312. data/aws-crt-ffi/crt/s2n/utils/s2n_blob.h +15 -8
  313. data/aws-crt-ffi/crt/s2n/utils/s2n_fork_detection.c +2 -6
  314. data/aws-crt-ffi/crt/s2n/utils/s2n_random.c +9 -9
  315. data/aws-crt-ffi/src/input_stream.c +32 -15
  316. data/ext/compile.rb +13 -5
  317. data/lib/aws-crt/platforms.rb +14 -5
  318. data/lib/aws-crt/string_blob.rb +3 -3
  319. metadata +61 -7
  320. data/aws-crt-ffi/crt/aws-c-auth/source/external/cJSON.c +0 -2987
  321. data/aws-crt-ffi/crt/aws-c-auth/tests/external/cJSON.c +0 -2986
  322. data/aws-crt-ffi/crt/aws-c-io/tests/error_test.c +0 -20
@@ -190,6 +190,10 @@ if (BYO_CRYPTO)
190
190
  target_compile_definitions(${PROJECT_NAME} PUBLIC "-DBYO_CRYPTO")
191
191
  endif()
192
192
 
193
+ if (USE_S2N)
194
+ target_compile_definitions(${PROJECT_NAME} PRIVATE "-DUSE_S2N")
195
+ endif()
196
+
193
197
  if (BUILD_RELOCATABLE_BINARIES)
194
198
  target_compile_definitions(${PROJECT_NAME} PRIVATE "-DCOMPAT_MODE")
195
199
  endif()
@@ -2,11 +2,12 @@
2
2
  "name": "aws-c-io",
3
3
  "upstream": [
4
4
  { "name": "aws-c-common" },
5
+ { "name": "aws-c-cal" },
5
6
  {
6
7
  "name": "s2n",
8
+ "revision": "v1.3.11",
7
9
  "targets": ["linux", "android"]
8
- },
9
- { "name": "aws-c-cal" }
10
+ }
10
11
  ],
11
12
  "downstream": [
12
13
  { "name": "aws-c-mqtt" },
@@ -279,11 +279,32 @@ struct aws_io_message *aws_channel_acquire_message_from_pool(
279
279
  * This is the ideal way to move a task into the correct thread. It's also handy for context switches.
280
280
  * This function is safe to call from any thread.
281
281
  *
282
+ * If called from the channel's event loop, the task will get directly added to the run-now list.
283
+ * If called from outside the channel's event loop, the task will go into a cross-thread task queue.
284
+ *
285
+ * If tasks must be serialized relative to some source synchronization, you may not want to use this API
286
+ * because tasks submitted from the event loop thread can "jump ahead" of tasks submitted from external threads
287
+ * due to this optimization. If this is a problem, you can either refactor your submission logic or use
288
+ * the aws_channel_schedule_task_now_serialized variant which does not perform this optimization.
289
+ *
282
290
  * The task should not be cleaned up or modified until its function is executed.
283
291
  */
284
292
  AWS_IO_API
285
293
  void aws_channel_schedule_task_now(struct aws_channel *channel, struct aws_channel_task *task);
286
294
 
295
+ /**
296
+ * Schedules a task to run on the event loop as soon as possible.
297
+ *
298
+ * This variant always uses the cross thread queue rather than conditionally skipping it when already in
299
+ * the destination event loop. While not "optimal", this allows us to serialize task execution no matter where
300
+ * the task was submitted from: if you are submitting tasks from a critical section, the serialized order that you
301
+ * submit is guaranteed to be the order that they execute on the event loop.
302
+ *
303
+ * The task should not be cleaned up or modified until its function is executed.
304
+ */
305
+ AWS_IO_API
306
+ void aws_channel_schedule_task_now_serialized(struct aws_channel *channel, struct aws_channel_task *task);
307
+
287
308
  /**
288
309
  * Schedules a task to run on the event loop at the specified time.
289
310
  * This is the ideal way to move a task into the correct thread. It's also handy for context switches.
@@ -240,6 +240,9 @@ enum aws_io_errors {
240
240
 
241
241
  AWS_ERROR_IO_PINNED_EVENT_LOOP_MISMATCH,
242
242
 
243
+ AWS_ERROR_PKCS11_ENCODING_ERROR,
244
+ AWS_IO_TLS_ERROR_DEFAULT_TRUST_STORE_NOT_FOUND,
245
+
243
246
  AWS_IO_ERROR_END_RANGE = AWS_ERROR_ENUM_END_RANGE(AWS_C_IO_PACKAGE_ID),
244
247
  AWS_IO_INVALID_FILE_HANDLE = AWS_ERROR_INVALID_FILE_HANDLE,
245
248
  };
@@ -176,6 +176,12 @@ AWS_IO_API int aws_socket_connect(
176
176
  */
177
177
  AWS_IO_API int aws_socket_bind(struct aws_socket *socket, const struct aws_socket_endpoint *local_endpoint);
178
178
 
179
+ /**
180
+ * Get the local address which the socket is bound to.
181
+ * Raises an error if no address is bound.
182
+ */
183
+ AWS_IO_API int aws_socket_get_bound_address(const struct aws_socket *socket, struct aws_socket_endpoint *out_address);
184
+
179
185
  /**
180
186
  * TCP, LOCAL and VSOCK only. Sets up the socket to listen on the address bound to in `aws_socket_bind()`.
181
187
  */
@@ -6,6 +6,7 @@
6
6
  * SPDX-License-Identifier: Apache-2.0.
7
7
  */
8
8
 
9
+ #include <aws/common/ref_count.h>
9
10
  #include <aws/io/io.h>
10
11
 
11
12
  struct aws_input_stream;
@@ -38,17 +39,46 @@ struct aws_input_stream_vtable {
38
39
  int (*read)(struct aws_input_stream *stream, struct aws_byte_buf *dest);
39
40
  int (*get_status)(struct aws_input_stream *stream, struct aws_stream_status *status);
40
41
  int (*get_length)(struct aws_input_stream *stream, int64_t *out_length);
41
- void (*destroy)(struct aws_input_stream *stream);
42
+
43
+ /**
44
+ * Optional.
45
+ * If not set, the default aws_ref_count_acquire/release will be used.
46
+ * Set for high level language binding that has its own refcounting implementation and needs to be kept alive from
47
+ * C.
48
+ * If set, ref_count member will not be used.
49
+ */
50
+ void (*acquire)(struct aws_input_stream *stream);
51
+ void (*release)(struct aws_input_stream *stream);
42
52
  };
43
53
 
54
+ /**
55
+ * Base class for input streams.
56
+ * Note: when you implement one input stream, the ref_count needs to be initialized to clean up the resource when
57
+ * reaches to zero.
58
+ */
44
59
  struct aws_input_stream {
45
- struct aws_allocator *allocator;
60
+ /* point to the impl only set if needed. */
46
61
  void *impl;
47
- struct aws_input_stream_vtable *vtable;
62
+ const struct aws_input_stream_vtable *vtable;
63
+ struct aws_ref_count ref_count;
48
64
  };
49
65
 
50
66
  AWS_EXTERN_C_BEGIN
51
67
 
68
+ /**
69
+ * Increments the reference count on the input stream, allowing the caller to take a reference to it.
70
+ *
71
+ * Returns the same input stream passed in.
72
+ */
73
+ AWS_IO_API struct aws_input_stream *aws_input_stream_acquire(struct aws_input_stream *stream);
74
+
75
+ /**
76
+ * Decrements a input stream's ref count. When the ref count drops to zero, the input stream will be destroyed.
77
+ *
78
+ * Returns NULL always.
79
+ */
80
+ AWS_IO_API struct aws_input_stream *aws_input_stream_release(struct aws_input_stream *stream);
81
+
52
82
  /*
53
83
  * Seek to a position within a stream; analagous to fseek() and its relatives
54
84
  */
@@ -72,8 +102,8 @@ AWS_IO_API int aws_input_stream_get_status(struct aws_input_stream *stream, stru
72
102
  */
73
103
  AWS_IO_API int aws_input_stream_get_length(struct aws_input_stream *stream, int64_t *out_length);
74
104
 
75
- /*
76
- * Tears down the stream
105
+ /* DEPRECATED
106
+ * Tears down the stream. Equivalent to aws_input_stream_release()
77
107
  */
78
108
  AWS_IO_API void aws_input_stream_destroy(struct aws_input_stream *stream);
79
109
 
@@ -24,16 +24,57 @@ enum aws_tls_versions {
24
24
 
25
25
  enum aws_tls_cipher_pref {
26
26
  AWS_IO_TLS_CIPHER_PREF_SYSTEM_DEFAULT = 0,
27
- AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2019_06 = 1,
28
- AWS_IO_TLS_CIPHER_PREF_KMS_PQ_SIKE_TLSv1_0_2019_11 = 2,
29
- AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2020_02 = 3,
30
- AWS_IO_TLS_CIPHER_PREF_KMS_PQ_SIKE_TLSv1_0_2020_02 = 4,
31
- AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2020_07 = 5,
27
+
28
+ /* Deprecated */ AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2019_06 = 1,
29
+ /* Deprecated */ AWS_IO_TLS_CIPHER_PREF_KMS_PQ_SIKE_TLSv1_0_2019_11 = 2,
30
+ /* Deprecated */ AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2020_02 = 3,
31
+ /* Deprecated */ AWS_IO_TLS_CIPHER_PREF_KMS_PQ_SIKE_TLSv1_0_2020_02 = 4,
32
+ /* Deprecated */ AWS_IO_TLS_CIPHER_PREF_KMS_PQ_TLSv1_0_2020_07 = 5,
33
+
34
+ /*
35
+ * This TLS cipher preference list contains post-quantum key exchange algorithms that have been submitted to NIST
36
+ * for potential future standardization. Support for this preference list, or PQ algorithms present in it, may be
37
+ * removed at any time in the future. PQ algorithms in this preference list will be used in hybrid mode, and always
38
+ * combined with a classical ECDHE key exchange.
39
+ */
32
40
  AWS_IO_TLS_CIPHER_PREF_PQ_TLSv1_0_2021_05 = 6,
33
41
 
34
42
  AWS_IO_TLS_CIPHER_PREF_END_RANGE = 0xFFFF
35
43
  };
36
44
 
45
+ /**
46
+ * The hash algorithm of a TLS private key operation. Any custom private key operation handlers are expected to perform
47
+ * operations on the input TLS data using the correct hash algorithm or fail the operation.
48
+ */
49
+ enum aws_tls_hash_algorithm {
50
+ AWS_TLS_HASH_UNKNOWN,
51
+ AWS_TLS_HASH_SHA1,
52
+ AWS_TLS_HASH_SHA224,
53
+ AWS_TLS_HASH_SHA256,
54
+ AWS_TLS_HASH_SHA384,
55
+ AWS_TLS_HASH_SHA512,
56
+ };
57
+
58
+ /**
59
+ * The signature of a TLS private key operation. Any custom private key operation handlers are expected to perform
60
+ * operations on the input TLS data using the correct signature algorithm or fail the operation.
61
+ */
62
+ enum aws_tls_signature_algorithm {
63
+ AWS_TLS_SIGNATURE_UNKNOWN,
64
+ AWS_TLS_SIGNATURE_RSA,
65
+ AWS_TLS_SIGNATURE_ECDSA,
66
+ };
67
+
68
+ /**
69
+ * The TLS private key operation that needs to be performed by a custom private key operation handler when making
70
+ * a connection using mutual TLS.
71
+ */
72
+ enum aws_tls_key_operation_type {
73
+ AWS_TLS_KEY_OPERATION_UNKNOWN,
74
+ AWS_TLS_KEY_OPERATION_SIGN,
75
+ AWS_TLS_KEY_OPERATION_DECRYPT,
76
+ };
77
+
37
78
  struct aws_tls_ctx {
38
79
  struct aws_allocator *alloc;
39
80
  void *impl;
@@ -94,6 +135,13 @@ struct aws_tls_connection_options {
94
135
  uint32_t timeout_ms;
95
136
  };
96
137
 
138
+ /**
139
+ * A struct containing all of the data needed for a private key operation when
140
+ * making a mutual TLS connection. This struct contains the data that needs
141
+ * to be operated on, like performing a sign operation or a decrypt operation.
142
+ */
143
+ struct aws_tls_key_operation;
144
+
97
145
  struct aws_tls_ctx_options {
98
146
  struct aws_allocator *allocator;
99
147
 
@@ -193,17 +241,13 @@ struct aws_tls_ctx_options {
193
241
  void *ctx_options_extension;
194
242
 
195
243
  /**
196
- * Set if using PKCS#11 for private key operations.
197
- * See aws_tls_ctx_pkcs11_options for more details.
244
+ * Set if using custom private key operations.
245
+ * See aws_custom_key_op_handler for more details
246
+ *
247
+ * Note: Custom key operations (and PKCS#11 integration) hasn't been tested with TLS 1.3, so don't use
248
+ * cipher preferences that allow TLS 1.3. If this is set, we will always use non TLS 1.3 preferences.
198
249
  */
199
- struct {
200
- struct aws_pkcs11_lib *lib; /* required */
201
- struct aws_string *user_pin; /* NULL if token uses "protected authentication path" */
202
- struct aws_string *token_label; /* optional */
203
- struct aws_string *private_key_object_label; /* optional */
204
- uint64_t slot_id; /* optional */
205
- bool has_slot_id;
206
- } pkcs11;
250
+ struct aws_custom_key_op_handler *custom_key_op_handler;
207
251
  };
208
252
 
209
253
  struct aws_tls_negotiated_protocol_message {
@@ -295,6 +339,81 @@ AWS_IO_API int aws_tls_ctx_options_init_client_mtls(
295
339
  const struct aws_byte_cursor *cert,
296
340
  const struct aws_byte_cursor *pkey);
297
341
 
342
+ /**
343
+ * vtable for aws_custom_key_op_handler.
344
+ */
345
+ struct aws_custom_key_op_handler_vtable {
346
+ /**
347
+ * Called when the a TLS handshake has an operation it needs the custom key operation handler to perform.
348
+ * NOTE: You must call aws_tls_key_operation_complete() or aws_tls_key_operation_complete_with_error()
349
+ * otherwise the TLS handshake will stall the TLS connection indefinitely and leak memory.
350
+ */
351
+ void (*on_key_operation)(struct aws_custom_key_op_handler *key_op_handler, struct aws_tls_key_operation *operation);
352
+ };
353
+
354
+ /**
355
+ * The custom key operation that is used when performing a mutual TLS handshake. This can
356
+ * be extended to provide custom private key operations, like PKCS11 or similar.
357
+ */
358
+ struct aws_custom_key_op_handler {
359
+ /**
360
+ * A void* intended to be populated with a reference to whatever class is extending this class. For example,
361
+ * if you have extended aws_custom_key_op_handler with a custom struct, you would put a pointer to this struct
362
+ * to *impl so you can retrieve it back in the vtable functions.
363
+ */
364
+ void *impl;
365
+
366
+ /**
367
+ * A vtable containing all of the functions the aws_custom_key_op_handler implements. Is intended to be extended.
368
+ * NOTE: Use "aws_custom_key_op_handler_<func>" to access vtable functions.
369
+ */
370
+ const struct aws_custom_key_op_handler_vtable *vtable;
371
+
372
+ /**
373
+ * A reference count for handling memory usage.
374
+ * Use aws_custom_key_op_handler_acquire and aws_custom_key_op_handler_release to increase/decrease count.
375
+ */
376
+ struct aws_ref_count ref_count;
377
+ };
378
+
379
+ /**
380
+ * Increases the reference count for the passed-in aws_custom_key_op_handler and returns it.
381
+ */
382
+ AWS_IO_API struct aws_custom_key_op_handler *aws_custom_key_op_handler_acquire(
383
+ struct aws_custom_key_op_handler *key_op_handler);
384
+
385
+ /**
386
+ * Decreases the reference count for the passed-in aws_custom_key_op_handler and returns NULL.
387
+ */
388
+ AWS_IO_API struct aws_custom_key_op_handler *aws_custom_key_op_handler_release(
389
+ struct aws_custom_key_op_handler *key_op_handler);
390
+
391
+ /**
392
+ * Calls the on_key_operation vtable function. See aws_custom_key_op_handler_vtable for function details.
393
+ */
394
+ AWS_IO_API void aws_custom_key_op_handler_perform_operation(
395
+ struct aws_custom_key_op_handler *key_op_handler,
396
+ struct aws_tls_key_operation *operation);
397
+
398
+ /**
399
+ * Initializes options for use with mutual TLS in client mode,
400
+ * where private key operations are handled by custom code.
401
+ *
402
+ * Note: cert_file_contents will be copied into a new buffer after this
403
+ * function is called, so you do not need to keep that data alive
404
+ * after calling this function.
405
+ *
406
+ * @param options aws_tls_ctx_options to be initialized.
407
+ * @param allocator Allocator to use.
408
+ * @param custom Options for custom key operations.
409
+ * @param cert_file_contents The contents of a certificate file.
410
+ */
411
+ AWS_IO_API int aws_tls_ctx_options_init_client_mtls_with_custom_key_operations(
412
+ struct aws_tls_ctx_options *options,
413
+ struct aws_allocator *allocator,
414
+ struct aws_custom_key_op_handler *custom,
415
+ const struct aws_byte_cursor *cert_file_contents);
416
+
298
417
  /**
299
418
  * This struct exists as a graceful way to pass many arguments when
300
419
  * calling init-with-pkcs11 functions on aws_tls_ctx_options (this also makes
@@ -698,6 +817,65 @@ AWS_IO_API struct aws_byte_buf aws_tls_handler_protocol(struct aws_channel_handl
698
817
  */
699
818
  AWS_IO_API struct aws_byte_buf aws_tls_handler_server_name(struct aws_channel_handler *handler);
700
819
 
820
+ /**************************** TLS KEY OPERATION *******************************/
821
+
822
+ /* Note: Currently this assumes the user knows what key is being used for key/cert pairs
823
+ but s2n supports multiple cert/key pairs. This functionality is not used in the
824
+ CRT currently, but in the future, we may need to implement this */
825
+
826
+ /**
827
+ * Complete a successful TLS private key operation by providing its output.
828
+ * The output is copied into the TLS connection.
829
+ * The operation is freed by this call.
830
+ *
831
+ * You MUST call this or aws_tls_key_operation_complete_with_error().
832
+ * Failure to do so will stall the TLS connection indefinitely and leak memory.
833
+ */
834
+ AWS_IO_API
835
+ void aws_tls_key_operation_complete(struct aws_tls_key_operation *operation, struct aws_byte_cursor output);
836
+
837
+ /**
838
+ * Complete an failed TLS private key operation.
839
+ * The TLS connection will fail.
840
+ * The operation is freed by this call.
841
+ *
842
+ * You MUST call this or aws_tls_key_operation_complete().
843
+ * Failure to do so will stall the TLS connection indefinitely and leak memory.
844
+ */
845
+ AWS_IO_API
846
+ void aws_tls_key_operation_complete_with_error(struct aws_tls_key_operation *operation, int error_code);
847
+
848
+ /**
849
+ * Returns the input data that needs to be operated on by the custom key operation.
850
+ */
851
+ AWS_IO_API
852
+ struct aws_byte_cursor aws_tls_key_operation_get_input(const struct aws_tls_key_operation *operation);
853
+
854
+ /**
855
+ * Returns the type of operation that needs to be performed by the custom key operation.
856
+ * If the implementation cannot perform the operation,
857
+ * use aws_tls_key_operation_complete_with_error() to preventing stalling the TLS connection.
858
+ */
859
+ AWS_IO_API
860
+ enum aws_tls_key_operation_type aws_tls_key_operation_get_type(const struct aws_tls_key_operation *operation);
861
+
862
+ /**
863
+ * Returns the algorithm the operation is expected to be operated with.
864
+ * If the implementation does not support the signature algorithm,
865
+ * use aws_tls_key_operation_complete_with_error() to preventing stalling the TLS connection.
866
+ */
867
+ AWS_IO_API
868
+ enum aws_tls_signature_algorithm aws_tls_key_operation_get_signature_algorithm(
869
+ const struct aws_tls_key_operation *operation);
870
+
871
+ /**
872
+ * Returns the algorithm the operation digest is signed with.
873
+ * If the implementation does not support the digest algorithm,
874
+ * use aws_tls_key_operation_complete_with_error() to preventing stalling the TLS connection.
875
+ */
876
+ AWS_IO_API
877
+ enum aws_tls_hash_algorithm aws_tls_key_operation_get_digest_algorithm(const struct aws_tls_key_operation *operation);
878
+
701
879
  /********************************* Misc TLS related *********************************/
702
880
 
703
881
  /*
@@ -710,6 +888,24 @@ AWS_IO_API int aws_channel_setup_client_tls(
710
888
  struct aws_channel_slot *right_of_slot,
711
889
  struct aws_tls_connection_options *tls_options);
712
890
 
891
+ /**
892
+ * Given enum, return string like: AWS_TLS_HASH_SHA256 -> "SHA256"
893
+ */
894
+ AWS_IO_API
895
+ const char *aws_tls_hash_algorithm_str(enum aws_tls_hash_algorithm hash);
896
+
897
+ /**
898
+ * Given enum, return string like: AWS_TLS_SIGNATURE_RSA -> "RSA"
899
+ */
900
+ AWS_IO_API
901
+ const char *aws_tls_signature_algorithm_str(enum aws_tls_signature_algorithm signature);
902
+
903
+ /**
904
+ * Given enum, return string like: AWS_TLS_SIGNATURE_RSA -> "RSA"
905
+ */
906
+ AWS_IO_API
907
+ const char *aws_tls_key_operation_type_str(enum aws_tls_key_operation_type operation_type);
908
+
713
909
  AWS_EXTERN_C_END
714
910
 
715
911
  #endif /* AWS_IO_TLS_CHANNEL_HANDLER_H */
@@ -540,46 +540,39 @@ void aws_channel_task_init(
540
540
  channel_task->type_tag = type_tag;
541
541
  }
542
542
 
543
- /* Common functionality for scheduling "now" and "future" tasks.
544
- * For "now" tasks, pass 0 for `run_at_nanos` */
545
- static void s_register_pending_task(
543
+ static void s_register_pending_task_in_event_loop(
546
544
  struct aws_channel *channel,
547
545
  struct aws_channel_task *channel_task,
548
546
  uint64_t run_at_nanos) {
549
547
 
550
- /* Reset every property on channel task other than user's fn & arg.*/
551
- aws_task_init(&channel_task->wrapper_task, s_channel_task_run, channel, channel_task->type_tag);
552
- channel_task->wrapper_task.timestamp = run_at_nanos;
553
- aws_linked_list_node_reset(&channel_task->node);
548
+ AWS_LOGF_TRACE(
549
+ AWS_LS_IO_CHANNEL,
550
+ "id=%p: scheduling task with wrapper task id %p.",
551
+ (void *)channel,
552
+ (void *)&channel_task->wrapper_task);
554
553
 
555
- if (aws_channel_thread_is_callers_thread(channel)) {
556
- AWS_LOGF_TRACE(
554
+ /* If channel is shut down, run task immediately as canceled */
555
+ if (channel->channel_state == AWS_CHANNEL_SHUT_DOWN) {
556
+ AWS_LOGF_DEBUG(
557
557
  AWS_LS_IO_CHANNEL,
558
- "id=%p: scheduling task with wrapper task id %p.",
558
+ "id=%p: Running %s channel task immediately as canceled due to shut down channel",
559
559
  (void *)channel,
560
- (void *)&channel_task->wrapper_task);
561
-
562
- /* If channel is shut down, run task immediately as canceled */
563
- if (channel->channel_state == AWS_CHANNEL_SHUT_DOWN) {
564
- AWS_LOGF_DEBUG(
565
- AWS_LS_IO_CHANNEL,
566
- "id=%p: Running %s channel task immediately as canceled due to shut down channel",
567
- (void *)channel,
568
- channel_task->type_tag);
569
- channel_task->task_fn(channel_task, channel_task->arg, AWS_TASK_STATUS_CANCELED);
570
- return;
571
- }
572
-
573
- aws_linked_list_push_back(&channel->channel_thread_tasks.list, &channel_task->node);
574
- if (run_at_nanos == 0) {
575
- aws_event_loop_schedule_task_now(channel->loop, &channel_task->wrapper_task);
576
- } else {
577
- aws_event_loop_schedule_task_future(
578
- channel->loop, &channel_task->wrapper_task, channel_task->wrapper_task.timestamp);
579
- }
560
+ channel_task->type_tag);
561
+ channel_task->task_fn(channel_task, channel_task->arg, AWS_TASK_STATUS_CANCELED);
580
562
  return;
581
563
  }
582
564
 
565
+ aws_linked_list_push_back(&channel->channel_thread_tasks.list, &channel_task->node);
566
+ if (run_at_nanos == 0) {
567
+ aws_event_loop_schedule_task_now(channel->loop, &channel_task->wrapper_task);
568
+ } else {
569
+ aws_event_loop_schedule_task_future(
570
+ channel->loop, &channel_task->wrapper_task, channel_task->wrapper_task.timestamp);
571
+ }
572
+ }
573
+
574
+ static void s_register_pending_task_cross_thread(struct aws_channel *channel, struct aws_channel_task *channel_task) {
575
+
583
576
  AWS_LOGF_TRACE(
584
577
  AWS_LS_IO_CHANNEL,
585
578
  "id=%p: scheduling task with wrapper task id %p from "
@@ -609,10 +602,43 @@ static void s_register_pending_task(
609
602
  }
610
603
  }
611
604
 
605
+ static void s_reset_pending_channel_task(
606
+ struct aws_channel *channel,
607
+ struct aws_channel_task *channel_task,
608
+ uint64_t run_at_nanos) {
609
+
610
+ /* Reset every property on channel task other than user's fn & arg.*/
611
+ aws_task_init(&channel_task->wrapper_task, s_channel_task_run, channel, channel_task->type_tag);
612
+ channel_task->wrapper_task.timestamp = run_at_nanos;
613
+ aws_linked_list_node_reset(&channel_task->node);
614
+ }
615
+
616
+ /* Common functionality for scheduling "now" and "future" tasks.
617
+ * For "now" tasks, pass 0 for `run_at_nanos` */
618
+ static void s_register_pending_task(
619
+ struct aws_channel *channel,
620
+ struct aws_channel_task *channel_task,
621
+ uint64_t run_at_nanos) {
622
+
623
+ s_reset_pending_channel_task(channel, channel_task, run_at_nanos);
624
+
625
+ if (aws_channel_thread_is_callers_thread(channel)) {
626
+ s_register_pending_task_in_event_loop(channel, channel_task, run_at_nanos);
627
+ } else {
628
+ s_register_pending_task_cross_thread(channel, channel_task);
629
+ }
630
+ }
631
+
612
632
  void aws_channel_schedule_task_now(struct aws_channel *channel, struct aws_channel_task *task) {
613
633
  s_register_pending_task(channel, task, 0);
614
634
  }
615
635
 
636
+ void aws_channel_schedule_task_now_serialized(struct aws_channel *channel, struct aws_channel_task *task) {
637
+
638
+ s_reset_pending_channel_task(channel, task, 0);
639
+ s_register_pending_task_cross_thread(channel, task);
640
+ }
641
+
616
642
  void aws_channel_schedule_task_future(
617
643
  struct aws_channel *channel,
618
644
  struct aws_channel_task *task,
@@ -1096,28 +1096,4 @@ struct aws_tls_ctx *aws_tls_client_ctx_new(struct aws_allocator *alloc, const st
1096
1096
  return s_tls_ctx_new(alloc, options);
1097
1097
  }
1098
1098
 
1099
- void aws_tls_ctx_destroy(struct aws_tls_ctx *ctx) {
1100
-
1101
- if (ctx == NULL) {
1102
- return;
1103
- }
1104
-
1105
- struct secure_transport_ctx *secure_transport_ctx = ctx->impl;
1106
-
1107
- if (secure_transport_ctx->certs) {
1108
- aws_release_identity(secure_transport_ctx->certs);
1109
- }
1110
-
1111
- if (secure_transport_ctx->ca_cert) {
1112
- aws_release_certificates(secure_transport_ctx->ca_cert);
1113
- }
1114
-
1115
- if (secure_transport_ctx->alpn_list) {
1116
- aws_string_destroy(secure_transport_ctx->alpn_list);
1117
- }
1118
-
1119
- CFRelease(secure_transport_ctx->wrapped_allocator);
1120
- aws_mem_release(secure_transport_ctx->ctx.alloc, secure_transport_ctx);
1121
- }
1122
-
1123
1099
  #pragma clang diagnostic pop
@@ -278,6 +278,15 @@ static struct aws_error_info s_errors[] = {
278
278
  AWS_DEFINE_ERROR_INFO_IO(
279
279
  AWS_ERROR_IO_PINNED_EVENT_LOOP_MISMATCH,
280
280
  "A connection was requested on an event loop that is not associated with the client bootstrap's event loop group."),
281
+
282
+ AWS_DEFINE_ERROR_INFO_IO(
283
+ AWS_ERROR_PKCS11_ENCODING_ERROR,
284
+ "A PKCS#11 (Cryptoki) library function was unable to ASN.1 (DER) encode a data structure. See log for more details."),
285
+ AWS_DEFINE_ERROR_INFO_IO(
286
+ AWS_IO_TLS_ERROR_DEFAULT_TRUST_STORE_NOT_FOUND,
287
+ "Default TLS trust store not found on this system."
288
+ " Trusted CA certificates must be installed,"
289
+ " or \"override default trust store\" must be used while creating the TLS context."),
281
290
  };
282
291
  /* clang-format on */
283
292