diff options
Diffstat (limited to 'set2/task16.c')
| -rw-r--r-- | set2/task16.c | 48 |
1 files changed, 48 insertions, 0 deletions
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); +} |
