Merge pull request #871 from majestrate/ed25519-signing

Ed25519 signing
pull/870/head
Jeff 5 years ago committed by GitHub
commit 3a6c16aa36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -142,13 +142,6 @@ endif(WOW64_CROSS_COMPILE OR WIN64_CROSS_COMPILE)
if(DEBIAN)
add_definitions(-DDEBIAN)
elseif(NOT ANDROID AND NOT NON_PC_TARGET)
if (NOT USE_AVX2)
# Public binary releases
set(CRYPTO_FLAGS -march=nocona -mtune=core2 -mfpmath=sse)
else()
set(CRYPTO_FLAGS -march=haswell -mtune=native -mfpmath=sse)
endif()
endif()
# only needed if using AVX2

@ -16,6 +16,8 @@ BUILD_TYPE ?= Debug
PYTHON ?= python
PYTHON3 ?= python3
FORMAT ?= clang-format
SETCAP ?= which setcap && setcap cap_net_admin,cap_net_bind_service=+eip
SHADOW_ROOT ?= $(HOME)/.shadow
@ -252,11 +254,11 @@ abyss: debug
$(ABYSS_EXE)
format:
clang-format -i $$(find jni daemon llarp include libabyss | grep -E '\.[h,c](pp)?$$')
$(FORMAT) -i $$(find jni daemon llarp include libabyss | grep -E '\.[h,c](pp)?$$')
format-verify: format
(type clang-format)
clang-format --version
(type $(FORMAT))
$(FORMAT) --version
git diff --quiet || (echo 'Please run make format!!' && git --no-pager diff ; exit 1)
analyze-config: clean

@ -35,11 +35,9 @@
#if !defined Linux
#include <netinet/in.h>
#endif
#if defined Linux
#include <linux/if.h>
#else
#include <net/if.h>
#endif
#if defined Linux
#include <netinet/in.h>
#elif defined(iOS)

@ -138,7 +138,6 @@ set(LIB_SRC
crypto/crypto_libsodium.cpp
crypto/crypto_noop.cpp
crypto/crypto.cpp
crypto/ec.cpp
crypto/encrypted_frame.cpp
crypto/encrypted.cpp
crypto/types.cpp

@ -13,8 +13,6 @@ extern "C"
sodium_init(void);
}
#include "ec.hpp"
namespace llarp
{
namespace sodium
@ -156,91 +154,6 @@ namespace llarp
!= -1;
}
using ec_scalar = AlignedBuffer< 32 >;
struct s_comm final
: public AlignedBuffer< LongHash::SIZE + (ec_scalar::SIZE * 2) >
{
byte_t *
H()
{
return data();
}
byte_t *
K()
{
return data() + LongHash::SIZE;
}
byte_t *
C()
{
return data() + LongHash::SIZE + ec_scalar::SIZE;
}
};
static inline bool
IsNonZero(const byte_t *s)
{
return (((int)(s[0] | s[1] | s[2] | s[3] | s[4] | s[5] | s[6] | s[7]
| s[8] | s[9] | s[10] | s[11] | s[12] | s[13] | s[14]
| s[15] | s[16] | s[17] | s[18] | s[19] | s[20] | s[21]
| s[22] | s[23] | s[24] | s[25] | s[26] | s[27] | s[28]
| s[29] | s[30] | s[31])
- 1)
>> 8)
+ 1;
}
static inline bool
less32(const unsigned char *k0, const unsigned char *k1)
{
for(int n = 31; n >= 0; --n)
{
if(k0[n] < k1[n])
return true;
if(k0[n] > k1[n])
return false;
}
return false;
}
static void
rand32_unbais(byte_t *k)
{
// l = 2^252 + 27742317777372353535851937790883648493.
// it fits 15 in 32 bytes
static const unsigned char limit[32] = {
0xe3, 0x6a, 0x67, 0x72, 0x8b, 0xce, 0x13, 0x29, 0x8f, 0x30, 0x82,
0x8c, 0x0b, 0xa4, 0x10, 0x39, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0};
do
{
randombytes(k, 32);
} while(!IsNonZero(k) && !less32(k, limit));
sc25519_reduce32(k);
}
static bool
check_key(const byte_t *k)
{
ge25519_p3 p;
return ge25519_frombytes_vartime(&p, k) == 0;
}
template < typename T, size_t outsz = ec_scalar::SIZE >
static inline bool
hash_to_scalar(const T &in, byte_t *out)
{
if(crypto_generichash_blake2b(out, outsz, in.data(), in.size(), nullptr,
0)
== -1)
return false;
sc25519_reduce32(out);
return true;
}
static bool
hash(uint8_t *result, const llarp_buffer_t &buff)
{
@ -253,71 +166,28 @@ namespace llarp
CryptoLibSodium::sign(Signature &sig, const SecretKey &secret,
const llarp_buffer_t &buf)
{
s_comm tmp;
if(!hash(tmp.H(), buf))
return false;
ge25519_p3 tmp3;
ec_scalar K;
const PubKey pk = secret.toPublic();
std::copy_n(pk.begin(), pk.size(), tmp.K());
do
{
rand32_unbais(K.data());
if(((const uint32_t *)(K.data()))[7]
== 0) // we don't want tiny numbers here
continue;
ge25519_scalarmult_base(&tmp3, K.data());
ge25519_p3_tobytes(tmp.C(), &tmp3);
hash_to_scalar(tmp, sig.C());
if(!IsNonZero(sig.C()))
continue;
sc25519_mulsub(sig.R(), sig.C(), secret.data(), K.data());
if(!IsNonZero(sig.R()))
continue;
return true;
} while(true);
return crypto_sign_detached(sig.data(), nullptr, buf.base, buf.sz,
secret.data())
!= -1;
}
bool
CryptoLibSodium::verify(const PubKey &pub, const llarp_buffer_t &buf,
const Signature &sig)
{
s_comm tmp;
ge25519_p2 tmp2;
ge25519_p3 tmp3;
ec_scalar C;
std::copy_n(pub.begin(), pub.size(), tmp.K());
if(!hash(tmp.H(), buf))
return false;
if(ge25519_frombytes_vartime(&tmp3, pub.data()) != 0)
return false;
if(sc25519_check(sig.C()) != 0 || sc25519_check(sig.R()) != 0
|| !IsNonZero(sig.C()))
return false;
ge25519_double_scalarmult_base_vartime(&tmp2, sig.C(), &tmp3, sig.R());
ge25519_tobytes(tmp.C(), &tmp2);
static const ec_scalar infinity{{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
if(memcmp(tmp.C(), &infinity, 32) == 0)
return false;
hash_to_scalar(tmp, C.data());
sc25519_sub(C.data(), C.data(), sig.C());
return !IsNonZero(C.data());
return crypto_sign_verify_detached(sig.data(), buf.base, buf.sz,
pub.data())
!= -1;
}
bool
CryptoLibSodium::seed_to_secretkey(llarp::SecretKey &secret,
const llarp::IdentitySecret &seed)
{
if(sc25519_check(seed.data()) != 0)
return false;
ge25519_p3 A;
std::copy_n(seed.begin(), 32, secret.begin());
ge25519_scalarmult_base(&A, seed.data());
byte_t *pub = secret.data() + 32;
ge25519_p3_tobytes(pub, &A);
return true;
PubKey pk;
return crypto_sign_ed25519_seed_keypair(pk.data(), secret.data(),
seed.data())
!= -1;
}
void
@ -335,16 +205,18 @@ namespace llarp
void
CryptoLibSodium::identity_keygen(llarp::SecretKey &keys)
{
llarp::IdentitySecret seed;
rand32_unbais(seed.data());
seed_to_secretkey(keys, seed);
PubKey pk;
int result = crypto_sign_keypair(pk.data(), keys.data());
assert(result != -1);
const PubKey sk_pk = keys.toPublic();
assert(pk == sk_pk);
}
void
CryptoLibSodium::encryption_keygen(llarp::SecretKey &keys)
{
auto d = keys.data();
rand32_unbais(d);
randbytes(d, 32);
crypto_scalarmult_curve25519_base(d + 32, d);
}

@ -52,6 +52,7 @@ namespace llarp
bool
verify(const PubKey &, const llarp_buffer_t &,
const Signature &) override;
/// seed to secretkey
bool
seed_to_secretkey(llarp::SecretKey &,

File diff suppressed because it is too large Load Diff

@ -1,46 +0,0 @@
#ifndef LLARP_CRYPTO_EC_HPP
#define LLARP_CRYPTO_EC_HPP
#include "types.hpp"
extern "C"
{
#include <sodium/private/ed25519_ref10.h>
}
namespace llarp
{
namespace sodium
{
void
sc25519_reduce32(byte_t *s);
/*
Input:
a[0]+256*a[1]+...+256^31*a[31] = a
b[0]+256*b[1]+...+256^31*b[31] = b
c[0]+256*c[1]+...+256^31*c[31] = c
Output:
s[0]+256*s[1]+...+256^31*s[31] = (c-ab) mod l
where l = 2^252 + 27742317777372353535851937790883648493.
*/
void
sc25519_mulsub(byte_t *s, const byte_t *a, const byte_t *b,
const byte_t *c);
void
sc25519_sub(byte_t *, const byte_t *, const byte_t *);
int
ge25519_frombytes_vartime(ge25519_p3 *, const byte_t *);
int
sc25519_check(const byte_t *);
void
ge25519_double_scalarmult_base_vartime(ge25519_p2 *, const byte_t *,
const ge25519_p3 *, const byte_t *);
} // namespace sodium
} // namespace llarp
#endif

@ -20,6 +20,7 @@ typedef SSIZE_T ssize_t;
#else
#include <netinet/in.h>
#include <sys/socket.h>
#include <net/net_if.hpp>
#endif
#include <memory>

@ -1,6 +1,7 @@
#include <ev/ev_libuv.hpp>
#include <net/net_addr.hpp>
#include <util/thread/logic.hpp>
#include <util/thread/queue.hpp>
#include <cstring>
@ -24,6 +25,33 @@ namespace libuv
/// tcp connection glue between llarp and libuv
struct conn_glue : public glue
{
using WriteBuffer_t = std::vector< char >;
struct WriteEvent
{
WriteBuffer_t data;
uv_write_t request;
WriteEvent() = default;
explicit WriteEvent(WriteBuffer_t buf) : data(std::move(buf))
{
request.data = this;
}
uv_buf_t
Buffer()
{
return uv_buf_init(data.data(), data.size());
}
uv_write_t*
Request()
{
return &request;
}
};
uv_tcp_t m_Handle;
uv_connect_t m_Connect;
uv_check_t m_Ticker;
@ -31,11 +59,11 @@ namespace libuv
llarp_tcp_acceptor* const m_Accept;
llarp_tcp_conn m_Conn;
llarp::Addr m_Addr;
std::deque< std::vector< char > > m_WriteQueue;
llarp::thread::Queue< WriteBuffer_t > m_WriteQueue;
uv_async_t m_WriteNotify;
conn_glue(uv_loop_t* loop, llarp_tcp_connecter* tcp, const sockaddr* addr)
: m_TCP(tcp), m_Accept(nullptr), m_Addr(*addr)
: m_TCP(tcp), m_Accept(nullptr), m_Addr(*addr), m_WriteQueue(32)
{
m_Connect.data = this;
m_Handle.data = this;
@ -43,24 +71,29 @@ namespace libuv
uv_tcp_init(loop, &m_Handle);
m_Ticker.data = this;
uv_check_init(loop, &m_Ticker);
m_Conn.close = &ExplicitClose;
m_Conn.write = &ExplicitWrite;
m_Conn.close = &ExplicitClose;
m_Conn.write = &ExplicitWrite;
m_WriteNotify.data = this;
uv_async_init(loop, &m_WriteNotify, &OnShouldWrite);
}
conn_glue(uv_loop_t* loop, llarp_tcp_acceptor* tcp, const sockaddr* addr)
: m_TCP(nullptr), m_Accept(tcp), m_Addr(*addr)
: m_TCP(nullptr), m_Accept(tcp), m_Addr(*addr), m_WriteQueue(32)
{
m_Connect.data = nullptr;
m_Handle.data = this;
uv_tcp_init(loop, &m_Handle);
m_Ticker.data = this;
uv_check_init(loop, &m_Ticker);
m_Accept->close = &ExplicitCloseAccept;
m_Conn.write = nullptr;
m_Conn.closed = nullptr;
m_Accept->close = &ExplicitCloseAccept;
m_Conn.write = nullptr;
m_Conn.closed = nullptr;
m_WriteNotify.data = this;
uv_async_init(loop, &m_WriteNotify, &OnShouldWrite);
}
conn_glue(conn_glue* parent) : m_TCP(nullptr), m_Accept(nullptr)
conn_glue(conn_glue* parent)
: m_TCP(nullptr), m_Accept(nullptr), m_WriteQueue(32)
{
m_Connect.data = nullptr;
m_Conn.close = &ExplicitClose;
@ -69,6 +102,8 @@ namespace libuv
uv_tcp_init(parent->m_Handle.loop, &m_Handle);
m_Ticker.data = this;
uv_check_init(parent->m_Handle.loop, &m_Ticker);
m_WriteNotify.data = this;
uv_async_init(parent->m_Handle.loop, &m_WriteNotify, &OnShouldWrite);
}
static void
@ -177,32 +212,50 @@ namespace libuv
static void
OnWritten(uv_write_t* req, int status)
{
conn_glue* conn = static_cast< conn_glue* >(req->data);
if(status)
WriteEvent* ev = static_cast< WriteEvent* >(req->data);
if(status == 0)
{
llarp::LogError("write failed on tcp: ", uv_strerror(status));
conn->Close();
llarp::LogDebug("wrote ", ev->data.size());
}
else
Call(conn->Stream(), std::bind(&conn_glue::DrainOne, conn));
delete req;
{
llarp::LogDebug("write fail");
}
delete ev;
}
void
DrainOne()
int
WriteAsync(char* data, size_t sz)
{
m_WriteQueue.pop_front();
if(uv_is_closing((const uv_handle_t*)&m_Handle))
return -1;
if(uv_is_closing((const uv_handle_t*)&m_WriteNotify))
return -1;
WriteBuffer_t buf(sz);
std::copy_n(data, sz, buf.begin());
if(m_WriteQueue.pushBack(std::move(buf))
== llarp::thread::QueueReturn::Success)
{
uv_async_send(&m_WriteNotify);
return sz;
}
return -1;
}
int
WriteAsync(char* data, size_t sz)
void
FlushWrite()
{
m_WriteQueue.emplace_back(sz);
std::copy_n(data, sz, m_WriteQueue.back().begin());
auto buf = uv_buf_init(m_WriteQueue.back().data(), sz);
auto* req = new uv_write_t();
req->data = this;
return uv_write(req, Stream(), &buf, 1, &OnWritten) == 0 ? sz : 0;
while(not m_WriteQueue.empty())
{
auto data = m_WriteQueue.popFront();
WriteEvent* ev = new WriteEvent(std::move(data));
auto buf = ev->Buffer();
if(uv_write(ev->Request(), Stream(), &buf, 1, &OnWritten) != 0)
{
Close();
return;
}
}
}
static void
@ -249,15 +302,25 @@ namespace libuv
delete shut;
}
static void
OnWriteClosed(uv_handle_t* h)
{
conn_glue* conn = static_cast< conn_glue* >(h->data);
auto* shut = new uv_shutdown_t();
shut->data = conn;
uv_shutdown(shut, conn->Stream(), &OnShutdown);
}
void
Close() override
{
if(uv_is_closing((uv_handle_t*)&m_WriteNotify))
return;
llarp::LogDebug("close tcp connection");
m_WriteQueue.disable();
uv_close((uv_handle_t*)&m_WriteNotify, &OnWriteClosed);
uv_check_stop(&m_Ticker);
uv_read_stop(Stream());
auto* shut = new uv_shutdown_t();
shut->data = this;
uv_shutdown(shut, Stream(), &OnShutdown);
}
static void
@ -274,6 +337,12 @@ namespace libuv
}
}
static void
OnShouldWrite(uv_async_t* h)
{
static_cast< conn_glue* >(h->data)->FlushWrite();
}
static void
OnTick(uv_check_t* t)
{
@ -714,20 +783,19 @@ namespace libuv
bool
Loop::init()
{
m_Impl.reset(uv_loop_new());
if(uv_loop_init(m_Impl.get()) == -1)
if(uv_loop_init(&m_Impl) == -1)
return false;
m_Impl->data = this;
uv_loop_configure(m_Impl.get(), UV_LOOP_BLOCK_SIGNAL, SIGPIPE);
m_Impl.data = this;
uv_loop_configure(&m_Impl, UV_LOOP_BLOCK_SIGNAL, SIGPIPE);
m_TickTimer.data = this;
m_Run.store(true);
return uv_timer_init(m_Impl.get(), &m_TickTimer) != -1;
return uv_timer_init(&m_Impl, &m_TickTimer) != -1;
}
void
Loop::update_time()
{
uv_update_time(m_Impl.get());
uv_update_time(&m_Impl);
}
bool
@ -745,7 +813,7 @@ namespace libuv
bool
Loop::tcp_connect(llarp_tcp_connecter* tcp, const sockaddr* addr)
{
auto* impl = new conn_glue(m_Impl.get(), tcp, addr);
auto* impl = new conn_glue(&m_Impl, tcp, addr);
tcp->impl = impl;
if(impl->ConnectAsync())
return true;
@ -764,14 +832,14 @@ namespace libuv
Loop::tick(int ms)
{
uv_timer_start(&m_TickTimer, &OnTickTimeout, ms, 0);
uv_run(m_Impl.get(), UV_RUN_ONCE);
uv_run(&m_Impl, UV_RUN_ONCE);
return 0;
}
void
Loop::stop()
{
uv_stop(m_Impl.get());
uv_stop(&m_Impl);
llarp::LogInfo("stopping event loop");
m_Run.store(false);
CloseAll();
@ -782,7 +850,7 @@ namespace libuv
{
llarp::LogInfo("Closing all handles");
uv_walk(
m_Impl.get(),
&m_Impl,
[](uv_handle_t* h, void*) {
if(uv_is_closing(h))
return;
@ -804,7 +872,7 @@ namespace libuv
bool
Loop::udp_listen(llarp_udp_io* udp, const sockaddr* src)
{
auto* impl = new udp_glue(m_Impl.get(), udp, src);
auto* impl = new udp_glue(&m_Impl, udp, src);
udp->impl = impl;
if(impl->Bind())
{
@ -817,7 +885,7 @@ namespace libuv
bool
Loop::add_ticker(std::function< void(void) > func)
{
auto* ticker = new ticker_glue(m_Impl.get(), func);
auto* ticker = new ticker_glue(&m_Impl, func);
if(ticker->Start())
{
return true;
@ -843,7 +911,7 @@ namespace libuv
{
auto* glue = new tun_glue(tun);
tun->impl = glue;
if(glue->Init(m_Impl.get()))
if(glue->Init(&m_Impl))
{
return true;
}
@ -854,7 +922,7 @@ namespace libuv
bool
Loop::tcp_listen(llarp_tcp_acceptor* tcp, const sockaddr* addr)
{
auto* glue = new conn_glue(m_Impl.get(), tcp, addr);
auto* glue = new conn_glue(&m_Impl, tcp, addr);
tcp->impl = glue;
if(glue->Server())
return true;
@ -866,7 +934,7 @@ namespace libuv
bool
Loop::add_pipe(llarp_ev_pkt_pipe* p)
{
auto* glue = new pipe_glue(m_Impl.get(), p);
auto* glue = new pipe_glue(&m_Impl, p);
if(glue->Start())
return true;
delete glue;

@ -104,16 +104,7 @@ namespace libuv
}
private:
struct DestructLoop
{
void
operator()(uv_loop_t* l) const
{
uv_loop_close(l);
}
};
std::unique_ptr< uv_loop_t, DestructLoop > m_Impl;
uv_loop_t m_Impl;
uv_timer_t m_TickTimer;
std::atomic< bool > m_Run;
std::shared_ptr< llarp::Logic > m_Logic;

@ -1,33 +1,18 @@
#include <net/net.hpp>
#include <net/net_if.hpp>
#ifdef ANDROID
#include <android/ifaddrs.h>
#endif
#ifndef _WIN32
#include <arpa/inet.h>
#endif
#ifndef ANDROID
#include <ifaddrs.h>
#endif
// Work around for broken glibc/linux header definitions in xenial that makes
// including both net/if.h (which we need for if_nametoindex) and linux/if.h
// (which tuntap.h includes) impossible. When we stop supporting xenial we can
// remove this mess and just include net/if.h here.
#if defined(Linux) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 23
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) \
&& LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
#define _NET_IF_H 1
#include <linux/if.h>
extern "C" unsigned int
if_nametoindex(const char* __ifname) __THROW;
#endif
#else
#include <net/if.h>
#endif
#endif
#include <net/net_addr.hpp>
#include <net/ip.hpp>
#include <util/logging/logger.hpp>

@ -0,0 +1,26 @@
#ifndef LLARP_NET_NET_IF_HPP
#define LLARP_NET_NET_IF_HPP
#ifndef _WIN32
// this file is a shim include for #include <net/if.h>
// Work around for broken glibc/linux header definitions in xenial that makes
// including both net/if.h (which we need for if_nametoindex) and linux/if.h
// (which tuntap.h includes) impossible. When we stop supporting xenial we can
// remove this mess and just include net/if.h here.
#if defined(Linux) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 23
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) \
&& LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
#define _NET_IF_H 1
#ifndef IFNAMSIZ
#define IFNAMSIZ (16)
#endif
#include <linux/if.h>
extern "C" unsigned int
if_nametoindex(const char* __ifname) __THROW;
#endif
#else
#include <net/if.h>
#endif
#endif
#endif

@ -33,6 +33,8 @@ namespace llarp
void
RCLookupHandler::SetRouterWhitelist(const std::vector< RouterID > &routers)
{
if(routers.empty())
return;
util::Lock l(&_mutex);
whitelistRouters.clear();

@ -71,39 +71,41 @@ namespace llarp
HandleJSONResult(const nlohmann::json& result) override
{
PubkeyList_t keys;
if(!result.is_object())
if(not result.is_object())
{
LogWarn("Invalid result: not an object");
handler({}, false);
return false;
}
const auto itr = result.find("keys");
const auto itr = result.find("service_node_states");
if(itr == result.end())
{
LogWarn("Invalid result: no keys member");
LogWarn("Invalid result: no service_node_states member");
handler({}, false);
return false;
}
if(!itr.value().is_array())
if(not itr.value().is_array())
{
LogWarn("Invalid result: keys is not an array");
LogWarn("Invalid result: service_node_states is not an array");
handler({}, false);
return false;
}
for(const auto item : itr.value())
{
if(item.is_string())
{
keys.emplace_back();
std::string str = item.get< std::string >();
if(!Base32Decode(str, keys.back()))
{
LogWarn("Invalid key: ", str);
keys.pop_back();
}
}
if(not item.is_object())
continue;
if(not item.value("active", false))
continue;
if(not item.value("funded", false))
continue;
const std::string pk = item.value("pubkey_ed25519", "");
if(pk.empty())
continue;
PubKey k;
if(k.FromString(pk))
keys.emplace_back(std::move(k));
}
handler(keys, true);
handler(keys, not keys.empty());
return true;
}
@ -147,7 +149,10 @@ namespace llarp
AsyncUpdatePubkeyList()
{
LogInfo("Updating service node list");
QueueRPC("get_all_service_nodes_keys", nlohmann::json::object(),
nlohmann::json params = {
{"fields",
{{"pubkey_ed25519", true}, {"active", true}, {"funded", true}}}};
QueueRPC("get_n_service_nodes", std::move(params),
util::memFn(&CallerImpl::NewAsyncUpdatePubkeyListConn, this));
}

@ -15,6 +15,13 @@ namespace llarp
}
};
TEST_F(IdentityKeyTest, TestKeyGen)
{
SecretKey secret;
crypto.identity_keygen(secret);
ASSERT_FALSE(secret.IsZero());
}
TEST_F(IdentityKeyTest, TestSignVerify)
{
SecretKey secret;
@ -23,7 +30,7 @@ namespace llarp
random.Randomize();
Signature sig;
llarp_buffer_t buf(random);
const llarp_buffer_t buf(random);
ASSERT_TRUE(crypto.sign(sig, secret, buf));
ASSERT_TRUE(crypto.verify(secret.toPublic(), buf, sig));
random.Randomize();

@ -25,6 +25,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <tuntap.h>
#ifdef __sun
#define BSD_COMP
#define TUNSDEBUG _IOW('t', 90, int)
@ -39,6 +41,7 @@
#if defined(Linux)
#include <linux/if_tun.h>
#include <linux/if_ether.h>
#include <linux/if.h>
#else
#include <net/if.h>
@ -62,7 +65,6 @@
#include <time.h>
#include <unistd.h>
#include <tuntap.h>
int
tuntap_start(struct device *dev, int mode, int tun)
@ -380,7 +382,7 @@ tuntap_set_debug(struct device *dev, int set)
}
#ifndef Darwin
if(ioctl(dev->tun_fd, TUNSDEBUG, &set) == -1)
if(ioctl(dev->tun_fd, TUNSETDEBUG, &set) == -1)
{
switch(set)
{

Loading…
Cancel
Save