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
@@ -23,13 +23,15 @@
23
23
  #include "utils/s2n_random.h"
24
24
  #include "utils/s2n_blob.h"
25
25
 
26
+ static bool ignore_prediction_resistance_for_testing = false;
27
+
26
28
  #define s2n_drbg_key_size(drgb) EVP_CIPHER_CTX_key_length((drbg)->ctx)
27
29
  #define s2n_drbg_seed_size(drgb) (S2N_DRBG_BLOCK_SIZE + s2n_drbg_key_size(drgb))
28
30
 
29
31
  /* This function is the same as s2n_increment_sequence_number
30
32
  but it does not check for overflow, since overflow is
31
33
  acceptable in DRBG */
32
- int s2n_increment_drbg_counter(struct s2n_blob *counter)
34
+ S2N_RESULT s2n_increment_drbg_counter(struct s2n_blob *counter)
33
35
  {
34
36
  for (uint32_t i = counter->size; i > 0; i--) {
35
37
  counter->data[i-1] += 1;
@@ -39,60 +41,62 @@ int s2n_increment_drbg_counter(struct s2n_blob *counter)
39
41
 
40
42
  /* seq[i] wrapped, so let it carry */
41
43
  }
42
- return 0;
44
+ return S2N_RESULT_OK;
43
45
  }
44
46
 
45
- static int s2n_drbg_block_encrypt(EVP_CIPHER_CTX * ctx, uint8_t in[S2N_DRBG_BLOCK_SIZE], uint8_t out[S2N_DRBG_BLOCK_SIZE])
47
+ static S2N_RESULT s2n_drbg_block_encrypt(EVP_CIPHER_CTX *ctx, uint8_t in[S2N_DRBG_BLOCK_SIZE], uint8_t out[S2N_DRBG_BLOCK_SIZE])
46
48
  {
47
- POSIX_ENSURE_REF(ctx);
49
+ RESULT_ENSURE_REF(ctx);
50
+
48
51
  int len = S2N_DRBG_BLOCK_SIZE;
49
- POSIX_GUARD_OSSL(EVP_EncryptUpdate(ctx, out, &len, in, S2N_DRBG_BLOCK_SIZE), S2N_ERR_DRBG);
50
- POSIX_ENSURE_EQ(len, S2N_DRBG_BLOCK_SIZE);
52
+ RESULT_GUARD_OSSL(EVP_EncryptUpdate(ctx, out, &len, in, S2N_DRBG_BLOCK_SIZE), S2N_ERR_DRBG);
53
+ RESULT_ENSURE_EQ(len, S2N_DRBG_BLOCK_SIZE);
51
54
 
52
- return 0;
55
+ return S2N_RESULT_OK;
53
56
  }
54
57
 
55
- static int s2n_drbg_bits(struct s2n_drbg *drbg, struct s2n_blob *out)
58
+ static S2N_RESULT s2n_drbg_bits(struct s2n_drbg *drbg, struct s2n_blob *out)
56
59
  {
57
- POSIX_ENSURE_REF(drbg);
58
- POSIX_ENSURE_REF(drbg->ctx);
59
- POSIX_ENSURE_REF(out);
60
+ RESULT_ENSURE_REF(drbg);
61
+ RESULT_ENSURE_REF(drbg->ctx);
62
+ RESULT_ENSURE_REF(out);
60
63
 
61
64
  struct s2n_blob value = {0};
62
- POSIX_GUARD(s2n_blob_init(&value, drbg->v, sizeof(drbg->v)));
65
+ RESULT_GUARD_POSIX(s2n_blob_init(&value, drbg->v, sizeof(drbg->v)));
63
66
  int block_aligned_size = out->size - (out->size % S2N_DRBG_BLOCK_SIZE);
64
67
 
65
68
  /* Per NIST SP800-90A 10.2.1.2: */
66
69
  for (int i = 0; i < block_aligned_size; i += S2N_DRBG_BLOCK_SIZE) {
67
- POSIX_GUARD(s2n_increment_drbg_counter(&value));
68
- POSIX_GUARD(s2n_drbg_block_encrypt(drbg->ctx, drbg->v, out->data + i));
70
+ RESULT_GUARD(s2n_increment_drbg_counter(&value));
71
+ RESULT_GUARD(s2n_drbg_block_encrypt(drbg->ctx, drbg->v, out->data + i));
69
72
  drbg->bytes_used += S2N_DRBG_BLOCK_SIZE;
70
73
  }
71
74
 
72
75
  if (out->size <= block_aligned_size) {
73
- return 0;
76
+ return S2N_RESULT_OK;
74
77
  }
75
78
 
76
79
  uint8_t spare_block[S2N_DRBG_BLOCK_SIZE];
77
- POSIX_GUARD(s2n_increment_drbg_counter(&value));
78
- POSIX_GUARD(s2n_drbg_block_encrypt(drbg->ctx, drbg->v, spare_block));
80
+ RESULT_GUARD(s2n_increment_drbg_counter(&value));
81
+ RESULT_GUARD(s2n_drbg_block_encrypt(drbg->ctx, drbg->v, spare_block));
79
82
  drbg->bytes_used += S2N_DRBG_BLOCK_SIZE;
80
83
 
81
- POSIX_CHECKED_MEMCPY(out->data + block_aligned_size, spare_block, out->size - block_aligned_size);
84
+ RESULT_CHECKED_MEMCPY(out->data + block_aligned_size, spare_block, out->size - block_aligned_size);
82
85
 
83
- return 0;
86
+ return S2N_RESULT_OK;
84
87
  }
