diff options
| author | Egor Tensin <egor@tensin.name> | 2026-07-21 15:51:54 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-07-21 15:51:54 +0200 |
| commit | 63bb177920dede88ca6e5197ca37a4fbbf6307df (patch) | |
| tree | b6525589fbf57669cb522d7bee13ac852a720928 | |
| parent | remove some more duplication and the Doxygen "comments" (diff) | |
| download | aes-tools-63bb177920dede88ca6e5197ca37a4fbbf6307df.tar.gz aes-tools-63bb177920dede88ca6e5197ca37a4fbbf6307df.zip | |
aes/box: remove useless interface method
| -rw-r--r-- | aes/include/aes/box_data.h | 3 | ||||
| -rw-r--r-- | aes/src/box.c | 48 | ||||
| -rw-r--r-- | aes/src/box_aes.c | 12 |
3 files changed, 7 insertions, 56 deletions
diff --git a/aes/include/aes/box_data.h b/aes/include/aes/box_data.h index 0777d2e..b0a82a5 100644 --- a/aes/include/aes/box_data.h +++ b/aes/include/aes/box_data.h @@ -72,15 +72,12 @@ typedef AES_StatusCode (*AES_BoxDecryptBlock)( AES_ErrorDetails* err_details ); -typedef AES_StatusCode (*AES_BoxGetBlockSize)(size_t*, AES_ErrorDetails*); - typedef struct { AES_BoxCalculateRoundKeys calc_round_keys; AES_BoxParseKey parse_key; AES_BoxFormatKey format_key; AES_BoxEncryptBlock encrypt_block; AES_BoxDecryptBlock decrypt_block; - AES_BoxGetBlockSize get_block_size; } AES_BoxInterface; typedef struct { diff --git a/aes/src/box.c b/aes/src/box.c index d279fd8..178f1dc 100644 --- a/aes/src/box.c +++ b/aes/src/box.c @@ -222,12 +222,7 @@ static AES_StatusCode aes_box_get_encrypted_buffer_size( switch (box->mode) { case AES_ECB: case AES_CBC: { - size_t block_size; - - status = box->algorithm->get_block_size(&block_size, err_details); - if (aes_is_error(status)) - return status; - + size_t block_size = sizeof(AES_Block); *padding_size = block_size - src_size % block_size; *dest_size = src_size + *padding_size; return status; @@ -273,12 +268,7 @@ static AES_StatusCode aes_box_encrypt_buffer_partial_block_with_padding( ) { AES_StatusCode status = AES_SUCCESS; - size_t block_size; - - status = box->algorithm->get_block_size(&block_size, err_details); - if (aes_is_error(status)) - return status; - + size_t block_size = sizeof(AES_Block); void* plaintext_buf = malloc(block_size); if (plaintext_buf == NULL) @@ -314,12 +304,7 @@ static AES_StatusCode aes_box_encrypt_buffer_partial_block( if (src_size == 0) return status; - size_t block_size; - - status = box->algorithm->get_block_size(&block_size, err_details); - if (aes_is_error(status)) - return status; - + size_t block_size = sizeof(AES_Block); void* plaintext_buf = malloc(block_size); if (plaintext_buf == NULL) @@ -377,12 +362,7 @@ AES_StatusCode aes_box_encrypt_buffer( if (src == NULL && src_size != 0) return aes_error_null_argument(err_details, "src"); - size_t block_size; - - status = box->algorithm->get_block_size(&block_size, err_details); - if (aes_is_error(status)) - return status; - + size_t block_size = sizeof(AES_Block); const size_t src_len = src_size / block_size; for (size_t i = 0; i < src_len; ++i) { @@ -416,11 +396,7 @@ static AES_StatusCode aes_box_get_decrypted_buffer_size( switch (box->mode) { case AES_ECB: case AES_CBC: { - size_t block_size; - - status = box->algorithm->get_block_size(&block_size, err_details); - if (aes_is_error(status)) - return status; + size_t block_size = sizeof(AES_Block); if (src_size == 0 || src_size % block_size != 0) return aes_error_missing_padding(err_details); @@ -472,12 +448,7 @@ static AES_StatusCode aes_box_decrypt_buffer_partial_block( if (src_size == 0) return status; - size_t block_size; - - status = box->algorithm->get_block_size(&block_size, err_details); - if (aes_is_error(status)) - return status; - + size_t block_size = sizeof(AES_Block); void* ciphertext_buf = malloc(block_size); if (ciphertext_buf == NULL) @@ -534,12 +505,7 @@ AES_StatusCode aes_box_decrypt_buffer( if (src == NULL) return aes_error_null_argument(err_details, "src"); - size_t block_size; - - status = box->algorithm->get_block_size(&block_size, err_details); - if (aes_is_error(status)) - return status; - + size_t block_size = sizeof(AES_Block); const size_t src_len = src_size / block_size; for (size_t i = 0; i < src_len; ++i) { diff --git a/aes/src/box_aes.c b/aes/src/box_aes.c index c566b36..368ec9e 100644 --- a/aes/src/box_aes.c +++ b/aes/src/box_aes.c @@ -128,15 +128,6 @@ static AES_StatusCode aes_box_format_key_aes256( return aes256_format_key(&dest->aes256, &src->aes256_key, err_details); } -static AES_StatusCode aes_box_get_block_size_aes( - size_t* block_size, - AES_ErrorDetails* err_details -) { - AES_UNUSED_PARAMETER(err_details); - *block_size = 16; - return AES_SUCCESS; -} - static AES_StatusCode aes_box_encrypt_block_aes128( const AES_Block* input, const AES_BoxEncryptionRoundKeys* params, @@ -209,7 +200,6 @@ AES_BoxInterface aes128_box_interface = { &aes_box_format_key_aes128, &aes_box_encrypt_block_aes128, &aes_box_decrypt_block_aes128, - &aes_box_get_block_size_aes, }; AES_BoxInterface aes192_box_interface = { @@ -218,7 +208,6 @@ AES_BoxInterface aes192_box_interface = { &aes_box_format_key_aes192, &aes_box_encrypt_block_aes192, &aes_box_decrypt_block_aes192, - &aes_box_get_block_size_aes, }; AES_BoxInterface aes256_box_interface = { @@ -227,5 +216,4 @@ AES_BoxInterface aes256_box_interface = { &aes_box_format_key_aes256, &aes_box_encrypt_block_aes256, &aes_box_decrypt_block_aes256, - &aes_box_get_block_size_aes, }; |
