janmojzis / tinyssh

TinySSH is small server (less than 100000 words of code)
Creative Commons Zero v1.0 Universal
1.41k stars 75 forks source link

Does not link properly to libsodium #70

Open vt-alt opened 2 years ago

vt-alt commented 2 years ago

When attempting to build with libsodium (as a drop-in libnacl replacement) as suggested in FAQ it does not actually links to libsodium:

export LIBS="-lsodium"
export CFLAGS="-I/usr/include/sodium"
...
=== Mon Aug 22 13:34:51 UTC 2022 === starting crypto headers
=== Mon Aug 22 13:34:51 UTC 2022 ===   crypto_stream_chacha20.h (tinyssh\n) ok
=== Mon Aug 22 13:34:52 UTC 2022 ===   crypto_onetimeauth_poly1305.h (tinyssh\n) ok
=== Mon Aug 22 13:34:52 UTC 2022 ===   crypto_hash_sha512.h (tinyssh\n) ok
=== Mon Aug 22 13:34:52 UTC 2022 ===   crypto_hash_sha256.h (tinyssh\n) ok
=== Mon Aug 22 13:34:52 UTC 2022 ===   crypto_verify_16.h (tinyssh\n) ok
=== Mon Aug 22 13:34:52 UTC 2022 ===   crypto_verify_32.h (tinyssh\n) ok
=== Mon Aug 22 13:34:53 UTC 2022 ===   crypto_scalarmult_curve25519.h (tinyssh\n) ok
=== Mon Aug 22 13:34:54 UTC 2022 ===   crypto_sign_ed25519.h (tinyssh\n) ok
=== Mon Aug 22 13:34:54 UTC 2022 ===   crypto_sort_uint32.h (tinyssh\n) ok
=== Mon Aug 22 13:34:56 UTC 2022 ===   crypto_kem_sntrup761.h (tinyssh\n) ok
=== Mon Aug 22 13:34:58 UTC 2022 ===   crypto_kem_sntrup761x25519.h (tinyssh\n) ok
=== Mon Aug 22 13:34:58 UTC 2022 === finishing

(Also note \n in tinyssh\n).

It seems because of errors like this:

=== Mon Aug 22 13:34:51 UTC 2022 === trying: ext. crypto_stream_chacha20:
In file included from crypto_stream_chacha20test.c:8:
misc.h:9:10: fatal error: crypto_uint8.h: No such file or directory
    9 | #include "crypto_uint8.h"
      |          ^~~~~~~~~~~~~~~~
compilation terminated.

Except for the symbol crypto_verify_16 which is alone linked to libsodium.

Adding -I${PWD}/crypto to CFLAGS fixes the problem:

export LIBS="-lsodium"
export CFLAGS="-I/usr/include/sodium -I${PWD}/crypto"
...
=== Mon Aug 22 13:41:33 UTC 2022 === starting crypto headers
=== Mon Aug 22 13:41:33 UTC 2022 ===   crypto_stream_chacha20.h () ok
=== Mon Aug 22 13:41:34 UTC 2022 ===   crypto_onetimeauth_poly1305.h () ok
=== Mon Aug 22 13:41:34 UTC 2022 ===   crypto_hash_sha512.h () ok
=== Mon Aug 22 13:41:34 UTC 2022 ===   crypto_hash_sha256.h () ok
=== Mon Aug 22 13:41:34 UTC 2022 ===   crypto_verify_16.h () ok
=== Mon Aug 22 13:41:34 UTC 2022 ===   crypto_verify_32.h () ok
=== Mon Aug 22 13:41:34 UTC 2022 ===   crypto_scalarmult_curve25519.h () ok
=== Mon Aug 22 13:41:34 UTC 2022 ===   crypto_sign_ed25519.h () ok
=== Mon Aug 22 13:41:34 UTC 2022 ===   crypto_sort_uint32.h (tinyssh\n) ok
=== Mon Aug 22 13:41:36 UTC 2022 ===   crypto_kem_sntrup761.h (tinyssh\n) ok
=== Mon Aug 22 13:41:38 UTC 2022 ===   crypto_kem_sntrup761x25519.h (tinyssh\n) ok
=== Mon Aug 22 13:41:38 UTC 2022 === finishing