summaryrefslogtreecommitdiff
path: root/task7.c
diff options
context:
space:
mode:
authorBenedict <benedict@0xb8000.de>2017-02-21 12:52:02 +0100
committerBenedict <benedict@0xb8000.de>2017-02-21 13:00:25 +0100
commitddce9b2d44ab48fc566870c5155b39c8fc06f24d (patch)
tree61e6f8d636190ef19f75bfd9cd8e4861ee04cf4f /task7.c
parentf71df313c4480fb3edd91edb572d8013bec6d352 (diff)
moved files of set1 into subdir
Diffstat (limited to 'task7.c')
-rw-r--r--task7.c86
1 files changed, 0 insertions, 86 deletions
diff --git a/task7.c b/task7.c
deleted file mode 100644
index d71da7a..0000000
--- a/task7.c
+++ /dev/null
@@ -1,86 +0,0 @@
-#include <openssl/conf.h>
-#include <openssl/evp.h>
-#include <openssl/bio.h>
-#include <openssl/err.h>
-
-int handleErrors()
-{
- ERR_print_errors_fp(stderr);
- abort();
-}
-
-int do_crypt(FILE *in, FILE *out, int do_encrypt)
-{
- unsigned char inbuf[1024], outbuf[1024 + EVP_MAX_BLOCK_LENGTH];
- int inlen, outlen;
- EVP_CIPHER_CTX *ctx;
-
- unsigned char key[] = "YELLOW SUBMARINE";
-
- ctx = EVP_CIPHER_CTX_new();
-
- EVP_CipherInit_ex(ctx, EVP_aes_128_ecb(), NULL, NULL, NULL, do_encrypt);
-
- EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, do_encrypt);
-
- for(;;) {
- inlen = fread(inbuf, 1, 1024, in);
- if (inlen <= 0)
- break;
-
- if(!EVP_CipherUpdate(ctx, outbuf, &outlen, inbuf, inlen)) {
- EVP_CIPHER_CTX_free(ctx);
- return 0;
- }
-
- fwrite(outbuf, 1, outlen, out);
- }
-
- if(!EVP_CipherFinal_ex(ctx, outbuf, &outlen)) {
- EVP_CIPHER_CTX_free(ctx);
- return 0;
- }
-
- fwrite(outbuf, 1, outlen, out);
-
- EVP_CIPHER_CTX_free(ctx);
- return 1;
-}
-
-int main(int argc, char **argv)
-{
- ERR_load_crypto_strings();
-
- OpenSSL_add_all_algorithms();
-
- OPENSSL_config(NULL);
-
-
- FILE *in;
- FILE *out;
-
- in = fopen("7unbased.txt", "r");
- out = fopen ("7cleartext.txt", "w");
-
- if ( in == NULL) {
- printf("error in\n");
- return 1;
- }
-
- if (out == NULL) {
- printf("error out\n");
- return 1;
- }
-
- do_crypt(in, out, 0);
-
-
- EVP_cleanup();
-
- CRYPTO_cleanup_all_ex_data();
-
- ERR_free_strings();
-
- return 0;
-}
-