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
@@ -45,8 +45,14 @@ struct fgn_test_case {
45
45
  static void s2n_verify_child_exit_status(pid_t proc_pid)
46
46
  {
47
47
  int status = 0;
48
+ #if defined(S2N_CLONE_SUPPORTED)
48
49
  EXPECT_EQUAL(waitpid(proc_pid, &status, __WALL), proc_pid);
49
-
50
+ #else
51
+ /* __WALL is not relevant when clone() is not supported
52
+ * https://man7.org/linux/man-pages/man2/wait.2.html#NOTES
53
+ */
54
+ EXPECT_EQUAL(waitpid(proc_pid, &status, 0), proc_pid);
55
+ #endif
50
56
  /* Check that child exited with EXIT_SUCCESS. If not, this indicates
51
57
  * that an error was encountered in the unit tests executed in that
52
58
  * child process.
@@ -249,16 +255,25 @@ static int s2n_unit_tests_common(struct fgn_test_case *test_case)
249
255
 
250
256
  static int s2n_test_case_default_cb(struct fgn_test_case *test_case)
251
257
  {
258
+ EXPECT_SUCCESS(s2n_init());
259
+
252
260
  EXPECT_EQUAL(s2n_unit_tests_common(test_case), S2N_SUCCESS);
253
261
 
262
+ EXPECT_SUCCESS(s2n_cleanup());
263
+
254
264
  return S2N_SUCCESS;
255
265
  }
256
266
 
257
267
  static int s2n_test_case_pthread_atfork_cb(struct fgn_test_case *test_case)
258
268
  {
259
269
  POSIX_GUARD_RESULT(s2n_ignore_wipeonfork_and_inherit_zero_for_testing());
270
+
271
+ EXPECT_SUCCESS(s2n_init());
272
+
260
273
  EXPECT_EQUAL(s2n_unit_tests_common(test_case), S2N_SUCCESS);
261
274
 
275
+ EXPECT_SUCCESS(s2n_cleanup());
276
+
262
277
  return S2N_SUCCESS;
263
278
  }
264
279
 
@@ -268,10 +283,14 @@ static int s2n_test_case_madv_wipeonfork_cb(struct fgn_test_case *test_case)
268
283
  TEST_DEBUG_PRINT("s2n_fork_generation_number_test.c test case not supported. Skipping.\nTest case: %s\n", test_case->test_case_label);
269
284
  return S2N_SUCCESS;
270
285
  }
271
-
272
286
  POSIX_GUARD_RESULT(s2n_ignore_pthread_atfork_for_testing());
287
+
288
+ EXPECT_SUCCESS(s2n_init());
289
+
273
290
  EXPECT_EQUAL(s2n_unit_tests_common(test_case), S2N_SUCCESS);
274
291
 
292
+ EXPECT_SUCCESS(s2n_cleanup());
293
+
275
294
  return S2N_SUCCESS;
276
295
  }
277
296
 
@@ -281,10 +300,14 @@ static int s2n_test_case_map_inherit_zero_cb(struct fgn_test_case *test_case)
281
300
  TEST_DEBUG_PRINT("s2n_fork_generation_number_test.c test case not supported. Skipping.\nTest case: %s\n", test_case->test_case_label);
282
301
  return S2N_SUCCESS;
283
302
  }
284
-
285
303
  POSIX_GUARD_RESULT(s2n_ignore_pthread_atfork_for_testing());
304
+
305
+ EXPECT_SUCCESS(s2n_init());
306
+
286
307
  EXPECT_EQUAL(s2n_unit_tests_common(test_case), S2N_SUCCESS);
287
308
 
309
+ EXPECT_SUCCESS(s2n_cleanup());
310
+
288
311
  return S2N_SUCCESS;
289
312
  }
290
313
 
@@ -297,7 +320,7 @@ struct fgn_test_case fgn_test_cases[NUMBER_OF_FGN_TEST_CASES] = {
297
320
 
298
321
  int main(int argc, char **argv)
299
322
  {
300
- BEGIN_TEST();
323
+ BEGIN_TEST_NO_INIT();
301
324
 
302
325
  EXPECT_TRUE(s2n_array_len(fgn_test_cases) == NUMBER_OF_FGN_TEST_CASES);
303
326
 
@@ -331,5 +354,5 @@ int main(int argc, char **argv)
331
354
  }
332
355
  }
333
356
 
334
- END_TEST();
357
+ END_TEST_NO_INIT();
335
358
  }
@@ -234,6 +234,11 @@ int main(int argc, char **argv)
234
234
  ssize_t handshake_diff = (vm_data_after_handshakes - vm_data_initial);
235
235
  ssize_t allocation_diff = (vm_data_after_allocation - vm_data_initial);
236
236
 
237
+ /*
238
+ * get_vm_data_size is required for this test to succeed.
239
+ * Any platform that doesn't implement get_vm_data_size should be excluded here.
240
+ */
241
+ #ifndef __APPLE__
237
242
  if (allocation_diff > maxAllowedMemDiff
238
243
  || handshake_diff > maxAllowedMemDiff
239
244
  || handshake_diff < minAllowedMemDiff) {
@@ -241,6 +246,7 @@ int main(int argc, char **argv)
241
246
  (int) ACTUAL_MEM_PER_CONNECTION(connectionsToUse, handshake_diff));
242
247
  FAIL_MSG("Unexpected memory usage. If expected, update MEM_PER_CONNECTION.");
243
248
  }
249
+ #endif
244
250
 
245
251
  END_TEST();
246
252
  }
