make it work on mac os with makefiles

pull/1/head
Jeff 6 years ago
parent 22d4d5b3d0
commit 98f332f7a5

@ -10,14 +10,12 @@ namespace llarp
{ {
struct EncryptedFrame : public Encrypted struct EncryptedFrame : public Encrypted
{ {
static constexpr size_t OverheadSize =
PUBKEYSIZE + TUNNONCESIZE + SHORTHASHSIZE;
EncryptedFrame() = default; EncryptedFrame() = default;
EncryptedFrame(byte_t* buf, size_t sz) : Encrypted(buf, sz) EncryptedFrame(byte_t* buf, size_t sz) : Encrypted(buf, sz)
{ {
} }
EncryptedFrame(size_t sz) : Encrypted(sz + OverheadSize) EncryptedFrame(size_t sz)
: Encrypted(sz + PUBKEYSIZE + TUNNONCESIZE + SHORTHASHSIZE)
{ {
} }
@ -68,7 +66,8 @@ namespace llarp
// TODO: should we own otherKey? // TODO: should we own otherKey?
otherKey = other; otherKey = other;
frame = new EncryptedFrame(buf.sz); frame = new EncryptedFrame(buf.sz);
memcpy(frame->data + EncryptedFrame::OverheadSize, buf.base, buf.sz); memcpy(frame->data + PUBKEYSIZE + TUNNONCESIZE + SHORTHASHSIZE, buf.base,
buf.sz);
user = u; user = u;
llarp_threadpool_queue_job(worker, {this, &Encrypt}); llarp_threadpool_queue_job(worker, {this, &Encrypt});
} }
@ -110,6 +109,6 @@ namespace llarp
llarp_threadpool_queue_job(worker, {this, &Decrypt}); llarp_threadpool_queue_job(worker, {this, &Decrypt});
} }
}; };
} } // namespace llarp
#endif #endif

@ -111,7 +111,7 @@ namespace llarp
auto& hop = ctx->path.hops[ctx->idx]; auto& hop = ctx->path.hops[ctx->idx];
ctx->dh(hop.shared, hop.encryptionKey, hop.nonce, ctx->secretkey); ctx->dh(hop.shared, hop.encryptionKey, hop.nonce, ctx->secretkey);
++ctx->idx; ++ctx->idx;
if(ctx->idx < ctx.path.hops.size()) if(ctx->idx < ctx->path.hops.size())
{ {
llarp_threadpool_queue_job(ctx->worker, {ctx, &GenerateNextKey}); llarp_threadpool_queue_job(ctx->worker, {ctx, &GenerateNextKey});
} }
@ -294,4 +294,4 @@ namespace llarp
}; };
} }
#endif #endif

@ -2,6 +2,8 @@
#include <llarp/encrypted_frame.hpp> #include <llarp/encrypted_frame.hpp>
#include "logger.hpp" #include "logger.hpp"
#define OverheadSize (PUBKEYSIZE + TUNNONCESIZE + SHORTHASHSIZE)
namespace llarp namespace llarp
{ {
Encrypted::Encrypted(const byte_t* buf, size_t sz) Encrypted::Encrypted(const byte_t* buf, size_t sz)

@ -31,6 +31,7 @@
#include <string> #include <string>
#include <iosfwd> #include <iosfwd>
#include <iterator> #include <iterator>
#include <iostream>
namespace cpp17 namespace cpp17
{ {

Loading…
Cancel
Save