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 | |
parent | utils: usage message update (diff) | |
download | aes-tools-7468cbc7c4e69bbd2593c71c8a22953f41536963.tar.gz aes-tools-7468cbc7c4e69bbd2593c71c8a22953f41536963.zip |
refactoring
Diffstat (limited to '')
-rw-r--r-- | src/aes128.asm | 8 | ||||
-rw-r--r-- | src/aes128.c | 4 | ||||
-rw-r--r-- | src/aes192.asm | 8 | ||||
-rw-r--r-- | src/aes192.c | 4 | ||||
-rw-r--r-- | src/aes256.asm | 8 | ||||
-rw-r--r-- | src/aes256.c | 4 | ||||
-rw-r--r-- | src/file.c | 26 |
7 files changed, 32 insertions, 30 deletions
diff --git a/src/aes128.asm b/src/aes128.asm index 081f25d..b49de0e 100644 --- a/src/aes128.asm +++ b/src/aes128.asm @@ -8,7 +8,7 @@ .code -@raw_aes128_encrypt@20 proc +@raw_aes128_encrypt_block@20 proc pxor xmm0, [ecx] aesenc xmm0, [ecx + 10h] aesenc xmm0, [ecx + 20h] @@ -21,9 +21,9 @@ aesenc xmm0, [ecx + 90h] aesenclast xmm0, [ecx + 0A0h] ret -@raw_aes128_encrypt@20 endp +@raw_aes128_encrypt_block@20 endp -@raw_aes128_decrypt@20 proc +@raw_aes128_decrypt_block@20 proc pxor xmm0, [ecx] aesdec xmm0, [ecx + 10h] aesdec xmm0, [ecx + 20h] @@ -36,7 +36,7 @@ aesdec xmm0, [ecx + 90h] aesdeclast xmm0, [ecx + 0A0h] ret -@raw_aes128_decrypt@20 endp +@raw_aes128_decrypt_block@20 endp @raw_aes128_expand_key_schedule@20 proc ; A "word" (in terms of the FIPS 187 standard) is a 32-bit block. diff --git a/src/aes128.c b/src/aes128.c index c700e30..d4c609d 100644 --- a/src/aes128.c +++ b/src/aes128.c @@ -11,7 +11,7 @@ #include <emmintrin.h> #include <wmmintrin.h> -AesBlock128 __fastcall raw_aes128_encrypt( +AesBlock128 __fastcall raw_aes128_encrypt_block( AesBlock128 plain, Aes128KeySchedule* key_schedule) { @@ -28,7 +28,7 @@ AesBlock128 __fastcall raw_aes128_encrypt( return _mm_aesenclast_si128(plain, key_schedule->keys[10]); } -AesBlock128 __fastcall raw_aes128_decrypt( +AesBlock128 __fastcall raw_aes128_decrypt_block( AesBlock128 cipher, Aes128KeySchedule* inverted_schedule) { diff --git a/src/aes192.asm b/src/aes192.asm index a437801..5cc8ded 100644 --- a/src/aes192.asm +++ b/src/aes192.asm @@ -8,7 +8,7 @@ .code -@raw_aes192_encrypt@20 proc +@raw_aes192_encrypt_block@20 proc pxor xmm0, [ecx] aesenc xmm0, [ecx + 10h] aesenc xmm0, [ecx + 20h] @@ -23,9 +23,9 @@ aesenc xmm0, [ecx + 0B0h] aesenclast xmm0, [ecx + 0C0h] ret -@raw_aes192_encrypt@20 endp +@raw_aes192_encrypt_block@20 endp -@raw_aes192_decrypt@20 proc +@raw_aes192_decrypt_block@20 proc pxor xmm0, [ecx] aesdec xmm0, [ecx + 10h] aesdec xmm0, [ecx + 20h] @@ -40,7 +40,7 @@ aesdec xmm0, [ecx + 0B0h] aesdeclast xmm0, [ecx + 0C0h] ret -@raw_aes192_decrypt@20 endp +@raw_aes192_decrypt_block@20 endp @raw_aes192_expand_key_schedule@36 proc ; A "word" (in terms of the FIPS 187 standard) is a 32-bit block. diff --git a/src/aes192.c b/src/aes192.c index 62f6ce7..fec8f06 100644 --- a/src/aes192.c +++ b/src/aes192.c @@ -11,7 +11,7 @@ #include <emmintrin.h> #include <wmmintrin.h> -AesBlock128 __fastcall raw_aes192_encrypt( +AesBlock128 __fastcall raw_aes192_encrypt_block( AesBlock128 plain, Aes192KeySchedule* key_schedule) { @@ -30,7 +30,7 @@ AesBlock128 __fastcall raw_aes192_encrypt( return _mm_aesenclast_si128(plain, key_schedule->keys[12]); } -AesBlock128 __fastcall raw_aes192_decrypt( +AesBlock128 __fastcall raw_aes192_decrypt_block( AesBlock128 cipher, Aes192KeySchedule* inverted_schedule) { diff --git a/src/aes256.asm b/src/aes256.asm index 3dfd4b2..413e67b 100644 --- a/src/aes256.asm +++ b/src/aes256.asm @@ -8,7 +8,7 @@ .code -@raw_aes256_encrypt@20 proc +@raw_aes256_encrypt_block@20 proc pxor xmm0, [ecx] aesenc xmm0, [ecx + 10h] aesenc xmm0, [ecx + 20h] @@ -25,9 +25,9 @@ aesenc xmm0, [ecx + 0D0h] aesenclast xmm0, [ecx + 0E0h] ret -@raw_aes256_encrypt@20 endp +@raw_aes256_encrypt_block@20 endp -@raw_aes256_decrypt@20 proc +@raw_aes256_decrypt_block@20 proc pxor xmm0, [ecx] aesdec xmm0, [ecx + 10h] aesdec xmm0, [ecx + 20h] @@ -44,7 +44,7 @@ aesdec xmm0, [ecx + 0D0h] aesdeclast xmm0, [ecx + 0E0h] ret -@raw_aes256_decrypt@20 endp +@raw_aes256_decrypt_block@20 endp @raw_aes256_expand_key_schedule@36 proc ; A "word" (in terms of the FIPS 187 standard) is a 32-bit block. diff --git a/src/aes256.c b/src/aes256.c index 25cee25..be4f783 100644 --- a/src/aes256.c +++ b/src/aes256.c @@ -11,7 +11,7 @@ #include <emmintrin.h> #include <wmmintrin.h> -AesBlock128 __fastcall raw_aes256_encrypt( +AesBlock128 __fastcall raw_aes256_encrypt_block( AesBlock128 plain, Aes256KeySchedule* key_schedule) { @@ -32,7 +32,7 @@ AesBlock128 __fastcall raw_aes256_encrypt( return _mm_aesenclast_si128(plain, key_schedule->keys[14]); } -AesBlock128 __fastcall raw_aes256_decrypt( +AesBlock128 __fastcall raw_aes256_decrypt_block( AesBlock128 cipher, Aes256KeySchedule* inverted_schedule) { @@ -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); |