Code Monkey home page Code Monkey logo

noise-c's People

Contributors

dalecbt avatar efidler avatar elazarl avatar gram-signal avatar howjmay avatar nayuta-ueno avatar nazar-pc avatar pallas avatar rweather 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

noise-c's Issues

Move structs from *.c files to *.h files

There is a struct NoiseRandState_s, it is defined in src/protocol/randstate.c file, which causes difficulties with linking when multiple files included this file:

error: Linking globals named 'noise_randstate_new': symbol multiply defined!

Similarly, for _Noise_CertificateChain, _Noise_Certificate and _Noise_PrivateKey I have to include src/keys/certificate.c, which is not a problem for me yet, but it does include some functions and might become a problem later.

Could you move those structs into *.h files with guarding from re-definition as it is for other structs already?

Compile without SIMD

Is there a way to compile this library without SIMD with clang?
I've tried following:

#undef __AVX2__
#undef __AVX__
#undef __SSE2__
#undef __SSSE3__

But it didn't help unfortunately.

Here is full list of functions that add SIMD instructions:

  • noise_handshakestate_get_fixed_ephemeral_dh
  • noise_handshakestate_get_fixed_hybrid_dh
  • noise_handshakestate_new_by_id
  • noise_handshakestate_new_by_name
  • noise_dhstate_new_by_id
  • noise_dhstate_new_by_name

When mentioned functions are not used, SIMD instructions do not appear in compiled output.

rev32 support

As mentioned in Issue #28, rev32 (and rev34) are not yet supported by this library. @rweather, you noted that there were only a handful of missing bits. If you enumerate them for me (since I'm new to this library), I'm happy to help.

Make EC25519 implementation optional for static library

Description

curve25519-donna-c64.c/curve25519-donna.c is built even for static libraries and this could lead to multiple implementation of ec25519 in binary.

Steps to reproduce

  • build noise-c as static library

Actual result: ec25519 implementation is part of static library.
Expected result: user should decide whether he/she wants the ec25519 implementation to be part of static library.

macro expansion producing 'defined' has undefined behavior

When compiling with Clang 4 I'm getting following warnings:

In file included from vendor/src/backend/ref/cipher-chachapoly.c:25:
vendor/src/crypto/donna/poly1305-donna.c:18:6: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if (HAS_SIZEOF_INT128_64BIT || HAS_MSVC_64BIT || HAS_GCC_4_4_64BIT)
     ^
vendor/src/crypto/donna/poly1305-donna.c:14:34: note: expanded from macro 'HAS_SIZEOF_INT128_64BIT'
#define HAS_SIZEOF_INT128_64BIT (defined(__SIZEOF_INT128__) && defined(__LP64__))
                                 ^
vendor/src/crypto/donna/poly1305-donna.c:18:6: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
vendor/src/crypto/donna/poly1305-donna.c:14:64: note: expanded from macro 'HAS_SIZEOF_INT128_64BIT'
#define HAS_SIZEOF_INT128_64BIT (defined(__SIZEOF_INT128__) && defined(__LP64__))
                                                               ^
vendor/src/crypto/donna/poly1305-donna.c:18:33: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if (HAS_SIZEOF_INT128_64BIT || HAS_MSVC_64BIT || HAS_GCC_4_4_64BIT)
                                ^
vendor/src/crypto/donna/poly1305-donna.c:15:25: note: expanded from macro 'HAS_MSVC_64BIT'
#define HAS_MSVC_64BIT (defined(_MSC_VER) && defined(_M_X64))
                        ^
vendor/src/crypto/donna/poly1305-donna.c:18:33: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
vendor/src/crypto/donna/poly1305-donna.c:15:46: note: expanded from macro 'HAS_MSVC_64BIT'
#define HAS_MSVC_64BIT (defined(_MSC_VER) && defined(_M_X64))
                                             ^
vendor/src/crypto/donna/poly1305-donna.c:18:51: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if (HAS_SIZEOF_INT128_64BIT || HAS_MSVC_64BIT || HAS_GCC_4_4_64BIT)
                                                  ^
