diff options
| author | Egor Tensin <egor@tensin.name> | 2026-07-20 22:01:35 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-07-20 22:06:06 +0200 |
| commit | 2b1facdd2418c0eefb88be3671c393510079ed81 (patch) | |
| tree | 17259f5de874a9ae90c95b40554650d97f66bfc4 | |
| parent | remove a few levels of stupid indirection (diff) | |
| download | aes-tools-2b1facdd2418c0eefb88be3671c393510079ed81.tar.gz aes-tools-2b1facdd2418c0eefb88be3671c393510079ed81.zip | |
aes: minor refactoring
| -rw-r--r-- | aes/include/aes/box_aes.h | 6 | ||||
| -rw-r--r-- | aes/include/aes/box_data.h | 4 | ||||
| -rw-r--r-- | aes/src/box.c | 18 | ||||
| -rw-r--r-- | aes/src/box_aes.c | 6 |
4 files changed, 17 insertions, 17 deletions
diff --git a/aes/include/aes/box_aes.h b/aes/include/aes/box_aes.h index e15f0cb..476f692 100644 --- a/aes/include/aes/box_aes.h +++ b/aes/include/aes/box_aes.h @@ -11,9 +11,9 @@ extern "C" { #endif -extern AES_BoxAlgorithmInterface aes_box_algorithm_aes128; -extern AES_BoxAlgorithmInterface aes_box_algorithm_aes192; -extern AES_BoxAlgorithmInterface aes_box_algorithm_aes256; +extern AES_BoxInterface aes128_box_interface; +extern AES_BoxInterface aes192_box_interface; +extern AES_BoxInterface aes256_box_interface; #ifdef __cplusplus } diff --git a/aes/include/aes/box_data.h b/aes/include/aes/box_data.h index 5e5ab98..e3137f3 100644 --- a/aes/include/aes/box_data.h +++ b/aes/include/aes/box_data.h @@ -115,10 +115,10 @@ typedef struct { AES_BoxGetBlockSize get_block_size; AES_BoxStoreBlock store_block; AES_BoxLoadBlock load_block; -} AES_BoxAlgorithmInterface; +} AES_BoxInterface; typedef struct { - const AES_BoxAlgorithmInterface* algorithm; + const AES_BoxInterface* algorithm; AES_BoxEncryptionRoundKeys encryption_keys; AES_BoxDecryptionRoundKeys decryption_keys; AES_Mode mode; diff --git a/aes/src/box.c b/aes/src/box.c index 8d2c202..3d12591 100644 --- a/aes/src/box.c +++ b/aes/src/box.c @@ -10,10 +10,10 @@ #include <stdlib.h> #include <string.h> -static const AES_BoxAlgorithmInterface* aes_box_algorithms[] = { - &aes_box_algorithm_aes128, - &aes_box_algorithm_aes192, - &aes_box_algorithm_aes256, +static const AES_BoxInterface* aes_box_interfaces[] = { + &aes128_box_interface, + &aes192_box_interface, + &aes256_box_interface, }; AES_StatusCode aes_box_init( @@ -26,7 +26,7 @@ AES_StatusCode aes_box_init( ) { AES_StatusCode status = AES_SUCCESS; - box->algorithm = aes_box_algorithms[algorithm]; + box->algorithm = aes_box_interfaces[algorithm]; status = box->algorithm->calc_round_keys( box_key, &box->encryption_keys, &box->decryption_keys, err_details @@ -614,7 +614,7 @@ AES_StatusCode aes_box_parse_block( if (src == NULL) return aes_error_null_argument(err_details, "src"); - return aes_box_algorithms[algorithm]->parse_block(dest, src, err_details); + return aes_box_interfaces[algorithm]->parse_block(dest, src, err_details); } AES_StatusCode aes_box_parse_key( @@ -628,7 +628,7 @@ AES_StatusCode aes_box_parse_key( if (src == NULL) return aes_error_null_argument(err_details, "src"); - return aes_box_algorithms[algorithm]->parse_key(dest, src, err_details); + return aes_box_interfaces[algorithm]->parse_key(dest, src, err_details); } AES_StatusCode aes_box_format_block( @@ -642,7 +642,7 @@ AES_StatusCode aes_box_format_block( if (src == NULL) return aes_error_null_argument(err_details, "src"); - return aes_box_algorithms[algorithm]->format_block(dest, src, err_details); + return aes_box_interfaces[algorithm]->format_block(dest, src, err_details); } AES_StatusCode aes_box_format_key( @@ -656,5 +656,5 @@ AES_StatusCode aes_box_format_key( if (src == NULL) return aes_error_null_argument(err_details, "src"); - return aes_box_algorithms[algorithm]->format_key(dest, src, err_details); + return aes_box_interfaces[algorithm]->format_key(dest, src, err_details); } diff --git a/aes/src/box_aes.c b/aes/src/box_aes.c index fb858f0..8c79335 100644 --- a/aes/src/box_aes.c +++ b/aes/src/box_aes.c @@ -263,7 +263,7 @@ static AES_StatusCode aes_box_decrypt_block_aes256( return AES_SUCCESS; } -AES_BoxAlgorithmInterface aes_box_algorithm_aes128 = { +AES_BoxInterface aes128_box_interface = { &aes_box_derive_params_aes128, &aes_box_parse_block_aes, &aes_box_parse_key_aes128, @@ -278,7 +278,7 @@ AES_BoxAlgorithmInterface aes_box_algorithm_aes128 = { &aes_box_load_block_aes, }; -AES_BoxAlgorithmInterface aes_box_algorithm_aes192 = { +AES_BoxInterface aes192_box_interface = { &aes_box_derive_params_aes192, &aes_box_parse_block_aes, &aes_box_parse_key_aes192, @@ -293,7 +293,7 @@ AES_BoxAlgorithmInterface aes_box_algorithm_aes192 = { &aes_box_load_block_aes, }; -AES_BoxAlgorithmInterface aes_box_algorithm_aes256 = { +AES_BoxInterface aes256_box_interface = { &aes_box_derive_params_aes256, &aes_box_parse_block_aes, &aes_box_parse_key_aes256, |
