aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/box.c
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-05-19 04:48:59 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-05-19 04:48:59 +0300
commitf0393777befc4ff1024513dab3ab6bad0e7ec45f (patch)
tree97571103c522ff60f96a8fdde35a0bbee9532837 /src/box.c
parentrename the project (diff)
downloadaes-tools-f0393777befc4ff1024513dab3ab6bad0e7ec45f.tar.gz
aes-tools-f0393777befc4ff1024513dab3ab6bad0e7ec45f.zip
'aesni' -> 'aes'
Diffstat (limited to 'src/box.c')
-rw-r--r--src/box.c454
1 files changed, 227 insertions, 227 deletions
diff --git a/src/box.c b/src/box.c
index 7a26333..ca5479e 100644
--- a/src/box.c
+++ b/src/box.c
@@ -11,26 +11,26 @@
#include <stdlib.h>
#include <string.h>
-static const AesNI_BoxAlgorithmInterface* aesni_box_algorithms[] =
+static const AES_BoxAlgorithmInterface* aes_box_algorithms[] =
{
- &aesni_box_algorithm_aes128,
- &aesni_box_algorithm_aes192,
- &aesni_box_algorithm_aes256,
+ &aes_box_algorithm_aes128,
+ &aes_box_algorithm_aes192,
+ &aes_box_algorithm_aes256,
};
-AesNI_StatusCode aesni_box_init(
- AesNI_Box* box,
- AesNI_Algorithm algorithm,
- const AesNI_BoxKey* box_key,
- AesNI_Mode mode,
- const AesNI_BoxBlock* iv,
- AesNI_ErrorDetails* err_details)
+AES_StatusCode aes_box_init(
+ AES_Box* box,
+ AES_Algorithm algorithm,
+ const AES_BoxKey* box_key,
+ AES_Mode mode,
+ const AES_BoxBlock* iv,
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
- box->algorithm = aesni_box_algorithms[algorithm];
+ box->algorithm = aes_box_algorithms[algorithm];
- if (aesni_is_error(status = box->algorithm->calc_round_keys(
+ if (aes_is_error(status = box->algorithm->calc_round_keys(
box_key,
&box->encryption_keys,
&box->decryption_keys,
@@ -44,30 +44,30 @@ AesNI_StatusCode aesni_box_init(
return status;
}
-static AesNI_StatusCode aesni_box_encrypt_block_ecb(
- AesNI_Box* box,
- const AesNI_BoxBlock* input,
- AesNI_BoxBlock* output,
- AesNI_ErrorDetails* err_details)
+static AES_StatusCode aes_box_encrypt_block_ecb(
+ AES_Box* box,
+ const AES_BoxBlock* input,
+ AES_BoxBlock* output,
+ AES_ErrorDetails* err_details)
{
return box->algorithm->encrypt_block(
input, &box->encryption_keys, output, err_details);
}
-static AesNI_StatusCode aesni_box_encrypt_block_cbc(
- AesNI_Box* box,
- const AesNI_BoxBlock* input,
- AesNI_BoxBlock* output,
- AesNI_ErrorDetails* err_details)
+static AES_StatusCode aes_box_encrypt_block_cbc(
+ AES_Box* box,
+ const AES_BoxBlock* input,
+ AES_BoxBlock* output,
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
- AesNI_BoxBlock xored_input = *input;
+ AES_StatusCode status = AES_SUCCESS;
+ AES_BoxBlock xored_input = *input;
- if (aesni_is_error(status = box->algorithm->xor_block(
+ if (aes_is_error(status = box->algorithm->xor_block(
&xored_input, &box->iv, err_details)))
return status;
- if (aesni_is_error(status = box->algorithm->encrypt_block(
+ if (aes_is_error(status = box->algorithm->encrypt_block(
&xored_input, &box->encryption_keys, output, err_details)))
return status;
@@ -75,19 +75,19 @@ static AesNI_StatusCode aesni_box_encrypt_block_cbc(
return status;
}
-static AesNI_StatusCode aesni_box_encrypt_block_cfb(
- AesNI_Box* box,
- const AesNI_BoxBlock* input,
- AesNI_BoxBlock* output,
- AesNI_ErrorDetails* err_details)
+static AES_StatusCode aes_box_encrypt_block_cfb(
+ AES_Box* box,
+ const AES_BoxBlock* input,
+ AES_BoxBlock* output,
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
- if (aesni_is_error(status = box->algorithm->encrypt_block(
+ if (aes_is_error(status = box->algorithm->encrypt_block(
&box->iv, &box->encryption_keys, output, err_details)))
return status;
- if (aesni_is_error(status = box->algorithm->xor_block(
+ if (aes_is_error(status = box->algorithm->xor_block(
output, input, err_details)))
return status;
@@ -95,98 +95,98 @@ static AesNI_StatusCode aesni_box_encrypt_block_cfb(
return status;
}
-static AesNI_StatusCode aesni_box_encrypt_block_ofb(
- AesNI_Box* box,
- const AesNI_BoxBlock* input,
- AesNI_BoxBlock* output,
- AesNI_ErrorDetails* err_details)
+static AES_StatusCode aes_box_encrypt_block_ofb(
+ AES_Box* box,
+ const AES_BoxBlock* input,
+ AES_BoxBlock* output,
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
- if (aesni_is_error(status = box->algorithm->encrypt_block(
+ if (aes_is_error(status = box->algorithm->encrypt_block(
&box->iv, &box->encryption_keys, &box->iv, err_details)))
return status;
*output = box->iv;
- if (aesni_is_error(status = box->algorithm->xor_block(
+ if (aes_is_error(status = box->algorithm->xor_block(
output, input, err_details)))
return status;
return status;
}
-static AesNI_StatusCode aesni_box_encrypt_block_ctr(
- AesNI_Box* box,
- const AesNI_BoxBlock* input,
- AesNI_BoxBlock* output,
- AesNI_ErrorDetails* err_details)
+static AES_StatusCode aes_box_encrypt_block_ctr(
+ AES_Box* box,
+ const AES_BoxBlock* input,
+ AES_BoxBlock* output,
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
- if (aesni_is_error(status = box->algorithm->encrypt_block(
+ if (aes_is_error(status = box->algorithm->encrypt_block(
&box->iv, &box->encryption_keys, output, err_details)))
return status;
- if (aesni_is_error(status = box->algorithm->xor_block(
+ if (aes_is_error(status = box->algorithm->xor_block(
output, input, err_details)))
return status;
- if (aesni_is_error(status = box->algorithm->inc_block(
+ if (aes_is_error(status = box->algorithm->inc_block(
&box->iv, err_details)))
return status;
return status;
}
-typedef AesNI_StatusCode (*AesNI_BoxEncryptBlockInMode)(
- AesNI_Box*,
- const AesNI_BoxBlock*,
- AesNI_BoxBlock*,
- AesNI_ErrorDetails*);
+typedef AES_StatusCode (*AES_BoxEncryptBlockInMode)(
+ AES_Box*,
+ const AES_BoxBlock*,
+ AES_BoxBlock*,
+ AES_ErrorDetails*);
-static AesNI_BoxEncryptBlockInMode aesni_box_encrypt_block_in_mode[] =
+static AES_BoxEncryptBlockInMode aes_box_encrypt_block_in_mode[] =
{
- &aesni_box_encrypt_block_ecb,
- &aesni_box_encrypt_block_cbc,
- &aesni_box_encrypt_block_cfb,
- &aesni_box_encrypt_block_ofb,
- &aesni_box_encrypt_block_ctr,
+ &aes_box_encrypt_block_ecb,
+ &aes_box_encrypt_block_cbc,
+ &aes_box_encrypt_block_cfb,
+ &aes_box_encrypt_block_ofb,
+ &aes_box_encrypt_block_ctr,
};
-AesNI_StatusCode aesni_box_encrypt_block(
- AesNI_Box* box,
- const AesNI_BoxBlock* input,
- AesNI_BoxBlock* output,
- AesNI_ErrorDetails* err_details)
+AES_StatusCode aes_box_encrypt_block(
+ AES_Box* box,
+ const AES_BoxBlock* input,
+ AES_BoxBlock* output,
+ AES_ErrorDetails* err_details)
{
- return aesni_box_encrypt_block_in_mode[box->mode](
+ return aes_box_encrypt_block_in_mode[box->mode](
box, input, output, err_details);
}
-static AesNI_StatusCode aesni_box_decrypt_block_ecb(
- AesNI_Box* box,
- const AesNI_BoxBlock* input,
- AesNI_BoxBlock* output,
- AesNI_ErrorDetails* err_details)
+static AES_StatusCode aes_box_decrypt_block_ecb(
+ AES_Box* box,
+ const AES_BoxBlock* input,
+ AES_BoxBlock* output,
+ AES_ErrorDetails* err_details)
{
return box->algorithm->decrypt_block(
input, &box->decryption_keys, output, err_details);
}
-static AesNI_StatusCode aesni_box_decrypt_block_cbc(
- AesNI_Box* box,
- const AesNI_BoxBlock* input,
- AesNI_BoxBlock* output,
- AesNI_ErrorDetails* err_details)
+static AES_StatusCode aes_box_decrypt_block_cbc(
+ AES_Box* box,
+ const AES_BoxBlock* input,
+ AES_BoxBlock* output,
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
- if (aesni_is_error(status = box->algorithm->decrypt_block(
+ if (aes_is_error(status = box->algorithm->decrypt_block(
input, &box->decryption_keys, output, err_details)))
return status;
- if (aesni_is_error(status = box->algorithm->xor_block(
+ if (aes_is_error(status = box->algorithm->xor_block(
output, &box->iv, err_details)))
return status;
@@ -194,19 +194,19 @@ static AesNI_StatusCode aesni_box_decrypt_block_cbc(
return status;
}
-static AesNI_StatusCode aesni_box_decrypt_block_cfb(
- AesNI_Box* box,
- const AesNI_BoxBlock* input,
- AesNI_BoxBlock* output,
- AesNI_ErrorDetails* err_details)
+static AES_StatusCode aes_box_decrypt_block_cfb(
+ AES_Box* box,
+ const AES_BoxBlock* input,
+ AES_BoxBlock* output,
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
- if (aesni_is_error(status = box->algorithm->encrypt_block(
+ if (aes_is_error(status = box->algorithm->encrypt_block(
&box->iv, &box->encryption_keys, output, err_details)))
return status;
- if (aesni_is_error(status = box->algorithm->xor_block(
+ if (aes_is_error(status = box->algorithm->xor_block(
output, input, err_details)))
return status;
@@ -214,44 +214,44 @@ static AesNI_StatusCode aesni_box_decrypt_block_cfb(
return status;
}
-typedef AesNI_BoxEncryptBlockInMode AesNI_BoxDecryptBlockInMode;
+typedef AES_BoxEncryptBlockInMode AES_BoxDecryptBlockInMode;
-static AesNI_BoxDecryptBlockInMode aesni_box_decrypt_block_in_mode[] =
+static AES_BoxDecryptBlockInMode aes_box_decrypt_block_in_mode[] =
{
- &aesni_box_decrypt_block_ecb,
- &aesni_box_decrypt_block_cbc,
- &aesni_box_decrypt_block_cfb,
- &aesni_box_encrypt_block_ofb,
- &aesni_box_encrypt_block_ctr,
+ &aes_box_decrypt_block_ecb,
+ &aes_box_decrypt_block_cbc,
+ &aes_box_decrypt_block_cfb,
+ &aes_box_encrypt_block_ofb,
+ &aes_box_encrypt_block_ctr,
};
-AesNI_StatusCode aesni_box_decrypt_block(
- AesNI_Box* box,
- const AesNI_BoxBlock* input,
- AesNI_BoxBlock* output,
- AesNI_ErrorDetails* err_details)
+AES_StatusCode aes_box_decrypt_block(
+ AES_Box* box,
+ const AES_BoxBlock* input,
+ AES_BoxBlock* output,
+ AES_ErrorDetails* err_details)
{
- return aesni_box_decrypt_block_in_mode[box->mode](
+ return aes_box_decrypt_block_in_mode[box->mode](
box, input, output, err_details);
}
-static AesNI_StatusCode aesni_box_get_encrypted_buffer_size(
- AesNI_Box* box,
+static AES_StatusCode aes_box_get_encrypted_buffer_size(
+ AES_Box* box,
size_t src_size,
size_t* dest_size,
size_t* padding_size,
- AesNI_ErrorDetails* err_details)
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
switch (box->mode)
{
- case AESNI_ECB:
- case AESNI_CBC:
+ case AES_ECB:
+ case AES_CBC:
{
size_t block_size;
- if (aesni_is_error(status = box->algorithm->get_block_size(
+ if (aes_is_error(status = box->algorithm->get_block_size(
&block_size, err_details)))
return status;
@@ -260,77 +260,77 @@ static AesNI_StatusCode aesni_box_get_encrypted_buffer_size(
return status;
}
- case AESNI_CFB:
- case AESNI_OFB:
- case AESNI_CTR:
+ case AES_CFB:
+ case AES_OFB:
+ case AES_CTR:
*dest_size = src_size;
*padding_size = 0;
return status;
default:
- return aesni_error_not_implemented(
+ return aes_error_not_implemented(
err_details, "unsupported mode of operation");
}
}
-static AesNI_StatusCode aesni_box_encrypt_buffer_block(
- AesNI_Box* box,
+static AES_StatusCode aes_box_encrypt_buffer_block(
+ AES_Box* box,
const void* src,
void* dest,
- AesNI_ErrorDetails* err_details)
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
- AesNI_BoxBlock plaintext;
+ AES_BoxBlock plaintext;
- if (aesni_is_error(status = box->algorithm->load_block(
+ if (aes_is_error(status = box->algorithm->load_block(
&plaintext, src, err_details)))
return status;
- AesNI_BoxBlock ciphertext;
+ AES_BoxBlock ciphertext;
- if (aesni_is_error(status = aesni_box_encrypt_block(
+ if (aes_is_error(status = aes_box_encrypt_block(
box, &plaintext, &ciphertext, err_details)))
return status;
- if (aesni_is_error(status = box->algorithm->store_block(
+ if (aes_is_error(status = box->algorithm->store_block(
dest, &ciphertext, err_details)))
return status;
return status;
}
-static AesNI_StatusCode aesni_box_encrypt_buffer_partial_block_with_padding(
- AesNI_Box* box,
+static AES_StatusCode aes_box_encrypt_buffer_partial_block_with_padding(
+ AES_Box* box,
const void* src,
size_t src_size,
void* dest,
size_t padding_size,
- AesNI_ErrorDetails* err_details)
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
size_t block_size;
- if (aesni_is_error(status = box->algorithm->get_block_size(
+ if (aes_is_error(status = box->algorithm->get_block_size(
&block_size, err_details)))
return status;
void* plaintext_buf = malloc(block_size);
if (plaintext_buf == NULL)
- return status = aesni_error_memory_allocation(err_details);
+ return status = aes_error_memory_allocation(err_details);
memcpy(plaintext_buf, src, src_size);
- if (aesni_is_error(status = aesni_fill_with_padding(
- AESNI_PADDING_PKCS7,
+ if (aes_is_error(status = aes_fill_with_padding(
+ AES_PADDING_PKCS7,
(char*) plaintext_buf + src_size,
padding_size,
err_details)))
goto FREE_PLAINTEXT_BUF;
- if (aesni_is_error(status = aesni_box_encrypt_buffer_block(
+ if (aes_is_error(status = aes_box_encrypt_buffer_block(
box, plaintext_buf, dest, err_details)))
goto FREE_PLAINTEXT_BUF;
@@ -340,28 +340,28 @@ FREE_PLAINTEXT_BUF:
return status;
}
-static AesNI_StatusCode aesni_box_encrypt_buffer_partial_block(
- AesNI_Box* box,
+static AES_StatusCode aes_box_encrypt_buffer_partial_block(
+ AES_Box* box,
const void* src,
size_t src_size,
void* dest,
- AesNI_ErrorDetails* err_details)
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
if (src_size == 0)
return status;
size_t block_size;
- if (aesni_is_error(status = box->algorithm->get_block_size(
+ if (aes_is_error(status = box->algorithm->get_block_size(
&block_size, err_details)))
return status;
void* plaintext_buf = malloc(block_size);
if (plaintext_buf == NULL)
- return status = aesni_error_memory_allocation(err_details);
+ return status = aes_error_memory_allocation(err_details);
memset(plaintext_buf, 0x00, block_size);
memcpy(plaintext_buf, src, src_size);
@@ -370,11 +370,11 @@ static AesNI_StatusCode aesni_box_encrypt_buffer_partial_block(
if (ciphertext_buf == NULL)
{
- status = aesni_error_memory_allocation(err_details);
+ status = aes_error_memory_allocation(err_details);
goto FREE_PLAINTEXT_BUF;
}
- if (aesni_is_error(status = aesni_box_encrypt_buffer_block(
+ if (aes_is_error(status = aes_box_encrypt_buffer_block(
box, plaintext_buf, ciphertext_buf, err_details)))
goto FREE_CIPHERTEXT_BUF;
@@ -389,35 +389,35 @@ FREE_PLAINTEXT_BUF:
return status;
}
-AesNI_StatusCode aesni_box_encrypt_buffer(
- AesNI_Box* box,
+AES_StatusCode aes_box_encrypt_buffer(
+ AES_Box* box,
const void* src,
size_t src_size,
void* dest,
size_t* dest_size,
- AesNI_ErrorDetails* err_details)
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
if (box == NULL)
- return aesni_error_null_argument(err_details, "box");
+ return aes_error_null_argument(err_details, "box");
if (dest_size == NULL)
- return aesni_error_null_argument(err_details, "dest_size");
+ return aes_error_null_argument(err_details, "dest_size");
size_t padding_size = 0;
- if (aesni_is_error(status = aesni_box_get_encrypted_buffer_size(
+ if (aes_is_error(status = aes_box_get_encrypted_buffer_size(
box, src_size, dest_size, &padding_size, err_details)))
return status;
if (dest == NULL)
- return AESNI_SUCCESS;
+ return AES_SUCCESS;
if (src == NULL && src_size != 0)
- return aesni_error_null_argument(err_details, "src");
+ return aes_error_null_argument(err_details, "src");
size_t block_size;
- if (aesni_is_error(status = box->algorithm->get_block_size(
+ if (aes_is_error(status = box->algorithm->get_block_size(
&block_size, err_details)))
return status;
@@ -425,7 +425,7 @@ AesNI_StatusCode aesni_box_encrypt_buffer(
for (size_t i = 0; i < src_len; ++i)
{
- if (aesni_is_error(status = aesni_box_encrypt_buffer_block(
+ if (aes_is_error(status = aes_box_encrypt_buffer_block(
box, src, dest, err_details)))
return status;
@@ -433,103 +433,103 @@ AesNI_StatusCode aesni_box_encrypt_buffer(
}
if (padding_size == 0)
- return aesni_box_encrypt_buffer_partial_block(
+ return aes_box_encrypt_buffer_partial_block(
box, src, src_size % block_size, dest, err_details);
else
- return aesni_box_encrypt_buffer_partial_block_with_padding(
+ return aes_box_encrypt_buffer_partial_block_with_padding(
box, src, src_size % block_size, dest, padding_size, err_details);
}
-static AesNI_StatusCode aesni_box_get_decrypted_buffer_size(
- AesNI_Box* box,
+static AES_StatusCode aes_box_get_decrypted_buffer_size(
+ AES_Box* box,
size_t src_size,
size_t* dest_size,
size_t* max_padding_size,
- AesNI_ErrorDetails* err_details)
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
switch (box->mode)
{
- case AESNI_ECB:
- case AESNI_CBC:
+ case AES_ECB:
+ case AES_CBC:
{
size_t block_size;
- if (aesni_is_error(status = box->algorithm->get_block_size(
+ if (aes_is_error(status = box->algorithm->get_block_size(
&block_size, err_details)))
return status;
if (src_size == 0 || src_size % block_size != 0)
- return aesni_error_missing_padding(err_details);
+ return aes_error_missing_padding(err_details);
*dest_size = src_size;
*max_padding_size = block_size;
return status;
}
- case AESNI_CFB:
- case AESNI_OFB:
- case AESNI_CTR:
+ case AES_CFB:
+ case AES_OFB:
+ case AES_CTR:
*dest_size = src_size;
*max_padding_size = 0;
return status;
default:
- return aesni_error_not_implemented(
+ return aes_error_not_implemented(
err_details, "unsupported mode of operation");
}
}
-static AesNI_StatusCode aesni_box_decrypt_buffer_block(
- AesNI_Box* box,
+static AES_StatusCode aes_box_decrypt_buffer_block(
+ AES_Box* box,
const void* src,
void* dest,
- AesNI_ErrorDetails* err_details)
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
- AesNI_BoxBlock ciphertext;
+ AES_BoxBlock ciphertext;
- if (aesni_is_error(status = box->algorithm->load_block(
+ if (aes_is_error(status = box->algorithm->load_block(
&ciphertext, src, err_details)))
return status;
- AesNI_BoxBlock plaintext;
+ AES_BoxBlock plaintext;
- if (aesni_is_error(status = aesni_box_decrypt_block(
+ if (aes_is_error(status = aes_box_decrypt_block(
box, &ciphertext, &plaintext, err_details)))
return status;
- if (aesni_is_error(status = box->algorithm->store_block(
+ if (aes_is_error(status = box->algorithm->store_block(
dest, &plaintext, err_details)))
return status;
return status;
}
-static AesNI_StatusCode aesni_box_decrypt_buffer_partial_block(
- AesNI_Box* box,
+static AES_StatusCode aes_box_decrypt_buffer_partial_block(
+ AES_Box* box,
const void* src,
size_t src_size,
void* dest,
- AesNI_ErrorDetails* err_details)
+ AES_ErrorDetails* err_details)
{
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
if (src_size == 0)
return status;
size_t block_size;
- if (aesni_is_error(status = box->algorithm->get_block_size(
+ if (aes_is_error(status = box->algorithm->get_block_size(
&block_size, err_details)))
return status;
void* ciphertext_buf = malloc(block_size);
if (ciphertext_buf == NULL)
- return status = aesni_error_memory_allocation(err_details);
+ return status = aes_error_memory_allocation(err_details);
memset(ciphertext_buf, 0x00, block_size);
memcpy(ciphertext_buf, src, src_size);
@@ -538,11 +538,11 @@ static AesNI_StatusCode aesni_box_decrypt_buffer_partial_block(
if (plaintext_buf == NULL)
{
- status = aesni_error_memory_allocation(err_details);
+ status = aes_error_memory_allocation(err_details);
goto FREE_CIPHERTEXT_BUF;
}
- if (aesni_is_error(status = aesni_box_decrypt_buffer_block(
+ if (aes_is_error(status = aes_box_decrypt_buffer_block(
box, ciphertext_buf, plaintext_buf, err_details)))
goto FREE_PLAINTEXT_BUF;
@@ -557,34 +557,34 @@ FREE_CIPHERTEXT_BUF:
return status;
}
-AesNI_StatusCode aesni_box_decrypt_buffer(
- AesNI_Box* box,
+AES_StatusCode aes_box_decrypt_buffer(
+ AES_Box* box,
const void* src,
size_t src_size,
void* dest,
size_t* dest_size,
- AesNI_ErrorDetails* err_details)
+ AES_ErrorDetails* err_details)
{
if (box == NULL)
- return aesni_error_null_argument(err_details, "box");
+ return aes_error_null_argument(err_details, "box");
if (dest_size == NULL)
- return aesni_error_null_argument(err_details, "dest_size");
+ return aes_error_null_argument(err_details, "dest_size");
- AesNI_StatusCode status = AESNI_SUCCESS;
+ AES_StatusCode status = AES_SUCCESS;
size_t max_padding_size = 0;
- if (aesni_is_error(status = aesni_box_get_decrypted_buffer_size(
+ if (aes_is_error(status = aes_box_get_decrypted_buffer_size(
box, src_size, dest_size, &max_padding_size, err_details)))
return status;
if (dest == NULL)
- return AESNI_SUCCESS;
+ return AES_SUCCESS;
if (src == NULL)
- return aesni_error_null_argument(err_details, "src");
+ return aes_error_null_argument(err_details, "src");
size_t block_size;
- if (aesni_is_error(status = box->algorithm->get_block_size(
+ if (aes_is_error(status = box->algorithm->get_block_size(
&block_size, err_details)))
return status;
@@ -592,7 +592,7 @@ AesNI_StatusCode aesni_box_decrypt_buffer(
for (size_t i = 0; i < src_len; ++i)
{
- if (aesni_is_error(status = aesni_box_decrypt_buffer_block(
+ if (aes_is_error(status = aes_box_decrypt_buffer_block(
box, src, dest, err_details)))
return status;
@@ -601,15 +601,15 @@ AesNI_StatusCode aesni_box_decrypt_buffer(
if (max_padding_size == 0)
{
- return aesni_box_decrypt_buffer_partial_block(
+ return aes_box_decrypt_buffer_partial_block(
box, src, src_size % block_size, dest, err_details);
}
else
{
size_t padding_size;
- if (aesni_is_error(status = aesni_extract_padding_size(
- AESNI_PADDING_PKCS7,
+ if (aes_is_error(status = aes_extract_padding_size(
+ AES_PADDING_PKCS7,
(char*) dest - block_size,
block_size,
&padding_size,
@@ -621,62 +621,62 @@ AesNI_StatusCode aesni_box_decrypt_buffer(
}
}
-AesNI_StatusCode aesni_box_parse_block(
- AesNI_BoxBlock* dest,
- AesNI_Algorithm algorithm,
+AES_StatusCode aes_box_parse_block(
+ AES_BoxBlock* dest,
+ AES_Algorithm algorithm,
const char* src,
- AesNI_ErrorDetails* err_details)
+ AES_ErrorDetails* err_details)
{
if (dest == NULL)
- return aesni_error_null_argument(err_details, "dest");
+ return aes_error_null_argument(err_details, "dest");
if (src == NULL)
- return aesni_error_null_argument(err_details, "src");
+ return aes_error_null_argument(err_details, "src");
- return aesni_box_algorithms[algorithm]->parse_block(
+ return aes_box_algorithms[algorithm]->parse_block(
dest, src, err_details);
}
-AesNI_StatusCode aesni_box_parse_key(
- AesNI_BoxKey* dest,
- AesNI_Algorithm algorithm,
+AES_StatusCode aes_box_parse_key(
+ AES_BoxKey* dest,
+ AES_Algorithm algorithm,
const char* src,
- AesNI_ErrorDetails* err_details)
+ AES_ErrorDetails* err_details)
{
if (dest == NULL)
- return aesni_error_null_argument(err_details, "dest");
+ return aes_error_null_argument(err_details, "dest");
if (src == NULL)
- return aesni_error_null_argument(err_details, "src");
+ return aes_error_null_argument(err_details, "src");
- return aesni_box_algorithms[algorithm]->parse_key(
+ return aes_box_algorithms[algorithm]->parse_key(
dest, src, err_details);
}
-AesNI_StatusCode aesni_box_format_block(
- AesNI_BoxBlockString* dest,
- AesNI_Algorithm algorithm,
- const AesNI_BoxBlock* src,
- AesNI_ErrorDetails* err_details)
+AES_StatusCode aes_box_format_block(
+ AES_BoxBlockString* dest,
+ AES_Algorithm algorithm,
+ const AES_BoxBlock* src,
+ AES_ErrorDetails* err_details)
{
if (dest == NULL)
- return aesni_error_null_argument(err_details, "dest");
+ return aes_error_null_argument(err_details, "dest");
if (src == NULL)
- return aesni_error_null_argument(err_details, "src");
+ return aes_error_null_argument(err_details, "src");
- return aesni_box_algorithms[algorithm]->format_block(
+ return aes_box_algorithms[algorithm]->format_block(
dest, src, err_details);
}
-AesNI_StatusCode aesni_box_format_key(
- AesNI_BoxKeyString* dest,
- AesNI_Algorithm algorithm,
- const AesNI_BoxKey* src,
- AesNI_ErrorDetails* err_details)
+AES_StatusCode aes_box_format_key(
+ AES_BoxKeyString* dest,
+ AES_Algorithm algorithm,
+ const AES_BoxKey* src,
+ AES_ErrorDetails* err_details)
{
if (dest == NULL)
- return aesni_error_null_argument(err_details, "dest");
+ return aes_error_null_argument(err_details, "dest");
if (src == NULL)
- return aesni_error_null_argument(err_details, "src");
+ return aes_error_null_argument(err_details, "src");
- return aesni_box_algorithms[algorithm]->format_key(
+ return aes_box_algorithms[algorithm]->format_key(
dest, src, err_details);
}