vendor/src/crypto/donna/poly1305-donna.c:16:28: note: expanded from macro 'HAS_GCC_4_4_64BIT'
#define HAS_GCC_4_4_64BIT (defined(__GNUC__) && defined(__LP64__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))))
                           ^
vendor/src/crypto/donna/poly1305-donna.c:18:51: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
vendor/src/crypto/donna/poly1305-donna.c:16:49: note: expanded from macro 'HAS_GCC_4_4_64BIT'
#define HAS_GCC_4_4_64BIT (defined(__GNUC__) && defined(__LP64__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))))
                                                ^
6 warnings generated.

Pre-fallback handshake roles are not preserved

http://noiseprotocol.org/noise.html#fallback-patterns:

The initiator and responder roles from the pre-fallback handshake are preserved in the fallback handshake. Thus, the responder sends the first message in a fallback handshake.

However:

/* Fallback on the responder side */
compare(noise_handshakestate_fallback(responder), NOISE_ERROR_NONE);
compare(noise_handshakestate_get_role(initiator), NOISE_ROLE_INITIATOR);
compare(noise_handshakestate_get_role(responder), NOISE_ROLE_INITIATOR);

/* Fallback on the initiator side */
compare(noise_handshakestate_fallback(initiator), NOISE_ERROR_NONE);
compare(noise_handshakestate_get_role(initiator), NOISE_ROLE_RESPONDER);
compare(noise_handshakestate_get_role(responder), NOISE_ROLE_INITIATOR);

You can argue that this is an implementation detail, but still it would be better to not confuse those who use this library after reading the spec and introduce separate entity to indicate that fallback protocol is used.

UPD: I saw This function reverses the roles of initiator and responder., but this conflicts with the spec.

noise/keys.h is not installed

Hi, i noticed that noise/keys.h is not installed.

 /usr/bin/install -c -m 644 protocol.h protobufs.h '/usr/local/include/noise'

Full log

$ make install
Making install in include
make[1]: Entering directory '/tmp/noise-c/include'
Making install in noise
make[2]: Entering directory '/tmp/noise-c/include/noise'
Making install in .
make[3]: Entering directory '/tmp/noise-c/include/noise'
make[4]: Entering directory '/tmp/noise-c/include/noise'
make[4]: Nothing to be done for 'install-exec-am'.
 /usr/bin/mkdir -p '/usr/local/include/noise'
 /usr/bin/install -c -m 644 protocol.h protobufs.h '/usr/local/include/noise'
make[4]: Leaving directory '/tmp/noise-c/include/noise'
make[3]: Leaving directory '/tmp/noise-c/include/noise'
Making install in protocol
make[3]: Entering directory '/tmp/noise-c/include/noise/protocol'
make[4]: Entering directory '/tmp/noise-c/include/noise/protocol'
make[4]: Nothing to be done for 'install-exec-am'.
 /usr/bin/mkdir -p '/usr/local/include/noise/protocol'
 /usr/bin/install -c -m 644 buffer.h cipherstate.h constants.h dhstate.h errors.h handshakestate.h hashstate.h names.h randstate.h signstate.h symmetricstate.h util.h '/usr/local/include/noise/protocol'
make[4]: Leaving directory '/tmp/noise-c/include/noise/protocol'
make[3]: Leaving directory '/tmp/noise-c/include/noise/protocol'
Making install in keys
make[3]: Entering directory '/tmp/noise-c/include/noise/keys'
make[4]: Entering directory '/tmp/noise-c/include/noise/keys'
make[4]: Nothing to be done for 'install-exec-am'.
 /usr/bin/mkdir -p '/usr/local/include/noise/keys'
 /usr/bin/install -c -m 644 certificate.h loader.h '/usr/local/include/noise/keys'
