blob: 6015717f50b82822776e30688852c3d2633ace8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
// https://cryptopals.com/sets/2/challenges/10
#include "util/aes.h"
#include "util/base64.h"
#include "util/io.h"
/*
* in CBC mode each ciphertext is added to the next plaintext block prior to
* next call to cipher core. first plaintext block is added to the "0th
* ciphertext block" called the initialization vector (IV).
*/
int main() {
size_t ciphertext_len;
uint8_t *ciphertext = base64_decode(read_non_space(stdin), &ciphertext_len);
unsigned char *key = (unsigned char *)"YELLOW SUBMARINE", iv[16] = {0};
unsigned char *decrypted = malloc(ciphertext_len + 16); // inl + block_size
int decrypted_len =
cbc_decrypt(ciphertext, ciphertext_len, key, iv, decrypted);
fwrite(decrypted, 1, decrypted_len, stdout);
return 0;
}
|