diff --git a/.ci/build.sh b/.ci/build.sh index 61103a3..eb40a1f 100755 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -9,7 +9,7 @@ cd "$(dirname "$0")" apk add build-base clang bash libsodium-dev libsodium-static libressl-dev # first build for libressl, which doesn't have "EVP_PBE_scrypt" so can only be compiled with libsodium -make clean all PEGH_LIBSODIUM=1 PEGH_OPENSSL=1 CC=clang LDFLAGS="-static -lcrypto" || clang pegh.c -DPEGH_LIBSODIUM -DPEGH_OPENSSL -static -lsodium -lcrypto -O3 -o pegh +make clean all PEGH_LIBSODIUM=1 PEGH_OPENSSL=1 CC=clang LDFLAGS="-static" mv pegh pegh.static.libsodium-libressl # now remove libressl and install openssl @@ -17,11 +17,11 @@ apk del libressl-dev apk add openssl-dev openssl-libs-static # gcc is apparantly incapable of building a static binary, even gcc -static helloworld.c ends up linked to libc, instead of solving, use clang -make clean all PEGH_LIBSODIUM=1 CC=clang LDFLAGS="-static -lsodium" || clang pegh.c -DPEGH_LIBSODIUM -static -lsodium -O3 -o pegh +make clean all PEGH_LIBSODIUM=1 CC=clang LDFLAGS="-static" mv pegh pegh.static.libsodium -make clean all PEGH_OPENSSL=1 CC=clang LDFLAGS="-static -lcrypto" || clang pegh.c -DPEGH_OPENSSL -static -lcrypto -O3 -o pegh +make clean all PEGH_OPENSSL=1 CC=clang LDFLAGS="-static" mv pegh pegh.static.openssl -make clean all PEGH_LIBSODIUM=1 PEGH_OPENSSL=1 CC=clang LDFLAGS="-static -lcrypto" || clang pegh.c -DPEGH_LIBSODIUM -DPEGH_OPENSSL -static -lsodium -lcrypto -O3 -o pegh +make clean all PEGH_LIBSODIUM=1 PEGH_OPENSSL=1 CC=clang LDFLAGS="-static" mv pegh pegh.static.libsodium-openssl ./pegh.static.libsodium-openssl -h diff --git a/Makefile b/Makefile index 3687d38..e03ef49 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ CFLAGS += -Wall -Wextra -Werror -std=c89 -pedantic \ -Wstrict-prototypes -Wold-style-definition -Wconversion \ - -Wno-missing-prototypes -Wno-missing-noreturn \ + -Wno-missing-prototypes -Wno-missing-noreturn -Wno-format \ -O3 ifdef PEGH_OPENSSL @@ -13,22 +13,22 @@ ifdef PEGH_OPENSSL ifdef PEGH_LIBSODIUM # both libsodium and openssl CFLAGS += -DPEGH_LIBSODIUM -DPEGH_OPENSSL -LDFLAGS += -lsodium -lcrypto +LDLIBS += -lsodium -lcrypto else # only openssl CFLAGS += -DPEGH_OPENSSL -LDFLAGS += -lcrypto +LDLIBS += -lcrypto endif else ifdef PEGH_LIBSODIUM # only libsodium CFLAGS += -DPEGH_LIBSODIUM -LDFLAGS += -lsodium +LDLIBS += -lsodium else # default of only openssl CFLAGS += -DPEGH_OPENSSL -LDFLAGS += -lcrypto +LDLIBS += -lcrypto endif endif diff --git a/pegh.c b/pegh.c index b9287f7..aea875e 100644 --- a/pegh.c +++ b/pegh.c @@ -515,10 +515,10 @@ int gcm_stream(const unsigned char *key, size_t buffer_size, if(buffer_size > CHUNK_SIZE_MAX) { if(NULL != err) { #ifdef PEGH_OPENSSL - fprintf(err, "due to openssl API limitation, buffer_size can at most be %ld\n", CHUNK_SIZE_MAX); + fprintf(err, "due to openssl API limitation, buffer_size can at most be %lu\n", CHUNK_SIZE_MAX); #endif #ifdef PEGH_LIBSODIUM - fprintf(err, "due to AES-256-GCM security constraints, buffer_size can at most be %ld\n", CHUNK_SIZE_MAX); + fprintf(err, "due to AES-256-GCM security constraints, buffer_size can at most be %lu\n", CHUNK_SIZE_MAX); #endif } return 0; @@ -686,7 +686,7 @@ usage: pegh [options...] password\n\ fprintf(stderr, "\ only allocated after scrypt is finished so max usage will be\n\ the highest of these only, not both combined,\n\ - max: %ld, default: %d\n\ + max: %lu, default: %d\n\ -m maximum megabytes of ram to use when deriving key from password\n\ with scrypt, applies for encryption AND decryption, must\n\ almost linearly scale with -N, if too low operation will fail,\n\ @@ -823,7 +823,7 @@ int main(int argc, char **argv) case 'c': buffer_size = parse_int_arg(++optind, argc, argv) * 1024 * 1024; if(buffer_size > CHUNK_SIZE_MAX) { - fprintf(stderr, "Error: %s chunk size cannot exceed %ld megabytes\n", argv[optind - 1], CHUNK_SIZE_MAX / 1024 / 1024); + fprintf(stderr, "Error: %s chunk size cannot exceed %lu megabytes\n", argv[optind - 1], CHUNK_SIZE_MAX / 1024 / 1024); return help(2); } break; diff --git a/test.sh b/test.sh index a493a0d..9cb5869 100755 --- a/test.sh +++ b/test.sh @@ -18,15 +18,15 @@ set -euxo pipefail rm -f pegh # compile against openssl -make PEGH_OPENSSL=1 || cc pegh.c -DPEGH_OPENSSL -lcrypto -O3 -o pegh +make PEGH_OPENSSL=1 || cc -O3 -DPEGH_OPENSSL pegh.c -lcrypto -o pegh mv pegh pegh.openssl # compile against libsodium -make PEGH_LIBSODIUM=1 || cc pegh.c -DPEGH_LIBSODIUM -lsodium -O3 -o pegh +make PEGH_LIBSODIUM=1 || cc -O3 -DPEGH_LIBSODIUM pegh.c -lsodium -o pegh mv pegh pegh.libsodium # compile against both libsodium and openssl as a fallback for CPUs libsodium doesn't support -make PEGH_LIBSODIUM=1 PEGH_OPENSSL=1 || cc pegh.c -DPEGH_LIBSODIUM -DPEGH_OPENSSL -lsodium -lcrypto -O3 -o pegh +make PEGH_LIBSODIUM=1 PEGH_OPENSSL=1 || cc -O3 -DPEGH_LIBSODIUM -DPEGH_OPENSSL pegh.c -lsodium -lcrypto -o pegh mv pegh pegh.libsodium-openssl export key="$(< /dev/urandom tr -dc 'a-z0-9' | head -c12)"