aws-crt 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/VERSION +1 -1
  4. data/aws-crt-ffi/crt/aws-c-cal/CMakeLists.txt +2 -0
  5. data/aws-crt-ffi/crt/aws-c-cal/bin/produce_x_platform_fuzz_corpus/CMakeLists.txt +30 -0
  6. data/aws-crt-ffi/crt/aws-c-cal/bin/produce_x_platform_fuzz_corpus/main.c +208 -0
  7. data/aws-crt-ffi/crt/aws-c-cal/bin/run_x_platform_fuzz_corpus/CMakeLists.txt +30 -0
  8. data/aws-crt-ffi/crt/aws-c-cal/bin/run_x_platform_fuzz_corpus/main.c +244 -0
  9. data/aws-crt-ffi/crt/aws-c-cal/ecdsa-fuzz-corpus/darwin/p256_sig_corpus.txt +10000 -0
  10. data/aws-crt-ffi/crt/aws-c-cal/ecdsa-fuzz-corpus/windows/p256_sig_corpus.txt +10000 -0
  11. data/aws-crt-ffi/crt/aws-c-cal/source/windows/bcrypt_ecc.c +8 -0
  12. data/aws-crt-ffi/crt/aws-c-http/tests/CMakeLists.txt +11 -10
  13. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/tls_channel_handler.h +2 -0
  14. data/aws-crt-ffi/crt/aws-c-io/source/darwin/darwin_pki_utils.c +8 -0
  15. data/aws-crt-ffi/crt/aws-c-io/source/tls_channel_handler.c +2 -0
  16. data/aws-crt-ffi/crt/aws-c-io/source/windows/windows_pki_utils.c +65 -35
  17. data/aws-crt-ffi/crt/s2n/CMakeLists.txt +67 -21
  18. data/aws-crt-ffi/crt/s2n/Makefile +10 -0
  19. data/aws-crt-ffi/crt/s2n/bin/Makefile +9 -0
  20. data/aws-crt-ffi/crt/s2n/bindings/rust/Makefile +14 -0
  21. data/aws-crt-ffi/crt/s2n/bindings/rust/integration/Cargo.toml +2 -2
  22. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/Cargo.toml +3 -2
  23. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/src/raw/config.rs +265 -39
  24. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/src/raw/connection.rs +170 -20
  25. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/src/testing/s2n_tls.rs +120 -0
  26. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/src/testing.rs +58 -23
  27. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/Cargo.toml +1 -1
  28. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/src/internal.rs +3 -0
  29. data/aws-crt-ffi/crt/s2n/crypto/s2n_composite_cipher_aes_sha.c +1 -1
  30. data/aws-crt-ffi/crt/s2n/crypto/s2n_drbg.c +8 -3
  31. data/aws-crt-ffi/crt/s2n/error/s2n_errno.c +3 -0
  32. data/aws-crt-ffi/crt/s2n/error/s2n_errno.h +2 -0
  33. data/aws-crt-ffi/crt/s2n/lib/Makefile +11 -0
  34. data/aws-crt-ffi/crt/s2n/pq-crypto/kyber_90s_r2/ntt.h +2 -2
  35. data/aws-crt-ffi/crt/s2n/pq-crypto/kyber_r2/ntt.h +2 -2
  36. data/aws-crt-ffi/crt/s2n/pq-crypto/kyber_r3/kyber512r3_poly_avx2.h +2 -2
  37. data/aws-crt-ffi/crt/s2n/pq-crypto/kyber_r3/kyber512r3_polyvec_avx2.h +2 -2
  38. data/aws-crt-ffi/crt/s2n/pq-crypto/sike_r1/P503_internal_r1.h +1 -1
  39. data/aws-crt-ffi/crt/s2n/pq-crypto/sike_r1/fips202_r1.h +1 -1
  40. data/aws-crt-ffi/crt/s2n/pq-crypto/sike_r3/sikep434r3_fp_x64_asm.S +4 -0
  41. data/aws-crt-ffi/crt/s2n/s2n.mk +25 -0
  42. data/aws-crt-ffi/crt/s2n/scripts/s2n_safety_macros.py +14 -0
  43. data/aws-crt-ffi/crt/s2n/tests/benchmark/Readme.md +23 -9
  44. data/aws-crt-ffi/crt/s2n/tests/features/clone.c +24 -0
  45. data/aws-crt-ffi/crt/s2n/tests/features/madvise.c +27 -0
  46. data/aws-crt-ffi/crt/s2n/tests/features/minherit.c +22 -0
  47. data/aws-crt-ffi/crt/s2n/tests/integrationv2/conftest.py +2 -2
  48. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_connection_test.c +1 -1
  49. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_fork_generation_number_test.c +335 -0
  50. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_mem_usage_test.c +1 -1
  51. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_self_talk_client_hello_cb_test.c +93 -11
  52. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_server_hello_retry_test.c +123 -1
  53. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_key_schedule_rfc8448_test.c +18 -3
  54. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_key_schedule_test.c +0 -38
  55. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_secrets_test.c +134 -15
  56. data/aws-crt-ffi/crt/s2n/tls/s2n_cipher_suites.c +1 -1
  57. data/aws-crt-ffi/crt/s2n/tls/s2n_client_hello.c +20 -9
  58. data/aws-crt-ffi/crt/s2n/tls/s2n_client_hello.h +8 -0
  59. data/aws-crt-ffi/crt/s2n/tls/s2n_config.c +13 -0
  60. data/aws-crt-ffi/crt/s2n/tls/s2n_config.h +6 -0
  61. data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_io.c +2 -1
  62. data/aws-crt-ffi/crt/s2n/tls/s2n_internal.h +9 -0
  63. data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_key_schedule.c +7 -7
  64. data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_secrets.c +61 -8
  65. data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_secrets.h +11 -5
  66. data/aws-crt-ffi/crt/s2n/utils/s2n_fork_detection.c +367 -0
  67. data/aws-crt-ffi/crt/s2n/utils/s2n_fork_detection.h +28 -0
  68. data/aws-crt-ffi/crt/s2n/utils/s2n_safety_macros.h +13 -22
  69. metadata +18 -3
