Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channels fix: Resolve lts_compatibility test failures #3035

Merged
merged 4 commits into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/node/channels.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ namespace ccf
{
// Whatever else we _were_ doing, we've received a valid init from them
// - reset to use it
kex_ctx.reset();
if (status.check(ESTABLISHED))
{
kex_ctx.reset();
}
peer_cert = cert;
peer_cv = verifier;
}
Expand Down
19 changes: 12 additions & 7 deletions src/tls/key_exchange.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,28 @@ namespace tls
throw std::runtime_error("Missing peer key share");
}

int rc = mbedtls_ecdh_read_public(ctx.get(), ks.p, ks.n);
if (rc != 0)
{
throw std::logic_error(error_string(rc));
}

peer_key_share = {ks.p, ks.p + ks.n};
}

std::vector<uint8_t> compute_shared_secret()
{
int rc;
if (peer_key_share.size() > 0)
{
rc = mbedtls_ecdh_read_public(
ctx.get(), peer_key_share.data(), peer_key_share.size());
if (rc != 0)
{
throw std::logic_error(error_string(rc));
}
}

crypto::EntropyPtr entropy = crypto::create_entropy();

// Should only be called once, when peer public has been loaded.
std::vector<uint8_t> shared_secret(len_shared_secret);
size_t len;
int rc = mbedtls_ecdh_calc_secret(
rc = mbedtls_ecdh_calc_secret(
ctx.get(),
&len,
shared_secret.data(),
Expand Down