Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
goatgoose committed Sep 20, 2023
1 parent 61606d6 commit fa8faa3
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions tests/unit/s2n_client_hello_get_supported_groups_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#define TEST_SUPPORTED_GROUPS_EXTENSION_SIZE (2 + TEST_SUPPORTED_GROUPS_LIST_SIZE)

struct s2n_client_hello_context {
const struct s2n_kem_preferences *kem_preferences;
const struct s2n_ecc_preferences *ecc_preferences;
int invoked_count;
};

Expand All @@ -51,21 +49,22 @@ int s2n_check_received_supported_groups_cb(struct s2n_connection *conn, void *ct
&supported_groups_count, s2n_array_len(supported_groups)));
EXPECT_TRUE(supported_groups_count > 0);

uint16_t expected_groups_count = context->ecc_preferences->count;
const struct s2n_security_policy *security_policy = conn->config->security_policy;
uint16_t expected_groups_count = security_policy->ecc_preferences->count;
if (s2n_connection_get_protocol_version(conn) >= S2N_TLS13 && s2n_pq_is_enabled()) {
expected_groups_count += context->kem_preferences->tls13_kem_group_count;
expected_groups_count += security_policy->kem_preferences->tls13_kem_group_count;
}
EXPECT_EQUAL(supported_groups_count, expected_groups_count);

size_t offset = 0;
for (size_t i = 0; i < context->kem_preferences->tls13_kem_group_count; i++) {
const struct s2n_kem_group *group = context->kem_preferences->tls13_kem_groups[i];
for (size_t i = 0; i < security_policy->kem_preferences->tls13_kem_group_count; i++) {
const struct s2n_kem_group *group = security_policy->kem_preferences->tls13_kem_groups[i];
EXPECT_EQUAL(supported_groups[i], group->iana_id);
offset += 1;
}

for (size_t i = 0; i < context->ecc_preferences->count; i++) {
const struct s2n_ecc_named_curve *curve = context->ecc_preferences->ecc_curves[i];
for (size_t i = 0; i < security_policy->ecc_preferences->count; i++) {
const struct s2n_ecc_named_curve *curve = security_policy->ecc_preferences->ecc_curves[i];
EXPECT_EQUAL(supported_groups[offset + i], curve->iana_id);
}

Expand Down Expand Up @@ -342,8 +341,6 @@ int main(int argc, char **argv)
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(config, security_policies[i]));

struct s2n_client_hello_context context = {
.kem_preferences = config->security_policy->kem_preferences,
.ecc_preferences = config->security_policy->ecc_preferences,
.invoked_count = 0,
};
EXPECT_SUCCESS(s2n_config_set_client_hello_cb(config, s2n_check_received_supported_groups_cb,
Expand Down

0 comments on commit fa8faa3

Please sign in to comment.