all repos — cryptopals-challenges @ 08b7de53f2f279ab297af47e39a65a8bc7eccf32

cryptopals-challenges

Also implement fixed-xor bruteforcer
x1phosura x1phosura@x1phosura.zone
Wed, 27 Apr 2022 01:08:57 -0700
commit

08b7de53f2f279ab297af47e39a65a8bc7eccf32

parent

d85d53bb13c5a97eb82467a884b52014a2110759

2 files changed, 28 insertions(+), 1 deletions(-)

jump to
M set1/Makefileset1/Makefile

@@ -20,7 +20,6 @@ EXT_INCLUDES = -Iaes-libs/tiny-AES-c

#EXT_LIBS = -Laes-libs/tiny-AES-c #LDLIBS = -laes -#%: $(SRC_DIR)/%.c %: $(SRC_DIR)/%.c $(CC) $(CFLAGS) -o $(OUT_DIR)/$@ $<
A set1/src/ch3-brute-force.c

@@ -0,0 +1,28 @@

+#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> + +int main() +{ + uint8_t i = 0; + size_t k; + int8_t ciphertext[] = "\x1b\x37\x37\x33\x31\x36\x3f\x78\x15\x1b\x7f\x2b" + "\x78\x34\x31\x33\x3d\x78\x39\x78\x28\x37\x2d\x36" + "\x3c\x78\x37\x3e\x78\x3a\x39\x3b\x37\x36"; + int8_t attempt[sizeof(ciphertext) - 1]; + + do { + printf("i = %d\n", i); + for (k = 0; k < sizeof(attempt); ++k) { + attempt[k] = ciphertext[k] ^ i; + } + for (k = 0; k < sizeof(attempt); ++k) { + putchar(attempt[k]); + } + putchar('\n'); + ++i; + } while (i < 255); + + return EXIT_SUCCESS; +} +