diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-10 03:56:20 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-10 03:56:20 +0300 |
commit | 7468cbc7c4e69bbd2593c71c8a22953f41536963 (patch) | |
tree | bbc0b0ebb62ceb7385a418701897cb5577f035f9 /src/file.c | |
parent | utils: usage message update (diff) | |
download | aes-tools-7468cbc7c4e69bbd2593c71c8a22953f41536963.tar.gz aes-tools-7468cbc7c4e69bbd2593c71c8a22953f41536963.zip |
refactoring
Diffstat (limited to 'src/file.c')
-rw-r--r-- | src/file.c | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -11,10 +11,11 @@ #include <stdlib.h> #include <string.h> -size_t aes128ecb_encrypt_file(const unsigned char* src, - size_t src_size, - unsigned char* dest, - Aes128KeySchedule* key_schedule) +size_t aes128ecb_encrypt_buffer( + const unsigned char* src, + size_t src_size, + unsigned char* dest, + Aes128KeySchedule* key_schedule) { size_t rem_size = src_size % 16; size_t padding_size = 16 - rem_size; @@ -28,7 +29,7 @@ size_t aes128ecb_encrypt_file(const unsigned char* src, for (size_t i = 0; i < src_len; ++i, src += 16, dest += 16) { AesBlock128 plaintext = load_aes_block128(src); - AesBlock128 ciphertext = aes128ecb_encrypt(plaintext, key_schedule); + AesBlock128 ciphertext = aes128ecb_encrypt_block(plaintext, key_schedule); store_aes_block128(ciphertext, dest); } @@ -41,16 +42,17 @@ size_t aes128ecb_encrypt_file(const unsigned char* src, } AesBlock128 plaintext = load_aes_block128(padding); - AesBlock128 ciphertext = aes128ecb_encrypt(plaintext, key_schedule); + AesBlock128 ciphertext = aes128ecb_encrypt_block(plaintext, key_schedule); store_aes_block128(ciphertext, dest); return dest_size; } -size_t aes128ecb_decrypt_file(const unsigned char* src, - size_t src_size, - unsigned char* dest, - Aes128KeySchedule* inverted_schedule) +size_t aes128ecb_decrypt_buffer( + const unsigned char* src, + size_t src_size, + unsigned char* dest, + Aes128KeySchedule* inverted_schedule) { size_t dest_size = src_size; @@ -62,12 +64,12 @@ size_t aes128ecb_decrypt_file(const unsigned char* src, for (size_t i = 0; i < src_len - 1; ++i, src += 16, dest += 16) { AesBlock128 ciphertext = load_aes_block128(src); - AesBlock128 plaintext = aes128ecb_decrypt(ciphertext, inverted_schedule); + AesBlock128 plaintext = aes128ecb_decrypt_block(ciphertext, inverted_schedule); store_aes_block128(plaintext, dest); } AesBlock128 ciphertext = load_aes_block128(src); - AesBlock128 plaintext = aes128ecb_decrypt(ciphertext, inverted_schedule); + AesBlock128 plaintext = aes128ecb_decrypt_block(ciphertext, inverted_schedule); unsigned char padding[16]; store_aes_block128(plaintext, padding); |