aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/buffer.c b/src/buffer.c
index ff14f18..b4896f7 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -13,11 +13,11 @@
static unsigned char FULL_BLOCK_PADDING[16] = { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 };
-size_t aes128ecb_encrypt_buffer(
- const unsigned char* src,
+size_t aesni_encrypt_buffer_ecb128(
+ const void* src,
size_t src_size,
- unsigned char* dest,
- Aes128KeySchedule* key_schedule)
+ void* dest,
+ AesNI_KeySchedule128* key_schedule)
{
size_t rem_size = src_size % 16;
size_t padding_size = 16 - rem_size;
@@ -28,11 +28,11 @@ size_t aes128ecb_encrypt_buffer(
size_t src_len = src_size / 16;
- for (size_t i = 0; i < src_len; ++i, src += 16, dest += 16)
+ for (size_t i = 0; i < src_len; ++i, (char*) src += 16, (char*) dest += 16)
{
- AesBlock128 plaintext = load_aes_block128(src);
- AesBlock128 ciphertext = aes128ecb_encrypt_block(plaintext, key_schedule);
- store_aes_block128(ciphertext, dest);
+ AesNI_Block128 plaintext = aesni_load_block128(src);
+ AesNI_Block128 ciphertext = aesni_encrypt_block_ecb128(plaintext, key_schedule);
+ aesni_store_block128(dest, ciphertext);
}
unsigned char padding[16];
@@ -47,9 +47,9 @@ size_t aes128ecb_encrypt_buffer(
memset(padding + rem_size, padding_size, padding_size);
}
- AesBlock128 plaintext = load_aes_block128(padding);
- AesBlock128 ciphertext = aes128ecb_encrypt_block(plaintext, key_schedule);
- store_aes_block128(ciphertext, dest);
+ AesNI_Block128 plaintext = aesni_load_block128(padding);
+ AesNI_Block128 ciphertext = aesni_encrypt_block_ecb128(plaintext, key_schedule);
+ aesni_store_block128(dest, ciphertext);
return dest_size;
}
@@ -66,11 +66,11 @@ static unsigned char get_padding_size(const unsigned char* padding)
return padding[15];
}
-size_t aes128ecb_decrypt_buffer(
- const unsigned char* src,
+size_t aesni_decrypt_buffer_ecb128(
+ const void* src,
size_t src_size,
- unsigned char* dest,
- Aes128KeySchedule* inverted_schedule)
+ void* dest,
+ AesNI_KeySchedule128* inverted_schedule)
{
size_t dest_size = src_size;
@@ -79,17 +79,17 @@ size_t aes128ecb_decrypt_buffer(
size_t src_len = src_size / 16;
- for (size_t i = 0; i < src_len - 1; ++i, src += 16, dest += 16)
+ for (size_t i = 0; i < src_len - 1; ++i, (char*) src += 16, (char*) dest += 16)
{
- AesBlock128 ciphertext = load_aes_block128(src);
- AesBlock128 plaintext = aes128ecb_decrypt_block(ciphertext, inverted_schedule);
- store_aes_block128(plaintext, dest);
+ AesNI_Block128 ciphertext = aesni_load_block128(src);
+ AesNI_Block128 plaintext = aesni_decrypt_block_ecb128(ciphertext, inverted_schedule);
+ aesni_store_block128(dest, plaintext);
}
- AesBlock128 ciphertext = load_aes_block128(src);
- AesBlock128 plaintext = aes128ecb_decrypt_block(ciphertext, inverted_schedule);
+ AesNI_Block128 ciphertext = aesni_load_block128(src);
+ AesNI_Block128 plaintext = aesni_decrypt_block_ecb128(ciphertext, inverted_schedule);
unsigned char padding[16];
- store_aes_block128(plaintext, padding);
+ aesni_store_block128(padding, plaintext);
unsigned char padding_size = get_padding_size(padding);