From c3537aaeb9fd34731c9772e4fd72baa586684d10 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 4 Jun 2015 03:18:01 +0300 Subject: add BE-to-LE conversion functions --- include/aesni/data.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/aesni/data.h b/include/aesni/data.h index dec9367..4ed9f9f 100644 --- a/include/aesni/data.h +++ b/include/aesni/data.h @@ -45,6 +45,18 @@ typedef struct } Aes256KeySchedule; +static __inline AesBlock128 __fastcall aes128_le2be(AesBlock128 block) +{ + __declspec(align(16)) char xs[16]; + _mm_store_si128((__m128i*) xs, block); + return _mm_set_epi8(xs[0], xs[1], xs[2], xs[3], xs[4], xs[5], xs[6], xs[7], xs[8], xs[9], xs[10], xs[11], xs[12], xs[13], xs[14], xs[15]); +} + +static __inline AesBlock128 __fastcall aes128_be2le(AesBlock128 block) +{ + return aes128_le2be(block); +} + AesBlock128 make_aes_block128(int hi3, int hi2, int lo1, int lo0); AesBlock192 make_aes_block192(int hi5, int hi4, int lo3, int lo2, int lo1, int lo0); AesBlock256 make_aes_block256(int hi7, int hi6, int hi5, int hi4, int lo3, int lo2, int lo1, int lo0); -- cgit v1.2.3