Skip to content

Commit

Permalink
print key of both sides
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuho committed Jun 6, 2024
1 parent 135f6b2 commit cfb5f78
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,8 @@ static size_t decode_hexstring(uint8_t *dst, size_t capacity, const char *src)

static int cmd_calc_initial_secret(const char *dcid_hex)
{
uint8_t dcid[QUICLY_MAX_CID_LEN_V1], secret[PTLS_MAX_DIGEST_SIZE];
static const ptls_cipher_suite_t *cs = &ptls_openssl_aes128gcmsha256;
uint8_t dcid[QUICLY_MAX_CID_LEN_V1], server_secret[PTLS_MAX_DIGEST_SIZE], client_secret[PTLS_MAX_DIGEST_SIZE];
size_t dcid_len;

/* decode dcid_hex */
Expand All @@ -1292,13 +1293,14 @@ static int cmd_calc_initial_secret(const char *dcid_hex)

/* calc initial key */
const quicly_salt_t *salt = quicly_get_salt(QUICLY_PROTOCOL_VERSION_1);
if (quicly_calc_initial_keys(&ptls_openssl_aes128gcmsha256, NULL, secret, ptls_iovec_init(dcid, dcid_len), 1,
if (quicly_calc_initial_keys(cs, server_secret, client_secret, ptls_iovec_init(dcid, dcid_len), 1,
ptls_iovec_init(salt->initial, sizeof(salt->initial))) != 0) {
fprintf(stderr, "Crypto failure.\n");
return 1;
}

printf("%s\n", quicly_hexdump(secret, ptls_openssl_aes128gcmsha256.hash->digest_size, SIZE_MAX));
printf("client: %s\nserver: %s\n", quicly_hexdump(client_secret, cs->hash->digest_size, SIZE_MAX),
quicly_hexdump(server_secret, cs->hash->digest_size, SIZE_MAX));

return 0;
}
Expand Down

0 comments on commit cfb5f78

Please sign in to comment.