@@ -82,6 +82,10 @@ static size_t s_signature_length(const struct aws_ecc_key_pair *key_pair) {
82
82
  return s_der_overhead + aws_ecc_key_coordinate_byte_size_from_curve_name(key_pair->curve_name) * 2;
83
83
  }
84
84
 
85
+ static bool s_trim_zeros_predicate(uint8_t value) {
86
+ return value == 0;
87
+ }
88
+
85
89
  static int s_sign_message(
86
90
  const struct aws_ecc_key_pair *key_pair,
87
91
  const struct aws_byte_cursor *message,
@@ -124,8 +128,12 @@ static int s_sign_message(
124
128
 
125
129
  aws_der_encoder_begin_sequence(encoder);
126
130
  struct aws_byte_cursor integer_cur = aws_byte_cursor_from_array(temp_signature_buf.buffer, coordinate_len);
131
+ /* trim off the leading zero padding for DER encoding */
132
+ integer_cur = aws_byte_cursor_left_trim_pred(&integer_cur, s_trim_zeros_predicate);
127
133
  aws_der_encoder_write_integer(encoder, integer_cur);
128
134
  integer_cur = aws_byte_cursor_from_array(temp_signature_buf.buffer + coordinate_len, coordinate_len);
135
+ /* trim off the leading zero padding for DER encoding */
136
+ integer_cur = aws_byte_cursor_left_trim_pred(&integer_cur, s_trim_zeros_predicate);
129
137
  aws_der_encoder_write_integer(encoder, integer_cur);
130
138
  aws_der_encoder_end_sequence(encoder);
131
139
 
@@ -585,16 +585,17 @@ add_test_case(test_http_stats_split_across_gather_boundary)
585
585
  add_test_case(test_http_stats_pipelined)
586
586
  add_test_case(test_http_stats_multiple_requests_with_gap)
587
587
 
588
- add_test_case(h2_sm_sanity_check)
589
- add_test_case(h2_sm_mock_connection)
590
- add_test_case(h2_sm_mock_multiple_connections)
591
- add_test_case(h2_sm_mock_bad_connection_acquired)
592
- add_test_case(h2_sm_mock_connections_closed_before_request_made)
593
- add_test_case(h2_sm_mock_max_concurrent_streams_remote)
594
- add_test_case(h2_sm_mock_complete_stream)
595
- add_test_case(h2_sm_mock_ideal_num_streams)
596
- add_test_case(h2_sm_mock_large_ideal_num_streams)
597
- add_test_case(h2_sm_mock_goaway)
588
+ # Tests that not make real connection but use TLS. So, still need to be marked as net test
589
+ add_net_test_case(h2_sm_sanity_check)
590
+ add_net_test_case(h2_sm_mock_connection)
591
+ add_net_test_case(h2_sm_mock_multiple_connections)
592
+ add_net_test_case(h2_sm_mock_bad_connection_acquired)
593
+ add_net_test_case(h2_sm_mock_connections_closed_before_request_made)
594
+ add_net_test_case(h2_sm_mock_max_concurrent_streams_remote)
595
+ add_net_test_case(h2_sm_mock_complete_stream)
596
+ add_net_test_case(h2_sm_mock_ideal_num_streams)
597
+ add_net_test_case(h2_sm_mock_large_ideal_num_streams)
598
+ add_net_test_case(h2_sm_mock_goaway)
598
599
 
599
600
  add_net_test_case(h2_sm_acquire_stream)
600
601
  add_net_test_case(h2_sm_acquire_stream_multiple_connections)
@@ -379,6 +379,8 @@ AWS_IO_API int aws_tls_ctx_options_init_client_mtls_with_pkcs11(
379
379
  const struct aws_tls_ctx_pkcs11_options *pkcs11_options);
380
380
 
381
381
  /**
382
+ * @Deprecated
383
+ *
382
384
  * Sets a custom keychain path for storing the cert and pkey with mutual tls in client mode.
383
385
  *
384
386
  * NOTE: This only works on MacOS.
@@ -49,6 +49,12 @@ int aws_import_public_and_private_keys_to_identity(
49
49
  SecKeychainRef import_keychain = NULL;
50
50
 
51
51
  if (keychain_path) {
52
+ # pragma clang diagnostic push
53
+ # pragma clang diagnostic ignored "-Wdeprecated-declarations"
54
+ /* Starting in macOS 12, SecKeychainOpen() and SecKeychainUnlock() are marked as deprecated
55
+ * because "Custom keychain management is no longer supported".
56
+ * Disable compiler warnings for now, but consider removing support for keychain_path altogether */
57
+
52
58
  OSStatus keychain_status = SecKeychainOpen(aws_string_c_str(keychain_path), &import_keychain);
53
59
  if (keychain_status != errSecSuccess) {
54
60
  AWS_LOGF_ERROR(
@@ -67,6 +73,8 @@ int aws_import_public_and_private_keys_to_identity(
67
73
  keychain_status);
68
74
  return AWS_OP_ERR;
69
75
  }
76
+ # pragma clang diagnostic pop
77
+
70
78
  } else {
71
79
  OSStatus keychain_status = SecKeychainCopyDefault(&import_keychain);
72
80
  if (keychain_status != errSecSuccess) {
@@ -221,6 +221,8 @@ int aws_tls_ctx_options_set_keychain_path(
221
221
  struct aws_byte_cursor *keychain_path_cursor) {
222
222
 
223
223
  #if defined(__APPLE__) && !defined(AWS_OS_IOS)
224
+ AWS_LOGF_WARN(AWS_LS_IO_TLS, "static: Keychain path is deprecated.");
225
+
224
226
  options->keychain_path = aws_string_new_from_cursor(options->allocator, keychain_path_cursor);
225
227
  if (!options->keychain_path) {
226
228
  return AWS_OP_ERR;
@@ -21,66 +21,96 @@
21
21
  #define CERT_HASH_STR_LEN 40
22
22
  #define CERT_HASH_LEN 20
23
23
 
24
- int aws_load_cert_from_system_cert_store(const char *cert_path, HCERTSTORE *cert_store, PCCERT_CONTEXT *certs) {
24
+ /**
25
+ * Split system cert path into exactly three segments like:
26
+ * "CurrentUser\My\a11f8a9b5df5b98ba3508fbca575d09570e0d2c6"
27
+ * -> ["CurrentUser", "My", "a11f8a9b5df5b98ba3508fbca575d09570e0d2c6"]
28
+ */
29
+ static int s_split_system_cert_path(const char *cert_path, struct aws_byte_cursor out_splits[3]) {
30
+
31
+ struct aws_byte_cursor cert_path_cursor = aws_byte_cursor_from_c_str(cert_path);
32
+
33
+ struct aws_byte_cursor segment;
34
+ AWS_ZERO_STRUCT(segment);
35
+
36
+ for (size_t i = 0; i < 3; ++i) {
37
+ if (!aws_byte_cursor_next_split(&cert_path_cursor, '\\', &segment)) {
38
+ AWS_LOGF_ERROR(
39
+ AWS_LS_IO_PKI, "static: invalid certificate path '%s'. Expected additional '\\' separator.", cert_path);
40
+ return aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
41
+ }
25
42
 
26
- AWS_LOGF_INFO(AWS_LS_IO_PKI, "static: loading certificate at windows cert manager path %s.", cert_path);
27
- char *location_of_next_segment = strchr(cert_path, '\\');
43
+ out_splits[i] = segment;
44
+ }
28
45
 
29
- if (!location_of_next_segment) {
30
- AWS_LOGF_ERROR(AWS_LS_IO_PKI, "static: invalid certificate path %s.", cert_path);
46
+ if (aws_byte_cursor_next_split(&cert_path_cursor, '\\', &segment)) {
47
+ AWS_LOGF_ERROR(
48
+ AWS_LS_IO_PKI, "static: invalid certificate path '%s'. Too many '\\' separators found.", cert_path);
31
49
  return aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
32
50
  }
33
51
 
34
- size_t store_name_len = location_of_next_segment - cert_path;
35
- DWORD store_val = 0;
52
+ return AWS_OP_SUCCESS;
53
+ }
54
+
55
+ int aws_load_cert_from_system_cert_store(const char *cert_path, HCERTSTORE *cert_store, PCCERT_CONTEXT *certs) {
56
+
57
+ AWS_LOGF_INFO(AWS_LS_IO_PKI, "static: loading certificate at windows cert manager path '%s'.", cert_path);
36
58
 
37
- if (!strncmp(cert_path, "CurrentUser", store_name_len)) {
59
+ struct aws_byte_cursor segments[3];
60
+ if (s_split_system_cert_path(cert_path, segments)) {
61
+ return AWS_OP_ERR;
62
+ }
63
+ const struct aws_byte_cursor store_location = segments[0];
64
+ const struct aws_byte_cursor store_path_cursor = segments[1];
65
+ const struct aws_byte_cursor cert_hash_cursor = segments[2];
66
+
67
+ DWORD store_val = 0;
68
+ if (aws_byte_cursor_eq_c_str_ignore_case(&store_location, "CurrentUser")) {
38
69
  store_val = CERT_SYSTEM_STORE_CURRENT_USER;
39
- } else if (!strncmp(cert_path, "LocalMachine", store_name_len)) {
70
+ } else if (aws_byte_cursor_eq_c_str_ignore_case(&store_location, "LocalMachine")) {
40
71
  store_val = CERT_SYSTEM_STORE_LOCAL_MACHINE;
41
- } else if (!strncmp(cert_path, "CurrentService", store_name_len)) {
72
+ } else if (aws_byte_cursor_eq_c_str_ignore_case(&store_location, "CurrentService")) {
42
73
  store_val = CERT_SYSTEM_STORE_CURRENT_SERVICE;
43
- } else if (!strncmp(cert_path, "Services", store_name_len)) {
74
+ } else if (aws_byte_cursor_eq_c_str_ignore_case(&store_location, "Services")) {
44
75
  store_val = CERT_SYSTEM_STORE_SERVICES;
45
- } else if (!strncmp(cert_path, "Users", store_name_len)) {
76
+ } else if (aws_byte_cursor_eq_c_str_ignore_case(&store_location, "Users")) {
46
77
  store_val = CERT_SYSTEM_STORE_USERS;
47
- } else if (!strncmp(cert_path, "CurrentUserGroupPolicy", store_name_len)) {
78
+ } else if (aws_byte_cursor_eq_c_str_ignore_case(&store_location, "CurrentUserGroupPolicy")) {
48
79
  store_val = CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY;
49
- } else if (!strncmp(cert_path, "LocalMachineGroupPolicy", store_name_len)) {
80
+ } else if (aws_byte_cursor_eq_c_str_ignore_case(&store_location, "LocalMachineGroupPolicy")) {
50
81
  store_val = CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY;
51
- } else if (!strncmp(cert_path, "LocalMachineEnterprise", store_name_len)) {
82
+ } else if (aws_byte_cursor_eq_c_str_ignore_case(&store_location, "LocalMachineEnterprise")) {
52
83
  store_val = CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE;
53
84
  } else {
54
85
  AWS_LOGF_ERROR(
55
- AWS_LS_IO_PKI, "static: certificate path %s does not contain a valid cert store identifier.", cert_path);
86
+ AWS_LS_IO_PKI,
87
+ "static: invalid certificate path '%s'. System store location '" PRInSTR "' not recognized."
88
+ " Expected something like 'CurrentUser'.",
89
+ cert_path,
90
+ AWS_BYTE_CURSOR_PRI(store_location));
91
+
56
92
  return aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
57
93
  }
58
94
 
59
95
  AWS_LOGF_DEBUG(AWS_LS_IO_PKI, "static: determined registry value for lookup as %d.", (int)store_val);
60
- location_of_next_segment += 1;
61
- char *store_path_start = location_of_next_segment;
62
- location_of_next_segment = strchr(location_of_next_segment, '\\');
63
-
64
- if (!location_of_next_segment) {
65
- AWS_LOGF_ERROR(AWS_LS_IO_PKI, "static: invalid certificate path %s.", cert_path);
66
- return aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
67
- }
68
96
 
69
97
  /* The store_val value has to be only the path segment related to the physical store. Looking
70
98
  at the docs, 128 bytes should be plenty to store that segment.
71
99
  https://docs.microsoft.com/en-us/windows/desktop/SecCrypto/system-store-locations */
72
100
  char store_path[128] = {0};
73
- AWS_FATAL_ASSERT(location_of_next_segment - store_path_start < sizeof(store_path));
74
- memcpy(store_path, store_path_start, location_of_next_segment - store_path_start);
101
+ if (store_path_cursor.len >= sizeof(store_path)) {
102
+ AWS_LOGF_ERROR(AWS_LS_IO_PKI, "static: invalid certificate path '%s'. Store name is too long.", cert_path);
103
+ return aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
104
+ }
105
+ memcpy(store_path, store_path_cursor.ptr, store_path_cursor.len);
75
106
 
76
- location_of_next_segment += 1;
77
- if (strlen(location_of_next_segment) != CERT_HASH_STR_LEN) {
107
+ if (cert_hash_cursor.len != CERT_HASH_STR_LEN) {
78
108
  AWS_LOGF_ERROR(
79
109
  AWS_LS_IO_PKI,
80
- "static: invalid certificate path %s. %s should have been"
110
+ "static: invalid certificate path '%s'. '" PRInSTR "' should have been"
81
111
  " 40 bytes of hex encoded data",
82
112
  cert_path,
83
- location_of_next_segment);
113
+ AWS_BYTE_CURSOR_PRI(cert_hash_cursor));
84
114
  return aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
85
115
  }
86
116
 
@@ -90,7 +120,7 @@ int aws_load_cert_from_system_cert_store(const char *cert_path, HCERTSTORE *cert
90
120
  if (!*cert_store) {
91
121
  AWS_LOGF_ERROR(
92
122
  AWS_LS_IO_PKI,
93
- "static: invalid certificate path %s. Failed to load cert store with error code %d",
123
+ "static: invalid certificate path '%s'. Failed to load cert store with error code %d",
94
124
  cert_path,
95
125
  (int)GetLastError());
96
126
  return aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
@@ -103,7 +133,7 @@ int aws_load_cert_from_system_cert_store(const char *cert_path, HCERTSTORE *cert
103
133
  };
104
134
 
105
135
  if (!CryptStringToBinaryA(
106
- location_of_next_segment,
136
+ (LPCSTR)cert_hash_cursor.ptr, /* this is null-terminated, it's the last segment of c-str */
107
137
  CERT_HASH_STR_LEN,
108
138
  CRYPT_STRING_HEX,
109
139
  cert_hash.pbData,
@@ -112,9 +142,9 @@ int aws_load_cert_from_system_cert_store(const char *cert_path, HCERTSTORE *cert
112
142
  NULL)) {
113
143
  AWS_LOGF_ERROR(
114
144
  AWS_LS_IO_PKI,
115
- "static: invalid certificate path %s. %s should have been a hex encoded string",
145
+ "static: invalid certificate path '%s'. '" PRInSTR "' should have been a hex encoded string",
116
146
  cert_path,
117
- location_of_next_segment);
147
+ AWS_BYTE_CURSOR_PRI(cert_hash_cursor));
118
148
  aws_raise_error(AWS_ERROR_FILE_INVALID_PATH);
119
149
  goto on_error;
120
150
  }
@@ -125,7 +155,7 @@ int aws_load_cert_from_system_cert_store(const char *cert_path, HCERTSTORE *cert
125
155
  if (!*certs) {
126
156
  AWS_LOGF_ERROR(
127
157
  AWS_LS_IO_PKI,
128
- "static: invalid certificate path %s. "
158
+ "static: invalid certificate path '%s'. "
129
159
  "The referenced certificate was not found in the certificate store, error code %d",
130
160
  cert_path,
131
161
  (int)GetLastError());
@@ -275,6 +275,30 @@ try_compile(
275
275
  COMPILE_DEFINITIONS "-Werror"
276
276
  )
277
277
 
278
+ # Determine if madvise() is available
279
+ try_compile(
280
+ MADVISE_SUPPORTED
281
+ ${CMAKE_BINARY_DIR}
282
+ SOURCES "${CMAKE_CURRENT_LIST_DIR}/tests/features/madvise.c"
283
+ COMPILE_DEFINITIONS "-Werror"
284
+ )
285
+
286
+ # Determine if minherit() is available
287
+ try_compile(
288
+ MINHERIT_SUPPORTED
289
+ ${CMAKE_BINARY_DIR}
290
+ SOURCES "${CMAKE_CURRENT_LIST_DIR}/tests/features/minherit.c"
291
+ COMPILE_DEFINITIONS "-Werror"
292
+ )
293
+
294
+ # Determine if clone() is available
295
+ try_compile(
296
+ CLONE_SUPPORTED
297
+ ${CMAKE_BINARY_DIR}
298
+ SOURCES "${CMAKE_CURRENT_LIST_DIR}/tests/features/clone.c"
299
+ COMPILE_DEFINITIONS "-Werror"
300
+ )
301
+
278
302
  if(APPLE)
279
303
  set(OS_LIBS c Threads::Threads)
280
304
  elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
@@ -436,6 +460,21 @@ if (__RESTRICT__SUPPORTED)
436
460
  target_compile_options(${PROJECT_NAME} PUBLIC -DS2N___RESTRICT__SUPPORTED)
437
461
  endif()
438
462
 
463
+ if (MADVISE_SUPPORTED)
464
+ target_compile_options(${PROJECT_NAME} PUBLIC -DS2N_MADVISE_SUPPORTED)
465
+ message(STATUS "madvise() support detected")
466
+ endif()
467
+
468
+ if (MINHERIT_SUPPORTED)
469
+ target_compile_options(${PROJECT_NAME} PUBLIC -DS2N_MINHERIT_SUPPORTED)
470
+ message(STATUS "minherit() support detected")
471
+ endif()
472
+
473
+ if (CLONE_SUPPORTED)
474
+ target_compile_options(${PROJECT_NAME} PUBLIC -DS2N_CLONE_SUPPORTED)
475
+ message(STATUS "clone() support detected")
476
+ endif()
477
+
439
478
  list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
440
479
 
441
480
  #work around target differences
@@ -477,53 +516,60 @@ if (S2N_INTERN_LIBCRYPTO)
477
516
  message(FATAL_ERROR "libcrypto interning requires a static build of libcrypto.a to be available")
478
517
  endif()
479
518
 
519
+ # Don't call link_target_libraries here, just make sure the libcrypto include dir is in the path
520
+ include_directories("${crypto_INCLUDE_DIR}")
521
+
480
522
  add_custom_command(
481
523
  OUTPUT libcrypto.symbols
482
524
  COMMAND
483
525
  # copy the static version of libcrypto
484
- cp ${crypto_STATIC_LIBRARY} libcrypto.a &&
526
+ cp ${crypto_STATIC_LIBRARY} s2n_libcrypto.a &&
485
527
  # dump all of the symbols and prefix them with `s2n$`
486
- bash -c "nm libcrypto.a | awk '/ [A-Z] /{print $3\" s2n$\"$3}' | sort | uniq > libcrypto.symbols" &&
528
+ bash -c "nm s2n_libcrypto.a | awk '/ [A-Z] /{print $3\" s2n$\"$3}' | sort | uniq > libcrypto.symbols" &&
487
529
  # redefine the libcrypto libary symbols
488
- objcopy --redefine-syms libcrypto.symbols libcrypto.a &&
489
- rm -rf libcrypto &&
490
- mkdir libcrypto &&
491
- cd libcrypto &&
530
+ objcopy --redefine-syms libcrypto.symbols s2n_libcrypto.a &&
531
+ rm -rf s2n_libcrypto &&
532
+ mkdir s2n_libcrypto &&
533
+ cd s2n_libcrypto &&
492
534
  # extract libcrypto objects from the archive
493
- ar x ../libcrypto.a &&
535
+ ar x ../s2n_libcrypto.a &&
494
536
  # rename all of the object files so we don't have any object name collisions
495
537
  bash -c "find . -name '*.o' -type f -print0 | xargs -0 -n1 -- basename | xargs -I{} mv {} s2n_crypto__{}"
496
538
  VERBATIM
497
539
  )
498
540
 
499
- add_custom_target(libcrypto ALL
541
+ add_custom_target(s2n_libcrypto ALL
500
542
  DEPENDS libcrypto.symbols
501
543
  )
502
- add_dependencies(${PROJECT_NAME} libcrypto)
544
+ add_dependencies(${PROJECT_NAME} s2n_libcrypto)
503
545
 
504
- add_custom_command(
505
- TARGET ${PROJECT_NAME} PRE_LINK
506
- DEPENDS libcrypto.symbols
507
- COMMAND
508
- find ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}.dir -name '*.o' -exec objcopy --redefine-syms libcrypto.symbols {} \\\;
509
- )
546
+ if ((BUILD_SHARED_LIBS AND BUILD_TESTING) OR NOT BUILD_SHARED_LIBS)
547
+ # if libcrypto needs to be interned, rewrite libcrypto references so use of internal functions will link correctly
548
+ add_custom_command(
549
+ TARGET ${PROJECT_NAME} PRE_LINK
550
+ COMMAND
551
+ find "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}.dir" -name '*.c.o' -exec objcopy --redefine-syms libcrypto.symbols {} \\\;
552
+ )
553
+ endif()
510
554
 
511
555
  # copy the static libcrypto into the final artifact
512
556
  if (BUILD_SHARED_LIBS)
513
- # if we're building for testing, we export the prefixed symbols so tests can link to them
514
557
  if (BUILD_TESTING)
515
- set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS
516
- "-Wl,--whole-archive libcrypto.a -Wl,--no-whole-archive")
558
+ # if we're building tests, we export the prefixed symbols so tests can link to them
559
+ set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS
560
+ "-Wl,--whole-archive s2n_libcrypto.a -Wl,--no-whole-archive")
517
561
  else()
518
- set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS
519
- "-Wl,--whole-archive libcrypto.a -Wl,--no-whole-archive -Wl,--exclude-libs=ALL")
562
+ # if we're not building tests, then just copy the original archive, unmodified
563
+ set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS
564
+ "-Wl,--whole-archive ${crypto_STATIC_LIBRARY} -Wl,--no-whole-archive -Wl,--exclude-libs=ALL")
520
565
  endif()
521
566
  else()
567
+ # add all of the prefixed symbols to the archive
522
568
  add_custom_command(
523
569
  TARGET ${PROJECT_NAME} POST_BUILD
524
570
  DEPENDS libcrypto.symbols
525
571
  COMMAND
526
- bash -c "ar -r lib/libs2n.a libcrypto/*.o"
572
+ bash -c "ar -r lib/libs2n.a s2n_libcrypto/*.o"
527
573
  VERBATIM
528
574
  )
529
575
  endif()
@@ -157,6 +157,16 @@ DEV_VERSION ?= ubuntu_18.04_$(DEV_OPENSSL_VERSION)_gcc9
157
157
  dev:
158
158
  @docker run -it --rm --ulimit memlock=-1 -v `pwd`:/home/s2n-dev/s2n $(DEV_IMAGE):$(DEV_VERSION)
159
159
 
160
+ .PHONY : install
161
+ install: bin libs
162
+ $(MAKE) -C bin install
163
+ $(MAKE) -C lib install
164
+
165
+ .PHONY: uninstall
166
+ uninstall:
167
+ $(MAKE) -C bin uninstall
168
+ $(MAKE) -C lib uninstall
169
+
160
170
  .PHONY : clean
161
171
  clean:
162
172
  $(MAKE) -C pq-crypto clean
@@ -25,3 +25,12 @@ s2nc: s2nc.c echo.c
25
25
 
26
26
  s2nd: s2nd.c echo.c
27
27
  ${CC} ${CFLAGS} s2nd.c echo.c https.c common.c -o s2nd ${LDFLAGS}
28
+
29
+ $(bindir):
30
+ @mkdir -p $(bindir)
31
+
32
+ install: s2nc s2nd $(bindir)
33
+ @cp s2n? $(bindir)
34
+
35
+ uninstall:
36
+ @rm $(bindir)/s2n?
@@ -0,0 +1,14 @@
1
+ SHELL := /bin/bash
2
+
3
+ all: s2n-tls-sys/src/api.rs target/release/deps/s2nc-%
4
+
5
+ target/release/deps/s2nc-%:
6
+ cargo bench --no-run
7
+
8
+ s2n-tls-sys/src/api.rs:
9
+ ./generate.sh
10
+
11
+ .PHONY: clean
12
+ clean:
13
+ @cargo clean
14
+ @rm -f s2n-tls-sys/src/api.rs target/release/deps/s2nc-* target/release/deps/s2nd-*
@@ -6,8 +6,8 @@ edition = "2018"
6
6
  publish = false
7
7
 
8
8
  [dependencies]
9
- s2n-tls = { version = "0.0.2", path = "../s2n-tls", features = ["testing"] }
10
- s2n-tls-sys = { version = "0.0.2", path = "../s2n-tls-sys" }
9
+ s2n-tls = { path = "../s2n-tls", features = ["testing"] }
10
+ s2n-tls-sys = { path = "../s2n-tls-sys" }
11
11
  criterion = { version = "0.3", features = ["html_reports"] }
12
12
 
13
13
  [[bench]]
@@ -1,7 +1,7 @@
1
1
  [package]
2
2
  name = "s2n-tls"
3
3
  description = "A C99 implementation of the TLS/SSL protocols"
4
- version = "0.0.2"
4
+ version = "0.0.4"
5
5
  authors = ["AWS s2n"]
6
6
  edition = "2018"
7
7
  repository = "https://github.com/aws/s2n-tls"
@@ -17,8 +17,9 @@ testing = ["errno", "bytes"]
17
17
  bytes = { version = "1", optional = true }
18
18
  errno = { version = "0.2", optional = true }
19
19
  libc = "0.2"
20
- s2n-tls-sys = { version = "0.0.2", path = "../s2n-tls-sys", features = ["internal"] }
20
+ s2n-tls-sys = { version = "=0.0.4", path = "../s2n-tls-sys", features = ["internal"] }
21
21
 
22
22
  [dev-dependencies]
23
23
  bytes = { version = "1" }
24
24
  errno = { version = "0.2" }
25
+ futures-test = "0.3"