diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-22 01:52:57 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-22 01:52:57 +0300 |
commit | 3b705c046c53ee01ba3daed0d0e7468b1a682cbc (patch) | |
tree | 65b5769aaac6b4f950a79cd2690fc30c80923571 /src/box_aes.c | |
parent | bugfix & code style (diff) | |
download | aes-tools-3b705c046c53ee01ba3daed0d0e7468b1a682cbc.tar.gz aes-tools-3b705c046c53ee01ba3daed0d0e7468b1a682cbc.zip |
boxes: a number of improvements
* Algorithm interfaces are no longer required to load partial blocks,
the space for which is allocated dynamically.
* Padding schemes are now also separated, perhaps in the future to
become a "box" parameter.
Consequently, algorithm interfaces are no longer required to implement
padding either.
Diffstat (limited to 'src/box_aes.c')
-rw-r--r-- | src/box_aes.c | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/box_aes.c b/src/box_aes.c index 49c5326..470e39b 100644 --- a/src/box_aes.c +++ b/src/box_aes.c @@ -92,18 +92,6 @@ static AesNI_StatusCode aesni_box_store_block_aes( return AESNI_SUCCESS; } -static AesNI_StatusCode aesni_box_store_partial_block_aes( - void* dest, - const AesNI_BoxBlock* src, - size_t src_size, - AesNI_ErrorDetails* err_details) -{ - __declspec(align(16)) unsigned char buf[16]; - aesni_store_block128(buf, src->aes_block); - memcpy(dest, buf, src_size); - return AESNI_SUCCESS; -} - static AesNI_StatusCode aesni_box_load_block_aes( AesNI_BoxBlock* dest, const void* src, @@ -113,32 +101,6 @@ static AesNI_StatusCode aesni_box_load_block_aes( return AESNI_SUCCESS; } -static AesNI_StatusCode aesni_box_load_partial_block_aes( - AesNI_BoxBlock* dest, - const void* src, - size_t src_size, - AesNI_ErrorDetails* err_details) -{ - __declspec(align(16)) unsigned char buf[16]; - memset(buf, 0x00, 16); - memcpy(buf, src, src_size); - dest->aes_block = aesni_load_block128_aligned(buf); - return AESNI_SUCCESS; -} - -static AesNI_StatusCode aesni_box_load_block_with_padding_aes( - AesNI_BoxBlock* dest, - const void* src, - size_t src_size, - AesNI_ErrorDetails* err_details) -{ - __declspec(align(16)) unsigned char padding[16]; - memset(padding + src_size, 16 - src_size, 16 - src_size); - memcpy(padding, src, src_size); - dest->aes_block = aesni_load_block128_aligned(padding); - return AESNI_SUCCESS; -} - static AesNI_StatusCode aesni_box_encrypt_block_aes128( const AesNI_BoxBlock* input, const AesNI_BoxEncryptionParams* params, @@ -220,10 +182,7 @@ AesNI_BoxAlgorithmInterface aesni_box_algorithm_aes128 = &aesni_box_next_counter_aes, &aesni_box_get_block_size_aes, &aesni_box_store_block_aes, - &aesni_box_store_partial_block_aes, &aesni_box_load_block_aes, - &aesni_box_load_partial_block_aes, - &aesni_box_load_block_with_padding_aes, }; AesNI_BoxAlgorithmInterface aesni_box_algorithm_aes192 = @@ -235,10 +194,7 @@ AesNI_BoxAlgorithmInterface aesni_box_algorithm_aes192 = &aesni_box_next_counter_aes, &aesni_box_get_block_size_aes, &aesni_box_store_block_aes, - &aesni_box_store_partial_block_aes, &aesni_box_load_block_aes, - &aesni_box_load_partial_block_aes, - &aesni_box_load_block_with_padding_aes, }; AesNI_BoxAlgorithmInterface aesni_box_algorithm_aes256 = @@ -250,8 +206,5 @@ AesNI_BoxAlgorithmInterface aesni_box_algorithm_aes256 = &aesni_box_next_counter_aes, &aesni_box_get_block_size_aes, &aesni_box_store_block_aes, - &aesni_box_store_partial_block_aes, &aesni_box_load_block_aes, - &aesni_box_load_partial_block_aes, - &aesni_box_load_block_with_padding_aes, }; |