Skip to content
This repository was archived by the owner on Feb 9, 2020. It is now read-only.

Commit 66e8c46

Browse files
rogersmxenith
authored andcommitted
Bcryp improvement (#22)
* Move va_end closer to va_start * Remove unsafe strncpy and use safer snprintf. * Add openwall bcrypt library. * Removing the old crypt library. * Clean up mud.h to include new crypto library include * Updated Makefile to include new crypt library * Small change to mud.h to add the right path to include ow-crypt.h * Added a test case to check the new bcrypt library works. * Added another test for the new bcrypt that must fail to pass. * Change all calls to crypt to correctly use the new API. * Some macOS rubbish that we don't want tracked into git. * Change a C++ comment to C so it can compile in Linux.
1 parent 0363f0a commit 66e8c46

13 files changed

+1762
-402
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ guildmud
44
.vscode/tasks.json
55
*.log
66
.vscode/settings.json
7-
src/libguildmud.a
8-
tests/*.run
7+
libguildmud.a
8+
libblowfish-1.3.a
9+
*.run
10+
Info.plist

Makefile

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ OBJ_FILES = $(filter-out src/main.o, $(SRC_FILES:.c=.o))
99
CHECK_FILES = $(wildcard tests/*.test)
1010
CHECK_FILES_EXE = $(CHECK_FILES:.test=.run)
1111

12-
all: src/main.o src/libguildmud.a
13-
@$(CC) -o src/guildmud src/main.o src/libguildmud.a $(L_FLAGS)
12+
all: src/main.o src/libguildmud.a src/crypt_blowfish-1.3-mini/libblowfish-1.3.a
13+
@$(CC) -o src/guildmud src/main.o src/libguildmud.a src/crypt_blowfish-1.3-mini/libblowfish-1.3.a $(L_FLAGS)
1414

1515
src/libguildmud.a: $(OBJ_FILES)
1616
@ar ru $@ $^
@@ -25,7 +25,7 @@ test: $(CHECK_FILES_EXE)
2525

2626

2727
tests/%.run: tests/%.c src/libguildmud.a
28-
@$(CC) -o $@ $< src/libguildmud.a $(C_FLAGS_TEST) $(L_FLAGS_TEST)
28+
@$(CC) -o $@ $< src/libguildmud.a src/crypt_blowfish-1.3-mini/libblowfish-1.3.a $(C_FLAGS_TEST) $(L_FLAGS_TEST)
2929
# $@ -- Uncomment if we want to run the compiled test
3030

3131
tests/%.c: tests/%.test
@@ -38,3 +38,32 @@ install:
3838
clean:
3939
@echo Cleaning code ...
4040
@rm -rf src/*.o src/guildmud src/libguildmud.a src/*~ tests/*.c tests/run* tests/*.dSYM src/*.dSYM
41+
@rm -rf src/crypt_blowfish-1.3-mini/*.o src/crypt_blowfish-1.3-mini/*~ src/crypt_blowfish-1.3-mini/*a src/crypt_blowfish-1.3-mini/mini-test
42+
43+
# Blowfish compilation rules
44+
45+
AS = $(CC)
46+
LD = $(CC)
47+
BFISH_CFLAGS = -g -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wundef -Wpointer-arith -O2 -fomit-frame-pointer -funroll-loops
48+
BFISH_ASFLAGS = -c
49+
BFISH_LDFLAGS = -sL
50+
51+
CRYPT_OBJS = src/crypt_blowfish-1.3-mini/crypt_blowfish.o \
52+
src/crypt_blowfish-1.3-mini/crypt_gensalt.o \
53+
src/crypt_blowfish-1.3-mini/wrapper.o
54+
55+
crypt: src/crypt_blowfish-1.3-mini/libblowfish-1.3.a src/crypt_blowfish-1.3-mini/mini-test
56+
57+
src/crypt_blowfish-1.3-mini/libblowfish-1.3.a: $(CRYPT_OBJS)
58+
@ar ru $@ $^
59+
@ranlib $@
60+
61+
src/crypt_blowfish-1.3-mini/mini-test: src/crypt_blowfish-1.3-mini/mini-test.o src/crypt_blowfish-1.3-mini/libblowfish-1.3.a
62+
$(CC) -o $@ $< $(L_FLAGS) src/crypt_blowfish-1.3-mini/libblowfish-1.3.a
63+
64+
src/crypt_blowfish-1.3-mini/crypt_blowfish.o: src/crypt_blowfish-1.3-mini/crypt_blowfish.h
65+
src/crypt_blowfish-1.3-mini/crypt_gensalt.o: src/crypt_blowfish-1.3-mini/crypt_gensalt.h
66+
src/crypt_blowfish-1.3-mini/wrapper.o: src/crypt_blowfish-1.3-mini/crypt.h src/crypt_blowfish-1.3-mini/ow-crypt.h \
67+
src/crypt_blowfish-1.3-mini/crypt_blowfish.h src/crypt_blowfish-1.3-mini/crypt_gensalt.h
68+
69+

0 commit comments

Comments
 (0)