_mm_aesenc_si128

Microsoft Specific

Emits the Advanced Encryption Standard (AES) instruction aesenc. This instruction performs one round of AES encryption.

__m128i _mm_aesenc_si128 (
   __m128i v,
   __m128i rkey
); 

Parameters

Parameter

Description

[in] v

The data that this instruction encrypts.

[in] rkey

The round key that this instruction uses to encrypt the data in v.

Return value

The encrypted form of the data in v.

Requirements

Intrinsic

Architecture

_mm_aesenc_si128

x86, x64

Header file <wmmintrin.h>

Remarks

This instruction encrypts data by using an Equivalent Inverse Cipher with a 128 bit key. AES encryption requires 10 iterations of encryption by using a cipher key that is 128 bits. Each iteration uses this instruction, except for the last iteration. The last iteration must be performed by _mm_aesenclast_si128.

To decrypt the encoded data, use _mm_aesdec_si128.

Example

#include <wmmintrin.h>
#include <stdio.h>

int main()
{
    __m128i a;
    __m128i res;
    __m128i key;

    a.m128i_u64[1] = 0x8899AABBCCDDEEFF;
    a.m128i_u64[0] = 0x0123456789ABCDEF;
    key.m128i_u64[1] = 0x0022446688AACCEE;
    key.m128i_u64[0] = 0x1133557799BBDDFF;

    res = _mm_aesenc_si128( a, key );

    printf_s("Original data: 0x%016I64x%016I64x\n",
        a.m128i_u64[1], a.m128i_u64[0]);
    printf_s("Encoded data: 0x%016I64x%016I64x\n",
        res.m128i_u64[1], res.m128i_u64[0]);

    return 0;
}
Original data: 0x8899aabbccddeeff0123456789abcdef
Encoded data: 0x28e4ee188450433316ab0e57dfc442ed

See Also

Reference

Compiler Intrinsics

_mm_aesenclast_si128

_mm_aesdec_si128

AES Intrinsics