Skip to content

Commit

Permalink
cosmetic: rename function so it does not read as a test
Browse files Browse the repository at this point in the history
run clang-format against lib/picotls.c and t/picotls.c
  • Loading branch information
robguima committed Feb 26, 2024
1 parent 61e0403 commit e4c793b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
15 changes: 8 additions & 7 deletions lib/picotls.c
Original file line number Diff line number Diff line change
Expand Up @@ -5131,14 +5131,15 @@ int ptls_export(ptls_t *tls, ptls_buffer_t *output)
if (tls->state != PTLS_STATE_SERVER_POST_HANDSHAKE)
return PTLS_ERROR_LIBRARY;
return export_tls13_params(output, tls->is_server, tls->is_psk_handshake, tls->cipher_suite, tls->client_random,
tls->server_name, negotiated_protocol, tls->traffic_protection.enc.secret, tls->traffic_protection.enc.seq,
tls->traffic_protection.dec.secret, tls->traffic_protection.dec.seq);
tls->server_name, negotiated_protocol, tls->traffic_protection.enc.secret,
tls->traffic_protection.enc.seq, tls->traffic_protection.dec.secret,
tls->traffic_protection.dec.seq);
} else {
return export_tls12_params(output, tls->is_server, tls->is_psk_handshake, tls->cipher_suite, tls->client_random,
tls->server_name, negotiated_protocol, tls->traffic_protection.enc.secret,
tls->traffic_protection.enc.secret + PTLS_MAX_SECRET_SIZE, tls->traffic_protection.enc.seq,
tls->traffic_protection.enc.tls12_enc_record_iv, tls->traffic_protection.dec.secret,
tls->traffic_protection.dec.secret + PTLS_MAX_SECRET_SIZE, tls->traffic_protection.dec.seq);
tls->server_name, negotiated_protocol, tls->traffic_protection.enc.secret,
tls->traffic_protection.enc.secret + PTLS_MAX_SECRET_SIZE, tls->traffic_protection.enc.seq,
tls->traffic_protection.enc.tls12_enc_record_iv, tls->traffic_protection.dec.secret,
tls->traffic_protection.dec.secret + PTLS_MAX_SECRET_SIZE, tls->traffic_protection.dec.seq);
}
}

Expand Down Expand Up @@ -5261,7 +5262,7 @@ int ptls_import(ptls_context_t *ctx, ptls_t **tls, ptls_iovec_t params)
goto Exit;
(*tls)->key_schedule = key_schedule_new((*tls)->cipher_suite, (*tls)->ctx->cipher_suites, (*tls)->ech.aead != NULL);
(*tls)->state = PTLS_STATE_SERVER_POST_HANDSHAKE;
goto Exit;
goto Exit;
default:
ret = PTLS_ALERT_ILLEGAL_PARAMETER;
break;
Expand Down
12 changes: 7 additions & 5 deletions t/picotls.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,22 +891,23 @@ static void aead_keys_cmp(ptls_t *src, ptls_t *dst, const char **err)
ok(memcmp(src_keys[dec_idx].iv, dst_keys[dec_idx].iv, PTLS_MAX_IV_SIZE) == 0);
}

static ptls_t *test_alloc_and_migrate_tls_context(ptls_t *prev_tls)
static ptls_t *alloc_and_migrate_tls_context(ptls_t *prev_tls)
{
ptls_buffer_t sess_data;
ptls_buffer_init(&sess_data, "", 0);
int r = ptls_export(prev_tls, &sess_data);
assert(r == 0);
ptls_t *tls = NULL;
r = ptls_import(ctx_peer, &tls, (ptls_iovec_t){ .base = sess_data.base, .len = sess_data.off });
r = ptls_import(ctx_peer, &tls, (ptls_iovec_t){.base = sess_data.base, .len = sess_data.off});

assert(r == 0);
const char *err = NULL;
aead_keys_cmp(prev_tls, tls, &err);
return tls;
}

static void test_handshake(ptls_iovec_t ticket, int mode, int expect_ticket, int check_ch, int require_client_authentication, int transfer_session)
static void test_handshake(ptls_iovec_t ticket, int mode, int expect_ticket, int check_ch, int require_client_authentication,
int transfer_session)
{
ptls_t *client, *server;
ptls_handshake_properties_t client_hs_prop = {{{{NULL}, ticket}}}, server_hs_prop = {{{{NULL}}}};
Expand Down Expand Up @@ -1113,7 +1114,7 @@ static void test_handshake(ptls_iovec_t ticket, int mode, int expect_ticket, int
ok(ptls_handshake_is_complete(server));
decbuf.off = 0;
cbuf.off = 0;
server = test_alloc_and_migrate_tls_context(original_server);
server = alloc_and_migrate_tls_context(original_server);

ret = ptls_send(server, &sbuf, resp, strlen(resp));
ok(ret == 0);
Expand Down Expand Up @@ -1348,7 +1349,8 @@ static void test_resumption_impl(int different_preferred_key_share, int require_
ctx_peer->encrypt_ticket = &et;
ctx->save_ticket = &st;

test_handshake(saved_ticket, different_preferred_key_share ? TEST_HANDSHAKE_2RTT : TEST_HANDSHAKE_1RTT, 1, 0, 0, transfer_session);
test_handshake(saved_ticket, different_preferred_key_share ? TEST_HANDSHAKE_2RTT : TEST_HANDSHAKE_1RTT, 1, 0, 0,
transfer_session);
ok(server_sc_callcnt == 1);
ok(saved_ticket.base != NULL);

Expand Down

0 comments on commit e4c793b

Please sign in to comment.