blob: 05449201b9bc0fee99c56de1ad565e8e9cb03c70 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include "util/aes.h"
#include "util/base64.h"
#include "util/io.h"
int main() {
char *b64txt = read_non_space(stdin);
if (b64txt == NULL) {
printf("read_non_space() failed\n");
exit(1);
}
size_t cyphertext_len;
uint8_t *cyphertext = base64_decode(b64txt, &cyphertext_len);
unsigned char *key =
(unsigned char *)"YELLOW SUBMARINE"; // 128bit best number :^)
unsigned char *decrypted = malloc(cyphertext_len + 16); // inl + block_size
EVP_CIPHER_CTX *ctx = evp_init();
int decrypted_len =
evp_ecb_decrypt(ctx, cyphertext, cyphertext_len, key, decrypted);
if (decrypted_len == -1)
handle_evp_errors();
evp_cleanup(ctx);
decrypted[decrypted_len] = '\0'; // NULL-terminate
printf("decrypted text is: %s\n", decrypted);
return 0;
}
|