@@ -105,7 +105,7 @@ int main(int argc, char **argv)
105
105
  EXPECT_SUCCESS(s2n_rand_set_callbacks(s2n_entropy_init_cleanup, s2n_entropy_init_cleanup, s2n_entropy_generator, s2n_entropy_generator));
106
106
 
107
107
  s2n_stack_blob(personalization_string, 32, 32);
108
- EXPECT_SUCCESS(s2n_drbg_instantiate(&drbg, &personalization_string, S2N_AES_256_CTR_NO_DF_PR));
108
+ EXPECT_OK(s2n_drbg_instantiate(&drbg, &personalization_string, S2N_AES_256_CTR_NO_DF_PR));
109
109
  EXPECT_OK(s2n_set_private_drbg_for_test(drbg));
110
110
  /* Verify we switched to a new DRBG */
111
111
  EXPECT_OK(s2n_get_private_random_bytes_used(&bytes_used));
@@ -54,59 +54,28 @@ void process_safety_tester(int write_fd)
54
54
  _exit(0);
55
55
  }
56
56
 
57
- static int init(void) {
57
+ static int init(void)
58
+ {
58
59
  return S2N_SUCCESS;
59
60
  }
60
61
 
61
- static int cleanup(void) {
62
+ static int cleanup(void)
63
+ {
62
64
  return S2N_SUCCESS;
63
65
  }
64
66
 
65
- static int entropy(void *ptr, uint32_t size) {
67
+ static int entropy(void *ptr, uint32_t size)
68
+ {
66
69
  return S2N_SUCCESS;
67
70
  }
68
71
 
69
- int main(int argc, char **argv)
72
+ static int fork_test(void)
70
73
  {
71
- uint8_t bits[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
72
- uint8_t bit_set_run[8];
73
- int p[2], status;
74
74
  pid_t pid;
75
- uint8_t data[5120];
75
+ int p[2], status;
76
+ uint8_t data[100];
76
77
  uint8_t child_data[100];
77
- struct s2n_blob blob = {.data = data };
78
-
79
- pthread_t threads[2];
80
-
81
- BEGIN_TEST();
82
- EXPECT_SUCCESS(s2n_disable_tls13_in_test());
83
-
84
- /* Verify that randomness callbacks can't be set to NULL */
85
- EXPECT_FAILURE(s2n_rand_set_callbacks(NULL, cleanup, entropy, entropy));
86
- EXPECT_FAILURE(s2n_rand_set_callbacks(init, NULL, entropy, entropy));
87
- EXPECT_FAILURE(s2n_rand_set_callbacks(init, cleanup, NULL, entropy));
88
- EXPECT_FAILURE(s2n_rand_set_callbacks(init, cleanup, entropy, NULL));
89
-
90
- /* Get one byte of data, to make sure the pool is (almost) full */
91
- blob.size = 1;
92
- EXPECT_OK(s2n_get_public_random_data(&blob));
93
-
94
- /* Create two threads and have them each grab 100 bytes */
95
- EXPECT_SUCCESS(pthread_create(&threads[0], NULL, thread_safety_tester, (void *)0));
96
- EXPECT_SUCCESS(pthread_create(&threads[1], NULL, thread_safety_tester, (void *)1));
97
-
98
- /* Wait for those threads to finish */
99
- EXPECT_SUCCESS(pthread_join(threads[0], NULL));
100
- EXPECT_SUCCESS(pthread_join(threads[1], NULL));
101
-
102
- /* Confirm that their data differs from each other */
103
- EXPECT_NOT_EQUAL(memcmp(thread_data[0], thread_data[1], 100), 0);
104
-
105
- /* Confirm that their data differs from the parent thread */
106
- blob.size = 100;
107
- EXPECT_OK(s2n_get_public_random_data(&blob));
108
- EXPECT_NOT_EQUAL(memcmp(thread_data[0], data, 100), 0);
109
- EXPECT_NOT_EQUAL(memcmp(thread_data[1], data, 100), 0);
78
+ struct s2n_blob blob = {.data = data, .size = 100};
110
79
 
111
80
  /* Create a pipe */
112
81
  EXPECT_SUCCESS(pipe(p));
@@ -146,6 +115,56 @@ int main(int argc, char **argv)
146
115
  EXPECT_OK(s2n_get_public_random_data(&blob));
147
116
  EXPECT_NOT_EQUAL(memcmp(child_data, data, 100), 0);
148
117
 
118
+ return S2N_SUCCESS;
119
+ }
120
+
121
+ int main(int argc, char **argv)
122
+ {
123
+ uint8_t bits[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
124
+ uint8_t bit_set_run[8];
125
+ uint8_t data[5120];
126
+ struct s2n_blob blob = {.data = data };
127
+
128
+ pthread_t threads[2];
129
+
130
+ BEGIN_TEST();
131
+ EXPECT_SUCCESS(s2n_disable_tls13_in_test());
132
+
133
+ /* Verify that randomness callbacks can't be set to NULL */
134
+ EXPECT_FAILURE(s2n_rand_set_callbacks(NULL, cleanup, entropy, entropy));
135
+ EXPECT_FAILURE(s2n_rand_set_callbacks(init, NULL, entropy, entropy));
136
+ EXPECT_FAILURE(s2n_rand_set_callbacks(init, cleanup, NULL, entropy));
137
+ EXPECT_FAILURE(s2n_rand_set_callbacks(init, cleanup, entropy, NULL));
138
+
139
+ /* Get one byte of data, to make sure the pool is (almost) full */
140
+ blob.size = 1;
141
+ EXPECT_OK(s2n_get_public_random_data(&blob));
142
+
143
+ /* Create two threads and have them each grab 100 bytes */
144
+ EXPECT_SUCCESS(pthread_create(&threads[0], NULL, thread_safety_tester, (void *)0));
145
+ EXPECT_SUCCESS(pthread_create(&threads[1], NULL, thread_safety_tester, (void *)1));
146
+
147
+ /* Wait for those threads to finish */
148
+ EXPECT_SUCCESS(pthread_join(threads[0], NULL));
149
+ EXPECT_SUCCESS(pthread_join(threads[1], NULL));
150
+
151
+ /* Confirm that their data differs from each other */
152
+ EXPECT_NOT_EQUAL(memcmp(thread_data[0], thread_data[1], 100), 0);
153
+
154
+ /* Confirm that their data differs from the parent thread */
155
+ blob.size = 100;
156
+ EXPECT_OK(s2n_get_public_random_data(&blob));
157
+ EXPECT_NOT_EQUAL(memcmp(thread_data[0], data, 100), 0);
158
+ EXPECT_NOT_EQUAL(memcmp(thread_data[1], data, 100), 0);
159
+
160
+ /* Fork with prediction resistance */
161
+ EXPECT_SUCCESS(fork_test());
162
+
163
+ /* Fork without prediction resistance */
164
+ EXPECT_OK(s2n_ignore_prediction_resistance_for_testing(true));
165
+ EXPECT_SUCCESS(fork_test());
166
+ EXPECT_OK(s2n_ignore_prediction_resistance_for_testing(false));
167
+
149
168
  /* Try to fetch a volume of randomly generated data, every size between 1 and 5120
150
169
  * bytes.
151
170
  */
@@ -59,7 +59,7 @@ void mock_client(struct s2n_test_io_pair *io_pair)
59
59
  exit(1);
60
60
  }
61
61
 
62
- #ifdef __FreeBSD__
62
+ #if defined(__FreeBSD__) || defined(__APPLE__)
63
63
  /* On FreeBSD shutdown from one end of the socket pair does not give EPIPE. Must use close. */
64
64
  s2n_io_pair_close_one_end(io_pair, S2N_CLIENT);
65
65
  #else
@@ -152,7 +152,7 @@ int main(int argc, char **argv)
152
152
  sleep(1);
153
153
  char buffer[1];
154
154
  /* Fist flush on half closed pipe should get EPIPE */
155
- size_t w = s2n_send(conn, buffer, 1, &blocked);
155
+ ssize_t w = s2n_send(conn, buffer, 1, &blocked);
156
156
  EXPECT_EQUAL(w, -1);
157
157
  EXPECT_EQUAL(s2n_errno, S2N_ERR_IO);
158
158
  EXPECT_EQUAL(errno, EPIPE);
@@ -285,10 +285,12 @@ int main()
285
285
  /* Rewrite hashes with known ClientHello */
286
286
  EXPECT_SUCCESS(s2n_conn_update_handshake_hashes(client_conn, &client_hello_msg));
287
287
 
288
+ EXPECT_OK(s2n_tls13_secrets_update(client_conn));
288
289
  EXPECT_OK(s2n_tls13_key_schedule_update(client_conn));
289
290
 
290
291
  /* Check early secret secret set correctly */
291
- EXPECT_BYTEARRAY_EQUAL(client_conn->secrets.tls13.early_secret, early_secret.data, early_secret.size);
292
+ EXPECT_EQUAL(client_conn->secrets.tls13.extract_secret_type, S2N_EARLY_SECRET);
293
+ EXPECT_BYTEARRAY_EQUAL(client_conn->secrets.tls13.extract_secret, early_secret.data, early_secret.size);
292
294
 
293
295
  /* Check IV calculated correctly */
294
296
  EXPECT_BYTEARRAY_EQUAL(client_conn->secure.client_implicit_iv, iv.data, iv.size);
@@ -35,6 +35,9 @@
35
35
  /* Included so we can test functions that are otherwise unavailable */
36
36
  #include "tls/s2n_tls13_handshake.c"
37
37
 
38
+ S2N_RESULT s2n_tls13_derive_secret(struct s2n_connection *conn, s2n_extract_secret_type_t secret_type,
39
+ s2n_mode mode, struct s2n_blob *secret);
40
+
38
41
  static int read_priv_ecc(EVP_PKEY **pkey, const char *priv_ecc);
39
42
  static int set_up_conns(struct s2n_connection *client_conn, struct s2n_connection *server_conn,
40
43
  const char *client_priv_ecc, const char *server_priv_ecc, const struct s2n_kem_group *kem_group,
@@ -560,7 +563,12 @@ int main(int argc, char **argv) {
560
563
  EXPECT_SUCCESS(s2n_hash_new(&hash_state));
561
564
  EXPECT_SUCCESS(s2n_hash_init(&hash_state, secrets.hash_algorithm));
562
565
  EXPECT_SUCCESS(s2n_hash_update(&hash_state, test_vector->transcript, strlen(test_vector->transcript)));
563
- EXPECT_SUCCESS(s2n_hash_digest(&hash_state, client_conn->handshake.hashes->server_hello_digest, secrets.size));
566
+ EXPECT_SUCCESS(s2n_hash_digest(&hash_state, client_conn->handshake.hashes->transcript_hash_digest, secrets.size));
567
+
568
+ client_conn->handshake.handshake_type = NEGOTIATED | FULL_HANDSHAKE;
569
+ while(s2n_conn_get_current_message_type(client_conn) != SERVER_HELLO) {
570
+ client_conn->handshake.message_number++;
571
+ }
564
572
 
565
573
  s2n_tls13_key_blob(client_traffic_secret, secrets.size);
566
574
  s2n_tls13_key_blob(server_traffic_secret, secrets.size);
@@ -58,6 +58,20 @@ static int s2n_test_set_recv_key(struct s2n_session_key *key, struct s2n_blob *i
58
58
  EXPECT_BYTEARRAY_EQUAL(test_recv_key, (key).data, (key).size); \
59
59
  }
60
60
 
61
+ static S2N_RESULT s2n_set_test_secret(struct s2n_connection *conn, uint8_t *secret_bytes, const struct s2n_blob secret)
62
+ {
63
+ RESULT_ENSURE_REF(conn);
64
+ RESULT_ENSURE_REF(secret_bytes);
65
+ RESULT_CHECKED_MEMCPY(secret_bytes, secret.data, secret.size);
66
+ /*
67
+ * Mark the last secret extracted as the master secret to
68
+ * indicate that all secrets have already been derived.
69
+ * This test is interested in keys, not secrets.
70
+ */
71
+ conn->secrets.tls13.extract_secret_type = S2N_MASTER_SECRET;
72
+ return S2N_RESULT_OK;
73
+ }
74
+
61
75
  int main(int argc, char **argv)
62
76
  {
63
77
  BEGIN_TEST();
@@ -92,36 +106,6 @@ int main(int argc, char **argv)
92
106
  [CLIENT_FINISHED] = 6,
93
107
  };
94
108
 
95
- /**
96
- *= https://www.rfc-editor.org/rfc/rfc8448.html#section-3
97
- *= type=test
98
- *# {client} extract secret "handshake" (same as server handshake
99
- *# secret)
100
- *
101
- *= https://www.rfc-editor.org/rfc/rfc8448.html#section-3
102
- *# {server} extract secret "handshake":
103
- *#
104
- *# salt (32 octets): 6f 26 15 a1 08 c7 02 c5 67 8f 54 fc 9d ba b6 97
105
- *# 16 c0 76 18 9c 48 25 0c eb ea c3 57 6c 36 11 ba
106
- *#
107
- *# IKM (32 octets): 8b d4 05 4f b5 5b 9d 63 fd fb ac f9 f0 4b 9f 0d
108
- *# 35 e6 d6 3f 53 75 63 ef d4 62 72 90 0f 89 49 2d
109
- *#
110
- *# secret (32 octets): 1d c8 26 e9 36 06 aa 6f dc 0a ad c1 2f 74 1b
111
- *# 01 04 6a a6 b9 9f 69 1e d2 21 a9 f0 ca 04 3f be ac
112
- */
113
- S2N_BLOB_FROM_HEX(handshake_secret, "1d c8 26 e9 36 06 aa 6f dc 0a ad c1 2f 74 1b \
114
- 01 04 6a a6 b9 9f 69 1e d2 21 a9 f0 ca 04 3f be ac");
115
-
116
- /**
117
- *= https://www.rfc-editor.org/rfc/rfc8448.html#section-3
118
- *= type=test
119
- *# hash (32 octets): 86 0c 06 ed c0 78 58 ee 8e 78 f0 e7 42 8c 58 ed
120
- *# d6 b4 3f 2c a3 e6 e9 5f 02 ed 06 3c f0 e1 ca d8
121
- */
122
- S2N_BLOB_FROM_HEX(server_hello_hash, "86 0c 06 ed c0 78 58 ee 8e 78 f0 e7 42 8c 58 ed \
123
- d6 b4 3f 2c a3 e6 e9 5f 02 ed 06 3c f0 e1 ca d8");
124
-
125
109
  /* Derive server handshake traffic keys */
126
110
  {
127
111
  /**
@@ -146,6 +130,8 @@ int main(int argc, char **argv)
146
130
  *#
147
131
  *# iv expanded (12 octets): 5d 31 3e b2 67 12 76 ee 13 00 0b 30
148
132
  */
133
+ S2N_BLOB_FROM_HEX(secret, "b6 7b 7d 69 0c c1 6c 4e 75 e5 42 13 cb 2d 37 b4 \
134
+ e9 c9 12 bc de d9 10 5d 42 be fd 59 d3 91 ad 38");
149
135
  S2N_BLOB_FROM_HEX(key, "3f ce 51 60 09 c2 17 27 d0 f2 e4 e8 6e \
150
136
  e4 03 bc");
151
137
  S2N_BLOB_FROM_HEX(iv, "5d 31 3e b2 67 12 76 ee 13 00 0b 30");
@@ -154,15 +140,13 @@ int main(int argc, char **argv)
154
140
  DEFER_CLEANUP(struct s2n_connection *conn = s2n_connection_new(modes[i]), s2n_connection_ptr_free);
155
141
  conn->secure.cipher_suite = cipher_suite;
156
142
  conn->actual_protocol_version = S2N_TLS13;
157
- EXPECT_OK(s2n_connection_set_test_handshake_secret(conn, &handshake_secret));
158
- EXPECT_MEMCPY_SUCCESS(conn->handshake.hashes->server_hello_digest,
159
- server_hello_hash.data, server_hello_hash.size);
143
+ EXPECT_OK(s2n_set_test_secret(conn, conn->secrets.tls13.server_handshake_secret, secret));
160
144
 
161
145
  conn->handshake.handshake_type = one_rtt_handshake_type;
162
146
  conn->handshake.message_number = one_rtt_message_nums[SERVER_HELLO];
163
147
  EXPECT_EQUAL(s2n_conn_get_current_message_type(conn), SERVER_HELLO);
164
-
165
148
  EXPECT_OK(s2n_tls13_key_schedule_update(conn));
149
+
166
150
  EXPECT_IVS_EQUAL(conn, iv, S2N_SERVER);
167
151
  EXPECT_KEYS_EQUAL(conn, key, S2N_SERVER);
168
152
  }
@@ -192,6 +176,8 @@ int main(int argc, char **argv)
192
176
  *#
193
177
  *# iv expanded (12 octets): 5b d3 c7 1b 83 6e 0b 76 bb 73 26 5f
194
178
  */
179
+ S2N_BLOB_FROM_HEX(secret, "b3 ed db 12 6e 06 7f 35 a7 80 b3 ab f4 5e 2d 8f \
180
+ 3b 1a 95 07 38 f5 2e 96 00 74 6a 0e 27 a5 5a 21");
195
181
  S2N_BLOB_FROM_HEX(key, "db fa a6 93 d1 76 2c 5b 66 6a f5 d9 50 \
196
182
  25 8d 01");
197
183
  S2N_BLOB_FROM_HEX(iv, "5b d3 c7 1b 83 6e 0b 76 bb 73 26 5f");
@@ -200,16 +186,9 @@ int main(int argc, char **argv)
200
186
  DEFER_CLEANUP(struct s2n_connection *conn = s2n_connection_new(modes[i]), s2n_connection_ptr_free);
201
187
  conn->secure.cipher_suite = cipher_suite;
202
188
  conn->actual_protocol_version = S2N_TLS13;
203
- EXPECT_OK(s2n_connection_set_test_handshake_secret(conn, &handshake_secret));
204
- EXPECT_MEMCPY_SUCCESS(conn->handshake.hashes->server_hello_digest,
205
- server_hello_hash.data, server_hello_hash.size);
189
+ EXPECT_OK(s2n_set_test_secret(conn, conn->secrets.tls13.client_handshake_secret, secret));
206
190
 
207
191
  conn->handshake.handshake_type = one_rtt_handshake_type;
208
-
209
- conn->handshake.message_number = one_rtt_message_nums[SERVER_HELLO];
210
- EXPECT_EQUAL(s2n_conn_get_current_message_type(conn), SERVER_HELLO);
211
- EXPECT_OK(s2n_tls13_secrets_update(conn));
212
-
213
192
  conn->handshake.message_number = one_rtt_message_nums[SERVER_FINISHED];
214
193
  EXPECT_EQUAL(s2n_conn_get_current_message_type(conn), SERVER_FINISHED);
215
194
  EXPECT_OK(s2n_tls13_key_schedule_update(conn));
@@ -219,38 +198,6 @@ int main(int argc, char **argv)
219
198
  }
220
199
  }
221
200
 
222
- /**
223
- *= https://www.rfc-editor.org/rfc/rfc8448.html#section-3
224
- *= type=test
225
- *# {client} extract secret "master" (same as server master secret)
226
- *
227
- *= https://www.rfc-editor.org/rfc/rfc8448.html#section-3
228
- *= type=test
229
- *# {server} extract secret "master":
230
- *#
231
- *# salt (32 octets): 43 de 77 e0 c7 77 13 85 9a 94 4d b9 db 25 90 b5
232
- *# 31 90 a6 5b 3e e2 e4 f1 2d d7 a0 bb 7c e2 54 b4
233
- *#
234
- *# IKM (32 octets): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
235
- *# 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
236
- **
237
- *= https://www.rfc-editor.org/rfc/rfc8448.html#section-3
238
- *= type=test
239
- *# secret (32 octets): 18 df 06 84 3d 13 a0 8b f2 a4 49 84 4c 5f 8a
240
- *# 47 80 01 bc 4d 4c 62 79 84 d5 a4 1d a8 d0 40 29 19
241
- */
242
- S2N_BLOB_FROM_HEX(master_secret, "18 df 06 84 3d 13 a0 8b f2 a4 49 84 4c 5f 8a \
243
- 47 80 01 bc 4d 4c 62 79 84 d5 a4 1d a8 d0 40 29 19");
244
-
245
- /**
246
- *= https://www.rfc-editor.org/rfc/rfc8448.html#section-3
247
- *= type=test
248
- *# hash (32 octets): 96 08 10 2a 0f 1c cc 6d b6 25 0b 7b 7e 41 7b 1a
249
- *# 00 0e aa da 3d aa e4 77 7a 76 86 c9 ff 83 df 13
250
- */
251
- S2N_BLOB_FROM_HEX(server_finished_hash, "96 08 10 2a 0f 1c cc 6d b6 25 0b 7b 7e 41 7b 1a \
252
- 00 0e aa da 3d aa e4 77 7a 76 86 c9 ff 83 df 13");
253
-
254
201
  /* Derive server application traffic keys */
255
202
  {
256
203
  /**
@@ -275,6 +222,8 @@ int main(int argc, char **argv)
275
222
  *#
276
223
  *# iv expanded (12 octets): cf 78 2b 88 dd 83 54 9a ad f1 e9 84
277
224
  */
225
+ S2N_BLOB_FROM_HEX(secret, "a1 1a f9 f0 55 31 f8 56 ad 47 11 6b 45 a9 50 32 \
226
+ 82 04 b4 f4 4b fb 6b 3a 4b 4f 1f 3f cb 63 16 43");
278
227
  S2N_BLOB_FROM_HEX(key, "9f 02 28 3b 6c 9c 07 ef c2 6b b9 f2 ac \
279
228
  92 e3 56");
280
229
  S2N_BLOB_FROM_HEX(iv, "cf 78 2b 88 dd 83 54 9a ad f1 e9 84");
@@ -289,16 +238,9 @@ int main(int argc, char **argv)
289
238
  DEFER_CLEANUP(struct s2n_connection *conn = s2n_connection_new(modes[i]), s2n_connection_ptr_free);
290
239
  conn->secure.cipher_suite = cipher_suite;
291
240
  conn->actual_protocol_version = S2N_TLS13;
292
- EXPECT_OK(s2n_connection_set_test_master_secret(conn, &master_secret));
293
- EXPECT_MEMCPY_SUCCESS(conn->handshake.hashes->server_finished_digest,
294
- server_finished_hash.data, server_finished_hash.size);
241
+ EXPECT_OK(s2n_set_test_secret(conn, conn->secrets.tls13.server_app_secret, secret));
295
242
 
296
243
  conn->handshake.handshake_type = one_rtt_handshake_type;
297
-
298
- conn->handshake.message_number = one_rtt_message_nums[SERVER_FINISHED];
299
- EXPECT_EQUAL(s2n_conn_get_current_message_type(conn), SERVER_FINISHED);
300
- EXPECT_OK(s2n_tls13_secrets_update(conn));
301
-
302
244
  conn->handshake.message_number = one_rtt_message_nums[trigger_message];
303
245
  EXPECT_EQUAL(s2n_conn_get_current_message_type(conn), trigger_message);
304
246
  EXPECT_OK(s2n_tls13_key_schedule_update(conn));
@@ -332,6 +274,8 @@ int main(int argc, char **argv)
332
274
  *#
333
275
  *# iv expanded (12 octets): 5b 78 92 3d ee 08 57 90 33 e5 23 d9
334
276
  */
277
+ S2N_BLOB_FROM_HEX(secret, "9e 40 64 6c e7 9a 7f 9d c0 5a f8 88 9b ce 65 52 \
278
+ 87 5a fa 0b 06 df 00 87 f7 92 eb b7 c1 75 04 a5");
335
279
  S2N_BLOB_FROM_HEX(key, "17 42 2d da 59 6e d5 d9 ac d8 90 e3 c6 \
336
280
  3f 50 51");
337
281
  S2N_BLOB_FROM_HEX(iv, "5b 78 92 3d ee 08 57 90 33 e5 23 d9");
@@ -340,16 +284,9 @@ int main(int argc, char **argv)
340
284
  DEFER_CLEANUP(struct s2n_connection *conn = s2n_connection_new(modes[i]), s2n_connection_ptr_free);
341
285
  conn->secure.cipher_suite = cipher_suite;
342
286
  conn->actual_protocol_version = S2N_TLS13;
343
- EXPECT_OK(s2n_connection_set_test_master_secret(conn, &master_secret));
344
- EXPECT_MEMCPY_SUCCESS(conn->handshake.hashes->server_finished_digest,
345
- server_finished_hash.data, server_finished_hash.size);
287
+ EXPECT_OK(s2n_set_test_secret(conn, conn->secrets.tls13.client_app_secret, secret));
346
288
 
347
289
  conn->handshake.handshake_type = one_rtt_handshake_type;
348
-
349
- conn->handshake.message_number = one_rtt_message_nums[SERVER_FINISHED];
350
- EXPECT_EQUAL(s2n_conn_get_current_message_type(conn), SERVER_FINISHED);
351
- EXPECT_OK(s2n_tls13_secrets_update(conn));
352
-
353
290
  conn->handshake.message_number = one_rtt_message_nums[CLIENT_FINISHED];
354
291
  EXPECT_EQUAL(s2n_conn_get_current_message_type(conn), CLIENT_FINISHED);
355
292
  EXPECT_OK(s2n_tls13_key_schedule_update(conn));
@@ -368,35 +305,6 @@ int main(int argc, char **argv)
368
305
  [SERVER_FINISHED] = 3,
369
306
  };
370
307
 
371
- /**
372
- *= https://www.rfc-editor.org/rfc/rfc8448.html#section-4
373
- *= type=test
374
- *# {server} extract secret "early" (same as client early secret)
375
- *
376
- *= https://www.rfc-editor.org/rfc/rfc8448.html#section-4
377
- *= type=test
378
- *# {client} extract secret "early":
379
- *#
380
- *# salt: 0 (all zero octets)
381
- *#
382
- *# IKM (32 octets): 4e cd 0e b6 ec 3b 4d 87 f5 d6 02 8f 92 2c a4 c5
383
- *# 85 1a 27 7f d4 13 11 c9 e6 2d 2c 94 92 e1 c4 f3
384
- *#
385
- *# secret (32 octets): 9b 21 88 e9 b2 fc 6d 64 d7 1d c3 29 90 0e 20
386
- *# bb 41 91 50 00 f6 78 aa 83 9c bb 79 7c b7 d8 33 2c
387
- */
388
- S2N_BLOB_FROM_HEX(early_secret, "9b 21 88 e9 b2 fc 6d 64 d7 1d c3 29 90 0e 20 \
389
- bb 41 91 50 00 f6 78 aa 83 9c bb 79 7c b7 d8 33 2c");
390
-
391
- /**
392
- *= https://www.rfc-editor.org/rfc/rfc8448.html#section-4
393
- *= type=test
394
- *# hash (32 octets): 08 ad 0f a0 5d 7c 72 33 b1 77 5b a2 ff 9f 4c 5b
395
- *# 8b 59 27 6b 7f 22 7f 13 a9 76 24 5f 5d 96 09 13
396
- */
397
- S2N_BLOB_FROM_HEX(client_hello_hash, "08 ad 0f a0 5d 7c 72 33 b1 77 5b a2 ff 9f 4c 5b \
398
- 8b 59 27 6b 7f 22 7f 13 a9 76 24 5f 5d 96 09 13");
399
-
400
308
  /* Derive early application traffic keys */
401
309
  {
402
310
  /**
@@ -421,6 +329,8 @@ int main(int argc, char **argv)
421
329
  *#
422
330
  *# iv expanded (12 octets): 6d 47 5f 09 93 c8 e5 64 61 0d b2 b9
423
331
  */
332
+ S2N_BLOB_FROM_HEX(secret, "3f bb e6 a6 0d eb 66 c3 0a 32 79 5a ba 0e ff 7e \
333
+ aa 10 10 55 86 e7 be 5c 09 67 8d 63 b6 ca ab 62");
424
334
  S2N_BLOB_FROM_HEX(key, "92 02 05 a5 b7 bf 21 15 e6 fc 5c 29 42 \
425
335
  83 4f 54");
426
336
  S2N_BLOB_FROM_HEX(iv, "6d 47 5f 09 93 c8 e5 64 61 0d b2 b9");
@@ -436,22 +346,13 @@ int main(int argc, char **argv)
436
346
  conn->secure.cipher_suite = cipher_suite;
437
347
  conn->actual_protocol_version = S2N_TLS13;
438
348
  conn->early_data_state = S2N_EARLY_DATA_REQUESTED;
439
- EXPECT_OK(s2n_connection_set_test_early_secret(conn, &early_secret));
440
- EXPECT_MEMCPY_SUCCESS(conn->handshake.hashes->client_hello_digest,
441
- client_hello_hash.data, client_hello_hash.size);
442
-
443
- /*
444
- * The handshake secret isn't factored into the early data key,
445
- * but needs to be set to something because the server derives the handshake
446
- * secret before it calculates the early data key.
447
- */
448
- EXPECT_OK(s2n_connection_set_test_handshake_secret(conn, &(struct s2n_blob){ 0 }));
349
+ EXPECT_OK(s2n_set_test_secret(conn, conn->secrets.tls13.client_early_secret, secret));
449
350
 
450
351
  conn->handshake.handshake_type = resumed_handshake_type;
451
352
  conn->handshake.message_number = resumed_message_nums[trigger_message];
452
353
  EXPECT_EQUAL(s2n_conn_get_current_message_type(conn), trigger_message);
453
-
454
354
  EXPECT_OK(s2n_tls13_key_schedule_update(conn));
355
+
455
356
  EXPECT_IVS_EQUAL(conn, iv, S2N_CLIENT);
456
357
  EXPECT_KEYS_EQUAL(conn, key, S2N_CLIENT);
457
358
  }
@@ -195,9 +195,6 @@ int main(int argc, char **argv)
195
195
  EXPECT_SUCCESS(s2n_connection_set_secret_callback(conn,
196
196
  s2n_test_secret_cb, (void*)&secrets));
197
197
 
198
- bool expect_early_data_secret = (conn->mode == S2N_SERVER && WITH_EARLY_DATA(conn))
199
- || (conn->mode == S2N_CLIENT && conn->early_data_state == S2N_EARLY_DATA_REQUESTED);
200
-
201
198
  /* Perform the handshake */
202
199
  while (s2n_conn_get_current_message_type(conn) != APPLICATION_DATA) {
203
200
  /*
@@ -272,11 +269,12 @@ int main(int argc, char **argv)
272
269
  break;
273
270
  }
274
271
 
272
+ EXPECT_OK(s2n_tls13_secrets_update(conn));
275
273
  EXPECT_OK(s2n_tls13_key_schedule_update(conn));
276
274
  conn->handshake.message_number++;
277
275
  }
278
276
 
279
- EXPECT_OK(s2n_connection_verify_secrets(conn, &secrets, expect_early_data_secret));
277
+ EXPECT_OK(s2n_connection_verify_secrets(conn, &secrets, test_cases[i].is_early_data_requested));
280
278
  }
281
279
 
282
280
  /* Restore derive and extract methods */
@@ -183,14 +183,19 @@ int s2n_test_tls13_pq_handshake(const struct s2n_security_policy *client_sec_pol
183
183
  struct s2n_tls13_secrets *server_secrets = &server_conn->secrets.tls13;
184
184
  POSIX_ENSURE_EQ(server_secret_info.size, client_secret_info.size);
185
185
  uint8_t size = server_secret_info.size;
186
- POSIX_ENSURE_NE(0, memcmp(all_zeros, client_secrets->early_secret, size));
187
- POSIX_ENSURE_NE(0, memcmp(all_zeros, client_secrets->handshake_secret, size));
188
- POSIX_ENSURE_NE(0, memcmp(all_zeros, server_secrets->early_secret, size));
189
- POSIX_ENSURE_NE(0, memcmp(all_zeros, server_secrets->handshake_secret, size));
186
+ POSIX_ENSURE_EQ(client_secrets->extract_secret_type, S2N_HANDSHAKE_SECRET);
187
+ POSIX_ENSURE_NE(0, memcmp(all_zeros, client_secrets->extract_secret, size));
188
+ POSIX_ENSURE_NE(0, memcmp(all_zeros, client_secrets->client_handshake_secret, size));
189
+ POSIX_ENSURE_NE(0, memcmp(all_zeros, client_secrets->server_handshake_secret, size));
190
+ POSIX_ENSURE_EQ(server_secrets->extract_secret_type, S2N_HANDSHAKE_SECRET);
191
+ POSIX_ENSURE_NE(0, memcmp(all_zeros, server_secrets->extract_secret, size));
192
+ POSIX_ENSURE_NE(0, memcmp(all_zeros, server_secrets->client_handshake_secret, size));
193
+ POSIX_ENSURE_NE(0, memcmp(all_zeros, server_secrets->server_handshake_secret, size));
190
194
 
191
195
  /* Verify client and server secrets are equal to each other */
192
- POSIX_ENSURE_EQ(0, memcmp(server_secrets->early_secret, client_secrets->early_secret, size));
193
- POSIX_ENSURE_EQ(0, memcmp(server_secrets->handshake_secret, client_secrets->handshake_secret, size));
196
+ POSIX_ENSURE_EQ(0, memcmp(server_secrets->extract_secret, client_secrets->extract_secret, size));
197
+ POSIX_ENSURE_EQ(0, memcmp(server_secrets->client_handshake_secret, client_secrets->client_handshake_secret, size));
198
+ POSIX_ENSURE_EQ(0, memcmp(server_secrets->server_handshake_secret, client_secrets->server_handshake_secret, size));
194
199
 
195
200
  /* Clean up */
196
201
  POSIX_GUARD(s2n_stuffer_free(&client_to_server));