AES为高级加密标准,是较流行的一种密码算法。
SIMD相关头文件包括:
//#include <ivec.h>//MMX
//#include <fvec.h>//SSE(also include ivec.h)
//#include <dvec.h>//SSE2(also include fvec.h)
#include <mmintrin.h> //MMX
#include <xmmintrin.h> //SSE(include mmintrin.h)
#include <emmintrin.h> //SSE2(include xmmintrin.h)
#include <pmmintrin.h> //SSE3(include emmintrin.h)
#include <tmmintrin.h>//SSSE3(include pmmintrin.h)
#include <smmintrin.h>//SSE4.1(include tmmintrin.h)
#include <nmmintrin.h>//SSE4.2(include smmintrin.h)
#include <wmmintrin.h>//AES(include nmmintrin.h)
#include <immintrin.h>//AVX(include wmmintrin.h)
#include <intrin.h>//(include immintrin.h)
mmintrin.h为MMX 头文件,其中__m64的定义为:
typedef union __declspec(intrin_type) _CRT_ALIGN(8) __m64
{
unsigned __int64 m64_u64;
float m64_f32[2];
__int8 m64_i8[8];
__int16 m64_i16[4];
__int32 m64_i32[2];
__int64 m64_i64;
unsigned __int8 m64_u8[8];
unsigned __int16 m64_u16[4];
unsigned __int32 m64_u32[2];
} __m64;
xmmintrin.h为SSE 头文件,此头文件里包含MMX头文件,其中__m128的定义为:
typedef union __declspec(intrin_type) _CRT_ALIGN(16) __m128 {
float m128_f32[4];
unsigned __int64 m128_u64[2];
__int8 m128_i8[16];
__int16 m128_i16[8];
__int32 m128_i32[4];
__int64 m128_i64[2];
unsigned __int8 m128_u8[16];
unsigned __int16 m128_u16[8];
unsigned __int32 m128_u32[4];
} __m128;
emmintrin.h为SSE2头文件,此头文件里包含SSE头文件,其中__m128i和__m128d的定义为:
typedef union __declspec(intrin_type) _CRT_ALIGN(16) __m128i {
__int8 m128i_i8[16];
__int16 m128i_i16[8];
__int32 m128i_i32[4];
__int64 m128i_i64[2];
unsigned __int8 m128i_u8[16];
unsigned __int16 m128i_u16[8];
unsigned __int32 m128i_u32[4];
unsigned __int64 m128i_u64[2];
} __m128i;
typedef struct __declspec(intrin_type) _CRT_ALIGN(16) __m128d {
double m128d_f64[2];
} __m128d;
wmmintrin.h
为AES头文件,其文件中各函数的介绍:
/*
* Performs 1 round of AES decryption of the first m128i using
* the second m128i as a round key.
*/
//The decrypted data. This instruction decrypts data by using an Equivalent Inverse
//Cipher with a 128 bit key. AES decryption requires 10 iterations of decryption 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_aesdeclast_si128.
extern __m128i _mm_aesdec_si128(__m128i v, __m128i rkey);
/*
* Performs the last round of AES decryption of the first m128i
* using the second m128i as a round key.
*/
//The decrypted data for v. This instruction decrypts data by using an Equivalent
//Inverse Cipher with a 128 bit key. AES decryption requires 10 iterations of decryption
//and uses a cipher key that consists of 128 bits. The final iteration must be performed
//by this instruction. The previous nine iterations use _mm_aesdec_si128.
extern __m128i _mm_aesdeclast_si128(__m128i v, __m128i rkey);
/*
* Performs 1 round of AES encryption of the first m128i using
* the second m128i as a round key.
*/
//The encrypted form of the data in v. 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.
extern __m128i _mm_aesenc_si128(__m128i v, __m128i rkey);
/*
* Performs the last round of AES encryption of the first m128i
* using the second m128i as a round key.
*/
//The encrypted form of the data in v. 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. You must perform the final
//iteration with this instruction. The previous nine iterations use _mm_aesenc_si128.
extern __m128i _mm_aesenclast_si128(__m128i v, __m128i rkey);
/*
* Performs the InverseMixColumn operation on the source m128i
* and stores the result into m128i destination.
*/
//The inverted data. To perform decryption, you should use the aesimc instruction on
//all the AES expanded round keys. This prepares them for decryption by using the
//Equivalent Inverse Cipher.
extern __m128i _mm_aesimc_si128(__m128i v);
/*
* Generates a m128i round key for the input m128i
* AES cipher key and byte round constant.
* The second parameter must be a compile time constant.
*/
//The AES encryption key. AES encryption requires 10 iterations of encryption with
//a 128 bit round key. Each round of encryption requires a different key. This
//instruction helps generate the round keys. The round keys can be generated
//independently of the encryption phase.
extern __m128i _mm_aeskeygenassist_si128(__m128i ckey, const int rcon);
/*
* Performs carry-less integer multiplication of 64-bit halves
* of 128-bit input operands.
* The third parameter inducates which 64-bit haves of the input parameters
* v1 and v2 should be used. It must be a compile time constant.
*/
//The product calculated by multiplying 64 bits of v1 and 64 bits of v2.
// This instruction performs a multiplication of two 64-bit integers.
//The multiplication does not calculate a carry bit.详见参考文献
extern __m128i _mm_clmulepi64_si128(__m128i v1, __m128i v2, const int imm8);
参考文献:http://msdn.microsoft.com/en-us/library/cc664767(v=vs.100).aspx
分享到:
相关推荐
AES: Advanced Encryption Standard AES对称加密算法
AES 是一种对称密钥算法。AES 使用 128、192 或 256 位密钥,并且用 128 位数据块分组对数据进行加密和解密
因特尔 aesni 指令加速aes加密算法白皮书;Intel® Advanced Encryption Standard (AES) New Instructions Set.pdf
AES(Advanced Encryption Standard)的C实现,仅支持128位密钥
intel 对AES算法推出了相应的指令支持,使得AES算法性能大幅提高。这是相应的指令集介绍文档。
Advanced Encryption Standard,AES加解密算法C语言实现。
The Advanced Encryption Standard (AES) is a National Institute of Standards and Technology specification for the encryption of electronic data. It is expected to become the accepted means of ...
官方的AES加密文档,原本没有目录,自己手动做的,内容详细不含糊
高级加密标准(英语:Advanced Encryption Standard,缩写:AES),在密码学中又称Rijndael加密法,是美国联邦政府采用的一种区块加密标准。这个标准用来替代原先的DES,已经被多方分析且广为全世界所使用。经过五年...
AES Advanced Encryption Standard 详细介绍参考博客:《》
aes advanced encryption standart.
Advanced Encryption Standard中文称为AES加密标准。本文件实现AES-128算法,并且容易扩展到192, 256 bit。 The irreducible polynomial of GF(2^8) is m(x) = x^8 + x^4 + x^3 + x + 1 const int Nr = 10; round ...
AES(Advanced Encryption Standard)是一种对称加密算法,它使用相同的密钥对数据进行加密和解密。 AES 的密钥长度有 128 位、192 位和 256 位三种可选,密钥长度越长,加密强度越高。 AES 的特点如下: 加密强度...
高级加密标准AES的数学原理和数学基础,内容详细。
Cross-platform-AES-encryption, 基本交叉平台AES加密 跨平台 256bit AES加密/解密。项目包含 256位AES加密的实现,该加密工作在所有平台( 。C#,iOS,安卓和 node.js ) 上。 一个关键的目标是让AES在所有平台上实现...
Advanced Encryption Standard Code. This matlab code explains how AES Encryption and decryption takes place.
AES encryption algorithm is Advanced Development Code AES 算法加密高级开发代码
documentation AES encryption
AES encryption and decryption
code for adavance encryption standard for security system by using matlab