diff options
Diffstat (limited to 'set2')
| -rw-r--r-- | set2/Makefile | 6 | ||||
| -rw-r--r-- | set2/task16.c | 48 |
2 files changed, 52 insertions, 2 deletions
diff --git a/set2/Makefile b/set2/Makefile index a2d66d4..914471a 100644 --- a/set2/Makefile +++ b/set2/Makefile @@ -3,7 +3,7 @@ CC=gcc CFLAGS := -g $(CFLAGS) CLIBS=`pkg-config --cflags --libs libcrypto` -all: task9 task10 task11 task12 task13 task15 +all: task9 task10 task11 task12 task13 task15 task16 task9: $(CC) $(CFLAGS) task9.c $(LIB) $(CLIBS) -o task9 @@ -17,5 +17,7 @@ task13: $(CC) $(CFLAGS) task13.c $(LIB) $(CLIBS) -o task13 task15: $(CC) $(CFLAGS) task15.c $(LIB) $(CLIBS) -o task15 +task16: + $(CC) $(CFLAGS) task16.c $(LIB) $(CLIBS) -o task16 clean: - rm task9 task10 task11 task12 task13 task15 + rm task9 task10 task11 task12 task13 task15 task16 diff --git a/set2/task16.c b/set2/task16.c new file mode 100644 index 0000000..f60205e --- /dev/null +++ b/set2/task16.c @@ -0,0 +1,48 @@ +#include "../lib/lib2.h" +#include "../lib/lib.h" +/** + * produces an identical bit error in the following block + * this means: we can control the whole content of the following + * block, when the counterpart decrpyts it + * If there is a 0 in the second block and we want a 1, then flip + * the bit in the prior block at the same position + * If there is a 0 and we want a null, than do nothing + * For one respectivally. + * + * Since ; and = are escaped we need charecters so that with one flip + * we can get ; and =. + * for ; use : in the plaintext. in the ciphtertext we need to flip the + * last bit of : and the resulting plaintext get ; + * for = we use <. we also need to flip the last bit + * + * so out plaintext we give the orcale function is :admin<true: + * + * + * + */ +int main(int argc, char **argv) +{ + // initialize key + generate_random_bytes(key, 16); + memset(iv, 0, 16); + //generate_random_bytes(iv, 16); + char *encrypted; + // one block of our input + int length = challenge16_encrypt(":admin<true:1234", &encrypted); + + printf("first the unchanged string:\n"); + challenge16_decrypt(encrypted, length); + /** + * change ciphertext here + * we now that our text start a the third block, because the + * challenge16_encrypt function prepends a string + * we need to flip three bits, the 8th bit, 56th bit and the + * 96th bit + */ + encrypted[32-16] ^= 0x01; + encrypted[38-16] ^= 0x01; + encrypted[43-16] ^= 0x01; + + printf("now the changed string:\n"); + challenge16_decrypt(encrypted, length); +} |
