aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/aesni/data.h
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-06-17 16:37:34 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-06-17 16:37:34 +0300
commit3baadcabe01da1148f0738f260cbba1d7389ea86 (patch)
treead59b02fb036d6eea61805fbf847075a5b100312 /include/aesni/data.h
parenttest: add utilities to play with "boxes" (diff)
downloadaes-tools-3baadcabe01da1148f0738f260cbba1d7389ea86.tar.gz
aes-tools-3baadcabe01da1148f0738f260cbba1d7389ea86.zip
factor out 128-bit XORing
Diffstat (limited to 'include/aesni/data.h')
-rw-r--r--include/aesni/data.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/include/aesni/data.h b/include/aesni/data.h
index 6f4da76..fbe6e31 100644
--- a/include/aesni/data.h
+++ b/include/aesni/data.h
@@ -37,6 +37,7 @@ typedef __m128i AesNI_Block128;
* \brief Loads a 128-bit block from a memory location.
*
* \param[in] src The pointer to a memory location. Must not be `NULL`.
+ *
* \return The loaded 128-bit block.
*/
static __inline AesNI_Block128 aesni_load_block128(const void* src)
@@ -47,8 +48,8 @@ static __inline AesNI_Block128 aesni_load_block128(const void* src)
/**
* \brief Loads a 128-bit block from a 16-byte aligned memory location.
*
- * \param[in] src The pointer to a 16-byte aligned memory location. Must not be
- * `NULL`.
+ * \param[in] src The pointer to a 16-byte aligned memory location. Must not be `NULL`.
+ *
* \return The loaded 128-bit block.
*/
static __inline AesNI_Block128 aesni_load_block128_aligned(const void* src)
@@ -60,10 +61,12 @@ static __inline AesNI_Block128 aesni_load_block128_aligned(const void* src)
* \brief Stores a 128-bit block in a memory location.
*
* \param[out] dest The pointer to a memory location. Must not be `NULL`.
+ *
* \param[in] block The block to be stored.
*/
static __inline void __fastcall aesni_store_block128(
- void* dest, AesNI_Block128 block)
+ void* dest,
+ AesNI_Block128 block)
{
_mm_storeu_si128((AesNI_Block128*) dest, block);
}
@@ -71,17 +74,33 @@ static __inline void __fastcall aesni_store_block128(
/**
* \brief Stores a 128-bit block in a 16-byte aligned memory location.
*
- * \param[out] dest The pointer to a 16-byte aligned memory location. Must not
- * be `NULL`.
+ * \param[out] dest The pointer to a 16-byte aligned memory location. Must not be `NULL`.
+ *
* \param[in] block The block to be stored.
*/
static __inline void __fastcall aesni_store_block128_aligned(
- void* dest, AesNI_Block128 block)
+ void* dest,
+ AesNI_Block128 block)
{
_mm_store_si128((AesNI_Block128*) dest, block);
}
/**
+ * \brief XORs two 128-bit blocks.
+ *
+ * \param[in] a The first XOR operand.
+ * \param[in] b The second XOR operand.
+ *
+ * \return `a^b`.
+ */
+static __inline AesNI_Block128 __fastcall aesni_xor_block128(
+ AesNI_Block128 a,
+ AesNI_Block128 b)
+{
+ return _mm_xor_si128(a, b);
+}
+
+/**
* \brief Builds a 128-bit block from four 4-byte values.
*
* Builds a 128-bit block like this: