GithubHelp home page GithubHelp logo

telehash / telehash-c Goto Github PK

View Code? Open in Web Editor NEW
122.0 28.0 31.0 6.07 MB

telehash tools library in c

License: MIT License

C 28.44% C++ 61.91% Objective-C 0.04% Shell 0.02% Makefile 0.47% JavaScript 1.39% Pawn 4.58% SourcePawn 3.09% CMake 0.06%

telehash-c's Introduction

telehash tools library in c

This is a full implementation of telehash in portable c for embedded systems, designed to be source that can be copied into other projects.

Building

Just run make to build a libtelehash.a and some utility apps into bin/*. Use make test to run a full test suite, and make static to generate a current standalone telehash.c and telehash.h.

Use npm install to automatically install optional crypto dependencies (libsodium and libtomcrypt).

Library Interface

The codebase is a set of components that can be used to create/integrate telehash services, here's a rough layout, see src/ and include/ for details.

  • e3x_*: all of the crypto handling
  • mesh_* and link_*: higher level easy interfaces for apps
  • ext_*: various useful extensions to a mesh to support built-in channels
  • pipe_* and net_*: transport and networking handling
  • util_* and libs: portable utilities and bundled libs

There's many examples of usage in the bundled tests.

Memory Notes

Most of the codebase uses lob_t as the primary data type since it handles JSON and binary for all packets.

The following methods return generated lobs (you must free):

  • e3x_channel_receiving
  • e3x_channel_sending
  • e3x_channel_oob
  • e3x_channel_packet
  • e3x_self_decrypt
  • e3x_exchange_message
  • e3x_exchange_handshake
  • e3x_exchange_receive
  • link_handshakes
  • link_sync
  • link_resync
  • mesh_on_open (callback must return or free the given lob)

And these methods consume lobs (will be free'd):

  • e3x_channel_receive
  • e3x_channel_send
  • link_handshake
  • link_receive
  • link_receive_handshake
  • link_send
  • link_flush
  • link_direct
  • mesh_handshake
  • mesh_handshakes
  • mesh_receive
  • mesh_receive_handshake

telehash-c's People

Contributors

alanz avatar dwaite avatar fd avatar jbdatko avatar mathias avatar quartzjer avatar simmons avatar sstorm avatar ukscone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

telehash-c's Issues

idgen always generates AAAAAAAAAAAAAAAAAAAA*

On my laptop (Debian amd64 unstable), every time I use idgen, I get a new 1a_secret that starts with a bunch of AAAAAAAAAA. For example, "1a_secret":"AAAAAAAAAAAAAAAAAAAAjgSzlPg=" This is worrying because no entropy.

This does not happen on another machine I tried (Debian i386 unstable), which generates 1a_secrets that seem to differ substantially each time.

Define a security vulnerability reporting procedure

There should be a way to securely report security vulnerabilities. It should be on the README or a link to a generic telehash one.

But it should be clear that github is not the place to do this. Ideally there should be a GPG key to send this to but some companies have a security reporting template.

malloc free lob parser

For embedded micro-controllers it would be better to have a lob parser that doesn't need malloc etc.

qsort_r funny in lib/packet.c

On linux the last two parameters of qsort_r seem to be swapped.

I need to replace

qsort_r(p->js,keys,sizeof(unsigned short)*4,p->json,pkeycmp);

with

qsort_r(p->js,keys,sizeof(unsigned short)*4,pkeycmp,p->json);

otherwise it segfaults.

What is the best way of resolving this?

Do we have a complete example?

Hi, all

I am looking for a complete example with router and two endpoints.

After looking at the code under tests, seems no one fits my expectation.

Do we have one to demonstrate how to use this library?

Error on "make test" after npm install telehash-c (OSX)

ld: can't open output file for writing: bin/test_lib_base32, errno=2 for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [bin/test_lib_base32] Error 1
make: *** [test] Error 2

The reason: There is a telehash-c/test/bin directory in the telehash-c repository. However, there is no telehash-c/test/bin directory after an npm install telehash-c on OSX. Does the .gitignore file in test/bin cause the directory to be skipped?

Mesh networking across multiple transports and platforms

Hello, on telehash.org, it states that telehash can, "enable mesh networking across multiple transports and platforms". Is there documentation related to enabling a mesh network? Perhaps a tutorial for doing so? I am interested in building a mesh network among arduino nodes. It would be great if I can add additional nodes that are outside of the arduino ecosystem. I appreciate any insight,.

Thank You

make fails on Ubuntu 15.04

cloned fresh repo, ran make on master and build fails with:

jbd@magrathea ~/repos/telehash-c (master) $ make
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/lib/lob.c -o src/lib/lob.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/lib/hashname.c -o src/lib/hashname.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/lib/xht.c -o src/lib/xht.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/lib/js0n.c -o src/lib/js0n.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/lib/base32.c -o src/lib/base32.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/lib/chacha.c -o src/lib/chacha.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/lib/murmur.c -o src/lib/murmur.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/e3x.c -o src/e3x/e3x.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/channel.c -o src/e3x/channel.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/self.c -o src/e3x/self.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/exchange.c -o src/e3x/exchange.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/event.c -o src/e3x/event.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/cipher.c -o src/e3x/cipher.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/mesh.c -o src/mesh.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/link.c -o src/link.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/pipe.c -o src/pipe.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/ext/stream.c -o src/ext/stream.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/ext/block.c -o src/ext/block.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/net/loopback.c -o src/net/loopback.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/net/udp4.c -o src/net/udp4.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/net/tcp4.c -o src/net/tcp4.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/net/serial.c -o src/net/serial.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/util/util.c -o src/util/util.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/util/uri.c -o src/util/uri.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/util/chunks.c -o src/util/chunks.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/unix/util.c -o src/unix/util.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/unix/util_sys.c -o src/unix/util_sys.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/cs1a/aes.c -o src/e3x/cs1a/aes.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/cs1a/hmac.c -o src/e3x/cs1a/hmac.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/cs1a/aes128.c -o src/e3x/cs1a/aes128.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/cs1a/cs1a.c -o src/e3x/cs1a/cs1a.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/cs1a/uECC.c -o src/e3x/cs1a/uECC.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/cs1a/sha256.c -o src/e3x/cs1a/sha256.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/cs2a_disabled.c -o src/e3x/cs2a_disabled.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/e3x/cs3a_disabled.c -o src/e3x/cs3a_disabled.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c util/idgen.c -o util/idgen.o
gcc -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -o bin/idgen src/lib/lob.o src/lib/hashname.o src/lib/xht.o src/lib/js0n.o src/lib/base32.o src/lib/chacha.o src/lib/murmur.o src/e3x/e3x.o src/e3x/channel.o src/e3x/self.o src/e3x/exchange.o src/e3x/event.o src/e3x/cipher.o src/mesh.o src/link.o src/pipe.o src/ext/stream.o src/ext/block.o src/net/loopback.o src/net/udp4.o src/net/tcp4.o src/net/serial.o src/util/util.o src/util/uri.o src/util/chunks.o src/unix/util.o src/unix/util_sys.o src/e3x/cs1a/aes.o src/e3x/cs1a/hmac.o src/e3x/cs1a/aes128.o src/e3x/cs1a/cs1a.o src/e3x/cs1a/uECC.o src/e3x/cs1a/sha256.o src/e3x/cs2a_disabled.o src/e3x/cs3a_disabled.o util/idgen.o 
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c util/router.c -o util/router.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/ext/router.c -o src/ext/router.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/ext/path.c -o src/ext/path.o
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c src/ext/peer.c -o src/ext/peer.o
gcc -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -o bin/router src/lib/lob.o src/lib/hashname.o src/lib/xht.o src/lib/js0n.o src/lib/base32.o src/lib/chacha.o src/lib/murmur.o src/e3x/e3x.o src/e3x/channel.o src/e3x/self.o src/e3x/exchange.o src/e3x/event.o src/e3x/cipher.o src/mesh.o src/link.o src/pipe.o src/ext/stream.o src/ext/block.o src/net/loopback.o src/net/udp4.o src/net/tcp4.o src/net/serial.o src/util/util.o src/util/uri.o src/util/chunks.o src/unix/util.o src/unix/util_sys.o src/e3x/cs1a/aes.o src/e3x/cs1a/hmac.o src/e3x/cs1a/aes128.o src/e3x/cs1a/cs1a.o src/e3x/cs1a/uECC.o src/e3x/cs1a/sha256.o src/e3x/cs2a_disabled.o src/e3x/cs3a_disabled.o util/router.o src/ext/router.o src/ext/path.o src/ext/peer.o 
gcc -Iinclude -Iinclude/lib -Iunix -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -c util/ping.c -o util/ping.o
gcc -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -o bin/ping src/lib/lob.o src/lib/hashname.o src/lib/xht.o src/lib/js0n.o src/lib/base32.o src/lib/chacha.o src/lib/murmur.o src/e3x/e3x.o src/e3x/channel.o src/e3x/self.o src/e3x/exchange.o src/e3x/event.o src/e3x/cipher.o src/mesh.o src/link.o src/pipe.o src/ext/stream.o src/ext/block.o src/net/loopback.o src/net/udp4.o src/net/tcp4.o src/net/serial.o src/util/util.o src/util/uri.o src/util/chunks.o src/unix/util.o src/unix/util_sys.o src/e3x/cs1a/aes.o src/e3x/cs1a/hmac.o src/e3x/cs1a/aes128.o src/e3x/cs1a/cs1a.o src/e3x/cs1a/uECC.o src/e3x/cs1a/sha256.o src/e3x/cs2a_disabled.o src/e3x/cs3a_disabled.o util/ping.o src/ext/path.o 
rm -f libtelehash.a
ar crs libtelehash.a src/lib/lob.o src/lib/hashname.o src/lib/xht.o src/lib/js0n.o src/lib/base32.o src/lib/chacha.o src/lib/murmur.o src/e3x/e3x.o src/e3x/channel.o src/e3x/self.o src/e3x/exchange.o src/e3x/event.o src/e3x/cipher.o src/mesh.o src/link.o src/pipe.o src/ext/stream.o src/ext/block.o src/net/loopback.o src/net/udp4.o src/net/tcp4.o src/net/serial.o src/util/util.o src/util/uri.o src/util/chunks.o src/unix/util.o src/unix/util_sys.o src/e3x/cs1a/aes.o src/e3x/cs1a/hmac.o src/e3x/cs1a/aes128.o src/e3x/cs1a/cs1a.o src/e3x/cs1a/uECC.o src/e3x/cs1a/sha256.o src/e3x/cs2a_disabled.o src/e3x/cs3a_disabled.o
sed: can't read /#include "/d: No such file or directory
Makefile:61: recipe for target 'static' failed
make: *** [static] Error 2

test_ext_peer sometimes segfaults

I think this distinct from #58. Sometimes instead of the unit tests failing as in that issue, the process itself actually segfaults!

You can view the full log at https://gist.github.com/natevw/26913782be7b00299c55 but here's the most interesting bit:

test_ext_peer(94169,0x7fff74824300) malloc: *** mach_vm_map(size=12270707960932937728) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
/bin/sh: line 1: 94169 Segmentation fault: 11  ./bin/test_$test

…seems that was a lucky capture, as usually it's a pretty silent segfault but this time there was some debug information. That seems like a pretty extreme size to be mapping (allocating?) so I wonder if this is related more to #64.

Actually running under a debugger to get a stacktrace should narrow down the cause even more, but I'm leaving this here for later to continue with the other problem I'm trying to track down.

Apparently corrupted lob

While debugging #58 I noticed the following log message:

src/link.c:258 link_receive_handshake() old/bad at: {"at":1437777722 (1437777722,0,1437777723)

This is generated by:

LOG("old/bad at: %s (%d,%d,%d)",lob_json(inner),lob_get_int(inner,"at"),e3x_exchange_in(link->x,0),e3x_exchange_out(link->x,0));

Why is the lob_json call returning the string {"at":1437777722 [sic] — i.e., with an unclosed brace? Looks like the result of lob_json is a verbatim copy of the lob's head, so it seems that something is corrupting the lob itself?

Crypto abstraction for hardware

I'm still reading the code, so this may be a non-issue, but is there a concept of a crypto-abstraction layer for devices that have hardware support?

While people are quick to throw out "pkcs11" as _the_ abstraction for these things, I'm not sure it makes sense here (or most places ;) ). Some SoCs have support for hardware acceleration and it might be nice to plan for some ability to switch between software and hardware implementations.

Simple client compilation fails

Hi guys,

I've generated standalone telehash.h and telehash.c (also added peer.c as a source as I need some methods from there) and created a simple telehash client that uses it.

Currently I got a bunch of compilation errors:

gcc -Iinclude -Iinclude/lib -Iunix -Ithrowback -g -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DDEBUG -c telehash.c -o telehash.o
telehash.c: In function ‘lob_set_printf’:
telehash.c:254:3: warning: implicit declaration of function ‘vasprintf’ [-Wimplicit-function-declaration]
   vasprintf(&val, format, ap);
   ^
telehash.c: In function ‘util_frames_await’:
telehash.c:7940:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if((frames->out * PAYLOAD(frames)) > lob_len(frames->outbox)) return frames;
                                      ^
telehash.c: In function ‘peer_send’:
telehash.c:9118:45: error: ‘struct pipe_struct’ has no member named ‘arg’
   if(!(router = mesh_linkid(link->mesh, pipe->arg)))
                                             ^
In file included from telehash.c:1:0:
telehash.c:9120:44: error: ‘struct pipe_struct’ has no member named ‘id’
     LOG("router link not found for %s",pipe->id);
                                            ^
include/telehash.h:5219:77: note: in definition of macro ‘LOG’
 #define LOG(fmt, ...) util_sys_log(7, __FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
                                                                             ^
telehash.c:9127:38: error: ‘struct pipe_struct’ has no member named ‘id’
     LOG("bridging via router %s",pipe->id);
                                      ^
include/telehash.h:5219:77: note: in definition of macro ‘LOG’
 #define LOG(fmt, ...) util_sys_log(7, __FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
                                                                             ^
telehash.c:9132:35: error: ‘struct pipe_struct’ has no member named ‘id’
   LOG("peering via router %s",pipe->id);
                                   ^
include/telehash.h:5219:77: note: in definition of macro ‘LOG’
 #define LOG(fmt, ...) util_sys_log(7, __FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
                                                                             ^
telehash.c:9137:3: error: too many arguments to function ‘link_direct’
   link_direct(router,open,NULL);
   ^
telehash.c:6960:8: note: declared here
 link_t link_direct(link_t link, lob_t inner)
        ^
telehash.c:9140:3: warning: implicit declaration of function ‘mesh_forward’ [-Wimplicit-function-declaration]
   mesh_forward(link->mesh, packet->body, link, 0);
   ^
telehash.c: In function ‘peer_pipe’:
telehash.c:9151:23: error: ‘struct mesh_struct’ has no member named ‘index’
   pipes = xht_get(mesh->index, "ext_peer_pipes");
                       ^
telehash.c:9152:60: error: ‘struct pipe_struct’ has no member named ‘id’
   for(pipe = pipes;pipe;pipe = pipe->next) if(util_cmp(pipe->id,sn) == 0) return pipe;
                                                            ^
telehash.c:9155:15: warning: implicit declaration of function ‘pipe_new’ [-Wimplicit-function-declaration]
   if(!(pipe = pipe_new("peer"))) return NULL;
               ^
telehash.c:9155:13: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
   if(!(pipe = pipe_new("peer"))) return NULL;
             ^
telehash.c:9156:7: error: ‘struct pipe_struct’ has no member named ‘id’
   pipe->id = strdup(hashname_short(peer));
       ^
telehash.c:9157:7: error: ‘struct pipe_struct’ has no member named ‘arg’
   pipe->arg = hashname_dup(peer);
       ^
telehash.c:9158:7: error: ‘struct pipe_struct’ has no member named ‘send’
   pipe->send = peer_send;
       ^
telehash.c:9160:15: error: ‘struct mesh_struct’ has no member named ‘index’
   xht_set(mesh->index,"ext_peer_pipes",pipe);
               ^
telehash.c: In function ‘peer_open_connect’:
telehash.c:9199:25: error: too many arguments to function ‘mesh_receive’
   if(hs->head_len == 1) mesh_receive(link->mesh, hs, pipe);
                         ^
telehash.c:6467:8: note: declared here
 link_t mesh_receive(mesh_t mesh, lob_t outer)
        ^
telehash.c:9202:5: error: too many arguments to function ‘mesh_receive_handshake’
     mesh_receive_handshake(link->mesh, hs, pipe);
     ^
telehash.c:6390:8: note: declared here
 link_t mesh_receive_handshake(mesh_t mesh, lob_t handshake)
        ^
telehash.c: In function ‘peer_open_peer’:
telehash.c:9241:3: error: too many arguments to function ‘link_direct’
   link_direct(peer,open,NULL); // encrypts then sends
   ^
telehash.c:6960:8: note: declared here
 link_t link_direct(link_t link, lob_t inner)
        ^
telehash.c: In function ‘peer_free’:
telehash.c:9249:23: error: ‘struct mesh_struct’ has no member named ‘index’
   pipes = xht_get(mesh->index, "ext_peer_pipes");
                       ^
telehash.c:9254:23: error: ‘struct pipe_struct’ has no member named ‘arg’
     hashname_free(pipe->arg);
                       ^
telehash.c: In function ‘peer_enable’:
telehash.c:9263:34: warning: passing argument 3 of ‘mesh_on_path’ from incompatible pointer type [-Wincompatible-pointer-types]
   mesh_on_path(mesh, "ext_peer", peer_path);
                                  ^
telehash.c:6332:6: note: expected ‘struct link_struct * (*)(struct link_struct *, struct lob_struct *)’ but argument is of type ‘struct pipe_struct * (*)(struct link_struct *, struct lob_struct *)’
 void mesh_on_path(mesh_t mesh, char *id, link_t (*path)(link_t link, lob_t path))
      ^
telehash.c: In function ‘peer_connect’:
telehash.c:9293:68: warning: implicit declaration of function ‘link_handshakes’ [-Wimplicit-function-declaration]
   if(!(pipe = peer_pipe(peer->mesh, router->id)) || !(handshakes = link_handshakes(peer))) return LOG("internal error");
                                                                    ^
telehash.c:9293:66: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
   if(!(pipe = peer_pipe(peer->mesh, router->id)) || !(handshakes = link_handshakes(peer))) return LOG("internal error");
                                                                  ^
Makefile:123: recipe for target 'telehash.o' failed
make: *** [telehash.o] Error 1

It seems like most of the errors is related to the fact that peer_*() methods expect different pipe_struct and mesh_struct, and some methods are expected to have different signatures.

Do you have any suggestions to resolve those issues?

Thanks!

review all packet owner cleanup

Most places packets are being created and passed around are not being free'd yet, needs a full review and consistent owner-free pattern applied.

ext_path cant make

ext_path.c in test is disabled?
cause it can't be compiled

telehash-c/test/ext_path.c:35: undefined reference to `path_on_open'

telehash-c/test/ext_path.c:41: undefined reference to `path_ping'

Documentation

Hi, do you have documentation for your protocol? Something like this.

npm install fails

After cloning the repo, running npm install fails to build libtomcrypt-c.
This is because libtomcrypt-c assumes libtommath-c is installed in its own ./node_modules which is not true for telehash-c.

Confusion of which public key to put in openize inner

The code in this line
https://github.com/telehash/telehash-c/blob/master/cs1a/crypt_1a.c#L214
copies the line public key into the inner packet.

I am basing my haskell code on this version, and if I do this the node code cannot verify the packet.

The equivalent JS code here https://github.com/quartzjer/telehash-cs1a/blob/master/cs1a.js#L62 uses the id public key.

If I change the haskell code to not use the line public key it interoperates with the node one.

How does the c version work?

Coverity work-off

The current build of telehash-c was added to coverity, with 34 defects. Some of these defects may be in borrowed code, nonetheless, there are many resource leaks detected.

These should be triaged and fixed.

make test randomly fails link_up(linkAC) test

running make test, it randomly fails with:

----------------------------------------------
ext_peer.c:69: test FAILED:
Failed test: link_up(linkAC)
----------------------------------------------
FAILED: ext_peer

re-running make test seems to pass, sometimes.

Some make targets fail

Having some errors on Linux system (Ubuntu 16.04 64-bit):

root@th01:~/bug-test/telehash-c# make static-cs1a 
sed: can't read /#include ".*h"/d: No such file or directory
Makefile:74: recipe for target 'static-cs1a' failed
make: *** [static-cs1a] Error 2
root@th01:~/bug-test/telehash-c# make static-tmesh 
sed: can't read /#include ".*h"/d: No such file or directory
Makefile:82: recipe for target 'static-tmesh' failed
make: *** [static-tmesh] Error 2
root@th01:~/bug-test/telehash-c# 

These targets seem to work fine on Mac.

JWT

Is incomplete, yet, only JWS so far and more of cs2a needs to be used.

New coverity issue

  1. I'm noticing you are not incrementing the version number in version.h for all of these changes. We probably know the users of libtelehash but technically you are making changes to the library, which... is a different version.
  2. New error:


** CID 130929:  Memory - illegal accesses  (USE_AFTER_FREE)
/src/unix/util.c: 46 in util_fjson()


________________________________________________________________________________________________________
*** CID 130929:  Memory - illegal accesses  (USE_AFTER_FREE)
/src/unix/util.c: 46 in util_fjson()
40         return LOG("fread %d != %d for %s: %s",len,fs.st_size,file,strerror(errno));
41       }
42       
43       p = lob_new();
44       lob_head(p, buf, len);
45       free(buf);
>>>     CID 130929:  Memory - illegal accesses  (USE_AFTER_FREE)
>>>     Passing freed pointer "buf" as an argument to "util_sys_log".
46       if(!p) return LOG("json failed %s parsing %.*s",file,len,buf);
47       return p;
48     }
49     
50     mesh_t util_links(mesh_t mesh, char *file)
51     {

Build on Debian requires freebsd-glue

In order to link on Debian, I had to

apt-get install freebsd-glue

and then set

LIBS+=-lfreebsd-glue

in the Makefile

Otherwise it cannot find srandomdev

Undefined Structure - unix/util.c:49:18: error: storage size of 'tv' isn't known

Environment

  • Alpine Linux 3.1.0
  • MUSL LibC

Make Output

gcc -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -o bin/idgen util/idgen.c unix/platform.c src/e3x/cs2a_disabled.c src/e3x/cs3a_disabled.c  src/lib/util.c src/lib/lob.c src/lib/hashname.c src/lib/xht.c src/lib/js0n.c src/lib/base32.c src/lib/chunks.c src/e3x/e3x.c src/e3x/channel3.c src/e3x/self3.c src/e3x/exchange3.c src/e3x/event3.c src/e3x/cipher3.c src/e3x/cs1a/aes.c src/e3x/cs1a/hmac.c src/e3x/cs1a/aes128.c src/e3x/cs1a/cs1a.c src/e3x/cs1a/uECC.c src/e3x/cs1a/sha256.c -Iunix -Isrc -Isrc/lib -Isrc/ext -Isrc/e3x -Isrc/net
gcc -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -o bin/router util/router.c src/*.c unix/util.c src/net/udp4.c src/net/tcp4.c unix/platform.c src/e3x/cs2a_disabled.c src/e3x/cs3a_disabled.c  src/lib/util.c src/lib/lob.c src/lib/hashname.c src/lib/xht.c src/lib/js0n.c src/lib/base32.c src/lib/chunks.c src/e3x/e3x.c src/e3x/channel3.c src/e3x/self3.c src/e3x/exchange3.c src/e3x/event3.c src/e3x/cipher3.c src/e3x/cs1a/aes.c src/e3x/cs1a/hmac.c src/e3x/cs1a/aes128.c src/e3x/cs1a/cs1a.c src/e3x/cs1a/uECC.c src/e3x/cs1a/sha256.c -Iunix -Isrc -Isrc/lib -Isrc/ext -Isrc/e3x -Isrc/net
unix/util.c: In function 'util_sock_timeout':
unix/util.c:49:18: error: stgcc -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -o bin/idgen util/idgen.c unix/platform.c src/e3x/cs2a_disabled.c src/e3x/cs3a_disabled.c  src/lib/util.c src/lib/lob.c src/lib/hashname.c src/lib/xht.c src/lib/js0n.c src/lib/base32.c src/lib/chunks.c src/e3x/e3x.c src/e3x/channel3.c src/e3x/self3.c src/e3x/exchange3.c src/e3x/event3.c src/e3x/cipher3.c src/e3x/cs1a/aes.c src/e3x/cs1a/hmac.c src/e3x/cs1a/aes128.c src/e3x/cs1a/cs1a.c src/e3x/cs1a/uECC.c src/e3x/cs1a/sha256.c -Iunix -Isrc -Isrc/lib -Isrc/ext -Isrc/e3x -Isrc/net
gcc -g -Wall -Wextra -Wno-unused-parameter -DDEBUG -o bin/router util/router.c src/*.c unix/util.c src/net/udp4.c src/net/tcp4.c unix/platform.c src/e3x/cs2a_disabled.c src/e3x/cs3a_disabled.c  src/lib/util.c src/lib/lob.c src/lib/hashname.c src/lib/xht.c src/lib/js0n.c src/lib/base32.c src/lib/chunks.c src/e3x/e3x.c src/e3x/channel3.c src/e3x/self3.c src/e3x/exchange3.c src/e3x/event3.c src/e3x/cipher3.c src/e3x/cs1a/aes.c src/e3x/cs1a/hmac.c src/e3x/cs1a/aes128.c src/e3x/cs1a/cs1a.c src/e3x/cs1a/uECC.c src/e3x/cs1a/sha256.c -Iunix -Isrc -Isrc/lib -Isrc/ext -Isrc/e3x -Isrc/net
unix/util.c: In function 'util_sock_timeout':
unix/util.c:49:18: error: storage size of 'tv' isn't known
   struct timeval tv;
                  ^
unix/util.c:49:18: warning: unused variable 'tv' [-Wunused-variable]
Makefile:138: recipe for target 'router' failed
make: *** [router] Error 1
orage size of 'tv' isn't known
   struct timeval tv;
                  ^
unix/util.c:49:18: warning: unused variable 'tv' [-Wunused-variable]
Makefile:138: recipe for target 'router' failed
make: *** [router] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.