diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2015-05-22 01:03:07 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2015-05-22 01:03:07 +0300 |
commit | 1463fd0559e0a664cd6a1bf6462a68dd79e58814 (patch) | |
tree | cd9ba513f473186a0780baf3f212c57d4521d91f /src/common.c | |
download | aes-tools-1463fd0559e0a664cd6a1bf6462a68dd79e58814.tar.gz aes-tools-1463fd0559e0a664cd6a1bf6462a68dd79e58814.zip |
initial commit
Diffstat (limited to 'src/common.c')
-rw-r--r-- | src/common.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c new file mode 100644 index 0000000..92f5e24 --- /dev/null +++ b/src/common.c @@ -0,0 +1,38 @@ +/** + * \file + * \author Egor Tensin <Egor.Tensin@gmail.com> + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#include "aesni/all.h" + +#include <intrin.h> + +#include <stdio.h> + +AesBlock make_aes_block(int highest, int high, int low, int lowest) +{ + return _mm_set_epi32(highest, high, low, lowest); +} + +AesState aes_block_to_state(AesBlock block) +{ + AesState state; + _mm_storeu_si128((__m128i*) &state.bytes, block); + return state; +} + +void print_aes_block(AesBlock block) +{ + int i, j; + AesState state = aes_block_to_state(block); + + for (i = 0; i < 4; ++i) + { + for (j = 0; j < 3; ++j) + printf("%02x ", state.bytes[j][i]); + printf("%02x\n", state.bytes[3][i]); + } +} |