| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "api/s2n.h" |
| 17 |
#include "s2n_test.h" |
| 18 |
#include "testlib/s2n_testlib.h" |
| 19 |
|
| 20 |
int main(int argc, char **argv) |
| 21 |
{ |
| 22 |
BEGIN_TEST(); |
| 23 |
|
| 24 |
struct s2n_connection *conn = NULL; |
| 25 |
EXPECT_NOT_NULL(conn = s2n_connection_new(S2N_CLIENT)); |
| 26 |
EXPECT_SUCCESS(s2n_connection_set_cipher_preferences(conn, "test_all")); |
| 27 |
|
| 28 |
uint8_t iana_value[2] = { 0 }; |
| 29 |
|
| 30 |
|
| 31 |
EXPECT_FAILURE(s2n_connection_get_cipher_iana_value(conn, &iana_value[0], &iana_value[1])); |
| 32 |
|
| 33 |
const struct s2n_security_policy *security_policy = conn->security_policy_override; |
| 34 |
EXPECT_NOT_NULL(security_policy); |
| 35 |
|
| 36 |
const struct s2n_cipher_preferences *cipher_preferences = security_policy->cipher_preferences; |
| 37 |
EXPECT_NOT_NULL(cipher_preferences); |
| 38 |
|
| 39 |
|
| 40 |
for (size_t cipher_idx = 0; cipher_idx < cipher_preferences->count; cipher_idx++) { |
| 41 |
struct s2n_cipher_suite *expected_cipher = cipher_preferences->suites[cipher_idx]; |
| 42 |
conn->secure->cipher_suite = expected_cipher; |
| 43 |
|
| 44 |
EXPECT_STRING_EQUAL(s2n_connection_get_cipher(conn), expected_cipher->name); |
| 45 |
EXPECT_SUCCESS(s2n_connection_get_cipher_iana_value(conn, &iana_value[0], &iana_value[1])); |
| 46 |
EXPECT_EQUAL(memcmp(expected_cipher->iana_value, iana_value, sizeof(iana_value)), 0); |
| 47 |
} |
| 48 |
|
| 49 |
EXPECT_SUCCESS(s2n_connection_free(conn)); |
| 50 |
|
| 51 |
END_TEST(); |
| 52 |
return S2N_SUCCESS; |
| 53 |
} |