From: Loup Vaillant Date: Wed, 26 Apr 2017 16:06:00 +0000 (+0200) Subject: organised stuff into folders X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=76a93e3fe829cb3a2e07cc63af82f81596473322;p=Monocypher.git organised stuff into folders --- diff --git a/makefile b/makefile index f09ea76..0586057 100644 --- a/makefile +++ b/makefile @@ -1,37 +1,43 @@ CC=gcc -CFLAGS=-O2 -Wall -Wextra -std=c11 -pedantic +CFLAGS= -I src -O2 -Wall -Wextra -std=c11 -pedantic -.PHONY: all clean +.PHONY: all clean directories # disable implicit rules .SUFFIXES: all: test sodium clean: - rm -f *.o *.gch test rename_* + rm -rf bin + rm -f src/*.gch src/rename_* + rm -f test sodium # Test suite based on test vectors -test: test.c monocypher.o sha512.o +test: tests/test.c bin/monocypher.o bin/sha512.o $(CC) $(CFLAGS) -o $@ $^ # Test suite based on comparison with libsodium C_SODIUM_FLAGS=$$(pkg-config --cflags libsodium) LD_SODIUM_FLAGS=$$(pkg-config --libs libsodium) -sodium: sodium.c rename_monocypher.o rename_sha512.o +sodium: tests/sodium.c bin/rename_monocypher.o bin/rename_sha512.o $(CC) $(CFLAGS) -o $@ $^ $(C_SODIUM_FLAGS) $(LD_SODIUM_FLAGS) # compile monocypher # use -DED25519_SHA512 for ed25519 compatibility -rename_monocypher.o: rename_monocypher.c rename_monocypher.h rename_sha512.h - $(CC) $(CFLAGS) -c $^ -DED25519_SHA512 -monocypher.o: monocypher.c monocypher.h sha512.h - $(CC) $(CFLAGS) -c $^ -DED25519_SHA512 +bin/rename_monocypher.o: src/rename_monocypher.c src/rename_monocypher.h src/rename_sha512.h + @mkdir -p $(@D) + $(CC) $(CFLAGS) -o $@ -c $< -DED25519_SHA512 +bin/monocypher.o: src/monocypher.c src/monocypher.h src/sha512.h + @mkdir -p $(@D) + $(CC) $(CFLAGS) -o $@ -c $< -DED25519_SHA512 # compile sha512. Only used for ed15519 compatibility -sha512.o: sha512.c sha512.h - $(CC) $(CFLAGS) -c $^ -rename_sha512.o: rename_sha512.c rename_sha512.h - $(CC) $(CFLAGS) -c $^ +bin/sha512.o: src/sha512.c src/sha512.h + @mkdir -p $(@D) + $(CC) $(CFLAGS) -o $@ -c $< +bin/rename_sha512.o: src/rename_sha512.c src/rename_sha512.h + @mkdir -p $(@D) + $(CC) $(CFLAGS) -o $@ -c $< # change the "crypto_" prefix to the "rename_" prefix, so you can use # monocypher with other crypto libraries without conflict. diff --git a/monocypher.c b/src/monocypher.c similarity index 100% rename from monocypher.c rename to src/monocypher.c diff --git a/monocypher.h b/src/monocypher.h similarity index 100% rename from monocypher.h rename to src/monocypher.h diff --git a/more_speed.c b/src/more_speed.c similarity index 100% rename from more_speed.c rename to src/more_speed.c diff --git a/sha512.c b/src/sha512.c similarity index 100% rename from sha512.c rename to src/sha512.c diff --git a/sha512.h b/src/sha512.h similarity index 100% rename from sha512.h rename to src/sha512.h diff --git a/sodium.c b/tests/sodium.c similarity index 100% rename from sodium.c rename to tests/sodium.c diff --git a/test.c b/tests/test.c similarity index 92% rename from test.c rename to tests/test.c index b220523..ace06d5 100644 --- a/test.c +++ b/tests/test.c @@ -433,21 +433,21 @@ static int test_aead() int main(void) { int status = 0; - status |= generic_test(equal, "vectors_test_equal" , 2); - status |= generic_test(diff , "vectors_test_diff" , 2); - status |= test(chacha20 , "vectors_chacha20" , 2); - status |= test(hchacha20 , "vectors_h_chacha20" , 2); - status |= test(xchacha20 , "vectors_x_chacha20" , 2); - status |= test(blake2b , "vectors_blake2b" , 2); - status |= test(blake2b_easy , "vectors_blake2b_easy", 1); - status |= test(poly1305 , "vectors_poly1305" , 2); - status |= test(argon2i , "vectors_argon2i" , 6); - status |= test(x25519 , "vectors_x25519" , 2); - status |= test(key_exchange , "vectors_key_exchange", 2); - status |= test(sha512 , "vectors_sha512" , 1); - status |= test(ed25519_key , "vectors_ed25519_key" , 1); - status |= test(ed25519_sign1, "vectors_ed25519_sign", 3); - status |= test(ed25519_sign2, "vectors_ed25519_sign", 3); + status |= generic_test(equal, "tests/vectors/test_equal" , 2); + status |= generic_test(diff , "tests/vectors/test_diff" , 2); + status |= test(chacha20 , "tests/vectors/chacha20" , 2); + status |= test(hchacha20 , "tests/vectors/h_chacha20" , 2); + status |= test(xchacha20 , "tests/vectors/x_chacha20" , 2); + status |= test(blake2b , "tests/vectors/blake2b" , 2); + status |= test(blake2b_easy , "tests/vectors/blake2b_easy", 1); + status |= test(poly1305 , "tests/vectors/poly1305" , 2); + status |= test(argon2i , "tests/vectors/argon2i" , 6); + status |= test(x25519 , "tests/vectors/x25519" , 2); + status |= test(key_exchange , "tests/vectors/key_exchange", 2); + status |= test(sha512 , "tests/vectors/sha512" , 1); + status |= test(ed25519_key , "tests/vectors/ed25519_key" , 1); + status |= test(ed25519_sign1, "tests/vectors/ed25519_sign", 3); + status |= test(ed25519_sign2, "tests/vectors/ed25519_sign", 3); status |= test_x25519(); status |= test_aead(); printf(status ? "TESTS FAILED\n" : "ALL TESTS OK\n"); diff --git a/vectors_argon2i b/tests/vectors/argon2i similarity index 100% rename from vectors_argon2i rename to tests/vectors/argon2i diff --git a/vectors_blake2b b/tests/vectors/blake2b similarity index 100% rename from vectors_blake2b rename to tests/vectors/blake2b diff --git a/vectors_blake2b_easy b/tests/vectors/blake2b_easy similarity index 100% rename from vectors_blake2b_easy rename to tests/vectors/blake2b_easy diff --git a/vectors_chacha20 b/tests/vectors/chacha20 similarity index 100% rename from vectors_chacha20 rename to tests/vectors/chacha20 diff --git a/vectors_ed25519_key b/tests/vectors/ed25519_key similarity index 100% rename from vectors_ed25519_key rename to tests/vectors/ed25519_key diff --git a/vectors_ed25519_sign b/tests/vectors/ed25519_sign similarity index 100% rename from vectors_ed25519_sign rename to tests/vectors/ed25519_sign diff --git a/vectors_h_chacha20 b/tests/vectors/h_chacha20 similarity index 100% rename from vectors_h_chacha20 rename to tests/vectors/h_chacha20 diff --git a/vectors_key_exchange b/tests/vectors/key_exchange similarity index 100% rename from vectors_key_exchange rename to tests/vectors/key_exchange diff --git a/vectors_poly1305 b/tests/vectors/poly1305 similarity index 100% rename from vectors_poly1305 rename to tests/vectors/poly1305 diff --git a/vectors_sha512 b/tests/vectors/sha512 similarity index 100% rename from vectors_sha512 rename to tests/vectors/sha512 diff --git a/vectors_test_diff b/tests/vectors/test_diff similarity index 100% rename from vectors_test_diff rename to tests/vectors/test_diff diff --git a/vectors_test_equal b/tests/vectors/test_equal similarity index 100% rename from vectors_test_equal rename to tests/vectors/test_equal diff --git a/vectors_x25519 b/tests/vectors/x25519 similarity index 100% rename from vectors_x25519 rename to tests/vectors/x25519 diff --git a/vectors_x_chacha20 b/tests/vectors/x_chacha20 similarity index 100% rename from vectors_x_chacha20 rename to tests/vectors/x_chacha20