| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "api/unstable/fingerprint.h" |
| 17 |
#include "crypto/s2n_fips.h" |
| 18 |
#include "s2n_test.h" |
| 19 |
#include "testlib/s2n_sslv2_client_hello.h" |
| 20 |
#include "testlib/s2n_testlib.h" |
| 21 |
#include "tls/s2n_tls.h" |
| 22 |
|
| 23 |
|
| 24 |
#define S2N_JA3_SSLV2_VAL 512 |
| 25 |
|
| 26 |
|
| 27 |
#define S2N_TEST_CLIENT_HELLO_AFTER_VERSION \ |
| 28 |
\ |
| 29 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 30 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 31 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 32 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ |
| 33 |
\ |
| 34 |
0x00 |
| 35 |
|
| 36 |
|
| 37 |
#define S2N_TEST_CLIENT_HELLO_AFTER_CIPHERS \ |
| 38 |
\ |
| 39 |
0x01, 0x00 |
| 40 |
|
| 41 |
|
| 42 |
#define S2N_INIT_CLIENT_HELLO(name, ...) \ |
| 43 |
uint8_t _##name##_message[] = { __VA_ARGS__ }; \ |
| 44 |
EXPECT_TRUE(sizeof(_##name##_message) <= UINT8_MAX); \ |
| 45 |
uint8_t name[] = { \ |
| 46 |
TLS_CLIENT_HELLO, \ |
| 47 |
0x00, 0x00, sizeof(_##name##_message), \ |
| 48 |
__VA_ARGS__ \ |
| 49 |
} |
| 50 |
|
| 51 |
typedef enum { |
| 52 |
S2N_CH_FROM_IO = 0, |
| 53 |
S2N_CH_FROM_RAW, |
| 54 |
} s2n_ch_source; |
| 55 |
|
| 56 |
static S2N_RESULT s2n_validate_ja3_str_list(struct s2n_stuffer *input) |
| 57 |
{ |
| 58 |
uint32_t skipped = 0; |
| 59 |
size_t count = 0; |
| 60 |
DEFER_CLEANUP(struct s2n_stuffer list = { 0 }, s2n_stuffer_free); |
| 61 |
RESULT_GUARD_POSIX(s2n_stuffer_growable_alloc(&list, 0)); |
| 62 |
RESULT_GUARD_POSIX(s2n_stuffer_read_token(input, &list, ',')); |
| 63 |
while (s2n_stuffer_data_available(&list)) { |
| 64 |
RESULT_GUARD_POSIX(s2n_stuffer_skip_to_char(&list, '-')); |
| 65 |
RESULT_GUARD_POSIX(s2n_stuffer_skip_expected_char(&list, '-', |
| 66 |
0, 1, &skipped)); |
| 67 |
count++; |
| 68 |
} |
| 69 |
RESULT_ENSURE_GT(count, 1); |
| 70 |
return S2N_RESULT_OK; |
| 71 |
} |
| 72 |
|
| 73 |
static S2N_RESULT s2n_validate_ja3_str(uint8_t *ja3, uint32_t ja3_size, |
| 74 |
const char *expected_version) |
| 75 |
{ |
| 76 |
struct s2n_blob input_blob = { 0 }; |
| 77 |
struct s2n_stuffer input = { 0 }; |
| 78 |
RESULT_GUARD_POSIX(s2n_blob_init(&input_blob, ja3, ja3_size)); |
| 79 |
RESULT_GUARD_POSIX(s2n_stuffer_init(&input, &input_blob)); |
| 80 |
RESULT_GUARD_POSIX(s2n_stuffer_skip_write(&input, ja3_size)); |
| 81 |
|
| 82 |
|
| 83 |
RESULT_GUARD_POSIX(s2n_stuffer_read_expected_str(&input, expected_version)); |
| 84 |
RESULT_GUARD_POSIX(s2n_stuffer_read_expected_str(&input, ",")); |
| 85 |
|
| 86 |
|
| 87 |
RESULT_GUARD(s2n_validate_ja3_str_list(&input)); |
| 88 |
|
| 89 |
|
| 90 |
RESULT_GUARD(s2n_validate_ja3_str_list(&input)); |
| 91 |
|
| 92 |
|
| 93 |
RESULT_GUARD(s2n_validate_ja3_str_list(&input)); |
| 94 |
|
| 95 |
|
| 96 |
RESULT_GUARD_POSIX(s2n_stuffer_read_expected_str(&input, "0")); |
| 97 |
|
| 98 |
RESULT_ENSURE_EQ(s2n_stuffer_data_available(&input), 0); |
| 99 |
return S2N_RESULT_OK; |
| 100 |
} |
| 101 |
|
| 102 |
static S2N_RESULT s2n_client_hello_from_source(struct s2n_client_hello **client_hello, |
| 103 |
struct s2n_connection *server, uint8_t *input, uint32_t input_size, s2n_ch_source source) |
| 104 |
{ |
| 105 |
switch (source) { |
| 106 |
case S2N_CH_FROM_IO: |
| 107 |
RESULT_GUARD_POSIX(s2n_connection_wipe(server)); |
| 108 |
RESULT_GUARD_POSIX(s2n_stuffer_write_bytes(&server->handshake.io, |
| 109 |
input + TLS_HANDSHAKE_HEADER_LENGTH, input_size - TLS_HANDSHAKE_HEADER_LENGTH)); |
| 110 |
RESULT_GUARD_POSIX(s2n_client_hello_recv(server)); |
| 111 |
*client_hello = s2n_connection_get_client_hello(server); |
| 112 |
RESULT_ENSURE_REF(*client_hello); |
| 113 |
break; |
| 114 |
case S2N_CH_FROM_RAW: |
| 115 |
*client_hello = s2n_client_hello_parse_message(input, input_size); |
| 116 |
RESULT_GUARD_PTR(*client_hello); |
| 117 |
break; |
| 118 |
} |
| 119 |
return S2N_RESULT_OK; |
| 120 |
} |
| 121 |
|
| 122 |
int main(int argc, char **argv) |
| 123 |
{ |
| 124 |
BEGIN_TEST(); |
| 125 |
|
| 126 |
uint8_t output_mem[500] = { 0 }; |
| 127 |
s2n_ch_source sources[] = { |
| 128 |
S2N_CH_FROM_IO, |
| 129 |
S2N_CH_FROM_RAW, |
| 130 |
}; |
| 131 |
|
| 132 |
DEFER_CLEANUP(struct s2n_cert_chain_and_key *chain_and_key = NULL, |
| 133 |
s2n_cert_chain_and_key_ptr_free); |
| 134 |
EXPECT_SUCCESS(s2n_test_cert_chain_and_key_new(&chain_and_key, |
| 135 |
S2N_DEFAULT_TEST_CERT_CHAIN, S2N_DEFAULT_TEST_PRIVATE_KEY)); |
| 136 |
|
| 137 |
DEFER_CLEANUP(struct s2n_config *config = s2n_config_new(), s2n_config_ptr_free); |
| 138 |
EXPECT_NOT_NULL(config); |
| 139 |
EXPECT_SUCCESS(s2n_config_add_cert_chain_and_key_to_store(config, chain_and_key)); |
| 140 |
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(config, "test_all")); |
| 141 |
|
| 142 |
uint8_t empty_md5_hash[MD5_DIGEST_LENGTH] = { 0 }; |
| 143 |
DEFER_CLEANUP(struct s2n_hash_state md5_hash = { 0 }, s2n_hash_free); |
| 144 |
EXPECT_SUCCESS(s2n_hash_new(&md5_hash)); |
| 145 |
EXPECT_SUCCESS(s2n_hash_init(&md5_hash, S2N_HASH_MD5)); |
| 146 |
EXPECT_SUCCESS(s2n_hash_digest(&md5_hash, empty_md5_hash, MD5_DIGEST_LENGTH)); |
| 147 |
|
| 148 |
|
| 149 |
{ |
| 150 |
DEFER_CLEANUP(struct s2n_connection *server = s2n_connection_new(S2N_SERVER), |
| 151 |
s2n_connection_ptr_free); |
| 152 |
struct s2n_client_hello *client_hello = &server->client_hello; |
| 153 |
uint32_t output_size = 0, str_size = 0; |
| 154 |
|
| 155 |
|
| 156 |
EXPECT_FAILURE_WITH_ERRNO( |
| 157 |
s2n_client_hello_get_fingerprint_string(NULL, S2N_FINGERPRINT_JA3, |
| 158 |
sizeof(output_mem), output_mem, &output_size), |
| 159 |
S2N_ERR_INVALID_ARGUMENT); |
| 160 |
EXPECT_FAILURE_WITH_ERRNO( |
| 161 |
s2n_client_hello_get_fingerprint_hash(NULL, S2N_FINGERPRINT_JA3, |
| 162 |
sizeof(output_mem), output_mem, &output_size, &str_size), |
| 163 |
S2N_ERR_INVALID_ARGUMENT); |
| 164 |
|
| 165 |
|
| 166 |
EXPECT_FAILURE_WITH_ERRNO( |
| 167 |
s2n_client_hello_get_fingerprint_string(client_hello, S2N_FINGERPRINT_JA3, |
| 168 |
sizeof(output_mem), NULL, &output_size), |
| 169 |
S2N_ERR_INVALID_ARGUMENT); |
| 170 |
EXPECT_FAILURE_WITH_ERRNO( |
| 171 |
s2n_client_hello_get_fingerprint_hash(client_hello, S2N_FINGERPRINT_JA3, |
| 172 |
sizeof(output_mem), NULL, &output_size, &str_size), |
| 173 |
S2N_ERR_INVALID_ARGUMENT); |
| 174 |
EXPECT_FAILURE_WITH_ERRNO( |
| 175 |
s2n_client_hello_get_fingerprint_string(client_hello, S2N_FINGERPRINT_JA3, |
| 176 |
0, NULL, &output_size), |
| 177 |
S2N_ERR_INSUFFICIENT_MEM_SIZE); |
| 178 |
EXPECT_FAILURE_WITH_ERRNO( |
| 179 |
s2n_client_hello_get_fingerprint_hash(client_hello, S2N_FINGERPRINT_JA3, |
| 180 |
0, NULL, &output_size, &str_size), |
| 181 |
S2N_ERR_INSUFFICIENT_MEM_SIZE); |
| 182 |
|
| 183 |
|
| 184 |
EXPECT_FAILURE_WITH_ERRNO( |
| 185 |
s2n_client_hello_get_fingerprint_string(client_hello, S2N_FINGERPRINT_JA3, |
| 186 |
sizeof(output_mem), output_mem, NULL), |
| 187 |
S2N_ERR_INVALID_ARGUMENT); |
| 188 |
EXPECT_FAILURE_WITH_ERRNO( |
| 189 |
s2n_client_hello_get_fingerprint_hash(client_hello, S2N_FINGERPRINT_JA3, |
| 190 |
sizeof(output_mem), output_mem, NULL, &str_size), |
| 191 |
S2N_ERR_INVALID_ARGUMENT); |
| 192 |
EXPECT_FAILURE_WITH_ERRNO( |
| 193 |
s2n_client_hello_get_fingerprint_hash(client_hello, S2N_FINGERPRINT_JA3, |
| 194 |
sizeof(output_mem), output_mem, &output_size, NULL), |
| 195 |
S2N_ERR_INVALID_ARGUMENT); |
| 196 |
|
| 197 |
|
| 198 |
EXPECT_FAILURE_WITH_ERRNO( |
| 199 |
s2n_client_hello_get_fingerprint_string(client_hello, S2N_FINGERPRINT_JA3 + 1, |
| 200 |
sizeof(output_mem), output_mem, &output_size), |
| 201 |
S2N_ERR_INVALID_ARGUMENT); |
| 202 |
EXPECT_FAILURE_WITH_ERRNO( |
| 203 |
s2n_client_hello_get_fingerprint_hash(client_hello, S2N_FINGERPRINT_JA3 + 1, |
| 204 |
sizeof(output_mem), output_mem, &output_size, &str_size), |
| 205 |
S2N_ERR_INVALID_ARGUMENT); |
| 206 |
}; |
| 207 |
|
| 208 |
|
| 209 |
{ |
| 210 |
|
| 211 |
{ |
| 212 |
DEFER_CLEANUP(struct s2n_connection *client = s2n_connection_new(S2N_CLIENT), |
| 213 |
s2n_connection_ptr_free); |
| 214 |
EXPECT_NOT_NULL(client); |
| 215 |
EXPECT_SUCCESS(s2n_connection_set_config(client, config)); |
| 216 |
|
| 217 |
DEFER_CLEANUP(struct s2n_connection *server = s2n_connection_new(S2N_SERVER), |
| 218 |
s2n_connection_ptr_free); |
| 219 |
EXPECT_NOT_NULL(server); |
| 220 |
EXPECT_SUCCESS(s2n_connection_set_config(server, config)); |
| 221 |
|
| 222 |
EXPECT_SUCCESS(s2n_client_hello_send(client)); |
| 223 |
EXPECT_SUCCESS(s2n_stuffer_copy(&client->handshake.io, &server->handshake.io, |
| 224 |
s2n_stuffer_data_available(&client->handshake.io))); |
| 225 |
EXPECT_SUCCESS(s2n_client_hello_recv(server)); |
| 226 |
|
| 227 |
struct s2n_client_hello *client_hello = s2n_connection_get_client_hello(server); |
| 228 |
EXPECT_NOT_NULL(client_hello); |
| 229 |
EXPECT_FALSE(client_hello->sslv2); |
| 230 |
|
| 231 |
uint32_t output_size = 0; |
| 232 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_string(client_hello, |
| 233 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size)); |
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
EXPECT_OK(s2n_validate_ja3_str(output_mem, output_size, "771")); |
| 238 |
}; |
| 239 |
|
| 240 |
|
| 241 |
{ |
| 242 |
DEFER_CLEANUP(struct s2n_connection *server = s2n_connection_new(S2N_SERVER), |
| 243 |
s2n_connection_ptr_free); |
| 244 |
EXPECT_NOT_NULL(server); |
| 245 |
EXPECT_SUCCESS(s2n_connection_set_config(server, config)); |
| 246 |
EXPECT_SUCCESS(s2n_connection_set_cipher_preferences(server, "test_all")); |
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
server->client_hello.sslv2 = true; |
| 258 |
server->client_hello.legacy_version = S2N_TLS12; |
| 259 |
|
| 260 |
uint8_t sslv2_client_hello[] = { |
| 261 |
SSLv2_CLIENT_HELLO_PREFIX, |
| 262 |
SSLv2_CLIENT_HELLO_CIPHER_SUITES, |
| 263 |
SSLv2_CLIENT_HELLO_CHALLENGE, |
| 264 |
}; |
| 265 |
EXPECT_SUCCESS(s2n_stuffer_write_bytes(&server->handshake.io, |
| 266 |
sslv2_client_hello, sizeof(sslv2_client_hello))); |
| 267 |
EXPECT_SUCCESS(s2n_client_hello_recv(server)); |
| 268 |
|
| 269 |
struct s2n_client_hello *client_hello = s2n_connection_get_client_hello(server); |
| 270 |
EXPECT_NOT_NULL(client_hello); |
| 271 |
EXPECT_TRUE(client_hello->sslv2); |
| 272 |
|
| 273 |
uint32_t output_size = 0; |
| 274 |
EXPECT_FAILURE_WITH_ERRNO( |
| 275 |
s2n_client_hello_get_fingerprint_string(client_hello, |
| 276 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size), |
| 277 |
S2N_ERR_PROTOCOL_VERSION_UNSUPPORTED); |
| 278 |
EXPECT_EQUAL(output_size, 0); |
| 279 |
}; |
| 280 |
|
| 281 |
|
| 282 |
for (size_t i = 0; i < s2n_array_len(sources); i++) { |
| 283 |
s2n_ch_source source = sources[i]; |
| 284 |
|
| 285 |
S2N_INIT_CLIENT_HELLO(client_hello_bytes, |
| 286 |
|
| 287 |
0x03, 0x02, |
| 288 |
S2N_TEST_CLIENT_HELLO_AFTER_VERSION, |
| 289 |
|
| 290 |
0x00, 0x02, |
| 291 |
|
| 292 |
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 293 |
S2N_TEST_CLIENT_HELLO_AFTER_CIPHERS, |
| 294 |
|
| 295 |
0x00, 0x08, |
| 296 |
|
| 297 |
0x00, TLS_EXTENSION_SUPPORTED_GROUPS, 0x00, 0x04, |
| 298 |
0x00, 0x02, 0x00, TLS_EC_CURVE_SECP_256_R1); |
| 299 |
const uint8_t expected_ja3[] = "770,49199,10,23,"; |
| 300 |
size_t expected_ja3_size = strlen((const char *) expected_ja3); |
| 301 |
|
| 302 |
DEFER_CLEANUP(struct s2n_connection *server = s2n_connection_new(S2N_SERVER), |
| 303 |
s2n_connection_ptr_free); |
| 304 |
EXPECT_NOT_NULL(server); |
| 305 |
EXPECT_SUCCESS(s2n_connection_set_config(server, config)); |
| 306 |
EXPECT_SUCCESS(s2n_connection_set_cipher_preferences(server, "test_all")); |
| 307 |
|
| 308 |
DEFER_CLEANUP(struct s2n_client_hello *client_hello = NULL, |
| 309 |
s2n_client_hello_free); |
| 310 |
EXPECT_OK(s2n_client_hello_from_source(&client_hello, server, |
| 311 |
client_hello_bytes, sizeof(client_hello_bytes), source)); |
| 312 |
|
| 313 |
uint32_t output_size = 0; |
| 314 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_string(client_hello, |
| 315 |
S2N_FINGERPRINT_JA3, expected_ja3_size, output_mem, &output_size)); |
| 316 |
EXPECT_EQUAL(output_size, expected_ja3_size); |
| 317 |
EXPECT_BYTEARRAY_EQUAL(expected_ja3, output_mem, output_size); |
| 318 |
}; |
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
for (size_t i = 0; i < s2n_array_len(sources); i++) { |
| 327 |
s2n_ch_source source = sources[i]; |
| 328 |
|
| 329 |
S2N_INIT_CLIENT_HELLO(client_hello_bytes, |
| 330 |
|
| 331 |
0x03, 0x01, |
| 332 |
S2N_TEST_CLIENT_HELLO_AFTER_VERSION, |
| 333 |
|
| 334 |
0x00, 0x02, |
| 335 |
|
| 336 |
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 337 |
S2N_TEST_CLIENT_HELLO_AFTER_CIPHERS, |
| 338 |
|
| 339 |
0x00, 0x00); |
| 340 |
const uint8_t expected_ja3[] = "769,49199,,,"; |
| 341 |
size_t expected_ja3_size = strlen((const char *) expected_ja3); |
| 342 |
|
| 343 |
DEFER_CLEANUP(struct s2n_connection *server = s2n_connection_new(S2N_SERVER), |
| 344 |
s2n_connection_ptr_free); |
| 345 |
EXPECT_NOT_NULL(server); |
| 346 |
EXPECT_SUCCESS(s2n_connection_set_config(server, config)); |
| 347 |
EXPECT_SUCCESS(s2n_connection_set_cipher_preferences(server, "test_all")); |
| 348 |
|
| 349 |
DEFER_CLEANUP(struct s2n_client_hello *client_hello = NULL, |
| 350 |
s2n_client_hello_free); |
| 351 |
EXPECT_OK(s2n_client_hello_from_source(&client_hello, server, |
| 352 |
client_hello_bytes, sizeof(client_hello_bytes), source)); |
| 353 |
|
| 354 |
uint32_t output_size = 0; |
| 355 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_string(client_hello, |
| 356 |
S2N_FINGERPRINT_JA3, expected_ja3_size, output_mem, &output_size)); |
| 357 |
EXPECT_EQUAL(output_size, expected_ja3_size); |
| 358 |
EXPECT_BYTEARRAY_EQUAL(expected_ja3, output_mem, output_size); |
| 359 |
}; |
| 360 |
|
| 361 |
|
| 362 |
{ |
| 363 |
DEFER_CLEANUP(struct s2n_connection *client = s2n_connection_new(S2N_CLIENT), |
| 364 |
s2n_connection_ptr_free); |
| 365 |
EXPECT_NOT_NULL(client); |
| 366 |
EXPECT_SUCCESS(s2n_connection_set_config(client, config)); |
| 367 |
|
| 368 |
DEFER_CLEANUP(struct s2n_connection *server = s2n_connection_new(S2N_SERVER), |
| 369 |
s2n_connection_ptr_free); |
| 370 |
EXPECT_NOT_NULL(server); |
| 371 |
EXPECT_SUCCESS(s2n_connection_set_config(server, config)); |
| 372 |
|
| 373 |
EXPECT_SUCCESS(s2n_client_hello_send(client)); |
| 374 |
EXPECT_SUCCESS(s2n_stuffer_copy(&client->handshake.io, &server->handshake.io, |
| 375 |
s2n_stuffer_data_available(&client->handshake.io))); |
| 376 |
EXPECT_SUCCESS(s2n_client_hello_recv(server)); |
| 377 |
|
| 378 |
struct s2n_client_hello *client_hello = s2n_connection_get_client_hello(server); |
| 379 |
EXPECT_NOT_NULL(client_hello); |
| 380 |
|
| 381 |
uint32_t output_size = 0; |
| 382 |
for (size_t i = 0; i < 10; i++) { |
| 383 |
EXPECT_FAILURE_WITH_ERRNO( |
| 384 |
s2n_client_hello_get_fingerprint_string(client_hello, |
| 385 |
S2N_FINGERPRINT_JA3, i, output_mem, &output_size), |
| 386 |
S2N_ERR_INSUFFICIENT_MEM_SIZE); |
| 387 |
EXPECT_EQUAL(output_size, 0); |
| 388 |
} |
| 389 |
}; |
| 390 |
|
| 391 |
|
| 392 |
for (size_t i = 0; i < s2n_array_len(sources); i++) { |
| 393 |
s2n_ch_source source = sources[i]; |
| 394 |
|
| 395 |
const uint8_t grease_value = 0x0A; |
| 396 |
S2N_INIT_CLIENT_HELLO(client_hello_bytes, |
| 397 |
|
| 398 |
0x03, 0x02, |
| 399 |
S2N_TEST_CLIENT_HELLO_AFTER_VERSION, |
| 400 |
|
| 401 |
0x00, 0x04, |
| 402 |
|
| 403 |
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 404 |
grease_value, grease_value, |
| 405 |
S2N_TEST_CLIENT_HELLO_AFTER_CIPHERS, |
| 406 |
|
| 407 |
0x00, 0x0E, |
| 408 |
|
| 409 |
grease_value, grease_value, 0x00, 0x00, |
| 410 |
|
| 411 |
0x00, TLS_EXTENSION_SUPPORTED_GROUPS, 0x00, 0x06, |
| 412 |
0x00, 0x04, 0x00, TLS_EC_CURVE_SECP_256_R1, grease_value, grease_value); |
| 413 |
const uint8_t expected_ja3[] = "770,49199,10,23,"; |
| 414 |
size_t expected_ja3_size = strlen((const char *) expected_ja3); |
| 415 |
|
| 416 |
DEFER_CLEANUP(struct s2n_connection *server = s2n_connection_new(S2N_SERVER), |
| 417 |
s2n_connection_ptr_free); |
| 418 |
EXPECT_NOT_NULL(server); |
| 419 |
EXPECT_SUCCESS(s2n_connection_set_config(server, config)); |
| 420 |
EXPECT_SUCCESS(s2n_connection_set_cipher_preferences(server, "test_all")); |
| 421 |
|
| 422 |
DEFER_CLEANUP(struct s2n_client_hello *client_hello = NULL, |
| 423 |
s2n_client_hello_free); |
| 424 |
EXPECT_OK(s2n_client_hello_from_source(&client_hello, server, |
| 425 |
client_hello_bytes, sizeof(client_hello_bytes), source)); |
| 426 |
|
| 427 |
uint32_t output_size = 0; |
| 428 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_string(client_hello, |
| 429 |
S2N_FINGERPRINT_JA3, expected_ja3_size, output_mem, &output_size)); |
| 430 |
EXPECT_EQUAL(output_size, expected_ja3_size); |
| 431 |
EXPECT_BYTEARRAY_EQUAL(expected_ja3, output_mem, output_size); |
| 432 |
}; |
| 433 |
}; |
| 434 |
|
| 435 |
|
| 436 |
{ |
| 437 |
|
| 438 |
{ |
| 439 |
DEFER_CLEANUP(struct s2n_connection *client = s2n_connection_new(S2N_CLIENT), |
| 440 |
s2n_connection_ptr_free); |
| 441 |
EXPECT_NOT_NULL(client); |
| 442 |
EXPECT_SUCCESS(s2n_connection_set_config(client, config)); |
| 443 |
|
| 444 |
DEFER_CLEANUP(struct s2n_connection *server = s2n_connection_new(S2N_SERVER), |
| 445 |
s2n_connection_ptr_free); |
| 446 |
EXPECT_NOT_NULL(server); |
| 447 |
EXPECT_SUCCESS(s2n_connection_set_config(server, config)); |
| 448 |
|
| 449 |
EXPECT_SUCCESS(s2n_client_hello_send(client)); |
| 450 |
EXPECT_SUCCESS(s2n_stuffer_copy(&client->handshake.io, &server->handshake.io, |
| 451 |
s2n_stuffer_data_available(&client->handshake.io))); |
| 452 |
EXPECT_SUCCESS(s2n_client_hello_recv(server)); |
| 453 |
|
| 454 |
struct s2n_client_hello *client_hello = s2n_connection_get_client_hello(server); |
| 455 |
EXPECT_NOT_NULL(client_hello); |
| 456 |
|
| 457 |
|
| 458 |
uint32_t output_size = 0, str_size = 0; |
| 459 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_hash(client_hello, |
| 460 |
S2N_FINGERPRINT_JA3, MD5_DIGEST_LENGTH, output_mem, &output_size, &str_size)); |
| 461 |
EXPECT_TRUE(str_size > MD5_DIGEST_LENGTH); |
| 462 |
EXPECT_EQUAL(output_size, MD5_DIGEST_LENGTH); |
| 463 |
EXPECT_BYTEARRAY_NOT_EQUAL(empty_md5_hash, output_mem, output_size); |
| 464 |
|
| 465 |
|
| 466 |
uint8_t output_mem_2[MD5_DIGEST_LENGTH] = { 0 }; |
| 467 |
uint32_t output_size_2 = 0, str_size_2 = 0; |
| 468 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_hash(client_hello, |
| 469 |
S2N_FINGERPRINT_JA3, MD5_DIGEST_LENGTH, output_mem_2, |
| 470 |
&output_size_2, &str_size_2)); |
| 471 |
EXPECT_EQUAL(str_size, str_size_2); |
| 472 |
EXPECT_EQUAL(output_size, output_size_2); |
| 473 |
EXPECT_BYTEARRAY_EQUAL(output_mem, output_mem_2, output_size_2); |
| 474 |
|
| 475 |
|
| 476 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_string(client_hello, |
| 477 |
S2N_FINGERPRINT_JA3, str_size, output_mem, &output_size)); |
| 478 |
EXPECT_FAILURE_WITH_ERRNO( |
| 479 |
s2n_client_hello_get_fingerprint_string(client_hello, |
| 480 |
S2N_FINGERPRINT_JA3, str_size - 1, output_mem, &output_size), |
| 481 |
S2N_ERR_INSUFFICIENT_MEM_SIZE); |
| 482 |
}; |
| 483 |
|
| 484 |
|
| 485 |
{ |
| 486 |
DEFER_CLEANUP(struct s2n_connection *client = s2n_connection_new(S2N_CLIENT), |
| 487 |
s2n_connection_ptr_free); |
| 488 |
EXPECT_NOT_NULL(client); |
| 489 |
EXPECT_SUCCESS(s2n_connection_set_config(client, config)); |
| 490 |
|
| 491 |
DEFER_CLEANUP(struct s2n_connection *server = s2n_connection_new(S2N_SERVER), |
| 492 |
s2n_connection_ptr_free); |
| 493 |
EXPECT_NOT_NULL(server); |
| 494 |
EXPECT_SUCCESS(s2n_connection_set_config(server, config)); |
| 495 |
|
| 496 |
EXPECT_SUCCESS(s2n_client_hello_send(client)); |
| 497 |
EXPECT_SUCCESS(s2n_stuffer_copy(&client->handshake.io, &server->handshake.io, |
| 498 |
s2n_stuffer_data_available(&client->handshake.io))); |
| 499 |
EXPECT_SUCCESS(s2n_client_hello_recv(server)); |
| 500 |
|
| 501 |
struct s2n_client_hello *client_hello = s2n_connection_get_client_hello(server); |
| 502 |
EXPECT_NOT_NULL(client_hello); |
| 503 |
|
| 504 |
uint32_t output_size = 0, str_size = 0; |
| 505 |
for (size_t i = 0; i < MD5_DIGEST_LENGTH; i++) { |
| 506 |
EXPECT_FAILURE_WITH_ERRNO( |
| 507 |
s2n_client_hello_get_fingerprint_hash(client_hello, |
| 508 |
S2N_FINGERPRINT_JA3, i, output_mem, &output_size, &str_size), |
| 509 |
S2N_ERR_INSUFFICIENT_MEM_SIZE); |
| 510 |
} |
| 511 |
EXPECT_EQUAL(output_size, 0); |
| 512 |
}; |
| 513 |
}; |
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
for (size_t i = 0; i < s2n_array_len(sources); i++) { |
| 521 |
s2n_ch_source source = sources[i]; |
| 522 |
|
| 523 |
DEFER_CLEANUP(struct s2n_connection *server = s2n_connection_new(S2N_SERVER), |
| 524 |
s2n_connection_ptr_free); |
| 525 |
EXPECT_NOT_NULL(server); |
| 526 |
EXPECT_SUCCESS(s2n_connection_set_config(server, config)); |
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
{ |
| 532 |
uint8_t raw_client_hello[135] = { |
| 533 |
0x01, 0x00, 0x00, 0x83, |
| 534 |
0x03, 0x00, 0x54, 0x3D, 0xD2, 0xA9, 0xB2, 0xD7, 0x59, 0xF7, 0xC4, |
| 535 |
0xCF, 0x64, 0x30, 0xEB, 0xCC, 0xF7, 0x36, 0x58, 0x9B, 0x78, 0xB8, |
| 536 |
0x9D, 0xB5, 0x0D, 0x59, 0xAF, 0x82, 0xA6, 0xC0, 0xAC, 0xFB, 0xA0, |
| 537 |
0xB1, 0x00, 0x00, 0x5C, 0xC0, 0x14, 0xC0, 0x0A, 0x00, 0x39, 0x00, |
| 538 |
0x38, 0x00, 0x88, 0x00, 0x87, 0xC0, 0x0F, 0xC0, 0x05, 0x00, 0x35, |
| 539 |
0x00, 0x84, 0xC0, 0x12, 0xC0, 0x08, 0x00, 0x16, 0x00, 0x13, 0xC0, |
| 540 |
0x0D, 0xC0, 0x03, 0x00, 0x0A, 0xC0, 0x13, 0xC0, 0x09, 0x00, 0x33, |
| 541 |
0x00, 0x32, 0x00, 0x9A, 0x00, 0x99, 0x00, 0x45, 0x00, 0x44, 0xC0, |
| 542 |
0x0E, 0xC0, 0x04, 0x00, 0x2F, 0x00, 0x96, 0x00, 0x41, 0x00, 0x07, |
| 543 |
0xC0, 0x11, 0xC0, 0x07, 0xC0, 0x0C, 0xC0, 0x02, 0x00, 0x05, 0x00, |
| 544 |
0x04, 0x00, 0x15, 0x00, 0x12, 0x00, 0x09, 0x00, 0x14, 0x00, 0x11, |
| 545 |
0x00, 0x08, 0x00, 0x06, 0x00, 0x03, 0x00, 0xFF, 0x01, 0x00 |
| 546 |
}; |
| 547 |
const char expected_ja3[] = "768,49172-49162-57-56-136-135-49167-" |
| 548 |
"49157-53-132-49170-49160-22-19-49165-49155-" |
| 549 |
"10-49171-49161-51-50-154-153-69-68-49166-" |
| 550 |
"49156-47-150-65-7-49169-49159-49164-49154-" |
| 551 |
"5-4-21-18-9-20-17-8-6-3-255,,,"; |
| 552 |
|
| 553 |
DEFER_CLEANUP(struct s2n_client_hello *client_hello = NULL, |
| 554 |
s2n_client_hello_free); |
| 555 |
EXPECT_OK(s2n_client_hello_from_source(&client_hello, server, |
| 556 |
raw_client_hello, sizeof(raw_client_hello), source)); |
| 557 |
|
| 558 |
uint32_t output_size = 0; |
| 559 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_string(client_hello, |
| 560 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size)); |
| 561 |
EXPECT_EQUAL(strlen(expected_ja3), output_size); |
| 562 |
EXPECT_BYTEARRAY_EQUAL(expected_ja3, output_mem, output_size); |
| 563 |
}; |
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
{ |
| 569 |
uint8_t raw_client_hello[164] = { |
| 570 |
0x01, 0x00, 0x00, 0xA0, |
| 571 |
0x03, 0x01, 0x54, 0x3D, 0xD2, 0xDD, 0x48, 0xF5, 0x17, 0xCA, 0x9A, |
| 572 |
0x93, 0xB1, 0xE5, 0x99, 0xF0, 0x19, 0xFD, 0xEC, 0xE7, 0x04, 0xA2, |
| 573 |
0x3E, 0x86, 0xC1, 0xDC, 0xAC, 0x58, 0x84, 0x27, 0xAB, 0xBA, 0xDD, |
| 574 |
0xF2, 0x00, 0x00, 0x5C, 0xC0, 0x14, 0xC0, 0x0A, 0x00, 0x39, 0x00, |
| 575 |
0x38, 0x00, 0x88, 0x00, 0x87, 0xC0, 0x0F, 0xC0, 0x05, 0x00, 0x35, |
| 576 |
0x00, 0x84, 0xC0, 0x12, 0xC0, 0x08, 0x00, 0x16, 0x00, 0x13, 0xC0, |
| 577 |
0x0D, 0xC0, 0x03, 0x00, 0x0A, 0xC0, 0x13, 0xC0, 0x09, 0x00, 0x33, |
| 578 |
0x00, 0x32, 0x00, 0x9A, 0x00, 0x99, 0x00, 0x45, 0x00, 0x44, 0xC0, |
| 579 |
0x0E, 0xC0, 0x04, 0x00, 0x2F, 0x00, 0x96, 0x00, 0x41, 0x00, 0x07, |
| 580 |
0xC0, 0x11, 0xC0, 0x07, 0xC0, 0x0C, 0xC0, 0x02, 0x00, 0x05, 0x00, |
| 581 |
0x04, 0x00, 0x15, 0x00, 0x12, 0x00, 0x09, 0x00, 0x14, 0x00, 0x11, |
| 582 |
0x00, 0x08, 0x00, 0x06, 0x00, 0x03, 0x00, 0xFF, 0x01, 0x00, 0x00, |
| 583 |
0x1B, 0x00, 0x0B, 0x00, 0x04, 0x03, 0x00, 0x01, 0x02, 0x00, 0x0A, |
| 584 |
0x00, 0x06, 0x00, 0x04, 0x00, 0x18, 0x00, 0x17, 0x00, 0x23, 0x00, |
| 585 |
0x00, 0x00, 0x0F, 0x00, 0x01, 0x01 |
| 586 |
}; |
| 587 |
const char expected_ja3[] = "769,49172-49162-57-56-136-135-49167-" |
| 588 |
"49157-53-132-49170-49160-22-19-49165-49155-" |
| 589 |
"10-49171-49161-51-50-154-153-69-68-49166-" |
| 590 |
"49156-47-150-65-7-49169-49159-49164-49154-" |
| 591 |
"5-4-21-18-9-20-17-8-6-3-255,11-10-35-15," |
| 592 |
"24-23,0-1-2"; |
| 593 |
|
| 594 |
DEFER_CLEANUP(struct s2n_client_hello *client_hello = NULL, |
| 595 |
s2n_client_hello_free); |
| 596 |
EXPECT_OK(s2n_client_hello_from_source(&client_hello, server, |
| 597 |
raw_client_hello, sizeof(raw_client_hello), source)); |
| 598 |
|
| 599 |
uint32_t output_size = 0; |
| 600 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_string(client_hello, |
| 601 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size)); |
| 602 |
EXPECT_EQUAL(strlen(expected_ja3), output_size); |
| 603 |
EXPECT_BYTEARRAY_EQUAL(expected_ja3, output_mem, output_size); |
| 604 |
}; |
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
{ |
| 610 |
uint8_t raw_client_hello[164] = { |
| 611 |
0x01, 0x00, 0x00, 0xA0, |
| 612 |
0x03, 0x02, 0x54, 0x3D, 0xD2, 0xED, 0x90, 0x7E, 0x47, 0xD0, 0x08, |
| 613 |
0x6F, 0x34, 0xBE, 0xE2, 0xC5, 0x2D, 0xD6, 0xCC, 0xD8, 0xDE, 0x63, |
| 614 |
0xBA, 0x93, 0x87, 0xF5, 0xE8, 0x10, 0xB0, 0x9D, 0x9D, 0x49, 0xB3, |
| 615 |
0x80, 0x00, 0x00, 0x5C, 0xC0, 0x14, 0xC0, 0x0A, 0x00, 0x39, 0x00, |
| 616 |
0x38, 0x00, 0x88, 0x00, 0x87, 0xC0, 0x0F, 0xC0, 0x05, 0x00, 0x35, |
| 617 |
0x00, 0x84, 0xC0, 0x12, 0xC0, 0x08, 0x00, 0x16, 0x00, 0x13, 0xC0, |
| 618 |
0x0D, 0xC0, 0x03, 0x00, 0x0A, 0xC0, 0x13, 0xC0, 0x09, 0x00, 0x33, |
| 619 |
0x00, 0x32, 0x00, 0x9A, 0x00, 0x99, 0x00, 0x45, 0x00, 0x44, 0xC0, |
| 620 |
0x0E, 0xC0, 0x04, 0x00, 0x2F, 0x00, 0x96, 0x00, 0x41, 0x00, 0x07, |
| 621 |
0xC0, 0x11, 0xC0, 0x07, 0xC0, 0x0C, 0xC0, 0x02, 0x00, 0x05, 0x00, |
| 622 |
0x04, 0x00, 0x15, 0x00, 0x12, 0x00, 0x09, 0x00, 0x14, 0x00, 0x11, |
| 623 |
0x00, 0x08, 0x00, 0x06, 0x00, 0x03, 0x00, 0xFF, 0x01, 0x00, 0x00, |
| 624 |
0x1B, 0x00, 0x0B, 0x00, 0x04, 0x03, 0x00, 0x01, 0x02, 0x00, 0x0A, |
| 625 |
0x00, 0x06, 0x00, 0x04, 0x00, 0x18, 0x00, 0x17, 0x00, 0x23, 0x00, |
| 626 |
0x00, 0x00, 0x0F, 0x00, 0x01, 0x01 |
| 627 |
}; |
| 628 |
const char expected_ja3[] = "770,49172-49162-57-56-136-135-49167-" |
| 629 |
"49157-53-132-49170-49160-22-19-49165-49155-" |
| 630 |
"10-49171-49161-51-50-154-153-69-68-49166-" |
| 631 |
"49156-47-150-65-7-49169-49159-49164-49154-" |
| 632 |
"5-4-21-18-9-20-17-8-6-3-255,11-10-35-15," |
| 633 |
"24-23,0-1-2"; |
| 634 |
|
| 635 |
DEFER_CLEANUP(struct s2n_client_hello *client_hello = NULL, |
| 636 |
s2n_client_hello_free); |
| 637 |
EXPECT_OK(s2n_client_hello_from_source(&client_hello, server, |
| 638 |
raw_client_hello, sizeof(raw_client_hello), source)); |
| 639 |
|
| 640 |
uint32_t output_size = 0; |
| 641 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_string(client_hello, |
| 642 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size)); |
| 643 |
EXPECT_EQUAL(strlen(expected_ja3), output_size); |
| 644 |
EXPECT_BYTEARRAY_EQUAL(expected_ja3, output_mem, output_size); |
| 645 |
}; |
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
{ |
| 651 |
uint8_t raw_client_hello[258] = { |
| 652 |
0x01, 0x00, 0x00, 0xFE, |
| 653 |
0x03, 0x03, 0x54, 0x3D, 0xD3, 0x28, 0x32, 0x83, 0x69, 0x2D, 0x85, |
| 654 |
0xF9, 0x41, 0x6B, 0x5C, 0xCC, 0x65, 0xD2, 0xAA, 0xFC, 0xA4, 0x5C, |
| 655 |
0x65, 0x30, 0xB3, 0xC6, 0xEA, 0xFB, 0xF6, 0xD3, 0x71, 0xB6, 0xA0, |
| 656 |
0x15, 0x00, 0x00, 0x94, 0xC0, 0x30, 0xC0, 0x2C, 0xC0, 0x28, 0xC0, |
| 657 |
0x24, 0xC0, 0x14, 0xC0, 0x0A, 0x00, 0xA3, 0x00, 0x9F, 0x00, 0x6B, |
| 658 |
0x00, 0x6A, 0x00, 0x39, 0x00, 0x38, 0x00, 0x88, 0x00, 0x87, 0xC0, |
| 659 |
0x32, 0xC0, 0x2E, 0xC0, 0x2A, 0xC0, 0x26, 0xC0, 0x0F, 0xC0, 0x05, |
| 660 |
0x00, 0x9D, 0x00, 0x3D, 0x00, 0x35, 0x00, 0x84, 0xC0, 0x12, 0xC0, |
| 661 |
0x08, 0x00, 0x16, 0x00, 0x13, 0xC0, 0x0D, 0xC0, 0x03, 0x00, 0x0A, |
| 662 |
0xC0, 0x2F, 0xC0, 0x2B, 0xC0, 0x27, 0xC0, 0x23, 0xC0, 0x13, 0xC0, |
| 663 |
0x09, 0x00, 0xA2, 0x00, 0x9E, 0x00, 0x67, 0x00, 0x40, 0x00, 0x33, |
| 664 |
0x00, 0x32, 0x00, 0x9A, 0x00, 0x99, 0x00, 0x45, 0x00, 0x44, 0xC0, |
| 665 |
0x31, 0xC0, 0x2D, 0xC0, 0x29, 0xC0, 0x25, 0xC0, 0x0E, 0xC0, 0x04, |
| 666 |
0x00, 0x9C, 0x00, 0x3C, 0x00, 0x2F, 0x00, 0x96, 0x00, 0x41, 0x00, |
| 667 |
0x07, 0xC0, 0x11, 0xC0, 0x07, 0xC0, 0x0C, 0xC0, 0x02, 0x00, 0x05, |
| 668 |
0x00, 0x04, 0x00, 0x15, 0x00, 0x12, 0x00, 0x09, 0x00, 0x14, 0x00, |
| 669 |
0x11, 0x00, 0x08, 0x00, 0x06, 0x00, 0x03, 0x00, 0xFF, 0x01, 0x00, |
| 670 |
0x00, 0x41, 0x00, 0x0B, 0x00, 0x04, 0x03, 0x00, 0x01, 0x02, 0x00, |
| 671 |
0x0A, 0x00, 0x06, 0x00, 0x04, 0x00, 0x18, 0x00, 0x17, 0x00, 0x23, |
| 672 |
0x00, 0x00, 0x00, 0x0D, 0x00, 0x22, 0x00, 0x20, 0x06, 0x01, 0x06, |
| 673 |
0x02, 0x06, 0x03, 0x05, 0x01, 0x05, 0x02, 0x05, 0x03, 0x04, 0x01, |
| 674 |
0x04, 0x02, 0x04, 0x03, 0x03, 0x01, 0x03, 0x02, 0x03, 0x03, 0x02, |
| 675 |
0x01, 0x02, 0x02, 0x02, 0x03, 0x01, 0x01, 0x00, 0x0F, 0x00, 0x01, |
| 676 |
0x01 |
| 677 |
}; |
| 678 |
const char expected_ja3[] = "771,49200-49196-49192-49188-49172-49162-" |
| 679 |
"163-159-107-106-57-56-136-135-49202-49198-" |
| 680 |
"49194-49190-49167-49157-157-61-53-132-" |
| 681 |
"49170-49160-22-19-49165-49155-10-49199-" |
| 682 |
"49195-49191-49187-49171-49161-162-158-103-" |
| 683 |
"64-51-50-154-153-69-68-49201-49197-49193-" |
| 684 |
"49189-49166-49156-156-60-47-150-65-7-" |
| 685 |
"49169-49159-49164-49154-5-4-21-18-9-20-" |
| 686 |
"17-8-6-3-255,11-10-35-13-15,24-23,0-1-2"; |
| 687 |
|
| 688 |
DEFER_CLEANUP(struct s2n_client_hello *client_hello = NULL, |
| 689 |
s2n_client_hello_free); |
| 690 |
EXPECT_OK(s2n_client_hello_from_source(&client_hello, server, |
| 691 |
raw_client_hello, sizeof(raw_client_hello), source)); |
| 692 |
|
| 693 |
uint32_t output_size = 0; |
| 694 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_string(client_hello, |
| 695 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size)); |
| 696 |
EXPECT_EQUAL(strlen(expected_ja3), output_size); |
| 697 |
EXPECT_BYTEARRAY_EQUAL(expected_ja3, output_mem, output_size); |
| 698 |
}; |
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
{ |
| 704 |
uint8_t raw_client_hello[512] = { |
| 705 |
0x01, 0x00, 0x01, 0xFC, |
| 706 |
0x03, 0x03, 0x86, 0xad, 0xa4, 0xcc, 0x19, 0xe7, 0x14, 0x54, 0x54, |
| 707 |
0xfd, 0xe7, 0x37, 0x33, 0xdf, 0x66, 0xcb, 0xf6, 0xef, 0x3e, 0xc0, |
| 708 |
0xa1, 0x54, 0xc6, 0xdd, 0x14, 0x5e, 0xc0, 0x83, 0xac, 0xb9, 0xb4, |
| 709 |
0xe7, 0x20, 0x1c, 0x64, 0xae, 0xa7, 0xa2, 0xc3, 0xe1, 0x8c, 0xd1, |
| 710 |
0x25, 0x02, 0x4d, 0xf7, 0x86, 0x4a, 0xc7, 0x19, 0xd0, 0xc4, 0xbd, |
| 711 |
0xfb, 0x40, 0xc2, 0xef, 0x7f, 0x6d, 0xd3, 0x9a, 0xa7, 0x53, 0xdf, |
| 712 |
0xdd, 0x00, 0x22, 0x1a, 0x1a, 0x13, 0x01, 0x13, 0x02, 0x13, 0x03, |
| 713 |
0xc0, 0x2b, 0xc0, 0x2f, 0xc0, 0x2c, 0xc0, 0x30, 0xcc, 0xa9, 0xcc, |
| 714 |
0xa8, 0xc0, 0x13, 0xc0, 0x14, 0x00, 0x9c, 0x00, 0x9d, 0x00, 0x2f, |
| 715 |
0x00, 0x35, 0x00, 0x0a, 0x01, 0x00, 0x01, 0x91, 0x0a, 0x0a, 0x00, |
| 716 |
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x1e, 0x00, 0x00, 0x1b, 0x67, |
| 717 |
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x61, 0x64, 0x73, 0x2e, 0x67, 0x2e, |
| 718 |
0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x63, 0x6c, 0x69, 0x63, 0x6b, |
| 719 |
0x2e, 0x6e, 0x65, 0x74, 0x00, 0x17, 0x00, 0x00, 0xff, 0x01, 0x00, |
| 720 |
0x01, 0x00, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x08, 0x9a, 0x9a, 0x00, |
| 721 |
0x1d, 0x00, 0x17, 0x00, 0x18, 0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, |
| 722 |
0x00, 0x23, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x0c, 0x02, |
| 723 |
0x68, 0x32, 0x08, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31, |
| 724 |
0x00, 0x05, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, |
| 725 |
0x00, 0x14, 0x00, 0x12, 0x04, 0x03, 0x08, 0x04, 0x04, 0x01, 0x05, |
| 726 |
0x03, 0x08, 0x05, 0x05, 0x01, 0x08, 0x06, 0x06, 0x01, 0x02, 0x01, |
| 727 |
0x00, 0x12, 0x00, 0x00, 0x00, 0x33, 0x00, 0x2b, 0x00, 0x29, 0x9a, |
| 728 |
0x9a, 0x00, 0x01, 0x00, 0x00, 0x1d, 0x00, 0x20, 0x59, 0x08, 0x6f, |
| 729 |
0x41, 0x9a, 0xa5, 0xaa, 0x1d, 0x81, 0xe3, 0x47, 0xf0, 0x25, 0x5f, |
| 730 |
0x92, 0x07, 0xfc, 0x4b, 0x13, 0x74, 0x51, 0x46, 0x98, 0x08, 0x74, |
| 731 |
0x3b, 0xde, 0x57, 0x86, 0xe8, 0x2c, 0x74, 0x00, 0x2d, 0x00, 0x02, |
| 732 |
0x01, 0x01, 0x00, 0x2b, 0x00, 0x0b, 0x0a, 0xfa, 0xfa, 0x03, 0x04, |
| 733 |
0x03, 0x03, 0x03, 0x02, 0x03, 0x01, 0x00, 0x1b, 0x00, 0x03, 0x02, |
| 734 |
0x00, 0x02, 0xba, 0xba, 0x00, 0x01, 0x00, 0x00, 0x15, 0x00, 0xbd, |
| 735 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 736 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 737 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 738 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 739 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 740 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 741 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 742 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 743 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 744 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 745 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 746 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 747 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 748 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 749 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 750 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 751 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 752 |
0x00, 0x00 |
| 753 |
}; |
| 754 |
const char expected_ja3[] = "771,4865-4866-4867-49195-49199-49196-" |
| 755 |
"49200-52393-52392-49171-49172-156-157-47-" |
| 756 |
"53-10,0-23-65281-10-11-35-16-5-13-18-51-" |
| 757 |
"45-43-27-21,29-23-24,0"; |
| 758 |
S2N_BLOB_FROM_HEX(expected_hash, "66918128f1b9b03303d77c6f2eefd128"); |
| 759 |
|
| 760 |
DEFER_CLEANUP(struct s2n_client_hello *client_hello = NULL, |
| 761 |
s2n_client_hello_free); |
| 762 |
EXPECT_OK(s2n_client_hello_from_source(&client_hello, server, |
| 763 |
raw_client_hello, sizeof(raw_client_hello), source)); |
| 764 |
|
| 765 |
uint32_t output_size = 0; |
| 766 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_string(client_hello, |
| 767 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size)); |
| 768 |
EXPECT_EQUAL(strlen(expected_ja3), output_size); |
| 769 |
EXPECT_BYTEARRAY_EQUAL(expected_ja3, output_mem, output_size); |
| 770 |
|
| 771 |
uint32_t str_size = 0; |
| 772 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_hash(client_hello, |
| 773 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size, |
| 774 |
&str_size)); |
| 775 |
EXPECT_EQUAL(strlen(expected_ja3), str_size); |
| 776 |
EXPECT_EQUAL(expected_hash.size, output_size); |
| 777 |
EXPECT_BYTEARRAY_EQUAL(expected_hash.data, output_mem, output_size); |
| 778 |
}; |
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
{ |
| 784 |
uint8_t raw_client_hello[512] = { |
| 785 |
0x01, 0x00, 0x01, 0xFC, |
| 786 |
0x03, 0x03, 0x40, 0xc7, 0x8a, 0xef, 0x5c, 0x7f, 0xed, 0x98, 0x4a, |
| 787 |
0x19, 0x8a, 0x03, 0x0b, 0xc0, 0x2d, 0xc0, 0xd6, 0x8f, 0x0b, 0x14, |
| 788 |
0x7d, 0x23, 0x3d, 0x90, 0xb4, 0x2b, 0x4b, 0x28, 0x2c, 0x44, 0x0c, |
| 789 |
0x4d, 0x20, 0xf4, 0x73, 0x04, 0xed, 0x17, 0x42, 0xd6, 0xb5, 0x08, |
| 790 |
0x2e, 0x73, 0x78, 0x71, 0x25, 0x52, 0x5c, 0xea, 0xe7, 0xd7, 0xe5, |
| 791 |
0x7c, 0xfa, 0x27, 0xfe, 0xa3, 0x52, 0x63, 0x7a, 0x27, 0xc3, 0x5d, |
| 792 |
0x58, 0x00, 0x3e, 0x13, 0x02, 0x13, 0x03, 0x13, 0x01, 0xc0, 0x2c, |
| 793 |
0xc0, 0x30, 0x00, 0x9f, 0xcc, 0xa9, 0xcc, 0xa8, 0xcc, 0xaa, 0xc0, |
| 794 |
0x2b, 0xc0, 0x2f, 0x00, 0x9e, 0xc0, 0x24, 0xc0, 0x28, 0x00, 0x6b, |
| 795 |
0xc0, 0x23, 0xc0, 0x27, 0x00, 0x67, 0xc0, 0x0a, 0xc0, 0x14, 0x00, |
| 796 |
0x39, 0xc0, 0x09, 0xc0, 0x13, 0x00, 0x33, 0x00, 0x9d, 0x00, 0x9c, |
| 797 |
0x00, 0x3d, 0x00, 0x3c, 0x00, 0x35, 0x00, 0x2f, 0x00, 0xff, 0x01, |
| 798 |
0x00, 0x01, 0x75, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, |
| 799 |
0x0b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, |
| 800 |
0x6d, 0x00, 0x0b, 0x00, 0x04, 0x03, 0x00, 0x01, 0x02, 0x00, 0x0a, |
| 801 |
0x00, 0x0c, 0x00, 0x0a, 0x00, 0x1d, 0x00, 0x17, 0x00, 0x1e, 0x00, |
| 802 |
0x19, 0x00, 0x18, 0x33, 0x74, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0e, |
| 803 |
0x00, 0x0c, 0x02, 0x68, 0x32, 0x08, 0x68, 0x74, 0x74, 0x70, 0x2f, |
| 804 |
0x31, 0x2e, 0x31, 0x00, 0x16, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, |
| 805 |
0x00, 0x0d, 0x00, 0x30, 0x00, 0x2e, 0x04, 0x03, 0x05, 0x03, 0x06, |
| 806 |
0x03, 0x08, 0x07, 0x08, 0x08, 0x08, 0x09, 0x08, 0x0a, 0x08, 0x0b, |
| 807 |
0x08, 0x04, 0x08, 0x05, 0x08, 0x06, 0x04, 0x01, 0x05, 0x01, 0x06, |
| 808 |
0x01, 0x03, 0x03, 0x02, 0x03, 0x03, 0x01, 0x02, 0x01, 0x03, 0x02, |
| 809 |
0x02, 0x02, 0x04, 0x02, 0x05, 0x02, 0x06, 0x02, 0x00, 0x2b, 0x00, |
| 810 |
0x09, 0x08, 0x03, 0x04, 0x03, 0x03, 0x03, 0x02, 0x03, 0x01, 0x00, |
| 811 |
0x2d, 0x00, 0x02, 0x01, 0x01, 0x00, 0x33, 0x00, 0x26, 0x00, 0x24, |
| 812 |
0x00, 0x1d, 0x00, 0x20, 0x29, 0x90, 0xc2, 0xec, 0x21, 0x68, 0x2c, |
| 813 |
0x5a, 0x7a, 0x5a, 0x46, 0x49, 0x59, 0x42, 0x54, 0x66, 0x02, 0x92, |
| 814 |
0x0c, 0x08, 0x16, 0x59, 0xf6, 0xcc, 0x75, 0xb8, 0x16, 0x53, 0x20, |
| 815 |
0x46, 0x79, 0x23, 0x00, 0x15, 0x00, 0xb6, 0x00, 0x00, 0x00, 0x00, |
| 816 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 817 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 818 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 819 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 820 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 821 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 822 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 823 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 824 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 825 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 826 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 827 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 828 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 829 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 830 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 831 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 832 |
0x00, 0x00 |
| 833 |
}; |
| 834 |
const char expected_ja3[] = "771,4866-4867-4865-49196-49200-159-52393-" |
| 835 |
"52392-52394-49195-49199-158-49188-49192-" |
| 836 |
"107-49187-49191-103-49162-49172-57-49161-" |
| 837 |
"49171-51-157-156-61-60-53-47-255,0-11-" |
| 838 |
"10-13172-16-22-23-13-43-45-51-21,29-23-" |
| 839 |
"30-25-24,0-1-2"; |
| 840 |
S2N_BLOB_FROM_HEX(expected_hash, "456523fc94726331a4d5a2e1d40b2cd7"); |
| 841 |
|
| 842 |
DEFER_CLEANUP(struct s2n_client_hello *client_hello = NULL, |
| 843 |
s2n_client_hello_free); |
| 844 |
EXPECT_OK(s2n_client_hello_from_source(&client_hello, server, |
| 845 |
raw_client_hello, sizeof(raw_client_hello), source)); |
| 846 |
|
| 847 |
uint32_t output_size = 0; |
| 848 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_string(client_hello, |
| 849 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size)); |
| 850 |
EXPECT_EQUAL(strlen(expected_ja3), output_size); |
| 851 |
EXPECT_BYTEARRAY_EQUAL(expected_ja3, output_mem, output_size); |
| 852 |
|
| 853 |
uint32_t str_size = 0; |
| 854 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_hash(client_hello, |
| 855 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size, |
| 856 |
&str_size)); |
| 857 |
EXPECT_EQUAL(strlen(expected_ja3), str_size); |
| 858 |
EXPECT_EQUAL(expected_hash.size, output_size); |
| 859 |
EXPECT_BYTEARRAY_EQUAL(expected_hash.data, output_mem, output_size); |
| 860 |
}; |
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
{ |
| 866 |
uint8_t raw_client_hello[240] = { |
| 867 |
0x01, 0x00, 0x00, 0xEC, |
| 868 |
0x03, 0x03, 0x90, 0xe8, 0xcc, 0xee, 0xe5, 0x70, 0xa2, 0xa1, 0x2f, |
| 869 |
0x6b, 0x69, 0xd2, 0x66, 0x96, 0x0f, 0xcf, 0x20, 0xd5, 0x32, 0x6e, |
| 870 |
0xc4, 0xb2, 0x8c, 0xc7, 0xbd, 0x0a, 0x06, 0xc2, 0xa5, 0x14, 0xfc, |
| 871 |
0x34, 0x20, 0xaf, 0x72, 0xbf, 0x39, 0x99, 0xfb, 0x20, 0x70, 0xc3, |
| 872 |
0x10, 0x83, 0x0c, 0xee, 0xfb, 0xfa, 0x72, 0xcc, 0x5d, 0xa8, 0x99, |
| 873 |
0xb4, 0xc5, 0x53, 0xd6, 0x3d, 0xa0, 0x53, 0x7a, 0x5c, 0xbc, 0xf5, |
| 874 |
0x0b, 0x00, 0x1e, 0xc0, 0x2b, 0xc0, 0x2f, 0xcc, 0xa9, 0xcc, 0xa8, |
| 875 |
0xc0, 0x2c, 0xc0, 0x30, 0xc0, 0x0a, 0xc0, 0x09, 0xc0, 0x13, 0xc0, |
| 876 |
0x14, 0x00, 0x33, 0x00, 0x39, 0x00, 0x2f, 0x00, 0x35, 0x00, 0x0a, |
| 877 |
0x01, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x23, 0x00, 0x21, 0x00, |
| 878 |
0x00, 0x1e, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x2e, |
| 879 |
0x74, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, 0x6d, |
| 880 |
0x6f, 0x7a, 0x69, 0x6c, 0x6c, 0x61, 0x2e, 0x6f, 0x72, 0x67, 0x00, |
| 881 |
0x17, 0x00, 0x00, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x0a, 0x00, |
| 882 |
0x0a, 0x00, 0x08, 0x00, 0x1d, 0x00, 0x17, 0x00, 0x18, 0x00, 0x19, |
| 883 |
0x00, 0x0b, 0x00, 0x02, 0x01, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, |
| 884 |
0x10, 0x00, 0x0e, 0x00, 0x0c, 0x02, 0x68, 0x32, 0x08, 0x68, 0x74, |
| 885 |
0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31, 0x00, 0x05, 0x00, 0x05, 0x01, |
| 886 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x18, 0x00, 0x16, 0x04, |
| 887 |
0x03, 0x05, 0x03, 0x06, 0x03, 0x08, 0x04, 0x08, 0x05, 0x08, 0x06, |
| 888 |
0x04, 0x01, 0x05, 0x01, 0x06, 0x01, 0x02, 0x03, 0x02, 0x01, 0x00, |
| 889 |
0x1c, 0x00, 0x02, 0x40, 0x00 |
| 890 |
}; |
| 891 |
const char expected_ja3[] = "771,49195-49199-52393-52392-49196-49200-" |
| 892 |
"49162-49161-49171-49172-51-57-47-53-10,0-" |
| 893 |
"23-65281-10-11-35-16-5-13-28,29-23-24-25,0"; |
| 894 |
S2N_BLOB_FROM_HEX(expected_hash, "839bbe3ed07fed922ded5aaf714d6842"); |
| 895 |
|
| 896 |
DEFER_CLEANUP(struct s2n_client_hello *client_hello = NULL, |
| 897 |
s2n_client_hello_free); |
| 898 |
EXPECT_OK(s2n_client_hello_from_source(&client_hello, server, |
| 899 |
raw_client_hello, sizeof(raw_client_hello), source)); |
| 900 |
|
| 901 |
uint32_t output_size = 0; |
| 902 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_string(client_hello, |
| 903 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size)); |
| 904 |
EXPECT_EQUAL(strlen(expected_ja3), output_size); |
| 905 |
EXPECT_BYTEARRAY_EQUAL(expected_ja3, output_mem, output_size); |
| 906 |
|
| 907 |
uint32_t str_size = 0; |
| 908 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_hash(client_hello, |
| 909 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size, |
| 910 |
&str_size)); |
| 911 |
EXPECT_EQUAL(strlen(expected_ja3), str_size); |
| 912 |
EXPECT_EQUAL(expected_hash.size, output_size); |
| 913 |
EXPECT_BYTEARRAY_EQUAL(expected_hash.data, output_mem, output_size); |
| 914 |
}; |
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
{ |
| 920 |
uint8_t raw_client_hello[512] = { |
| 921 |
0x01, 0x00, 0x01, 0xFC, |
| 922 |
0x03, 0x03, 0xf4, 0x0f, 0xfd, 0xee, 0xc7, 0x27, 0xc2, 0x1e, 0x32, |
| 923 |
0x70, 0x5f, 0x85, 0x25, 0xa6, 0xbb, 0x6c, 0xca, 0x4b, 0x6c, 0xbe, |
| 924 |
0x01, 0x66, 0x32, 0x66, 0x76, 0x4b, 0x67, 0x74, 0x3b, 0x91, 0xbd, |
| 925 |
0xb2, 0x20, 0x83, 0xd4, 0x9e, 0x77, 0xaf, 0xc1, 0x5a, 0x63, 0x35, |
| 926 |
0xba, 0x2f, 0xe9, 0x76, 0xbe, 0x9a, 0x42, 0x6b, 0x2e, 0xb5, 0x58, |
| 927 |
0x23, 0x84, 0x2a, 0x99, 0x2b, 0x37, 0x88, 0xd1, 0xf7, 0x9d, 0xd6, |
| 928 |
0x20, 0x00, 0x9c, 0x13, 0x02, 0x13, 0x03, 0x13, 0x01, 0xc0, 0x2c, |
| 929 |
0xc0, 0x30, 0x00, 0xa3, 0x00, 0x9f, 0xcc, 0xa9, 0xcc, 0xa8, 0xcc, |
| 930 |
0xaa, 0xc0, 0xaf, 0xc0, 0xad, 0xc0, 0xa3, 0xc0, 0x9f, 0xc0, 0x5d, |
| 931 |
0xc0, 0x61, 0xc0, 0x57, 0xc0, 0x53, 0xc0, 0x24, 0xc0, 0x28, 0x00, |
| 932 |
0x6b, 0x00, 0x6a, 0xc0, 0x73, 0xc0, 0x77, 0x00, 0xc4, 0x00, 0xc3, |
| 933 |
0xc0, 0x0a, 0xc0, 0x14, 0x00, 0x39, 0x00, 0x38, 0x00, 0x88, 0x00, |
| 934 |
0x87, 0x00, 0x9d, 0xc0, 0xa1, 0xc0, 0x9d, 0xc0, 0x51, 0x00, 0x3d, |
| 935 |
0x00, 0xc0, 0x00, 0x35, 0x00, 0x84, 0xc0, 0x2b, 0xc0, 0x2f, 0x00, |
| 936 |
0xa2, 0x00, 0x9e, 0xc0, 0xae, 0xc0, 0xac, 0xc0, 0xa2, 0xc0, 0x9e, |
| 937 |
0xc0, 0x5c, 0xc0, 0x60, 0xc0, 0x56, 0xc0, 0x52, 0xc0, 0x23, 0xc0, |
| 938 |
0x27, 0x00, 0x67, 0x00, 0x40, 0xc0, 0x72, 0xc0, 0x76, 0x00, 0xbe, |
| 939 |
0x00, 0xbd, 0xc0, 0x09, 0xc0, 0x13, 0x00, 0x33, 0x00, 0x32, 0x00, |
| 940 |
0x9a, 0x00, 0x99, 0x00, 0x45, 0x00, 0x44, 0x00, 0x9c, 0xc0, 0xa0, |
| 941 |
0xc0, 0x9c, 0xc0, 0x50, 0x00, 0x3c, 0x00, 0xba, 0x00, 0x2f, 0x00, |
| 942 |
0x96, 0x00, 0x41, 0x00, 0xff, 0x01, 0x00, 0x01, 0x17, 0x00, 0x00, |
| 943 |
0x00, 0x0e, 0x00, 0x0c, 0x00, 0x00, 0x09, 0x31, 0x32, 0x37, 0x2e, |
| 944 |
0x30, 0x2e, 0x30, 0x2e, 0x31, 0x00, 0x0b, 0x00, 0x04, 0x03, 0x00, |
| 945 |
0x01, 0x02, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x0a, 0x00, 0x1d, 0x00, |
| 946 |
0x17, 0x00, 0x1e, 0x00, 0x19, 0x00, 0x18, 0x00, 0x23, 0x00, 0x00, |
| 947 |
0x00, 0x16, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x0d, 0x00, |
| 948 |
0x30, 0x00, 0x2e, 0x04, 0x03, 0x05, 0x03, 0x06, 0x03, 0x08, 0x07, |
| 949 |
0x08, 0x08, 0x08, 0x09, 0x08, 0x0a, 0x08, 0x0b, 0x08, 0x04, 0x08, |
| 950 |
0x05, 0x08, 0x06, 0x04, 0x01, 0x05, 0x01, 0x06, 0x01, 0x03, 0x03, |
| 951 |
0x02, 0x03, 0x03, 0x01, 0x02, 0x01, 0x03, 0x02, 0x02, 0x02, 0x04, |
| 952 |
0x02, 0x05, 0x02, 0x06, 0x02, 0x00, 0x2b, 0x00, 0x09, 0x08, 0x03, |
| 953 |
0x04, 0x03, 0x03, 0x03, 0x02, 0x03, 0x01, 0x00, 0x2d, 0x00, 0x02, |
| 954 |
0x01, 0x01, 0x00, 0x33, 0x00, 0x26, 0x00, 0x24, 0x00, 0x1d, 0x00, |
| 955 |
0x20, 0x29, 0x61, 0x96, 0xc4, 0x0c, 0x16, 0x7c, 0xde, 0x20, 0x01, |
| 956 |
0x86, 0x32, 0xdf, 0x84, 0x2f, 0x67, 0x2f, 0x3f, 0x64, 0x17, 0xc0, |
| 957 |
0x2e, 0xa2, 0xb2, 0x9e, 0xfc, 0xa8, 0xb0, 0xc5, 0x71, 0x6e, 0x7d, |
| 958 |
0x00, 0x15, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 959 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 960 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 961 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 962 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 963 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 964 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 965 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 966 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 967 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 968 |
0x00, 0x00 |
| 969 |
}; |
| 970 |
const char expected_ja3[] = "771,4866-4867-4865-49196-49200-163-159-" |
| 971 |
"52393-52392-52394-49327-49325-49315-" |
| 972 |
"49311-49245-49249-49239-49235-49188-49192-" |
| 973 |
"107-106-49267-49271-196-195-49162-49172-" |
| 974 |
"57-56-136-135-157-49313-49309-49233-61-" |
| 975 |
"192-53-132-49195-49199-162-158-49326-" |
| 976 |
"49324-49314-49310-49244-49248-49238-49234-" |
| 977 |
"49187-49191-103-64-49266-49270-190-189-" |
| 978 |
"49161-49171-51-50-154-153-69-68-156-49312-" |
| 979 |
"49308-49232-60-186-47-150-65-255,0-11-" |
| 980 |
"10-35-22-23-13-43-45-51-21,29-23-30-25-" |
| 981 |
"24,0-1-2"; |
| 982 |
S2N_BLOB_FROM_HEX(expected_hash, "10a6b69a81bac09072a536ce9d35dd43"); |
| 983 |
|
| 984 |
DEFER_CLEANUP(struct s2n_client_hello *client_hello = NULL, |
| 985 |
s2n_client_hello_free); |
| 986 |
EXPECT_OK(s2n_client_hello_from_source(&client_hello, server, |
| 987 |
raw_client_hello, sizeof(raw_client_hello), source)); |
| 988 |
|
| 989 |
uint32_t output_size = 0; |
| 990 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_string(client_hello, |
| 991 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size)); |
| 992 |
EXPECT_EQUAL(strlen(expected_ja3), output_size); |
| 993 |
EXPECT_BYTEARRAY_EQUAL(expected_ja3, output_mem, output_size); |
| 994 |
|
| 995 |
uint32_t str_size = 0; |
| 996 |
EXPECT_SUCCESS(s2n_client_hello_get_fingerprint_hash(client_hello, |
| 997 |
S2N_FINGERPRINT_JA3, sizeof(output_mem), output_mem, &output_size, |
| 998 |
&str_size)); |
| 999 |
EXPECT_EQUAL(strlen(expected_ja3), str_size); |
| 1000 |
EXPECT_EQUAL(expected_hash.size, output_size); |
| 1001 |
EXPECT_BYTEARRAY_EQUAL(expected_hash.data, output_mem, output_size); |
| 1002 |
}; |
| 1003 |
}; |
| 1004 |
|
| 1005 |
END_TEST(); |
| 1006 |
} |