85
88
 
86
- static int s2n_drbg_update(struct s2n_drbg *drbg, struct s2n_blob *provided_data)
89
+ static S2N_RESULT s2n_drbg_update(struct s2n_drbg *drbg, struct s2n_blob *provided_data)
87
90
  {
88
- POSIX_ENSURE_REF(drbg);
89
- POSIX_ENSURE_REF(drbg->ctx);
91
+ RESULT_ENSURE_REF(drbg);
92
+ RESULT_ENSURE_REF(drbg->ctx);
93
+ RESULT_ENSURE_REF(provided_data);
90
94
 
91
- s2n_stack_blob(temp_blob, s2n_drbg_seed_size(drgb), S2N_DRBG_MAX_SEED_SIZE);
95
+ RESULT_STACK_BLOB(temp_blob, s2n_drbg_seed_size(drgb), S2N_DRBG_MAX_SEED_SIZE);
92
96
 
93
- POSIX_ENSURE_EQ(provided_data->size, s2n_drbg_seed_size(drbg));
97
+ RESULT_ENSURE_EQ(provided_data->size, s2n_drbg_seed_size(drbg));
94
98
 
95
- POSIX_GUARD(s2n_drbg_bits(drbg, &temp_blob));
99
+ RESULT_GUARD(s2n_drbg_bits(drbg, &temp_blob));
96
100
 
97
101
  /* XOR in the provided data */
98
102
  for (uint32_t i = 0; i < provided_data->size; i++) {
@@ -100,102 +104,109 @@ static int s2n_drbg_update(struct s2n_drbg *drbg, struct s2n_blob *provided_data
100
104
  }
101
105
 
102
106
  /* Update the key and value */
103
- POSIX_GUARD_OSSL(EVP_EncryptInit_ex(drbg->ctx, NULL, NULL, temp_blob.data, NULL), S2N_ERR_DRBG);
107
+ RESULT_GUARD_OSSL(EVP_EncryptInit_ex(drbg->ctx, NULL, NULL, temp_blob.data, NULL), S2N_ERR_DRBG);
104
108
 
105
- POSIX_CHECKED_MEMCPY(drbg->v, temp_blob.data + s2n_drbg_key_size(drbg), S2N_DRBG_BLOCK_SIZE);
109
+ RESULT_CHECKED_MEMCPY(drbg->v, temp_blob.data + s2n_drbg_key_size(drbg), S2N_DRBG_BLOCK_SIZE);
106
110
 
107
- return 0;
111
+ return S2N_RESULT_OK;
108
112
  }
109
113
 
110
- static int s2n_drbg_mix_in_entropy(struct s2n_drbg *drbg, struct s2n_blob *entropy, struct s2n_blob *ps)
114
+ static S2N_RESULT s2n_drbg_mix_in_entropy(struct s2n_drbg *drbg, struct s2n_blob *entropy, struct s2n_blob *ps)
111
115
  {
112
- POSIX_ENSURE_REF(drbg);
113
- POSIX_ENSURE_REF(drbg->ctx);
114
- POSIX_ENSURE_REF(entropy);
116
+ RESULT_ENSURE_REF(drbg);
117
+ RESULT_ENSURE_REF(drbg->ctx);
118
+ RESULT_ENSURE_REF(entropy);
115
119
 
116
- POSIX_ENSURE_GTE(entropy->size, ps->size);
120
+ RESULT_ENSURE_GTE(entropy->size, ps->size);
117
121
 
118
122
  for (uint32_t i = 0; i < ps->size; i++) {
119
123
  entropy->data[i] ^= ps->data[i];
120
124
  }
121
125
 
122
- POSIX_GUARD(s2n_drbg_update(drbg, entropy));
126
+ RESULT_GUARD(s2n_drbg_update(drbg, entropy));
123
127
 
124
- return 0;
128
+ return S2N_RESULT_OK;
125
129
  }
126
130
 
127
- static int s2n_drbg_seed(struct s2n_drbg *drbg, struct s2n_blob *ps)
131
+ static S2N_RESULT s2n_drbg_seed(struct s2n_drbg *drbg, struct s2n_blob *ps)
128
132
  {
129
- s2n_stack_blob(blob, s2n_drbg_seed_size(drbg), S2N_DRBG_MAX_SEED_SIZE);
133
+ RESULT_STACK_BLOB(blob, s2n_drbg_seed_size(drbg), S2N_DRBG_MAX_SEED_SIZE);
130
134
 
131
- POSIX_GUARD_RESULT(s2n_get_seed_entropy(&blob));
132
- POSIX_GUARD(s2n_drbg_mix_in_entropy(drbg, &blob, ps));
135
+ RESULT_GUARD(s2n_get_seed_entropy(&blob));
136
+ RESULT_GUARD(s2n_drbg_mix_in_entropy(drbg, &blob, ps));
133
137
 
134
138
  drbg->bytes_used = 0;
135
139
 
136
- return 0;
140
+ return S2N_RESULT_OK;
137
141
  }
138
142
 
139
- static int s2n_drbg_mix(struct s2n_drbg *drbg, struct s2n_blob *ps)
143
+ static S2N_RESULT s2n_drbg_mix(struct s2n_drbg *drbg, struct s2n_blob *ps)
140
144
  {
141
- s2n_stack_blob(blob, s2n_drbg_seed_size(drbg), S2N_DRBG_MAX_SEED_SIZE);
145
+ if (s2n_unlikely(ignore_prediction_resistance_for_testing)) {
146
+ RESULT_ENSURE(s2n_in_unit_test(), S2N_ERR_NOT_IN_UNIT_TEST);
147
+ return S2N_RESULT_OK;
148
+ }
142
149
 
143
- POSIX_GUARD_RESULT(s2n_get_mix_entropy(&blob));
144
- POSIX_GUARD(s2n_drbg_mix_in_entropy(drbg, &blob, ps));
150
+ RESULT_STACK_BLOB(blob, s2n_drbg_seed_size(drbg), S2N_DRBG_MAX_SEED_SIZE);
151
+
152
+ RESULT_GUARD(s2n_get_mix_entropy(&blob));
153
+ RESULT_GUARD(s2n_drbg_mix_in_entropy(drbg, &blob, ps));
145
154
 
146
155
  drbg->mixes += 1;
147
156
 
148
- return 0;
157
+ return S2N_RESULT_OK;
149
158
  }
150
159
 
151
- int s2n_drbg_instantiate(struct s2n_drbg *drbg, struct s2n_blob *personalization_string, const s2n_drbg_mode mode)
160
+ S2N_RESULT s2n_drbg_instantiate(struct s2n_drbg *drbg, struct s2n_blob *personalization_string, const s2n_drbg_mode mode)
152
161
  {
153
- POSIX_ENSURE_REF(drbg);
162
+ RESULT_ENSURE_REF(drbg);
163
+ RESULT_ENSURE_REF(personalization_string);
154
164
 
155
165
  drbg->ctx = EVP_CIPHER_CTX_new();
156
- S2N_ERROR_IF(!drbg->ctx, S2N_ERR_DRBG);
166
+ RESULT_GUARD_PTR(drbg->ctx);
157
167
 
158
- s2n_evp_ctx_init(drbg->ctx);
168
+ RESULT_EVP_CTX_INIT(drbg->ctx);
159
169
 
160
170
  switch(mode) {
161
171
  case S2N_AES_128_CTR_NO_DF_PR:
162
- POSIX_GUARD_OSSL(EVP_EncryptInit_ex(drbg->ctx, EVP_aes_128_ecb(), NULL, NULL, NULL), S2N_ERR_DRBG);
172
+ RESULT_GUARD_OSSL(EVP_EncryptInit_ex(drbg->ctx, EVP_aes_128_ecb(), NULL, NULL, NULL), S2N_ERR_DRBG);
163
173
  break;
164
174
  case S2N_AES_256_CTR_NO_DF_PR:
165
- POSIX_GUARD_OSSL(EVP_EncryptInit_ex(drbg->ctx, EVP_aes_256_ecb(), NULL, NULL, NULL), S2N_ERR_DRBG);
175
+ RESULT_GUARD_OSSL(EVP_EncryptInit_ex(drbg->ctx, EVP_aes_256_ecb(), NULL, NULL, NULL), S2N_ERR_DRBG);
166
176
  break;
167
177
  default:
168
- POSIX_BAIL(S2N_ERR_DRBG);
178
+ RESULT_BAIL(S2N_ERR_DRBG);
169
179
  }
170
180
 
171
- POSIX_ENSURE_LTE(s2n_drbg_key_size(drbg), S2N_DRBG_MAX_KEY_SIZE);
172
- POSIX_ENSURE_LTE(s2n_drbg_seed_size(drbg), S2N_DRBG_MAX_SEED_SIZE);
181
+ RESULT_ENSURE_LTE(s2n_drbg_key_size(drbg), S2N_DRBG_MAX_KEY_SIZE);
182
+ RESULT_ENSURE_LTE(s2n_drbg_seed_size(drbg), S2N_DRBG_MAX_SEED_SIZE);
173
183
 
174
184
  static const uint8_t zero_key[S2N_DRBG_MAX_KEY_SIZE] = {0};
175
185
 
176
186
  /* Start off with zeroed data, per 10.2.1.3.1 item 4 and 5 */
177
187
  memset(drbg->v, 0, sizeof(drbg->v));
178
- POSIX_GUARD_OSSL(EVP_EncryptInit_ex(drbg->ctx, NULL, NULL, zero_key, NULL), S2N_ERR_DRBG);
188
+ RESULT_GUARD_OSSL(EVP_EncryptInit_ex(drbg->ctx, NULL, NULL, zero_key, NULL), S2N_ERR_DRBG);
179
189
 
180
190
  /* Copy the personalization string */
181
- s2n_stack_blob(ps, s2n_drbg_seed_size(drbg), S2N_DRBG_MAX_SEED_SIZE);
182
- POSIX_GUARD(s2n_blob_zero(&ps));
191
+ RESULT_STACK_BLOB(ps, s2n_drbg_seed_size(drbg), S2N_DRBG_MAX_SEED_SIZE);
192
+ RESULT_GUARD_POSIX(s2n_blob_zero(&ps));
183
193
 
184
- POSIX_CHECKED_MEMCPY(ps.data, personalization_string->data, MIN(ps.size, personalization_string->size));
194
+ RESULT_CHECKED_MEMCPY(ps.data, personalization_string->data, MIN(ps.size, personalization_string->size));
185
195
 
186
196
  /* Seed the DRBG */
187
- POSIX_GUARD(s2n_drbg_seed(drbg, &ps));
197
+ RESULT_GUARD(s2n_drbg_seed(drbg, &ps));
188
198
 
189
- return 0;
199
+ return S2N_RESULT_OK;
190
200
  }
191
201
 
192
- int s2n_drbg_generate(struct s2n_drbg *drbg, struct s2n_blob *blob)
202
+ S2N_RESULT s2n_drbg_generate(struct s2n_drbg *drbg, struct s2n_blob *blob)
193
203
  {
194
- POSIX_ENSURE_REF(drbg);
195
- POSIX_ENSURE_REF(drbg->ctx);
196
- s2n_stack_blob(zeros, s2n_drbg_seed_size(drbg), S2N_DRBG_MAX_SEED_SIZE);
204
+ RESULT_ENSURE_REF(drbg);
205
+ RESULT_ENSURE_REF(drbg->ctx);
206
+
207
+ RESULT_STACK_BLOB(zeros, s2n_drbg_seed_size(drbg), S2N_DRBG_MAX_SEED_SIZE);
197
208
 
198
- S2N_ERROR_IF(blob->size > S2N_DRBG_GENERATE_LIMIT, S2N_ERR_DRBG_REQUEST_SIZE);
209
+ RESULT_ENSURE(blob->size <= S2N_DRBG_GENERATE_LIMIT, S2N_ERR_DRBG_REQUEST_SIZE);
199
210
 
200
211
  /* Mix in additional entropy for every randomness generation call. This
201
212
  * defense mechanism is referred to as "prediction resistance".
@@ -205,31 +216,41 @@ int s2n_drbg_generate(struct s2n_drbg *drbg, struct s2n_blob *blob)
205
216
  * 2. Re-consider whether the current fork detection strategy is still
206
217
  * sufficient.
207
218
  */
208
- POSIX_GUARD(s2n_drbg_mix(drbg, &zeros));
209
- POSIX_GUARD(s2n_drbg_bits(drbg, blob));
210
- POSIX_GUARD(s2n_drbg_update(drbg, &zeros));
219
+ RESULT_GUARD(s2n_drbg_mix(drbg, &zeros));
220
+ RESULT_GUARD(s2n_drbg_bits(drbg, blob));
221
+ RESULT_GUARD(s2n_drbg_update(drbg, &zeros));
211
222
 
212
- return 0;
223
+ return S2N_RESULT_OK;
213
224
  }
214
225
 
215
- int s2n_drbg_wipe(struct s2n_drbg *drbg)
226
+ S2N_RESULT s2n_drbg_wipe(struct s2n_drbg *drbg)
216
227
  {
217
- POSIX_ENSURE_REF(drbg);
228
+ RESULT_ENSURE_REF(drbg);
229
+
218
230
  if (drbg->ctx) {
219
- POSIX_GUARD_OSSL(EVP_CIPHER_CTX_cleanup(drbg->ctx), S2N_ERR_DRBG);
231
+ RESULT_GUARD_OSSL(EVP_CIPHER_CTX_cleanup(drbg->ctx), S2N_ERR_DRBG);
220
232
 
221
233
  EVP_CIPHER_CTX_free(drbg->ctx);
222
234
  drbg->ctx = NULL;
223
235
  }
224
236
 
225
237
  *drbg = (struct s2n_drbg) {0};
226
- return 0;
238
+ return S2N_RESULT_OK;
227
239
  }
228
240
 
229
- int s2n_drbg_bytes_used(struct s2n_drbg *drbg, uint64_t *bytes_used)
241
+ S2N_RESULT s2n_drbg_bytes_used(struct s2n_drbg *drbg, uint64_t *bytes_used)
230
242
  {
231
- POSIX_ENSURE_REF(drbg);
232
- POSIX_ENSURE_REF(bytes_used);
243
+ RESULT_ENSURE_REF(drbg);
244
+ RESULT_ENSURE_REF(bytes_used);
245
+
233
246
  *bytes_used = drbg->bytes_used;
234
- return 0;
247
+ return S2N_RESULT_OK;
248
+ }
249
+
250
+ S2N_RESULT s2n_ignore_prediction_resistance_for_testing(bool ignore_bool) {
251
+ RESULT_ENSURE(s2n_in_unit_test(), S2N_ERR_NOT_IN_UNIT_TEST);
252
+
253
+ ignore_prediction_resistance_for_testing = ignore_bool;
254
+
255
+ return S2N_RESULT_OK;
235
256
  }
@@ -52,12 +52,15 @@ typedef enum {S2N_AES_128_CTR_NO_DF_PR, S2N_AES_256_CTR_NO_DF_PR} s2n_drbg_mode;
52
52
 
53
53
  /* Per NIST SP 800-90C 6.3
54
54
  *
55
- * s2n's DRBG does provide prediction resistance
56
- * and does not support the additional_input parameter (which per 800-90C may be zero).
55
+ * s2n's DRBG uses prediction resistance and does not support the
56
+ * additional_input parameter (which per 800-90C may be zero).
57
57
  *
58
- * The security strength provided by s2n's DRBG is either 128 or 256 bits depending on the s2n_drbg_mode passed in.
58
+ * The security strength provided by s2n's DRBG is either 128 or 256 bits
59
+ * depending on the s2n_drbg_mode passed in.
59
60
  */
60
- extern int s2n_drbg_instantiate(struct s2n_drbg *drbg, struct s2n_blob *personalization_string, const s2n_drbg_mode mode);
61
- extern int s2n_drbg_generate(struct s2n_drbg *drbg, struct s2n_blob *returned_bits);
62
- extern int s2n_drbg_wipe(struct s2n_drbg *drbg);
63
- extern int s2n_drbg_bytes_used(struct s2n_drbg *drbg, uint64_t *bytes_used);
61
+ S2N_RESULT s2n_drbg_instantiate(struct s2n_drbg *drbg, struct s2n_blob *personalization_string, const s2n_drbg_mode mode);
62
+ S2N_RESULT s2n_drbg_generate(struct s2n_drbg *drbg, struct s2n_blob *returned_bits);
63
+ S2N_RESULT s2n_drbg_wipe(struct s2n_drbg *drbg);
64
+ S2N_RESULT s2n_drbg_bytes_used(struct s2n_drbg *drbg, uint64_t *bytes_used);
65
+ /* Use for testing only */
66
+ S2N_RESULT s2n_ignore_prediction_resistance_for_testing(bool true_or_false);
@@ -40,8 +40,10 @@
40
40
 
41
41
  #if (S2N_OPENSSL_VERSION_AT_LEAST(1, 1, 0)) && (!defined(OPENSSL_IS_BORINGSSL)) && (!defined(OPENSSL_IS_AWSLC))
42
42
  #define s2n_evp_ctx_init(ctx) POSIX_GUARD_OSSL(EVP_CIPHER_CTX_init(ctx), S2N_ERR_DRBG)
43
+ #define RESULT_EVP_CTX_INIT(ctx) RESULT_GUARD_OSSL(EVP_CIPHER_CTX_init(ctx), S2N_ERR_DRBG)
43
44
  #else
44
45
  #define s2n_evp_ctx_init(ctx) EVP_CIPHER_CTX_init(ctx)
46
+ #define RESULT_EVP_CTX_INIT(ctx) EVP_CIPHER_CTX_init(ctx)
45
47
  #endif
46
48
 
47
49
  #if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_FIPS) && !defined(LIBRESSL_VERSION_NUMBER) && !defined(OPENSSL_IS_AWSLC) && !defined(OPENSSL_NO_ENGINE)
@@ -267,7 +267,7 @@ static const char *no_such_error = "Internal s2n error";
267
267
  ERR_ENTRY(S2N_ERR_PKEY_CTX_INIT, "Unable to initialize the libcrypto pkey context") \
268
268
  ERR_ENTRY(S2N_ERR_FORK_DETECTION_INIT, "Fork detection initialization failed") \
269
269
  ERR_ENTRY(S2N_ERR_RETRIEVE_FORK_GENERATION_NUMBER, "Retrieving fork generation number failed") \
270
-
270
+ ERR_ENTRY(S2N_ERR_SECRET_SCHEDULE_STATE, "Correct inputs to secret calculation not available") \
271
271
  /* clang-format on */
272
272
 
273
273
  #define ERR_STR_CASE(ERR, str) case ERR: return str;
@@ -284,6 +284,7 @@ typedef enum {
284
284
  S2N_ERR_INVALID_X509_EXTENSION_TYPE,
285
285
  S2N_ERR_INSUFFICIENT_MEM_SIZE,
286
286
  S2N_ERR_KEYING_MATERIAL_EXPIRED,
287
+ S2N_ERR_SECRET_SCHEDULE_STATE,
287
288
  S2N_ERR_T_USAGE_END,
288
289
  } s2n_error;
289
290
 
@@ -158,6 +158,13 @@ ifeq ($(S2N_UNSAFE_FUZZING_MODE),1)
158
158
 
159
159
  endif
160
160
 
161
+ # Disable strict-prototypes check in clang
162
+ ifneq '' '$(findstring clang,$(CC))'
163
+ CFLAGS += -Wno-strict-prototypes
164
+ DEFAULT_CFLAGS += -Wno-strict-prototypes
165
+ CPPFLAGS += -Wno-strict-prototypes
166
+ endif
167
+
161
168
  # If COV_TOOL isn't set, pick a default COV_TOOL depending on if the LLVM Marker File was created.
162
169
  ifndef COV_TOOL
163
170
  ifneq ("$(wildcard $(LLVM_GCOV_MARKER_FILE))","")
@@ -0,0 +1,233 @@
1
+ """Discover repository properties like repository root, proof root, etc."""
2
+
3
+ from pathlib import Path
4
+ from subprocess import Popen, PIPE
5
+ import subprocess
6
+ import logging
7
+ import json
8
+ import re
9
+
10
+ ################################################################
11
+ # Construct an ascending relative path like "../../.." from a
12
+ # directory to an ancestor in the file system.
13
+ #
14
+ # The Path method dst.relative_to(src) requires that dst is a
15
+ # descendant of src and will not produce a path like "../../..".
16
+
17
+ def path_to_ancestor(descendant, ancestor):
18
+ """Relative path from descendant to ancestor."""
19
+
20
+ descendant = Path(descendant).resolve()
21
+ ancestor = Path(ancestor).resolve()
22
+
23
+ try:
24
+ path = descendant.relative_to(ancestor)
25
+ except ValueError:
26
+ raise UserWarning(f"{ancestor} is not an ancestor of {descendant}") from ValueError
27
+
28
+ return Path(*[Path('..') for part in path.parts])
29
+
30
+ ################################################################
31
+ # Discover the roots of
32
+ # * the respository and
33
+ # * the proofs subtree installed by the starter kit.
34
+
35
+ def repository_root(cwd='.', abspath=True):
36
+ """Path to root of repository containing current directory.
37
+
38
+ Return the absolute path if abspath is True. If abspath is False,
39
+ return the relative path from the current directory. If the
40
+ current directory is within a submodule of the repository, then
41
+ the root of the submodule is returned, not the repository itself.
42
+ """
43
+
44
+ cwd = Path(cwd).resolve()
45
+ for ancestor in [cwd, *cwd.parents]:
46
+ if (ancestor / '.git').is_dir():
47
+ return ancestor if abspath else path_to_ancestor(cwd, ancestor)
48
+ raise UserWarning(f"No git repository contains {cwd}")
49
+
50
+ def proofs_root(cwd='.', abspath=True):
51
+ """Path to root of proofs subtree installed by starter kit.
52
+
53
+ Return an absolute path if abspath is True, and a path relative to
54
+ cwd otherwise. Search starts at cwd and ascends until it reaches
55
+ the root of the enclosing repository, and raises UserWarning if
56
+ there is no enclosing repository."""
57
+
58
+ cwd = Path(cwd).resolve() # Where to start looking
59
+ root = repository_root(cwd=cwd, abspath=True) # Where to stop looking
60
+ proofs = "proofs" # What to look for
61
+
62
+ for path in [cwd, *cwd.parents]:
63
+ if path.name == proofs:
64
+ return path if abspath else path_to_ancestor(cwd, path)
65
+ if path == root:
66
+ break
67
+ raise UserWarning(f"'{cwd}' has no ancestor named '{proofs}'")
68
+
69
+ ################################################################
70
+ # Discover the roots of
71
+ # * the litani submodule
72
+ # * the starter kit submodule
73
+
74
+ def load_submodules(repo=None):
75
+ """Load file .gitmodules describing the installed submodules"""
76
+
77
+ repo = repo or repository_root()
78
+ try:
79
+ cmd = ['git', 'config', '-f', '.gitmodules', '--list']
80
+ kwds = {'cwd': str(repo), 'capture_output': True, 'text': True}
81
+ lines = subprocess.run(cmd, **kwds, check=True).stdout.splitlines()
82
+ except subprocess.CalledProcessError as error:
83
+ logging.debug(error)
84
+ raise UserWarning(
85
+ f"Can't load submodules in repository root '{repo}'"
86
+ ) from error
87
+
88
+ submodules = {}
89
+ for line in lines:
90
+ line=re.sub(r'\s+', ' ', line.strip())
91
+
92
+ # Output of git config is lines of the form
93
+ # submodule.ORGANIZATION/REPOSITORY.path=PATH
94
+ # submodule.ORGANIZATION/REPOSITORY.url=URL
95
+ # Parsing config output with a simple regular expression will
96
+ # fail if PATH or URL contains path= or url= as a substring.
97
+ match = re.match(r"^submodule\.(.+)\.(path|url)=(.+)", line)
98
+ if not match:
99
+ logging.debug("Can't parse git config output: '%s'", line)
100
+ continue
101
+
102
+ name, key, value = [string.strip() for string in match.groups()[0:3]]
103
+ if key == 'path':
104
+ value = Path(value)
105
+ if not value.is_dir(): # Maybe PATH included path= as a substring...
106
+ logging.debug("Not a directory: path %s for submodule %s", value, name)
107
+ submodules[name] = submodules.get(name, {})
108
+ submodules[name][key] = value
109
+
110
+ return submodules
111
+
112
+ def submodule_root(url, submodules=None, repo=None, abspath=True):
113
+ """Look up path to root of submodule url in submodules."""
114
+
115
+ url = url.lower()
116
+ repo = Path(repo) if repo else repository_root()
117
+ submodules = submodules or load_submodules(repo=repo)
118
+
119
+ for _, config in submodules.items():
120
+ config_url = config.get("url")
121
+ config_path = config.get("path")
122
+
123
+ if not config_url or not config_url.lower() in [url, url+".git"]:
124
+ continue
125
+ if not config_path:
126
+ logging.debug("Can't find path to submodule '%s'", url)
127
+ logging.debug("Found submodule config = %s", config)
128
+ return None
129
+ return repo/config_path if abspath else config_path
130
+
131
+ logging.debug("Can't find submodule '%s'", url)
132
+ logging.debug("Found submodules = %s", submodules)
133
+ return None
134
+
135
+
136
+ def litani_root(submodules=None, repo=None, abspath=True):
137
+ """Root of litani submodule."""
138
+
139
+ litani1 = 'https://github.com/awslabs/aws-build-accumulator'
140
+ litani2 = 'git@github.com:awslabs/aws-build-accumulator'
141
+ return (submodule_root(litani1, submodules, repo, abspath) or
142
+ submodule_root(litani2, submodules, repo, abspath))
143
+
144
+ def starter_kit_root(submodules=None, repo=None, abspath=True):
145
+ """Root of starter kit submodule."""
146
+
147
+ old_starter1 = 'https://github.com/awslabs/aws-templates-for-cbmc-proofs'
148
+ old_starter2 = 'git@github.com:awslabs/aws-templates-for-cbmc-proofs'
149
+ new_starter1 = 'https://github.com/model-checking/cbmc-starter-kit'
150
+ new_starter2 = 'git@github.com:model-checking/cbmc-starter-kit'
151
+ return (submodule_root(old_starter1, submodules, repo, abspath) or
152
+ submodule_root(old_starter2, submodules, repo, abspath) or
153
+ submodule_root(new_starter1, submodules, repo, abspath) or
154
+ submodule_root(new_starter2, submodules, repo, abspath))
155
+
156
+ ################################################################
157
+ # Discover the set of all source files in the repository that define a
158
+ # function named func.
159
+
160
+ def run(cmd, cwd=None, stdin=None):
161
+ """Run a command with string stdin on stdin, return stdout and stderr."""
162
+
163
+ cmd = [str(word) for word in cmd]
164
+ try:
165
+ with Popen(cmd, cwd=cwd, text=True, stdin=PIPE, stdout=PIPE, stderr=PIPE) as pipe:
166
+ stdout, stderr = pipe.communicate(input=stdin)
167
+ if pipe.returncode:
168
+ logging.debug("Nonzero return code %s: command: '%s'", pipe.returncode, ' '.join(cmd))
169
+ logging.debug("Nonzero return code %s: stderr: '%s'", pipe.returncode, pipe.stderr)
170
+ return None, None
171
+ return stdout, stderr
172
+ except FileNotFoundError:
173
+ logging.debug("FileNotFoundError: command '%s'", ' '.join(cmd))
174
+ return None, None
175
+
176
+ def function_tags(repo='.'):
177
+ """List of tags for function definitions in respository source files.
178
+
179
+ Each tag is a dict '{"name": function, "path": source}' naming a
180
+ function and a source file defining the function."""
181
+
182
+ repo = Path(repo).resolve()
183
+
184
+ find_cmd = ['find', '.', '-name', '*.c']
185
+ find_stdout, _ = run(find_cmd, cwd=repo)
186
+ if find_stdout is None: # run() logs errors on debug
187
+ return []
188
+
189
+ ctags_cmd = [
190
+ 'ctags',
191
+ '-L', '-', # read from standard input
192
+ '--c-types=f', # include only function definition tags
193
+ '--output-format=json', # each line is one json blob for one tag
194
+ '--fields=NF' # each json blob is {name="function", path="source"}
195
+ ]
196
+ ctags_stdout, _ = run(ctags_cmd, cwd=repo, stdin=find_stdout)
197
+ if ctags_stdout is None: # run() logs errors on debug
198
+ return []
199
+
200
+ blobs = ctags_stdout.splitlines() # a list of json blobs
201
+ blob = '[' + ','.join(blobs) + ']' # a json blob
202
+ try:
203
+ return json.loads(blob)
204
+ except json.decoder.JSONDecodeError as error:
205
+ logging.debug("Can't load json output of ctags in %s", repo)
206
+ logging.debug(error)
207
+ return []
208
+
209
+ def function_paths(func, tags):
210
+ """Paths to all source files in tags defining a function func."""
211
+
212
+ return sorted([tag['path'] for tag in tags if tag['name'] == func])
213
+
214
+ def function_sources(func, cwd='.', repo='.', abspath=True):
215
+ """Paths to all source files in the repository defining a function func.
216
+
217
+ Paths are absolute if abspath is True, and relative to cwd otherwise.
218
+
219
+ """
220
+
221
+ cwd = Path(cwd).resolve()
222
+ repo = Path(repo).resolve()
223
+
224
+ tags = function_tags(repo)
225
+ paths = function_paths(func, tags)
226
+
227
+ path_to_repo = repo if abspath else path_to_ancestor(cwd, repo)
228
+ sources = [Path(path_to_repo, path) for path in paths]
229
+
230
+ assert all(src.is_file() for src in sources)
231
+ return sources
232
+
233
+ ################################################################
@@ -9,6 +9,7 @@ import logging
9
9
  import os
10
10
  import shutil
11
11
 
12
+ import repository
12
13
  import util
13
14
 
14
15
  def proof_template_filenames():
@@ -17,16 +18,16 @@ def proof_template_filenames():
17
18
 
18
19
  def read_proof_template(filename):
19
20
  directory = os.path.join(util.templates_root(), util.PROOF_TEMPLATES)
20
- with open(os.path.join(directory, filename)) as data:
21
+ with open(os.path.join(directory, filename), encoding='utf-8') as data:
21
22
  return data.read().splitlines()
22
23
 
23
24
  def write_proof_template(lines, filename, directory):
24
- with open(os.path.join(directory, filename), "w") as data:
25
+ with open(os.path.join(directory, filename), "w", encoding='utf-8') as data:
25
26
  data.writelines(line + '\n' for line in lines)
26
27
 
27
28
  def rename_proof_harness(function, directory):
28
29
  shutil.move(os.path.join(directory, "FUNCTION_harness.c"),
29
- os.path.join(directory, "{}_harness.c".format(function)))
30
+ os.path.join(directory, f"{function}_harness.c"))
30
31
 
31
32
  def patch_function_name(lines, function):
32
33
  return [line.replace("<__FUNCTION_NAME__>", function) for line in lines]
@@ -48,10 +49,10 @@ def main():
48
49
 
49
50
  logging.basicConfig(format='%(levelname)s: %(message)s')
50
51
 
51
- function = util.read_function_name()
52
- source_file = util.read_source_path()
53
- source_root = util.read_source_root_path()
54
- proof_root = util.read_proof_root_path()
52
+ function = util.ask_for_function_name()
53
+ source_file = util.ask_for_source_file(function)
54
+ source_root = repository.repository_root()
55
+ proof_root = repository.proofs_root()
55
56
 
56
57
  proof_dir = os.path.abspath(function)
57
58
  os.mkdir(proof_dir)