Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 9 additions & 9 deletions src/security/tls/tls_details.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ namespace libp2p::security::tls_details {
constexpr size_t prefix_size = sign_prefix.size();
size_t msg_len = prefix_size + cert_pub_key.size();

uint8_t buf[msg_len]; // NOLINT
memcpy(buf, sign_prefix.data(), sign_prefix.size());
memcpy(buf + sign_prefix.size(), // NOLINT
std::vector<uint8_t> buf(msg_len);
memcpy(buf.data(), sign_prefix.data(), sign_prefix.size());
memcpy(buf.data() + sign_prefix.size(),
cert_pub_key.data(),
cert_pub_key.size());

Expand Down Expand Up @@ -203,8 +203,8 @@ namespace libp2p::security::tls_details {
void assignSerial(X509 *cert) {
BIGNUM *bn = BN_new();
CLEANUP_PTR(bn, BN_free);
if (BN_pseudo_rand(bn, 64, 0, 0) == 0) {
throw std::runtime_error("BN_pseudo_rand failed");
if (BN_rand(bn, 64, 0, 0) == 0) {
throw std::runtime_error("BN_rand failed");
}

ASN1_INTEGER *rand_int = ASN1_INTEGER_new();
Expand Down Expand Up @@ -402,13 +402,13 @@ namespace libp2p::security::tls_details {
constexpr size_t prefix_size = sign_prefix.size();

size_t msg_len = prefix_size + len;
uint8_t buf[msg_len]; // NOLINT
memcpy(buf, sign_prefix.data(), prefix_size);
uint8_t *b = buf + prefix_size; // NOLINT
std::vector<uint8_t> buf(msg_len);
memcpy(buf.data(), sign_prefix.data(), prefix_size);
uint8_t *b = buf.data() + prefix_size;
i2d_PUBKEY(cert_pubkey, &b);

auto verify_res = crypto::ed25519::Ed25519ProviderImpl{}.verify(
BytesIn(buf, buf + msg_len), // NOLINT
BytesIn(buf.data(), buf.data() + msg_len),
signature,
ed25519pkey);

Expand Down
3 changes: 1 addition & 2 deletions src/transport/tcp/tcp_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ namespace libp2p::transport {
auto &[info, layers] = r.value();
auto conn = std::make_shared<TcpConnection>(*context_, layers);
auto connect =
[=,
self{shared_from_this()},
[self{shared_from_this()},
handler{std::move(handler)},
layers = std::move(layers)](
outcome::result<boost::asio::ip::tcp::resolver::results_type>
Expand Down
Loading