aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/box.c
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-06-19 01:31:25 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-06-19 01:31:25 +0300
commit433df6f53252a5f4e8b97f1d905ba37928145a96 (patch)
treeba387f6ec6a83a9652cf509210a310cfae9dd1bf /src/box.c
parentrespect the generic interface in CTR functions (diff)
downloadaes-tools-433df6f53252a5f4e8b97f1d905ba37928145a96.tar.gz
aes-tools-433df6f53252a5f4e8b97f1d905ba37928145a96.zip
add CTR mode to "boxes"
Diffstat (limited to '')
-rw-r--r--src/box.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/box.c b/src/box.c
index e48c5d7..c74100c 100644
--- a/src/box.c
+++ b/src/box.c
@@ -132,7 +132,19 @@ static AesNI_StatusCode aesni_box_encrypt_ctr(
AesNI_BoxBlock* output,
AesNI_ErrorDetails* err_details)
{
- return aesni_error_not_implemented(err_details, "box encryption in CTR mode");
+ AesNI_StatusCode status = box->algorithm_iface->encrypt(
+ &box->iv,
+ &box->encrypt_params,
+ output,
+ err_details);
+ if (aesni_is_error(status))
+ return status;
+
+ status = box->algorithm_iface->xor_block(output, input, err_details);
+ if (aesni_is_error(status))
+ return status;
+
+ return box->algorithm_iface->inc_counter(&box->iv, err_details);
}
typedef AesNI_StatusCode (*AesNI_BoxEncryptMode)(
@@ -219,7 +231,6 @@ static AesNI_StatusCode aesni_box_decrypt_cfb(
return status;
box->iv = *input;
-
return status;
}
@@ -255,7 +266,7 @@ static AesNI_StatusCode aesni_box_decrypt_ctr(
AesNI_BoxBlock* output,
AesNI_ErrorDetails* err_details)
{
- return aesni_error_not_implemented(err_details, "box decryption in CTR mode");
+ return aesni_box_encrypt_ctr(box, input, output, err_details);
}
typedef AesNI_BoxEncryptMode AesNI_BoxDecryptMode;