make[4]: Leaving directory '/tmp/noise-c/include/noise/keys'
make[3]: Leaving directory '/tmp/noise-c/include/noise/keys'
make[2]: Leaving directory '/tmp/noise-c/include/noise'
make[2]: Entering directory '/tmp/noise-c/include'
make[3]: Entering directory '/tmp/noise-c/include'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/tmp/noise-c/include'
make[2]: Leaving directory '/tmp/noise-c/include'
make[1]: Leaving directory '/tmp/noise-c/include'
Making install in src
make[1]: Entering directory '/tmp/noise-c/src'
Making install in protocol
make[2]: Entering directory '/tmp/noise-c/src/protocol'
make[3]: Entering directory '/tmp/noise-c/src/protocol'
 /usr/bin/mkdir -p '/usr/local/lib'
 /usr/bin/install -c -m 644  libnoiseprotocol.a '/usr/local/lib'
 ( cd '/usr/local/lib' && ranlib libnoiseprotocol.a )
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/tmp/noise-c/src/protocol'
make[2]: Leaving directory '/tmp/noise-c/src/protocol'
Making install in protobufs
make[2]: Entering directory '/tmp/noise-c/src/protobufs'
make[3]: Entering directory '/tmp/noise-c/src/protobufs'
 /usr/bin/mkdir -p '/usr/local/lib'
 /usr/bin/install -c -m 644  libnoiseprotobufs.a '/usr/local/lib'
 ( cd '/usr/local/lib' && ranlib libnoiseprotobufs.a )
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/tmp/noise-c/src/protobufs'
make[2]: Leaving directory '/tmp/noise-c/src/protobufs'
Making install in keys
make[2]: Entering directory '/tmp/noise-c/src/keys'
make[3]: Entering directory '/tmp/noise-c/src/keys'
 /usr/bin/mkdir -p '/usr/local/lib'
 /usr/bin/install -c -m 644  libnoisekeys.a '/usr/local/lib'
 ( cd '/usr/local/lib' && ranlib libnoisekeys.a )
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/tmp/noise-c/src/keys'
make[2]: Leaving directory '/tmp/noise-c/src/keys'
make[2]: Entering directory '/tmp/noise-c/src'
make[3]: Entering directory '/tmp/noise-c/src'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/tmp/noise-c/src'
make[2]: Leaving directory '/tmp/noise-c/src'
make[1]: Leaving directory '/tmp/noise-c/src'
Making install in tools
make[1]: Entering directory '/tmp/noise-c/tools'
Making install in keytool
make[2]: Entering directory '/tmp/noise-c/tools/keytool'
make[3]: Entering directory '/tmp/noise-c/tools/keytool'
 /usr/bin/mkdir -p '/usr/local/bin'
  /usr/bin/install -c noise-keytool '/usr/local/bin'
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/tmp/noise-c/tools/keytool'
make[2]: Leaving directory '/tmp/noise-c/tools/keytool'
Making install in protoc
make[2]: Entering directory '/tmp/noise-c/tools/protoc'
make  install-am
make[3]: Entering directory '/tmp/noise-c/tools/protoc'
make[4]: Entering directory '/tmp/noise-c/tools/protoc'
 /usr/bin/mkdir -p '/usr/local/bin'
  /usr/bin/install -c noise-protoc '/usr/local/bin'
