none
为什么使用 _mm_aesenc_si128 加密之后再使用 _mm_aesdec_si128 解密 和原来的明文不一样 RRS feed

  • 问题

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

    int main()
    {
    __m128i a, b;
    __m128i res1, res2;
    __m128i key;

    a.m128i_u64[1] = 0x6665646362613039;
    a.m128i_u64[0] = 0x3837363534333231;

    b.m128i_u64[1] = 0xa946f2485c4685c7;
    b.m128i_u64[0] = 0x51680fbf571b3977;

    key.m128i_u64[1] = 0x495450f0e48348e2;
    key.m128i_u64[0] = 0x89485ed18949ed31;

    res1 = _mm_aesenc_si128(a, key);
    res2 = _mm_aesdec_si128(b, key);

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

    printf_s("Cipher data: 0x%016I64x%016I64x\n",
    b.m128i_u64[1], b.m128i_u64[0]);
    printf_s("Original data: 0x%016I64x%016I64x\n",
    res2.m128i_u64[1], res2.m128i_u64[0]);
    return 0;
    }
    2018年11月17日 17:58

全部回复

  • 你好,

    由于此论坛针对于VS IDE的卸载安装问题,根据你提供的内容,应该跟C编程有关。我将帮你将帖子移到正确的论坛,以便你能获得更加专业的支持。

    感谢你的理解。

    May


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    2018年11月19日 3:13
  • 你好,

    参考MSDN提供的文档, AES加密需要使用128位的密码密钥进行10次加密。除了最后一次迭代之外, 每个迭代都使用此指令。最后一次迭代必须由mm_aesenclast_si128完成。

    具体有关_mm_aesenc_si128, _mm_aesdec_si128的用法,建议你可以参考下这个链接

    Best Wishes,

    Jack Zhang.


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2018年11月19日 9:33
    版主