Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
RouterInfo: sign during router creation
Browse files Browse the repository at this point in the history
Sign, and append the signature, during RouterInfo creation.

Referencing #627 + #917
  • Loading branch information
coneiric committed Jul 1, 2018
1 parent ec3fede commit 012017b
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/core/router/info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -699,15 +699,6 @@ void RouterInfo::CreateBuffer(const PrivateKeys& private_keys)
m_Buffer(
reinterpret_cast<const std::uint8_t*>(router_info.Str().c_str()),
router_info.Str().size());

// Signature
// TODO(anonimal): signing should be done when creating RI, not after. Requires other refactoring.
private_keys.Sign(
m_Buffer.data(),
m_Buffer.size(),
m_Buffer.data() + m_Buffer.size());

m_Buffer(m_Buffer.size() + private_keys.GetPublic().GetSignatureLen());
}
catch (...)
{
Expand Down Expand Up @@ -879,7 +870,17 @@ void RouterInfo::CreateRouterInfo(
// Write remaining options to RI
router_info.Write(options.Str().c_str(), options.Str().size());

// TODO(anonimal): we should implement RI signing *here*
// Ensure signature has proper capacity
std::vector<std::uint8_t> sig_buf(private_keys.GetPublic().GetSignatureLen());

// Sign RI
private_keys.Sign(
reinterpret_cast<const std::uint8_t*>(router_info.Str().c_str()),
router_info.Str().size(),
sig_buf.data());

// Write signature to RI
router_info.Write(sig_buf.data(), sig_buf.size());

LOG(debug) << "RouterInfo: " << __func__
<< " total RI size: " << router_info.Str().size();
Expand Down

0 comments on commit 012017b

Please sign in to comment.