make[4]: Nothing to be done for 'install-data-am'.
make[4]: Leaving directory '/tmp/noise-c/tools/protoc'
make[3]: Leaving directory '/tmp/noise-c/tools/protoc'
make[2]: Leaving directory '/tmp/noise-c/tools/protoc'
make[2]: Entering directory '/tmp/noise-c/tools'
make[3]: Entering directory '/tmp/noise-c/tools'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/tmp/noise-c/tools'
make[2]: Leaving directory '/tmp/noise-c/tools'
make[1]: Leaving directory '/tmp/noise-c/tools'
Making install in tests
make[1]: Entering directory '/tmp/noise-c/tests'
Making install in unit
make[2]: Entering directory '/tmp/noise-c/tests/unit'
make[3]: Entering directory '/tmp/noise-c/tests/unit'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/tmp/noise-c/tests/unit'
make[2]: Leaving directory '/tmp/noise-c/tests/unit'
Making install in vector
make[2]: Entering directory '/tmp/noise-c/tests/vector'
make[3]: Entering directory '/tmp/noise-c/tests/vector'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/tmp/noise-c/tests/vector'
make[2]: Leaving directory '/tmp/noise-c/tests/vector'
Making install in vector-gen
make[2]: Entering directory '/tmp/noise-c/tests/vector-gen'
make[3]: Entering directory '/tmp/noise-c/tests/vector-gen'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/tmp/noise-c/tests/vector-gen'
make[2]: Leaving directory '/tmp/noise-c/tests/vector-gen'
Making install in performance
make[2]: Entering directory '/tmp/noise-c/tests/performance'
make[3]: Entering directory '/tmp/noise-c/tests/performance'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/tmp/noise-c/tests/performance'
make[2]: Leaving directory '/tmp/noise-c/tests/performance'
make[2]: Entering directory '/tmp/noise-c/tests'
make[3]: Entering directory '/tmp/noise-c/tests'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/tmp/noise-c/tests'
make[2]: Leaving directory '/tmp/noise-c/tests'
make[1]: Leaving directory '/tmp/noise-c/tests'
Making install in examples
make[1]: Entering directory '/tmp/noise-c/examples'
Making install in echo
make[2]: Entering directory '/tmp/noise-c/examples/echo'
Making install in echo-client
make[3]: Entering directory '/tmp/noise-c/examples/echo/echo-client'
make[4]: Entering directory '/tmp/noise-c/examples/echo/echo-client'
make[4]: Nothing to be done for 'install-exec-am'.
make[4]: Nothing to be done for 'install-data-am'.
make[4]: Leaving directory '/tmp/noise-c/examples/echo/echo-client'
make[3]: Leaving directory '/tmp/noise-c/examples/echo/echo-client'
Making install in echo-keygen
make[3]: Entering directory '/tmp/noise-c/examples/echo/echo-keygen'
make[4]: Entering directory '/tmp/noise-c/examples/echo/echo-keygen'
make[4]: Nothing to be done for 'install-exec-am'.
make[4]: Nothing to be done for 'install-data-am'.
make[4]: Leaving directory '/tmp/noise-c/examples/echo/echo-keygen'
make[3]: Leaving directory '/tmp/noise-c/examples/echo/echo-keygen'
Making install in echo-server
make[3]: Entering directory '/tmp/noise-c/examples/echo/echo-server'
make[4]: Entering directory '/tmp/noise-c/examples/echo/echo-server'
make[4]: Nothing to be done for 'install-exec-am'.
make[4]: Nothing to be done for 'install-data-am'.
make[4]: Leaving directory '/tmp/noise-c/examples/echo/echo-server'
make[3]: Leaving directory '/tmp/noise-c/examples/echo/echo-server'
make[3]: Entering directory '/tmp/noise-c/examples/echo'
make[4]: Entering directory '/tmp/noise-c/examples/echo'
make[4]: Nothing to be done for 'install-exec-am'.
make[4]: Nothing to be done for 'install-data-am'.
make[4]: Leaving directory '/tmp/noise-c/examples/echo'
make[3]: Leaving directory '/tmp/noise-c/examples/echo'
make[2]: Leaving directory '/tmp/noise-c/examples/echo'
make[2]: Entering directory '/tmp/noise-c/examples'
make[3]: Entering directory '/tmp/noise-c/examples'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/tmp/noise-c/examples'
make[2]: Leaving directory '/tmp/noise-c/examples'
make[1]: Leaving directory '/tmp/noise-c/examples'
Making install in doc
make[1]: Entering directory '/tmp/noise-c/doc'
make[2]: Entering directory '/tmp/noise-c/doc'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/tmp/noise-c/doc'
make[1]: Leaving directory '/tmp/noise-c/doc'
make[1]: Entering directory '/tmp/noise-c'
make[2]: Entering directory '/tmp/noise-c'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/tmp/noise-c'
make[1]: Leaving directory '/tmp/noise-c'

