summaryrefslogtreecommitdiff
path: root/set4/task26.c
diff options
context:
space:
mode:
authorBenedict <benedict@0xb8000.de>2016-08-18 23:20:46 +0200
committerBenedict <benedict@0xb8000.de>2017-02-21 13:00:25 +0100
commit2f6023b20f70885b874bf78c4c07046b30c479ab (patch)
tree594a38165ad7cbe43f6152fb5a1163df60863933 /set4/task26.c
parent23f5f88ff8a7dbddf5249d72cafae3d3d5e14294 (diff)
set4, completed challenge 26
Diffstat (limited to 'set4/task26.c')
-rw-r--r--set4/task26.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/set4/task26.c b/set4/task26.c
new file mode 100644
index 0000000..5c7b047
--- /dev/null
+++ b/set4/task26.c
@@ -0,0 +1,32 @@
+#include "../lib/lib.h"
+#include "../lib/lib2.h"
+#include "../lib/lib3.h"
+#include "../lib/lib4.h"
+#include <time.h>
+
+
+int main()
+{
+ generate_random_bytes(key, 16);
+ generate_random_bytes(iv, 16);
+
+ char *encrypted;
+ int length_enc = challenge16_encrypt(":admin<true:", &encrypted, 0);
+
+ char *plaintext;
+ printf("the unchanged string:\n%s\n", plaintext);
+ challenge16_decrypt(encrypted, length_enc, 0);
+ /**
+ * the encrpyt function prepends two blocks
+ *
+ * we need to flip three bits, the 8th bit, 56th bit and the
+ * 96th bit
+ */
+ encrypted[32] ^= 0x01;
+ encrypted[38] ^= 0x01;
+ encrypted[43] ^= 0x01;
+
+ printf("now the changed string:\n");
+ challenge16_decrypt(encrypted, length_enc, 0);
+ return 0;
+}