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
@@ -1,8 +1,14 @@
1
1
  import pytest
2
2
  import threading
3
3
 
4
- from common import ProviderOptions, Ciphers, Curves, Protocols, Certificates
5
- from global_flags import get_flag, S2N_PROVIDER_VERSION
4
+ from common import ProviderOptions, Ciphers, Curves, Protocols, Certificates, Signatures
5
+ from global_flags import get_flag, S2N_PROVIDER_VERSION, S2N_FIPS_MODE
6
+
7
+
8
+ TLS_13_LIBCRYPTOS = {
9
+ "awslc",
10
+ "openssl-1.1.1"
11
+ }
6
12
 
7
13
 
8
14
  class Provider(object):
@@ -22,6 +28,10 @@ class Provider(object):
22
28
  # put that message in ready_to_test_marker
23
29
  self.ready_to_test_marker = None
24
30
 
31
+ # If a newline character should be added to messages being sent. Required
32
+ # with some providers to properly write to stdin.
33
+ self.send_with_newline = False
34
+
25
35
  # By default, we expect clients to send, but not servers.
26
36
  if options.mode == Provider.ClientMode:
27
37
  self.ready_to_send_input_marker = self.get_send_marker()
@@ -70,6 +80,10 @@ class Provider(object):
70
80
  def supports_cipher(cls, cipher, with_curve=None):
71
81
  raise NotImplementedError
72
82
 
83
+ @classmethod
84
+ def supports_signature(cls, signature):
85
+ return True
86
+
73
87
  def get_cmd_line(self):
74
88
  return self.cmd_line
75
89
 
@@ -90,6 +104,7 @@ class Tcpdump(Provider):
90
104
  This class still follows the provider setup, but all values are hardcoded
91
105
  because this isn't expected to be used outside of the dynamic record test.
92
106
  """
107
+
93
108
  def __init__(self, options: ProviderOptions):
94
109
  Provider.__init__(self, options)
95
110
 
@@ -98,22 +113,22 @@ class Tcpdump(Provider):
98
113
  tcpdump_filter = "dst port {}".format(self.options.port)
99
114
 
100
115
  cmd_line = ["tcpdump",
101
- # Line buffer the output
102
- "-l",
116
+ # Line buffer the output
117
+ "-l",
103
118
 
104
- # Only read 10 packets before exiting. This is enough to find a large
105
- # packet, and still exit before the timeout.
106
- "-c", "10",
119
+ # Only read 10 packets before exiting. This is enough to find a large
120
+ # packet, and still exit before the timeout.
121
+ "-c", "10",
107
122
 
108
- # Watch the loopback device
109
- "-i", "lo",
123
+ # Watch the loopback device
124
+ "-i", "lo",
110
125
 
111
- # Don't resolve IP addresses
112
- "-nn",
126
+ # Don't resolve IP addresses
127
+ "-nn",
113
128
 
114
- # Set the buffer size to 1k
115
- "-B", "1024",
116
- tcpdump_filter]
129
+ # Set the buffer size to 1k
130
+ "-B", "1024",
131
+ tcpdump_filter]
117
132
 
118
133
  return cmd_line
119
134
 
@@ -122,24 +137,54 @@ class S2N(Provider):
122
137
  """
123
138
  The S2N provider translates flags into s2nc/s2nd command line arguments.