simple Makefile build

autoconf is not very portable. Would you be ok with a PR that adds a makefile that just includes the relevant source files? For example this is needed to build on arduino

Trouble compiling on Ubuntu 16.04 ARM

I'm following the instructions in the documentation but failing to build. I'm not sure if the ylwrap command is correct as it doesn't build the proto3-lexer.c file. I'm using bison for yacc and flex for lex.

root@h:~/noise-c# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04 LTS
Release:    16.04
Codename:   xenial

root@h:~/noise-c# uname -a
Linux h 4.5.7-std-4 #1 SMP Tue Jul 12 11:00:06 UTC 2016 armv7l armv7l armv7l GNU/Linux

root@h:~/noise-c# make
Making all in include
make[1]: Entering directory '/root/noise-c/include'
Making all in noise
make[2]: Entering directory '/root/noise-c/include/noise'
Making all in .
make[3]: Entering directory '/root/noise-c/include/noise'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/root/noise-c/include/noise'
Making all in protocol
make[3]: Entering directory '/root/noise-c/include/noise/protocol'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/root/noise-c/include/noise/protocol'
Making all in keys
make[3]: Entering directory '/root/noise-c/include/noise/keys'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/root/noise-c/include/noise/keys'
make[2]: Leaving directory '/root/noise-c/include/noise'
make[2]: Entering directory '/root/noise-c/include'
make[2]: Nothing to be done for 'all-am'.
make[2]: Leaving directory '/root/noise-c/include'
make[1]: Leaving directory '/root/noise-c/include'
Making all in src
make[1]: Entering directory '/root/noise-c/src'
Making all in protocol
make[2]: Entering directory '/root/noise-c/src/protocol'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/noise-c/src/protocol'
Making all in protobufs
make[2]: Entering directory '/root/noise-c/src/protobufs'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/noise-c/src/protobufs'
Making all in keys
make[2]: Entering directory '/root/noise-c/src/keys'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/noise-c/src/keys'
make[2]: Entering directory '/root/noise-c/src'
make[2]: Nothing to be done for 'all-am'.
make[2]: Leaving directory '/root/noise-c/src'
make[1]: Leaving directory '/root/noise-c/src'
Making all in tools
make[1]: Entering directory '/root/noise-c/tools'
Making all in keytool
make[2]: Entering directory '/root/noise-c/tools/keytool'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/noise-c/tools/keytool'
Making all in protoc
make[2]: Entering directory '/root/noise-c/tools/protoc'
/bin/bash ../../ylwrap proto3-lexer.l .c proto3-lexer.c -- :  
gcc -DPACKAGE_NAME=\"noise-c\" -DPACKAGE_TARNAME=\"noise-c\" -DPACKAGE_VERSION=\"0.0.1\" -DPACKAGE_STRING=\"noise-c\ 0.0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"noise-c\" -DVERSION=\"0.0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=4 -DHAVE_LIBRT=1 -DHAVE_POLL=1 -I.    -Wall -g -O2 -MT proto3-lexer.o -MD -MP -MF .deps/proto3-lexer.Tpo -c -o proto3-lexer.o proto3-lexer.c
gcc: error: proto3-lexer.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
Makefile:381: recipe for target 'proto3-lexer.o' failed
make[2]: *** [proto3-lexer.o] Error 1
make[2]: Leaving directory '/root/noise-c/tools/protoc'
Makefile:317: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/root/noise-c/tools'
Makefile:343: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

root@h:~/noise-c/tools/protoc# ../../ylwrap proto3-lexer.l
../../ylwrap: 157: shift: can't shift that many

Build fails on Ubuntu 16.04

Configure fails for me. Steps to reproduce:

I've started stock ubuntu image with vagrant: vagrant init ubuntu/xenial64 && vagrant up && vagrant ssh

