diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-19 01:21:19 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-19 01:21:19 +0300 |
commit | 03c815ff0a3fad7b69d29175bc1b9df1b2cdfef6 (patch) | |
tree | 394e28f2cea095d97cdf1d1807e1e50c609dc99f | |
parent | examples: output update (diff) | |
download | aes-tools-03c815ff0a3fad7b69d29175bc1b9df1b2cdfef6.tar.gz aes-tools-03c815ff0a3fad7b69d29175bc1b9df1b2cdfef6.zip |
add more block arithmetic functions
-rw-r--r-- | cxx/include/aesnixx/data.hpp | 10 | ||||
-rw-r--r-- | include/aesni/data.h | 7 |
2 files changed, 16 insertions, 1 deletions
diff --git a/cxx/include/aesnixx/data.hpp b/cxx/include/aesnixx/data.hpp index bd7e9bd..98b5c98 100644 --- a/cxx/include/aesnixx/data.hpp +++ b/cxx/include/aesnixx/data.hpp @@ -45,4 +45,14 @@ namespace aesni { return aesni_xor_block128(a, b); } + + inline Block128 reverse_byte_order(Block128& block) + { + return aesni_reverse_byte_order_block128(block); + } + + inline Block128 inc(Block128& block) + { + return aesni_inc_block128(block); + } } diff --git a/include/aesni/data.h b/include/aesni/data.h index 3ef1c48..94cff2c 100644 --- a/include/aesni/data.h +++ b/include/aesni/data.h @@ -110,11 +110,16 @@ static __inline AesNI_Block128 __fastcall aesni_make_block128(int hi3, int hi2, return _mm_set_epi32(hi3, hi2, lo1, lo0); } -static __inline AesNI_Block128 __fastcall aesni_reverse_bytes_block128(AesNI_Block128 block) +static __inline AesNI_Block128 __fastcall aesni_reverse_byte_order_block128(AesNI_Block128 block) { return _mm_shuffle_epi8(block, aesni_make_block128(0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f)); } +static __inline AesNI_Block128 __fastcall aesni_inc_block128(AesNI_Block128 x) +{ + return _mm_add_epi32(x, aesni_make_block128(0, 0, 0, 1)); +} + #ifdef __cplusplus } #endif |