124
139
  """
140
+
125
141
  def __init__(self, options: ProviderOptions):
126
142
  Provider.__init__(self, options)
127
143
 
144
+ self.send_with_newline = True
145
+
128
146
  @classmethod
129
147
  def get_send_marker(cls):
130
148
  return 's2n is ready'
131
149
 
132
150
  @classmethod
133
151
  def supports_protocol(cls, protocol, with_cert=None):
134
- # If s2n is built with OpenSSL 1.0.2 it can't connect to itself
135
- if protocol is Protocols.TLS13 and 'openssl-1.0.2' in OpenSSL.get_version():
136
- if with_cert is not None and with_cert.algorithm != 'EC':
137
- return False
152
+ # Disable TLS 1.3 tests for all libcryptos that don't support 1.3
153
+ if all([
154
+ libcrypto not in get_flag(S2N_PROVIDER_VERSION)
155
+ for libcrypto in TLS_13_LIBCRYPTOS
156
+ ]) and protocol == Protocols.TLS13:
157
+ return False
138
158
 
139
159
  return True
140
160
 
141
161
  @classmethod
142
162
  def supports_cipher(cls, cipher, with_curve=None):
163
+ # Disable chacha20 tests in unsupported libcryptos
164
+ if any([
165
+ libcrypto in get_flag(S2N_PROVIDER_VERSION)
166
+ for libcrypto in [
167
+ "openssl-1.0.2",
168
+ "libressl"
169
+ ]
170
+ ]) and "CHACHA20" in cipher.name:
171
+ return False
172
+
173
+ return True
174
+
175
+ @classmethod
176
+ def supports_signature(cls, signature):
177
+ # Disable RSA_PSS_RSAE_SHA256 in unsupported libcryptos
178
+ if any([
179
+ libcrypto in get_flag(S2N_PROVIDER_VERSION)
180
+ for libcrypto in [
181
+ "openssl-1.0.2",
182
+ "libressl",
183
+ "boringssl"
184
+ ]
185
+ ]) and signature == Signatures.RSA_PSS_RSAE_SHA256:
186
+ return False
187
+
143
188
  return True
144
189
 
145
190
  def setup_client(self):
@@ -187,6 +232,12 @@ class S2N(Provider):
187
232
  if self.options.cert:
188
233
  cmd_line.extend(['--cert', self.options.cert])
189
234
 
235
+ if get_flag(S2N_FIPS_MODE):
236
+ cmd_line.append("--enter-fips-mode")
237
+
238
+ if self.options.enable_client_ocsp:
239
+ cmd_line.extend(["--status"])
240
+
190
241
  if self.options.extra_flags is not None:
191
242
  cmd_line.extend(self.options.extra_flags)
192
243
 
@@ -240,7 +291,14 @@ class S2N(Provider):
240
291
  cmd_line.append('-T')
241
292
 
242
293
  if self.options.reconnects_before_exit is not None:
243
- cmd_line.append('--max-conns={}'.format(self.options.reconnects_before_exit))
294
+ cmd_line.append(
295
+ '--max-conns={}'.format(self.options.reconnects_before_exit))
296
+
297
+ if get_flag(S2N_FIPS_MODE):
298
+ cmd_line.append("--enter-fips-mode")
299
+
300
+ if self.options.ocsp_response is not None:
301
+ cmd_line.extend(["--ocsp", self.options.ocsp_response])
244
302
 
245
303
  if self.options.extra_flags is not None:
246
304
  cmd_line.extend(self.options.extra_flags)
@@ -285,10 +343,12 @@ class OpenSSL(Provider):
285
343
  # In the case of a cipher list we need to be sure TLS13 specific ciphers aren't
286
344
  # mixed with ciphers from previous versions
287
345
  is_tls13_or_above = (cipher[0].min_version >= Protocols.TLS13)
288
- mismatch = [c for c in cipher if (c.min_version >= Protocols.TLS13) != is_tls13_or_above]
346
+ mismatch = [c for c in cipher if (
347
+ c.min_version >= Protocols.TLS13) != is_tls13_or_above]
289
348
 
290
349
  if len(mismatch) > 0:
291
- raise Exception("Cannot combine ciphers for TLS1.3 or above with older ciphers: {}".format([c.name for c in cipher]))
350
+ raise Exception("Cannot combine ciphers for TLS1.3 or above with older ciphers: {}".format(
351
+ [c.name for c in cipher]))
292
352
 
293
353
  ciphers.append(self._join_ciphers(cipher))
294
354
  else:
@@ -308,29 +368,11 @@ class OpenSSL(Provider):
308
368
 
309
369
  @classmethod
310
370
  def supports_protocol(cls, protocol, with_cert=None):
311
- if protocol is Protocols.TLS13:
312
- if 'openssl-1.1.1' in OpenSSL.get_version():
313
- return True
314
- else:
315
- return False
316
-
317
371
  return True
318
372
 
319
373
  @classmethod
320
374
  def supports_cipher(cls, cipher, with_curve=None):
321
- is_openssl_111 = "openssl-1.1.1" in OpenSSL.get_version()
322
- if is_openssl_111 and cipher.openssl1_1_1 is False:
323
- return False
324
-
325
- if not is_openssl_111:
326
- # OpenSSL 1.0.2 does not have ChaChaPoly
327
- if 'CHACHA20' in cipher.name:
328
- return False
329
-
330
- if cipher.fips is False and "fips" in OpenSSL.get_version():
331
- return False
332
-
333
- if "openssl-1.0.2" in OpenSSL.get_version() and with_curve is not None:
375
+ if "openssl-1.0.2" in get_flag(S2N_PROVIDER_VERSION) and with_curve is not None:
334
376
  invalid_ciphers = [
335
377
  Ciphers.ECDHE_RSA_AES128_SHA,
336
378
  Ciphers.ECDHE_RSA_AES256_SHA,
@@ -349,7 +391,8 @@ class OpenSSL(Provider):
349
391
 
350
392
  def setup_client(self):
351
393
  cmd_line = ['openssl', 's_client']
352
- cmd_line.extend(['-connect', '{}:{}'.format(self.options.host, self.options.port)])
394
+ cmd_line.extend(
395
+ ['-connect', '{}:{}'.format(self.options.host, self.options.port)])
353
396
 
354
397
  # Additional debugging that will be captured incase of failure
355
398
  cmd_line.extend(['-debug', '-tlsextdebug', '-state'])
@@ -391,6 +434,16 @@ class OpenSSL(Provider):
391
434
  if self.options.verify_hostname is not None:
392
435
  cmd_line.extend(['-verify_hostname', self.options.server_name])
393
436
 
437
+ if self.options.enable_client_ocsp:
438
+ cmd_line.append("-status")
439
+
440
+ if self.options.signature_algorithm is not None:
441
+ cmd_line.extend(
442
+ ["-sigalgs", self.options.signature_algorithm.name])
443
+
444
+ if self.options.record_size is not None:
445
+ cmd_line.extend(["-max_send_frag", str(self.options.record_size)])
446
+
394
447
  # Clients are always ready to connect
395
448
  self.set_provider_ready()
396
449
 
@@ -405,7 +458,8 @@ class OpenSSL(Provider):
405
458
 
406
459
  if self.options.reconnects_before_exit is not None:
407
460
  # If the user request a specific reconnection count, set it here
408
- cmd_line.extend(['-naccept', str(self.options.reconnects_before_exit)])
461
+ cmd_line.extend(
462
+ ['-naccept', str(self.options.reconnects_before_exit)])
409
463
  else:
410
464
  # Exit after the first connection by default
411
465
  cmd_line.extend(['-naccept', '1'])
@@ -440,16 +494,25 @@ class OpenSSL(Provider):
440
494
  # We use "Verify" instead of "verify" to require a client cert
441
495
  cmd_line.extend(['-Verify', '1'])
442
496
 
497
+ if self.options.ocsp_response is not None:
498
+ cmd_line.extend(["-status_file", self.options.ocsp_response])
499
+
500
+ if self.options.signature_algorithm is not None:
501
+ cmd_line.extend(
502
+ ["-sigalgs", self.options.signature_algorithm.name])
503
+
443
504
  if self.options.extra_flags is not None:
444
505
  cmd_line.extend(self.options.extra_flags)
445
506
 
446
507
  return cmd_line
447
508
 
509
+
448
510
  class JavaSSL(Provider):
449
511
  """