Build steps:

sudo -i
apt update
apt install autoconf git build-essential
git clone https://github.com/rweather/noise-c.git
cd noise-c
autoreconf -i
./configure
make
make check

Configure step fails:

root@ubuntu-xenial:~/noise-c# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for gcc option to accept ISO C99... none needed
checking for gcc option to accept ISO Standard C... (cached) none needed
checking for ranlib... ranlib
checking for flex... no
checking for lex... no
checking for bison... no
checking for byacc... no
checking for doxygen... no
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether __x86_64__ is declared... yes
checking size of void *... 8
checking for clock_gettime in -lrt... yes
checking for _head_libws2_32_a in -lws2_32... no
checking for _head_lib32_libws2_32_a in -lws2_32... no
checking for _head_lib64_libws2_32_a in -lws2_32... no
checking for poll... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking whether gcc is Clang... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
./configure: line 6066: syntax error near unexpected token `libsodium,'
./configure: line 6066: `    PKG_CHECK_MODULES_STATIC(libsodium, libsodium, HAVE_LIBSODIUM=1) ;; #('

If I fix config script manually (disable libsodium and libssl) there is another error during make:

...
make[2]: Leaving directory '/root/noise-c/tools/keytool'
Making all in protoc
make[2]: Entering directory '/root/noise-c/tools/protoc'
/bin/bash ../../ylwrap proto3-grammar.y y.tab.c proto3-grammar.c y.tab.h `echo proto3-grammar.c | sed -e s/cc$/hh/ -e s/cpp$/hpp/ -e s/cxx$/hxx/ -e s/c++$/h++/ -e s/c$/h/` y.output proto3-grammar.output -- yacc -d
../../ylwrap: line 176: yacc: command not found
Makefile:416: recipe for target 'proto3-grammar.c' failed
make[2]: *** [proto3-grammar.c] Error 127
make[2]: Leaving directory '/root/noise-c/tools/protoc'
Makefile:333: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/root/noise-c/tools'
Makefile:360: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

Installing relevant packages apt install byacc flex bison fixes second problem (maybe some packages are redundant)

Building: error: cannot find input file

Following the instructions here I executed the commands
and got the error below:

`
xxx@pc:/mnt/c/Source/ALPS/noise-c# autoreconf --install

xxx@pc:/mnt/c/Source/ALPS/noise-c# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for gcc option to accept ISO C99... -std=gnu99
checking for gcc -std=gnu99 option to accept ISO Standard C... (cached) -std=gnu99
checking for ranlib... ranlib
checking for flex... no
checking for lex... no
checking for bison... no
checking for byacc... no
checking for doxygen... no
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether x86_64 is declared... yes
checking size of void *... 8
checking for clock_gettime in -lrt... yes
checking for _head_libws2_32_a in -lws2_32... no
checking for _head_lib32_libws2_32_a in -lws2_32... no
checking for _head_lib64_libws2_32_a in -lws2_32... no
checking for poll... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking whether gcc -std=gnu99 is Clang... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking for pkg-config... no
configure: WARNING: Can't find pkg-config. Using built-in reference crypto backend.
checking that generated files are newer than configure... done
configure: creating ./config.status
.in'ig.status: error: cannot find input file: `Makefile

