philanc / luanacha

"NaCl with Chacha in Lua" - a wrapper around the Monocypher crypto library
5 stars 4 forks source link

compiler warnings #3

Open Habbie opened 6 years ago

Habbie commented 6 years ago

Most of these are in monocypher, but not all of them. I can investigate the warnings more deeply if you like.

OSX stock clang:

$ make LUA=$(which lua-5.2) LUADIR=/usr/local/opt/lua clean luanacha.so test
rm -f *.o *.a *.so
cc -c -Os -fPIC -I/usr/local/opt/lua/include  src/*.c
src/luanacha.c:128:25: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to
      integer types with different sign [-Wpointer-sign]
    lua_pushlstring (L, buf, bufln);
                        ^~~
/usr/local/opt/lua/include/lua.h:209:66: note: passing argument to parameter 's' here
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
                                                                 ^
src/luanacha.c:155:25: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        crypto_lock(buf+pfxln, k, n, m, mln);
                               ^
src/monocypher.h:156:33: note: passing argument to parameter 'key' here
                 const uint8_t  key[32],
                                ^
src/luanacha.c:155:28: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        crypto_lock(buf+pfxln, k, n, m, mln);
                                  ^
src/monocypher.h:157:33: note: passing argument to parameter 'nonce' here
                 const uint8_t  nonce[24],
                                ^
src/luanacha.c:155:31: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        crypto_lock(buf+pfxln, k, n, m, mln);
                                     ^
src/monocypher.h:158:33: note: passing argument to parameter 'plaintext' here
                 const uint8_t *plaintext,
                                ^
src/luanacha.c:159:22: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to
      integer types with different sign [-Wpointer-sign]
        lua_pushlstring (L, buf, bufln);
                            ^~~
/usr/local/opt/lua/include/lua.h:209:66: note: passing argument to parameter 's' here
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
                                                                 ^
src/luanacha.c:183:25: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        r = crypto_unlock(buf, k, n, c+i, boxln);
                               ^
src/monocypher.h:162:34: note: passing argument to parameter 'key' here
                  const uint8_t  key[32],
                                 ^
src/luanacha.c:183:28: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        r = crypto_unlock(buf, k, n, c+i, boxln);
                                  ^
src/monocypher.h:163:34: note: passing argument to parameter 'nonce' here
                  const uint8_t  nonce[24],
                                 ^
src/luanacha.c:183:31: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        r = crypto_unlock(buf, k, n, c+i, boxln);
                                     ^~~
src/monocypher.h:164:34: note: passing argument to parameter 'box' here
                  const uint8_t *box,
                                 ^
src/luanacha.c:190:22: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to
      integer types with different sign [-Wpointer-sign]
        lua_pushlstring (L, buf, boxln-16);
                            ^~~
/usr/local/opt/lua/include/lua.h:209:66: note: passing argument to parameter 's' here
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
                                                                 ^
src/luanacha.c:207:22: warning: passing 'unsigned char [32]' to parameter of type 'const char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
        lua_pushlstring (L, pk, 32);
                            ^~
/usr/local/opt/lua/include/lua.h:209:66: note: passing argument to parameter 's' here
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
                                                                 ^
src/luanacha.c:208:22: warning: passing 'unsigned char [32]' to parameter of type 'const char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
        lua_pushlstring (L, sk, 32);
                            ^~
/usr/local/opt/lua/include/lua.h:209:66: note: passing argument to parameter 's' here
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
                                                                 ^
src/luanacha.c:221:31: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        crypto_x25519_public_key(pk, sk);
                                     ^~
src/monocypher.h:113:45: note: passing argument to parameter 'secret_key' here
                              const uint8_t secret_key[32]);
                                            ^
src/luanacha.c:222:22: warning: passing 'unsigned char [32]' to parameter of type 'const char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
        lua_pushlstring (L, pk, 32);
                            ^~
/usr/local/opt/lua/include/lua.h:209:66: note: passing argument to parameter 's' here
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
                                                                 ^
src/luanacha.c:239:25: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        crypto_key_exchange(k, sk, pk);
                               ^~
src/monocypher.h:135:39: note: passing argument to parameter 'your_secret_key' here
                        const uint8_t your_secret_key [32],
                                      ^
src/luanacha.c:239:29: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        crypto_key_exchange(k, sk, pk);
                                   ^~
src/monocypher.h:136:39: note: passing argument to parameter 'their_public_key' here
                        const uint8_t their_public_key[32]);
                                      ^
src/luanacha.c:240:21: warning: passing 'unsigned char [32]' to parameter of type 'const char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
        lua_pushlstring(L, k, 32);
                           ^
/usr/local/opt/lua/include/lua.h:209:66: note: passing argument to parameter 's' here
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
                                                                 ^
src/luanacha.c:257:28: warning: passing 'char [64]' to parameter of type 'uint8_t *' (aka 'unsigned char *') converts
      between pointers to integer types with different sign [-Wpointer-sign]
    crypto_blake2b_general(digest, 64, 0, 0, m, mln);
                           ^~~~~~
src/monocypher.h:88:44: note: passing argument to parameter 'out' here
void crypto_blake2b_general(uint8_t       *out, size_t out_size, // digest
                                           ^
src/luanacha.c:257:46: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
    crypto_blake2b_general(digest, 64, 0, 0, m, mln);
                                             ^
src/monocypher.h:90:44: note: passing argument to parameter 'in' here
                            const uint8_t *in , size_t in_size);
                                           ^
src/luanacha.c:279:13: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if ((keyln < 0)||(keyln > 64)) LERR("bad key size");
             ~~~~~ ^ ~
src/luanacha.c:283:45: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
    crypto_blake2b_general_init(ctx, digln, key, keyln);
                                            ^~~
src/monocypher.h:79:54: note: passing argument to parameter 'key' here
                                 const uint8_t      *key, size_t key_size);
                                                     ^
src/luanacha.c:299:32: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
    crypto_blake2b_update(ctx, t, tln);
                               ^
src/monocypher.h:84:43: note: passing argument to parameter 'in' here
                           const uint8_t *in, size_t in_size);
                                          ^
src/luanacha.c:318:25: warning: passing 'unsigned char [64]' to parameter of type 'const char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
    lua_pushlstring (L, dig, digln);
                        ^~~
/usr/local/opt/lua/include/lua.h:209:66: note: passing argument to parameter 's' here
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
                                                                 ^
src/luanacha.c:334:22: warning: passing 'unsigned char [32]' to parameter of type 'const char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
        lua_pushlstring (L, pk, 32);
                            ^~
/usr/local/opt/lua/include/lua.h:209:66: note: passing argument to parameter 's' here
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
                                                                 ^
src/luanacha.c:335:22: warning: passing 'unsigned char [32]' to parameter of type 'const char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
        lua_pushlstring (L, sk, 32);
                            ^~
/usr/local/opt/lua/include/lua.h:209:66: note: passing argument to parameter 's' here
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
                                                                 ^
src/luanacha.c:348:29: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        crypto_sign_public_key(pk, sk);
                                   ^~
src/monocypher.h:120:44: note: passing argument to parameter 'secret_key' here
                            const uint8_t  secret_key[32]);
                                           ^
src/luanacha.c:349:22: warning: passing 'unsigned char [32]' to parameter of type 'const char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
        lua_pushlstring (L, pk, 32);
                            ^~
/usr/local/opt/lua/include/lua.h:209:66: note: passing argument to parameter 's' here
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
                                                                 ^
src/luanacha.c:367:19: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        crypto_sign(sig, sk, pk, m, mln);
                         ^~
src/monocypher.h:123:33: note: passing argument to parameter 'secret_key' here
                 const uint8_t  secret_key[32],
                                ^
src/luanacha.c:367:23: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        crypto_sign(sig, sk, pk, m, mln);
                             ^~
src/monocypher.h:124:33: note: passing argument to parameter 'public_key' here
                 const uint8_t  public_key[32], // optional, may be 0
                                ^
src/luanacha.c:367:27: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        crypto_sign(sig, sk, pk, m, mln);
                                 ^
src/monocypher.h:125:33: note: passing argument to parameter 'message' here
                 const uint8_t *message, size_t message_size);
                                ^
src/luanacha.c:368:22: warning: passing 'unsigned char [64]' to parameter of type 'const char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
        lua_pushlstring (L, sig, 64);
                            ^~~
/usr/local/opt/lua/include/lua.h:209:66: note: passing argument to parameter 's' here
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
                                                                 ^
src/luanacha.c:386:19: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        r = crypto_check(sig, pk, m, mln);
                         ^~~
src/monocypher.h:127:33: note: passing argument to parameter 'signature' here
int crypto_check(const uint8_t  signature[64],
                                ^
src/luanacha.c:386:24: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        r = crypto_check(sig, pk, m, mln);
                              ^~
src/monocypher.h:128:33: note: passing argument to parameter 'public_key' here
                 const uint8_t  public_key[32],
                                ^
src/luanacha.c:386:28: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
        r = crypto_check(sig, pk, m, mln);
                                  ^
src/monocypher.h:129:33: note: passing argument to parameter 'message' here
                 const uint8_t *message, size_t message_size);
                                ^
src/luanacha.c:412:6: warning: passing 'const char *' to parameter of type 'const uint8_t *' (aka 'const unsigned char *')
      converts between pointers to integer types with different sign [-Wpointer-sign]
                                        pw, pwln, salt, saltln,
                                        ^~
src/monocypher.h:100:36: note: passing argument to parameter 'password' here
                    const uint8_t *password,  uint32_t password_size,
                                   ^
src/luanacha.c:412:16: warning: passing 'const char *' to parameter of type 'const uint8_t *'
      (aka 'const unsigned char *') converts between pointers to integer types with different sign [-Wpointer-sign]
                                        pw, pwln, salt, saltln,
                                                  ^~~~
src/monocypher.h:101:36: note: passing argument to parameter 'salt' here
                    const uint8_t *salt,      uint32_t salt_size,     // >= 8
                                   ^
src/luanacha.c:413:6: warning: passing 'char [1]' to parameter of type 'const uint8_t *' (aka 'const unsigned char *')
      converts between pointers to integer types with different sign [-Wpointer-sign]
                                        "", 0, "", 0    // optional key and additional data
                                        ^~
src/monocypher.h:102:36: note: passing argument to parameter 'key' here
                    const uint8_t *key,       uint32_t key_size,
                                   ^
src/luanacha.c:413:13: warning: passing 'char [1]' to parameter of type 'const uint8_t *' (aka 'const unsigned char *')
      converts between pointers to integer types with different sign [-Wpointer-sign]
                                        "", 0, "", 0    // optional key and additional data
                                               ^~
src/monocypher.h:103:36: note: passing argument to parameter 'ad' here
                    const uint8_t *ad,        uint32_t ad_size);
                                   ^
src/luanacha.c:416:22: warning: passing 'unsigned char [32]' to parameter of type 'const char *' converts between pointers
      to integer types with different sign [-Wpointer-sign]
        lua_pushlstring (L, k, 32);
                            ^
/usr/local/opt/lua/include/lua.h:209:66: note: passing argument to parameter 's' here
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t l);
                                                                 ^
38 warnings generated.
cc -bundle -undefined dynamic_lookup -fPIC -o luanacha.so luanacha.o monocypher.o randombytes.o
/usr/local/bin/lua-5.2 test_luanacha.lua
------------------------------------------------------------
Lua 5.2 luanacha-0.2
------------------------------------------------------------
testing authenticated encryption...
testing blake2b...
testing x25519 key exchange...
testing ed25519 signature...
testing argon2i...
argon2i (100MB, 10 iter) Execution time (sec):  1.572174
test_luanacha  ok
------------------------------------------------------------

Ubuntu 16.04 with -Wall added:

$ make LUAINC=/usr/include/lua5.1 LUADIR=/usr test
cc -c -Os -fPIC -I/usr/include/lua5.1 -Wall src/*.c
src/luanacha.c: In function 'ln_randombytes':
src/luanacha.c:132:25: warning: pointer targets in passing argument 2 of 'lua_pushlstring' differ in signedness [-Wpointer-sign]
     lua_pushlstring (L, buf, bufln);
                         ^
In file included from src/luanacha.c:89:0:
/usr/include/lua5.1/lua.h:163:16: note: expected 'const char *' but argument is of type 'unsigned char *'
 LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
                ^
src/luanacha.c: In function 'ln_lock':
src/luanacha.c:161:39: warning: pointer targets in passing argument 3 of 'crypto_lock' differ in signedness [-Wpointer-sign]
  crypto_lock(buf+pfxln, buf+pfxln+16, k, n, m, mln);
                                       ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:166:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 void crypto_lock(uint8_t        mac[16],
      ^
src/luanacha.c:161:42: warning: pointer targets in passing argument 4 of 'crypto_lock' differ in signedness [-Wpointer-sign]
  crypto_lock(buf+pfxln, buf+pfxln+16, k, n, m, mln);
                                          ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:166:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 void crypto_lock(uint8_t        mac[16],
      ^
src/luanacha.c:161:45: warning: pointer targets in passing argument 5 of 'crypto_lock' differ in signedness [-Wpointer-sign]
  crypto_lock(buf+pfxln, buf+pfxln+16, k, n, m, mln);
                                             ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:166:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 void crypto_lock(uint8_t        mac[16],
      ^
src/luanacha.c:165:22: warning: pointer targets in passing argument 2 of 'lua_pushlstring' differ in signedness [-Wpointer-sign]
  lua_pushlstring (L, buf, bufln);
                      ^
In file included from src/luanacha.c:89:0:
/usr/include/lua5.1/lua.h:163:16: note: expected 'const char *' but argument is of type 'unsigned char *'
 LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
                ^
src/luanacha.c:148:6: warning: unused variable 'r' [-Wunused-variable]
  int r;
      ^
src/luanacha.c: In function 'ln_unlock':
src/luanacha.c:191:25: warning: pointer targets in passing argument 2 of 'crypto_unlock' differ in signedness [-Wpointer-sign]
  r = crypto_unlock(buf, k, n, c+i, c+i+16, boxln-16);
                         ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:172:5: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 int crypto_unlock(uint8_t       *plain_text,
     ^
src/luanacha.c:191:28: warning: pointer targets in passing argument 3 of 'crypto_unlock' differ in signedness [-Wpointer-sign]
  r = crypto_unlock(buf, k, n, c+i, c+i+16, boxln-16);
                            ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:172:5: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 int crypto_unlock(uint8_t       *plain_text,
     ^
src/luanacha.c:191:31: warning: pointer targets in passing argument 4 of 'crypto_unlock' differ in signedness [-Wpointer-sign]
  r = crypto_unlock(buf, k, n, c+i, c+i+16, boxln-16);
                               ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:172:5: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 int crypto_unlock(uint8_t       *plain_text,
     ^
src/luanacha.c:191:36: warning: pointer targets in passing argument 5 of 'crypto_unlock' differ in signedness [-Wpointer-sign]
  r = crypto_unlock(buf, k, n, c+i, c+i+16, boxln-16);
                                    ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:172:5: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 int crypto_unlock(uint8_t       *plain_text,
     ^
src/luanacha.c:198:22: warning: pointer targets in passing argument 2 of 'lua_pushlstring' differ in signedness [-Wpointer-sign]
  lua_pushlstring (L, buf, boxln-16);
                      ^
In file included from src/luanacha.c:89:0:
/usr/include/lua5.1/lua.h:163:16: note: expected 'const char *' but argument is of type 'unsigned char *'
 LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
                ^
src/luanacha.c: In function 'ln_x25519_keypair':
src/luanacha.c:215:22: warning: pointer targets in passing argument 2 of 'lua_pushlstring' differ in signedness [-Wpointer-sign]
  lua_pushlstring (L, pk, 32);
                      ^
In file included from src/luanacha.c:89:0:
/usr/include/lua5.1/lua.h:163:16: note: expected 'const char *' but argument is of type 'unsigned char *'
 LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
                ^
src/luanacha.c:216:22: warning: pointer targets in passing argument 2 of 'lua_pushlstring' differ in signedness [-Wpointer-sign]
  lua_pushlstring (L, sk, 32);
                      ^
In file included from src/luanacha.c:89:0:
/usr/include/lua5.1/lua.h:163:16: note: expected 'const char *' but argument is of type 'unsigned char *'
 LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
                ^
src/luanacha.c: In function 'ln_x25519_public_key':
src/luanacha.c:229:31: warning: pointer targets in passing argument 2 of 'crypto_x25519_public_key' differ in signedness [-Wpointer-sign]
  crypto_x25519_public_key(pk, sk);
                               ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:123:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 void crypto_x25519_public_key(uint8_t       public_key[32],
      ^
src/luanacha.c:230:22: warning: pointer targets in passing argument 2 of 'lua_pushlstring' differ in signedness [-Wpointer-sign]
  lua_pushlstring (L, pk, 32);
                      ^
In file included from src/luanacha.c:89:0:
/usr/include/lua5.1/lua.h:163:16: note: expected 'const char *' but argument is of type 'unsigned char *'
 LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
                ^
src/luanacha.c: In function 'ln_key_exchange':
src/luanacha.c:247:25: warning: pointer targets in passing argument 2 of 'crypto_key_exchange' differ in signedness [-Wpointer-sign]
  crypto_key_exchange(k, sk, pk);
                         ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:145:5: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 int crypto_key_exchange(uint8_t       shared_key      [32],
     ^
src/luanacha.c:247:29: warning: pointer targets in passing argument 3 of 'crypto_key_exchange' differ in signedness [-Wpointer-sign]
  crypto_key_exchange(k, sk, pk);
                             ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:145:5: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 int crypto_key_exchange(uint8_t       shared_key      [32],
     ^
src/luanacha.c:248:21: warning: pointer targets in passing argument 2 of 'lua_pushlstring' differ in signedness [-Wpointer-sign]
  lua_pushlstring(L, k, 32);
                     ^
In file included from src/luanacha.c:89:0:
/usr/include/lua5.1/lua.h:163:16: note: expected 'const char *' but argument is of type 'unsigned char *'
 LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
                ^
src/luanacha.c: In function 'ln_blake2b':
src/luanacha.c:265:28: warning: pointer targets in passing argument 1 of 'crypto_blake2b_general' differ in signedness [-Wpointer-sign]
     crypto_blake2b_general(digest, 64, 0, 0, m, mln);
                            ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:98:6: note: expected 'uint8_t * {aka unsigned char *}' but argument is of type 'char *'
 void crypto_blake2b_general(uint8_t       *hash    , size_t hash_size,
      ^
src/luanacha.c:265:46: warning: pointer targets in passing argument 5 of 'crypto_blake2b_general' differ in signedness [-Wpointer-sign]
     crypto_blake2b_general(digest, 64, 0, 0, m, mln);
                                              ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:98:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 void crypto_blake2b_general(uint8_t       *hash    , size_t hash_size,
      ^
src/luanacha.c: In function 'ln_blake2b_init':
src/luanacha.c:291:45: warning: pointer targets in passing argument 3 of 'crypto_blake2b_general_init' differ in signedness [-Wpointer-sign]
     crypto_blake2b_general_init(ctx, digln, key, keyln);
                                             ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:88:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 void crypto_blake2b_general_init(crypto_blake2b_ctx *ctx, size_t hash_size,
      ^
src/luanacha.c: In function 'ln_blake2b_update':
src/luanacha.c:307:32: warning: pointer targets in passing argument 2 of 'crypto_blake2b_update' differ in signedness [-Wpointer-sign]
     crypto_blake2b_update(ctx, t, tln);
                                ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:93:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 void crypto_blake2b_update(crypto_blake2b_ctx *ctx,
      ^
src/luanacha.c: In function 'ln_blake2b_final':
src/luanacha.c:326:25: warning: pointer targets in passing argument 2 of 'lua_pushlstring' differ in signedness [-Wpointer-sign]
     lua_pushlstring (L, dig, digln);
                         ^
In file included from src/luanacha.c:89:0:
/usr/include/lua5.1/lua.h:163:16: note: expected 'const char *' but argument is of type 'unsigned char *'
 LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
                ^
src/luanacha.c: In function 'ln_sign_keypair':
src/luanacha.c:342:22: warning: pointer targets in passing argument 2 of 'lua_pushlstring' differ in signedness [-Wpointer-sign]
  lua_pushlstring (L, pk, 32);
                      ^
In file included from src/luanacha.c:89:0:
/usr/include/lua5.1/lua.h:163:16: note: expected 'const char *' but argument is of type 'unsigned char *'
 LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
                ^
src/luanacha.c:343:22: warning: pointer targets in passing argument 2 of 'lua_pushlstring' differ in signedness [-Wpointer-sign]
  lua_pushlstring (L, sk, 32);
                      ^
In file included from src/luanacha.c:89:0:
/usr/include/lua5.1/lua.h:163:16: note: expected 'const char *' but argument is of type 'unsigned char *'
 LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
                ^
src/luanacha.c: In function 'ln_sign_public_key':
src/luanacha.c:356:29: warning: pointer targets in passing argument 2 of 'crypto_sign_public_key' differ in signedness [-Wpointer-sign]
  crypto_sign_public_key(pk, sk);
                             ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:130:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 void crypto_sign_public_key(uint8_t        public_key[32],
      ^
src/luanacha.c:357:22: warning: pointer targets in passing argument 2 of 'lua_pushlstring' differ in signedness [-Wpointer-sign]
  lua_pushlstring (L, pk, 32);
                      ^
In file included from src/luanacha.c:89:0:
/usr/include/lua5.1/lua.h:163:16: note: expected 'const char *' but argument is of type 'unsigned char *'
 LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
                ^
src/luanacha.c: In function 'ln_sign':
src/luanacha.c:375:19: warning: pointer targets in passing argument 2 of 'crypto_sign' differ in signedness [-Wpointer-sign]
  crypto_sign(sig, sk, pk, m, mln);
                   ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:133:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 void crypto_sign(uint8_t        signature [64],
      ^
src/luanacha.c:375:23: warning: pointer targets in passing argument 3 of 'crypto_sign' differ in signedness [-Wpointer-sign]
  crypto_sign(sig, sk, pk, m, mln);
                       ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:133:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 void crypto_sign(uint8_t        signature [64],
      ^
src/luanacha.c:375:27: warning: pointer targets in passing argument 4 of 'crypto_sign' differ in signedness [-Wpointer-sign]
  crypto_sign(sig, sk, pk, m, mln);
                           ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:133:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 void crypto_sign(uint8_t        signature [64],
      ^
src/luanacha.c:376:22: warning: pointer targets in passing argument 2 of 'lua_pushlstring' differ in signedness [-Wpointer-sign]
  lua_pushlstring (L, sig, 64);
                      ^
In file included from src/luanacha.c:89:0:
/usr/include/lua5.1/lua.h:163:16: note: expected 'const char *' but argument is of type 'unsigned char *'
 LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
                ^
src/luanacha.c: In function 'ln_check':
src/luanacha.c:394:19: warning: pointer targets in passing argument 1 of 'crypto_check' differ in signedness [-Wpointer-sign]
  r = crypto_check(sig, pk, m, mln);
                   ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:138:5: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 int crypto_check(const uint8_t  signature [64],
     ^
src/luanacha.c:394:24: warning: pointer targets in passing argument 2 of 'crypto_check' differ in signedness [-Wpointer-sign]
  r = crypto_check(sig, pk, m, mln);
                        ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:138:5: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 int crypto_check(const uint8_t  signature [64],
     ^
src/luanacha.c:394:28: warning: pointer targets in passing argument 3 of 'crypto_check' differ in signedness [-Wpointer-sign]
  r = crypto_check(sig, pk, m, mln);
                            ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:138:5: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 int crypto_check(const uint8_t  signature [64],
     ^
src/luanacha.c: In function 'ln_argon2i':
src/luanacha.c:420:6: warning: pointer targets in passing argument 6 of 'crypto_argon2i' differ in signedness [-Wpointer-sign]
      pw, pwln, salt, saltln,
      ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:108:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 void crypto_argon2i(uint8_t       *hash,      uint32_t hash_size,     // >= 4
      ^
src/luanacha.c:420:16: warning: pointer targets in passing argument 8 of 'crypto_argon2i' differ in signedness [-Wpointer-sign]
      pw, pwln, salt, saltln,
                ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:108:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'const char *'
 void crypto_argon2i(uint8_t       *hash,      uint32_t hash_size,     // >= 4
      ^
src/luanacha.c:421:6: warning: pointer targets in passing argument 10 of 'crypto_argon2i' differ in signedness [-Wpointer-sign]
      "", 0, "", 0  // optional key and additional data
      ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:108:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'char *'
 void crypto_argon2i(uint8_t       *hash,      uint32_t hash_size,     // >= 4
      ^
src/luanacha.c:421:13: warning: pointer targets in passing argument 12 of 'crypto_argon2i' differ in signedness [-Wpointer-sign]
      "", 0, "", 0  // optional key and additional data
             ^
In file included from src/luanacha.c:91:0:
src/monocypher.h:108:6: note: expected 'const uint8_t * {aka const unsigned char *}' but argument is of type 'char *'
 void crypto_argon2i(uint8_t       *hash,      uint32_t hash_size,     // >= 4
      ^
src/luanacha.c:424:22: warning: pointer targets in passing argument 2 of 'lua_pushlstring' differ in signedness [-Wpointer-sign]
  lua_pushlstring (L, k, 32);
                      ^
In file included from src/luanacha.c:89:0:
/usr/include/lua5.1/lua.h:163:16: note: expected 'const char *' but argument is of type 'unsigned char *'
 LUA_API void  (lua_pushlstring) (lua_State *L, const char *s, size_t l);
                ^
src/luanacha.c:411:28: warning: unused variable 'mln' [-Wunused-variable]
  size_t pwln, saltln, kln, mln;
                            ^
src/luanacha.c:411:23: warning: unused variable 'kln' [-Wunused-variable]
  size_t pwln, saltln, kln, mln;
                       ^
cc -shared -fPIC -o luanacha.so luanacha.o monocypher.o randombytes.o
/usr/bin/lua test_luanacha.lua
------------------------------------------------------------
Lua 5.1 luanacha-0.3
------------------------------------------------------------
testing authenticated encryption...
testing blake2b...
testing x25519 key exchange...
testing ed25519 signature...
testing argon2i...
argon2i (100MB, 10 iter) Execution time (sec):  1.646793
test_luanacha  ok
------------------------------------------------------------
philanc commented 6 years ago

Thanks for the report. I cannot test on a Mac, but at least on linux with gcc -Wall and clang I should be able to get rid of many of these implicit cast warnings!