450
512
  NOTE: Only a Java SSL client has been set up. The server has not been
451
513
  implemented yet.
452
514
  """
515
+
453
516
  def __init__(self, options: ProviderOptions):
454
517
  Provider.__init__(self, options)
455
518
 
@@ -466,7 +529,7 @@ class JavaSSL(Provider):
466
529
 
467
530
  @classmethod
468
531
  def supports_cipher(cls, cipher, with_curve=None):
469
- # Java SSL does not support CHACHA20
532
+ # Java SSL does not support CHACHA20
470
533
  if 'CHACHA20' in cipher.name:
471
534
  return False
472
535
 
@@ -497,12 +560,14 @@ class JavaSSL(Provider):
497
560
 
498
561
  return cmd_line
499
562
 
563
+
500
564
  class BoringSSL(Provider):
501
565
  """
502
566
  NOTE: In order to focus on the general use of this framework, BoringSSL
503
567
  is not yet supported. The client works, the server has not yet been
504
568
  implemented, neither are in the default configuration.
505
569
  """
570
+
506
571
  def __init__(self, options: ProviderOptions):
507
572
  Provider.__init__(self, options)
508
573
 
@@ -515,18 +580,22 @@ class BoringSSL(Provider):
515
580
 
516
581
  def setup_client(self):
517
582
  cmd_line = ['bssl', 's_client']
518
- cmd_line.extend(['-connect', '{}:{}'.format(self.options.host, self.options.port)])
583
+ cmd_line.extend(
584
+ ['-connect', '{}:{}'.format(self.options.host, self.options.port)])
519
585
  if self.options.cert is not None:
520
586
  cmd_line.extend(['-cert', self.options.cert])
521
587
  if self.options.key is not None:
522
588
  cmd_line.extend(['-key', self.options.key])
523
589
  if self.options.cipher is not None:
524
590
  if self.options.cipher == Ciphersuites.TLS_CHACHA20_POLY1305_SHA256:
525
- cmd_line.extend(['-cipher', 'TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256'])
591
+ cmd_line.extend(
592
+ ['-cipher', 'TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256'])
526
593
  elif self.options.cipher == Ciphersuites.TLS_AES_128_GCM_256:
527
- pytest.skip('BoringSSL does not support Cipher {}'.format(self.options.cipher))
594
+ pytest.skip('BoringSSL does not support Cipher {}'.format(
595
+ self.options.cipher))
528
596
  elif self.options.cipher == Ciphersuites.TLS_AES_256_GCM_384:
529
- pytest.skip('BoringSSL does not support Cipher {}'.format(self.options.cipher))
597
+ pytest.skip('BoringSSL does not support Cipher {}'.format(
598
+ self.options.cipher))
530
599
  if self.options.curve is not None:
531
600
  if self.options.curve == Curves.P256:
532
601
  cmd_line.extend(['-curves', 'P-256'])
@@ -535,7 +604,8 @@ class BoringSSL(Provider):
535
604
  elif self.options.curve == Curves.P521:
536
605
  cmd_line.extend(['-curves', 'P-521'])
537
606
  elif self.options.curve == Curves.X25519:
538
- pytest.skip('BoringSSL does not support curve {}'.format(self.options.curve))
607
+ pytest.skip('BoringSSL does not support curve {}'.format(
608
+ self.options.curve))
539
609
 
540
610
  # Clients are always ready to connect
541
611
  self.set_provider_ready()
@@ -543,3 +613,189 @@ class BoringSSL(Provider):
543
613
  return cmd_line
544
614
 
545
615
 
616
+ class GnuTLS(Provider):
617
+ def __init__(self, options: ProviderOptions):
618
+ Provider.__init__(self, options)
619
+
620
+ self.expect_stderr = True
621
+ self.send_with_newline = True
622
+
623
+ @staticmethod
624
+ def cipher_to_priority_str(cipher):
625
+ return {
626
+ Ciphers.DHE_RSA_AES128_SHA: "DHE-RSA:+AES-128-CBC:+SHA1",
627
+ Ciphers.DHE_RSA_AES256_SHA: "DHE-RSA:+AES-256-CBC:+SHA1",
628
+ Ciphers.DHE_RSA_AES128_SHA256: "DHE-RSA:+AES-128-CBC:+SHA256",
629
+ Ciphers.DHE_RSA_AES256_SHA256: "DHE-RSA:+AES-256-CBC:+SHA256",
630
+ Ciphers.DHE_RSA_AES128_GCM_SHA256: "DHE-RSA:+AES-128-GCM:+AEAD",
631
+ Ciphers.DHE_RSA_AES256_GCM_SHA384: "DHE-RSA:+AES-256-GCM:+AEAD",
632
+ Ciphers.DHE_RSA_CHACHA20_POLY1305: "DHE-RSA:+CHACHA20-POLY1305:+AEAD",
633
+
634
+ Ciphers.AES128_SHA: "RSA:+AES-128-CBC:+SHA1",
635
+ Ciphers.AES256_SHA: "RSA:+AES-256-CBC:+SHA1",
636
+ Ciphers.AES128_SHA256: "RSA:+AES-128-CBC:+SHA256",
637
+ Ciphers.AES256_SHA256: "RSA:+AES-256-CBC:+SHA256",
638
+ Ciphers.AES128_GCM_SHA256: "RSA:+AES-128-GCM:+AEAD",
639
+ Ciphers.AES256_GCM_SHA384: "RSA:+AES-256-GCM:+AEAD",
640
+
641
+ Ciphers.ECDHE_ECDSA_AES128_SHA: "ECDHE-ECDSA:+AES-128-CBC:+SHA1",
642
+ Ciphers.ECDHE_ECDSA_AES256_SHA: "ECDHE-ECDSA:+AES-256-CBC:+SHA1",
643
+ Ciphers.ECDHE_ECDSA_AES128_SHA256: "ECDHE-ECDSA:+AES-128-CBC:+SHA256",
644
+ Ciphers.ECDHE_ECDSA_AES256_SHA384: "ECDHE-ECDSA:+AES-256-CBC:+SHA384",
645
+ Ciphers.ECDHE_ECDSA_AES128_GCM_SHA256: "ECDHE-ECDSA:+AES-128-GCM:+AEAD",
646
+ Ciphers.ECDHE_ECDSA_AES256_GCM_SHA384: "ECDHE-ECDSA:+AES-256-GCM:+AEAD",
647
+
648
+ Ciphers.ECDHE_RSA_AES128_SHA: "ECDHE-RSA:+AES-128-CBC:+SHA1",
649
+ Ciphers.ECDHE_RSA_AES256_SHA: "ECDHE-RSA:+AES-256-CBC:+SHA1",
650
+ Ciphers.ECDHE_RSA_AES128_SHA256: "ECDHE-RSA:+AES-128-CBC:+SHA256",
651
+ Ciphers.ECDHE_RSA_AES256_SHA384: "ECDHE-RSA:+AES-256-CBC:+SHA384",
652
+ Ciphers.ECDHE_RSA_AES128_GCM_SHA256: "ECDHE-RSA:+AES-128-GCM:+AEAD",
653
+ Ciphers.ECDHE_RSA_AES256_GCM_SHA384: "ECDHE-RSA:+AES-256-GCM:+AEAD",
654
+ Ciphers.ECDHE_RSA_CHACHA20_POLY1305: "ECDHE-RSA:+CHACHA20-POLY1305:+AEAD"
655
+ }.get(cipher)
656
+
657
+ @staticmethod
658
+ def protocol_to_priority_str(protocol):
659
+ return {
660
+ Protocols.TLS10.value: "VERS-TLS1.0",
661
+ Protocols.TLS11.value: "VERS-TLS1.1",
662
+ Protocols.TLS12.value: "VERS-TLS1.2",
663
+ Protocols.TLS13.value: "VERS-TLS1.3"
664
+ }.get(protocol.value)
665
+
666
+ @staticmethod
667
+ def curve_to_priority_str(curve):
668
+ return {
669
+ Curves.P256: "CURVE-SECP256R1",
670
+ Curves.P384: "CURVE-SECP384R1",
671
+ Curves.P521: "CURVE-SECP521R1",
672
+ Curves.X25519: "CURVE-X25519"
673
+ }.get(curve)
674
+
675
+ @staticmethod
676
+ def sigalg_to_priority_str(sigalg):
677
+ return {
678
+ Signatures.RSA_SHA1: "SIGN-RSA-SHA1",
679
+ Signatures.RSA_SHA256: "SIGN-RSA-SHA256",
680
+ Signatures.RSA_SHA384: "SIGN-RSA-SHA384",
681
+ Signatures.RSA_SHA512: "SIGN-RSA-SHA512",
682
+ }.get(sigalg)
683
+
684
+ @classmethod
685
+ def get_send_marker(cls):
686
+ return "Simple Client Mode:"
687
+
688
+ def create_priority_str(self):
689
+ priority_str = "NONE"
690
+
691
+ if self.options.protocol:
692
+ priority_str += ":+" + \
693
+ self.protocol_to_priority_str(self.options.protocol)
694
+ else:
695
+ priority_str += ":+VERS-ALL"
696
+
697
+ if self.options.cipher:
698
+ priority_str += ":+" + \
699
+ self.cipher_to_priority_str(self.options.cipher)
700
+ else:
701
+ priority_str += ":+KX-ALL:+CIPHER-ALL:+MAC-ALL"
702
+
703
+ if self.options.curve:
704
+ priority_str += ":+" + \
705
+ self.curve_to_priority_str(self.options.curve)
706
+ else:
707
+ priority_str += ":+GROUP-ALL"
708
+
709
+ if self.options.signature_algorithm:
710
+ priority_str += ":+" + \
711
+ self.sigalg_to_priority_str(self.options.signature_algorithm)
712
+ else:
713
+ priority_str += ":+SIGN-ALL"
714
+
715
+ priority_str += ":+COMP-NULL"
716
+
717
+ # A digital signature option is not included for the test RSA certs, so GnuTLS must be
718
+ # told to use these certs regardless. The %COMPAT priority string option enables this for
719
+ # client certificates, and the undocumented %DEBUG_ALLOW_KEY_USAGE_VIOLATIONS priority
720
+ # string option enables this for server certificates.
721
+ priority_str += ":%COMPAT"
722
+ priority_str += ":%DEBUG_ALLOW_KEY_USAGE_VIOLATIONS"
723
+
724
+ return priority_str
725
+
726
+ def setup_client(self):
727
+ self.set_provider_ready()
728
+
729
+ cmd_line = [
730
+ "gnutls-cli",
731
+ "--port", str(self.options.port),
732
+ self.options.host,
733
+ "--debug", "9999",
734
+ "--verbose"
735
+ ]
736
+
737
+ if self.options.cert and self.options.key:
738
+ cmd_line.extend(["--x509certfile", self.options.cert])
739
+ cmd_line.extend(["--x509keyfile", self.options.key])
740
+
741
+ priority_str = self.create_priority_str()
742
+ cmd_line.extend(["--priority", priority_str])
743
+
744
+ if self.options.insecure:
745
+ cmd_line.extend(["--insecure"])
746
+
747
+ if self.options.enable_client_ocsp:
748
+ cmd_line.append("--ocsp")
749
+
750
+ if self.options.record_size:
751
+ cmd_line.extend(["--recordsize", str(self.options.record_size)])
752
+
753
+ if self.options.extra_flags:
754
+ cmd_line.extend(self.options.extra_flags)
755
+
756
+ return cmd_line
757
+
758
+ def setup_server(self):
759
+ self.ready_to_test_marker = "Echo Server listening on"
760
+
761
+ cmd_line = [
762
+ "gnutls-serv",
763
+ f"--port={self.options.port}",
764
+ "--echo",
765
+ "--debug=9999"
766
+ ]
767
+
768
+ if self.options.cert is not None:
769
+ cmd_line.extend(["--x509certfile", self.options.cert])
770
+ if self.options.key is not None:
771
+ cmd_line.extend(["--x509keyfile", self.options.key])
772
+
773
+ priority_str = self.create_priority_str()
774
+ cmd_line.extend(["--priority", priority_str])
775
+
776
+ if self.options.cipher:
777
+ if self.options.cipher.parameters:
778
+ cmd_line.extend(["--dhparams", self.options.cipher.parameters])
779
+
780
+ if self.options.ocsp_response:
781
+ cmd_line.extend(["--ocsp-response", self.options.ocsp_response])
782
+
783
+ if self.options.use_client_auth:
784
+ cmd_line.append("--require-client-cert")
785
+
786
+ if self.options.extra_flags:
787
+ cmd_line.extend(self.options.extra_flags)
788
+
789
+ return cmd_line
790
+
791
+ @classmethod
792
+ def supports_protocol(cls, protocol, with_cert=None):
793
+ return GnuTLS.protocol_to_priority_str(protocol) is not None
794
+
795
+ @classmethod
796
+ def supports_cipher(cls, cipher, with_curve=None):
797
+ return GnuTLS.cipher_to_priority_str(cipher) is not None
798
+
799
+ @classmethod
800
+ def supports_signature(cls, signature):
801
+ return GnuTLS.sigalg_to_priority_str(signature) is not None
@@ -4,7 +4,7 @@ import pytest
4
4
  import time
5
5
 
6
6
  from configuration import (available_ports, ALL_TEST_CIPHERS, ALL_TEST_CURVES,
7
- ALL_TEST_CERTS, PROTOCOLS)
7
+ ALL_TEST_CERTS, PROTOCOLS)
8
8
  from common import Certificates, ProviderOptions, Protocols, data_bytes
9
9
  from fixtures import managed_process
10
10
  from providers import Provider, S2N, OpenSSL
@@ -21,6 +21,7 @@ CERTS_TO_TEST = [
21
21
  Certificates.RSA_PSS_2048_SHA256,
22
22
  ]
23
23
 
24
+
24
25
  def assert_openssl_handshake_complete(results, is_complete=True):
25
26
  if is_complete:
26
27
  assert b'read finished' in results.stderr
@@ -32,18 +33,22 @@ def assert_openssl_handshake_complete(results, is_complete=True):
32
33
  def assert_s2n_handshake_complete(results, protocol, provider, is_complete=True):
33
34
  expected_version = get_expected_s2n_version(protocol, provider)
34
35
  if is_complete:
35
- assert to_bytes("Actual protocol version: {}".format(expected_version)) in results.stdout
36
+ assert to_bytes("Actual protocol version: {}".format(
37
+ expected_version)) in results.stdout
36
38
  else:
37
- assert to_bytes("Actual protocol version: {}".format(expected_version)) not in results.stdout
39
+ assert to_bytes("Actual protocol version: {}".format(
40
+ expected_version)) not in results.stdout
38
41
 
39
42
 
40
43
  @pytest.mark.uncollect_if(func=invalid_test_parameters)
41
44
  @pytest.mark.parametrize("provider", [OpenSSL], ids=get_parameter_name)
45
+ @pytest.mark.parametrize("other_provider", [S2N], ids=get_parameter_name)
42
46
  @pytest.mark.parametrize("protocol", PROTOCOLS, ids=get_parameter_name)
43
47
  @pytest.mark.parametrize("cipher", ALL_TEST_CIPHERS, ids=get_parameter_name)
44
48
  @pytest.mark.parametrize("certificate", CERTS_TO_TEST, ids=get_parameter_name)
45
49
  @pytest.mark.parametrize("client_certificate", CERTS_TO_TEST, ids=get_parameter_name)
46
- def test_client_auth_with_s2n_server(managed_process, cipher, provider, protocol, certificate, client_certificate):
50
+ def test_client_auth_with_s2n_server(managed_process, provider, other_provider, protocol, cipher, certificate,
51
+ client_certificate):
47
52
  port = next(available_ports)
48
53
 
49
54
  random_bytes = data_bytes(64)
@@ -76,7 +81,6 @@ def test_client_auth_with_s2n_server(managed_process, cipher, provider, protocol
76
81
  assert b'write certificate verify' in results.stderr
77
82
  assert_openssl_handshake_complete(results)
78
83
 
79
-
80
84
  # S2N should successfully connect
81
85
  for results in server.get_results():
82
86
  results.assert_success()
@@ -86,11 +90,13 @@ def test_client_auth_with_s2n_server(managed_process, cipher, provider, protocol
86
90
 
87
91
  @pytest.mark.uncollect_if(func=invalid_test_parameters)
88
92
  @pytest.mark.parametrize("provider", [OpenSSL], ids=get_parameter_name)
93
+ @pytest.mark.parametrize("other_provider", [S2N], ids=get_parameter_name)
89
94
  @pytest.mark.parametrize("protocol", PROTOCOLS, ids=get_parameter_name)
90
95
  @pytest.mark.parametrize("cipher", ALL_TEST_CIPHERS, ids=get_parameter_name)
91
96
  @pytest.mark.parametrize("certificate", CERTS_TO_TEST, ids=get_parameter_name)
92
97
  @pytest.mark.parametrize("client_certificate", CERTS_TO_TEST, ids=get_parameter_name)
93
- def test_client_auth_with_s2n_server_using_nonmatching_certs(managed_process, cipher, provider, protocol, certificate, client_certificate):
98
+ def test_client_auth_with_s2n_server_using_nonmatching_certs(managed_process, provider, other_provider, protocol,
99
+ cipher, certificate, client_certificate):
94
100
  port = next(available_ports)
95
101
 
96
102
  client_options = ProviderOptions(
@@ -112,7 +118,7 @@ def test_client_auth_with_s2n_server_using_nonmatching_certs(managed_process, ci
112
118
  server_options.cert = certificate.cert
113
119
 
114
120
  # Tell the server to expect the wrong certificate
115
- server_options.trust_store=Certificates.RSA_2048_SHA256_WILDCARD.cert
121
+ server_options.trust_store = Certificates.RSA_2048_SHA256_WILDCARD.cert
116
122
 
117
123
  server = managed_process(S2N, server_options, timeout=5)
118
124
  client = managed_process(OpenSSL, client_options, timeout=5)
@@ -138,10 +144,11 @@ def test_client_auth_with_s2n_server_using_nonmatching_certs(managed_process, ci
138
144
 
139
145
  @pytest.mark.uncollect_if(func=invalid_test_parameters)
140
146
  @pytest.mark.parametrize("provider", [OpenSSL], ids=get_parameter_name)
147
+ @pytest.mark.parametrize("other_provider", [S2N], ids=get_parameter_name)
141
148
  @pytest.mark.parametrize("protocol", PROTOCOLS, ids=get_parameter_name)
142
149
  @pytest.mark.parametrize("cipher", ALL_TEST_CIPHERS, ids=get_parameter_name)
143
150
  @pytest.mark.parametrize("certificate", CERTS_TO_TEST, ids=get_parameter_name)
144
- def test_client_auth_with_s2n_client_no_cert(managed_process, cipher, protocol, provider, certificate):
151
+ def test_client_auth_with_s2n_client_no_cert(managed_process, provider, other_provider, protocol, cipher, certificate):
145
152
  port = next(available_ports)
146
153
 
147
154
  random_bytes = data_bytes(64)
@@ -174,20 +181,22 @@ def test_client_auth_with_s2n_client_no_cert(managed_process, cipher, protocol,
174
181
 
175
182
  for results in client.get_results():
176
183
  assert results.exception is None
177
- # TLS1.3 OpenSSL fails after the handshake, but pre-TLS1.3 fails during
184
+ # TLS1.3 OpenSSL fails after the handshake, but pre-TLS1.3 fails during
178
185
  if protocol is not Protocols.TLS13:
179
- assert (results.exit_code != 0)
186
+ assert (results.exit_code != 0)
180
187
  assert b"Failed to negotiate: 'TLS alert received'" in results.stderr
181
188
  assert_s2n_handshake_complete(results, protocol, provider, False)
182
189
 
183
190
 
184
191
  @pytest.mark.uncollect_if(func=invalid_test_parameters)
185
192
  @pytest.mark.parametrize("provider", [OpenSSL], ids=get_parameter_name)
193
+ @pytest.mark.parametrize("other_provider", [S2N], ids=get_parameter_name)
186
194
  @pytest.mark.parametrize("protocol", PROTOCOLS, ids=get_parameter_name)
187
195
  @pytest.mark.parametrize("cipher", ALL_TEST_CIPHERS, ids=get_parameter_name)
188
196
  @pytest.mark.parametrize("certificate", CERTS_TO_TEST, ids=get_parameter_name)
189
197
  @pytest.mark.parametrize("client_certificate", CERTS_TO_TEST, ids=get_parameter_name)
190
- def test_client_auth_with_s2n_client_with_cert(managed_process, cipher, protocol, provider, certificate, client_certificate):
198
+ def test_client_auth_with_s2n_client_with_cert(managed_process, provider, other_provider, protocol, cipher, certificate,
199
+ client_certificate):
191
200
  port = next(available_ports)
192
201
 
193
202
  random_bytes = data_bytes(64)