xxx@pc:/mnt/c/Source/ALPS/noise-c#
`

Tag next version with changelog

Now that noise-c.wasm looks ready for use, I'd like to ask you to tag changes in this library with changelog, so that it is possible to follow updates.

It is especially important for noise-c.wasm, since it is just a port to another language, and it should be clear to which version of upstream noise-c each particular release of nosie-c.wasm belongs.

My suggestion would be semantic versioning like 1.0.0+noise-32 to specify both library version and Noise spec version it implements.

Includes in src/backend/ref

I'm not a C/C++ developer, but still I'm trying to port this library to JavaScript using Emscripten (compile it into WebAssembly).

I'm having some issues with files in src/backend/ref. For instance, #include "internal.h" doesn't work here. Next few lines also seem to require changes.

From my limited understanding following:

#include "internal.h"
#include "crypto/aes/rijndael-alg-fst.h"
#include "crypto/ghash/ghash.h"

Should in fact be like this:

#include <protocol/internal.h>
#include <crypto/aes/rijndael-alg-fst.h>
#include <crypto/ghash/ghash.h>

Emscripten uses clang if it makes any difference.

Am I missing something or this is indeed a bug?

Compiling for Windows

I am not very experienced with cross-compiling, but I gave it a go with MinGW and MSYS on Windows, and I failed miserably.
I assume this library does support compiling for Windows since I saw an #ifdef WIN32 in the echo-common.c file.
Could you please enlighten me as to how such a feat could be accomplished?

USE_SODIUM in internal.c is never set

The USE_SODIUM flag in internal.c is not set by the configure scripts when configuring with libsodium. This leads to undefined references to noise_aesgcm_new_ref on older systems (like travis-Ci ubuntu 14.04). On newer systems the symbol is still undefined, but this is somehow ignored by the linker:

nm src/protocol/libnoiseprotocol.a | grep noise_aesgcm_new_ref

U noise_aesgcm_new_ref

Rekey() function is not present

Reading through the spec it seems like there should be a function like noise_cipherstate_rekey(), but there is none.
Will you add it to match the spec or it is already there, but named differently?

blake2s.c:258:26: error: incompatible types when initializing type ‘uint32_t {aka unsigned int}’ using type ‘BlakeVectorUInt32 {aka __vector(4) unsigned int}’

I'm getting the following compiler error when compiling with gcc 7 or 8.

$ make -C src/protocol
make: Entering directory '/tmp/noise-tmp/src/protocol'
depbase=`echo ../crypto/blake2/blake2s.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc-7 -DPACKAGE_NAME=\"noise-c\" -DPACKAGE_TARNAME=\"noise-c\" -DPACKAGE_VERSION=\"0.0.1\" -DPACKAGE_STRING=\"noise-c\ 0.0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"noise-c\" -DVERSION=\"0.0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DSIZEOF_VOID_P=8 -DHAVE_LIBRT=1 -DHAVE_POLL=1 -DHAVE_PTHREAD_PRIO_INHERIT=1 -I. -I/home/niklas/projects/external/noise-c/src/protocol  -I/home/niklas/projects/external/noise-c/include -I/home/niklas/projects/external/noise-c/src -I/home/niklas/projects/external/noise-c/src/crypto/goldilocks/src/include -I/home/niklas/projects/external/noise-c/src/crypto/goldilocks/src/p448 -I/home/niklas/projects/external/noise-c/src/crypto/goldilocks/src/p448/arch_x86_64   -DED25519_CUSTOMHASH -DED25519_CUSTOMRANDOM  -Wall   -g -O2 -pthread -MT ../crypto/blake2/blake2s.o -MD -MP -MF $depbase.Tpo -c -o ../crypto/blake2/blake2s.o /home/niklas/projects/external/noise-c/src/protocol/../crypto/blake2/blake2s.c &&\
mv -f $depbase.Tpo $depbase.Po
/home/niklas/projects/external/noise-c/src/protocol/../crypto/blake2/blake2s.c: In function ‘BLAKE2s_finish’:
/home/niklas/projects/external/noise-c/src/protocol/../crypto/blake2/blake2s.c:258:26: error: incompatible types when initializing type ‘uint32_t {aka unsigned int}’ using type ‘BlakeVectorUInt32 {aka __vector(4) unsigned int}’
             uint32_t h = context->h[posn];
                          ^~~~~~~
make: *** [Makefile:794: ../crypto/blake2/blake2s.o] Error 1
make: Leaving directory '/tmp/noise-tmp/src/protocol'

Configured with:

/home/niklas/projects/external/noise-c/configure --with-libsodium=no --with-openssl=no

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.