From d85d53bb13c5a97eb82467a884b52014a2110759 Mon Sep 17 00:00:00 2001 From: x1phosura Date: Wed, 27 Apr 2022 01:07:07 -0700 Subject: [PATCH] Add set 1 readme, misc. makefile changes --- .gitignore | 2 ++ set1/Makefile | 20 +++++++++++++++++--- set1/README.md | 28 ++++++++++++++++++++++++++++ set1/src/char-freq-analyze.c | 2 +- 4 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 set1/README.md diff --git a/.gitignore b/.gitignore index 356f27e..e45ea04 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ # general ignore patterns */bin/* +# set 1 ignores +set1/aes-libs/* diff --git a/set1/Makefile b/set1/Makefile index 32e47b9..cc27bd7 100644 --- a/set1/Makefile +++ b/set1/Makefile @@ -2,16 +2,30 @@ CC = gcc CFLAGS = -Wall -Wpedantic -Wextra -std=c99 -fstack-protector-all \ -fdiagnostics-color=auto DEBUG = -0g -ggdb -LINK = +LINK = +LIB_INC = SRC_DIR = src OUT_DIR = bin -TARGETS = base64 fixed-xor char-freq-analize +TARGETS = base64 fixed-xor char-freq-analyze repeating-key-xor aes-ecb all: $(TARGETS) +# TODO toggle mbedtls or tiny-AES-c +#EXT_INCLUDES = -Iaes-libs/mbedtls/include/ +#EXT_LIBS = -Laes-libs/mbedtls/library +#LDLIBS = -lmbedcrypto +# +EXT_INCLUDES = -Iaes-libs/tiny-AES-c +#EXT_LIBS = -Laes-libs/tiny-AES-c +#LDLIBS = -laes + +#%: $(SRC_DIR)/%.c %: $(SRC_DIR)/%.c - $(CC) $(CFLAGS) $(LINK) $< -o $(OUT_DIR)/$@ + $(CC) $(CFLAGS) -o $(OUT_DIR)/$@ $< + +aes-ecb: $(SRC_DIR)/aes-ecb.c + $(CC) $(CFLAGS) $(EXT_INCLUDES) $(EXT_LIBS) -o $(OUT_DIR)/$@ $< $(LDLIBS) clean: $(RM) *.o $(OUT_DIR)/* diff --git a/set1/README.md b/set1/README.md new file mode 100644 index 0000000..debfe6b --- /dev/null +++ b/set1/README.md @@ -0,0 +1,28 @@ +# Set 1 + +Note: may need to `pip install jinja2` in order to `make` mbedtls + +### Challenge 1: Convert hex to base64 +Provided by base64.c + +### Challenge 2: Fixed XOR +Provided by fixed-key-xor.c + +### Challenge 3: Single-byte XOR cipher +Provided by ch3-brute-force.c and char-freq-analyze.c + +### Challenge 4: Detect single-character XOR + + +### Challenge 5: Implement repeating-key XOR +Provided by repeating-key-xor.c + +### Challenge 6: Break repeating-key XOR + + +### Challenge 7: AES in ECB mode + + +### Challenge 8: Detect AES in ECB mode + + diff --git a/set1/src/char-freq-analyze.c b/set1/src/char-freq-analyze.c index 2aa7a8e..98cf44a 100644 --- a/set1/src/char-freq-analyze.c +++ b/set1/src/char-freq-analyze.c @@ -19,7 +19,7 @@ int main() for (i = 0; i < sizeof(byte_freq); ++i) { if (byte_freq[i] != 0) { - printf("%x occurs %d times\n", i, byte_freq[i]); + printf("%lx occurs %d times\n", i, byte_freq[i]); } }