当前位置: 首页 > 编程日记 > 正文

AES(Advanced Encryption Standard) Intrinsics各函数介绍

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

相关文章:

轻松应对Java试题,这是一份大数据分析工程师面试指南

作者 | HappyMint转载自大数据与人工智能&#xff08;ai-big-data&#xff09;导语&#xff1a;经过这一段时间与读者的互动与沟通&#xff0c;本文作者发现很多小伙伴会咨询面试相关的问题&#xff0c;特别是即将毕业的小伙伴&#xff0c;所以决定输出一系列面试相关的文章。本…

【Elasticsearch 5.6.12 源码】——【3】启动过程分析(下)...

版权声明&#xff1a;本文为博主原创&#xff0c;转载请注明出处&#xff01;简介 本文主要解决以下问题&#xff1a; 1、ES启动过程中的Node对象都初始化了那些服务&#xff1f;构造流程 Step 1、创建一个List暂存初始化失败时需要释放的资源&#xff0c;并使用临时的Logger对…

C++中的封装、继承、多态

封装(encapsulation)&#xff1a;就是将抽象得到的数据和行为(或功能)相结合&#xff0c;形成一个有机的整体&#xff0c;也就是将数据与操作数据的源代码进行有机的结合&#xff0c;形成”类”&#xff0c;其中数据和函数都是类的成员。封装的目的是增强安全性和简化编程&…

比尔盖茨护犊子 称iPad让大批用户沮丧

为什么80%的码农都做不了架构师&#xff1f;>>> 在5月6日接受美国CNBC电视台访问时&#xff0c;微软前任掌门人比尔盖茨维护了自家反响不那么好的Surface系列平板电脑&#xff0c;同时他还不忘吐槽了一把iPad。 当 谈到日渐颓败的PC市场时&#xff0c;盖茨称平板电…

小心陷阱:二维动态内存的不连续性

void new_test() {int** pp;pp new int*[10];for(int i0; i<10; i){pp[i] new int[10];}//pp[0], pp[1], ... , pp[9]在内存中连续;//a1 pp[0][0], pp[0][1], ... , pp[0][9]在内存中也是连续的;//a2 pp[1][0], pp[1][1], ... , pp[1][9]在内存中也是连续的;//...//a9 …

超酷炫!Facebook用深度学习和弱监督学习绘制全球精准道路图

作者 | Saikat Basu等译者 | 陆离责编 | 夕颜出品 | AI科技大本营&#xff08;ID: rgznai100&#xff09;导读&#xff1a;现如今&#xff0c;即使可以借助卫星图像和绘制软件&#xff0c;创建精确的道路图也依然是一个费时费力的人力加工过程。许多地区&#xff0c;特别是在发…

npm包发布记录

下雪了&#xff0c;在家闲着&#xff0c;不如写一个npm 包发布。简单的 npm 包的发布网上有很多教程&#xff0c;我就不记录了。这里记录下&#xff0c;一个复杂的 npm 包发布&#xff0c;复杂指的构建环境复杂。 整个工程使用 rollup 来构建&#xff0c;其中会引进 babel 来转…

设计模式之单例模式(Singleton)摘录

23种GOF设计模式一般分为三大类&#xff1a;创建型模式、结构型模式、行为模式。 创建型模式包括&#xff1a;1、FactoryMethod(工厂方法模式)&#xff1b;2、Abstract Factory(抽象工厂模式)&#xff1b;3、Singleton(单例模式)&#xff1b;4、Builder(建造者模式)&#xff1…

关于知识蒸馏,这三篇论文详解不可错过

作者 | 孟让转载自知乎导语&#xff1a;继《从Hinton开山之作开始&#xff0c;谈知识蒸馏的最新进展》之后&#xff0c;作者对知识蒸馏相关重要进行了更加全面的总结。在上一篇文章中主要介绍了attention transfer&#xff0c;FSP matrix和DarkRank&#xff0c;关注点在于寻找不…

设计模式之建造者模式(生成器模式、Builder)摘录

23种GOF设计模式一般分为三大类&#xff1a;创建型模式、结构型模式、行为模式。 创建型模式包括&#xff1a;1、FactoryMethod(工厂方法模式)&#xff1b;2、Abstract Factory(抽象工厂模式)&#xff1b;3、Singleton(单例模式)&#xff1b;4、Builder(建造者模式、生成器模式…

[置顶] webservice系列2---javabeanhandler

摘要&#xff1a;本节主要介绍以下两点&#xff0c;1.带javabean的webservice的开发和调用 2.handler的简单介绍及使用1.引言在之前的一篇博客webservice系列1---基于web工程上写一个基本数据类型的webservice中介绍了如何采用axis1.4来完成一个简单的webservice的开发流程(入参…

AI教育公司物灵科技完成战略融资,商汤科技投资

1月2日消息&#xff0c;从相关媒体报道&#xff0c;AI教育公司物灵科技近日完成了商汤的战略融资&#xff0c;本轮融资将用于产品迭代和扩大市场。 此前投资界曾报道&#xff0c;物灵科技已经获得1.5亿元Pre-A轮融资&#xff0c;当时具体资方未透露。 公开资料显示&#xff0…

Python之父发文,将重构现有核心解析器

原题 | PEG Parsers作者 | Guido van Rossum译者 | 豌豆花下猫转载自 Python猫&#xff08;ID: python_cat&#xff09; 导语&#xff1a;Guido van Rossum 是 Python 的创造者&#xff0c;虽然他现在放弃了“终身仁慈独裁者”的职位&#xff0c;但却成为了指导委员会的五位成员…

全面支持三大主流环境 |百度PaddlePaddle新增Windows环境支持

2019独角兽企业重金招聘Python工程师标准>>> PaddlePaddle作为国内首个深度学习框架&#xff0c;最近发布了更加强大的Fluid1.2版本, 增加了对windows环境的支持&#xff0c;全面支持了Linux、Mac、 windows三大环境。 PaddlePaddle在功能完备的基础上&#xff0c;也…

设计模式之原型模式(Prototype)摘录

23种GOF设计模式一般分为三大类&#xff1a;创建型模式、结构型模式、行为模式。 创建型模式包括&#xff1a;1、FactoryMethod(工厂方法模式)&#xff1b;2、Abstract Factory(抽象工厂模式)&#xff1b;3、Singleton(单例模式)&#xff1b;4、Builder(建造者模式、生成器模式…

NFS共享服务挂载时出现“access denied by server while mounting”的解决方法

笔者用的Linuxf发行版本为Centos6.4&#xff0c;以下方法理论上讲对于Fedora, Red Hat均有效&#xff1a; 搭建好NFS服务后&#xff0c;如果用以下的命令进行挂载&#xff1a; # mount -t nfs 172.16.12.140:/home/liangwode/test /mnt 出现如下错误提示&#xff1a; mount.nf…

设计模式之桥接模式(Bridge)摘录

23种GOF设计模式一般分为三大类&#xff1a;创建型模式、结构型模式、行为模式。 创建型模式包括&#xff1a;1、FactoryMethod(工厂方法模式)&#xff1b;2、Abstract Factory(抽象工厂模式)&#xff1b;3、Singleton(单例模式)&#xff1b;4、Builder(建造者模式、生成器模式…

原360首席科学家颜水成正式加入依图科技,任首席技术官

7 月 29 日&#xff0c;依图科技宣布原 360 首席科学家颜水成正式加入&#xff0c;担任依图科技首席技术官&#xff08;CTO&#xff09;一职。依图方面称&#xff0c;颜水成加入后将带领团队进一步夯实依图在人工智能基础理论和原创算法方面的技术优势&#xff0c;为依图在商业…

分布式存储fastdfs安装使用

1.下载地址https://github.com/happyfish100/fastdfshttps://github.com/happyfish100/fastdfs/wiki安装辅助说明文档2.安装编译环境yum install git gcc gcc-c make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y三台主机&#xff1a…

Hibernate学习(九)———— 二级缓存和事务级别详讲

序言 这算是hibernate的最后一篇文章了&#xff0c;下一系列会讲解Struts2的东西&#xff0c;然后说完Struts2&#xff0c;在到Spring&#xff0c;然后在写一个SSH如何整合的案例。之后就会在去讲SSM&#xff0c;在之后我自己的个人博客应该也差不多可以做出来了。基本上先这样…

超详细中文预训练模型ERNIE使用指南

作者 | 高开远&#xff0c;上海交通大学&#xff0c;自然语言处理研究方向最近在工作上处理的都是中文语料&#xff0c;也尝试了一些最近放出来的预训练模型&#xff08;ERNIE&#xff0c;BERT-CHINESE&#xff0c;WWM-BERT-CHINESE&#xff09;&#xff0c;比对之后还是觉得百…

linux内核SMP负载均衡浅析

需求 在《linux进程调度浅析》一文中提到&#xff0c;在SMP&#xff08;对称多处理器&#xff09;环境下&#xff0c;每个CPU对应一个run_queue&#xff08;可执行队列&#xff09;。如果一个进程处于TASK_RUNNING状态&#xff08;可执行状态&#xff09;&#xff0c;则它…

结构体中最后一个成员为[0]或[1]长度数组(柔性数组成员)的用法

结构体中最后一个成员为[0]长度数组的用法&#xff1a;这是个广泛使用的常见技巧&#xff0c;常用来构成缓冲区。比起指针&#xff0c;用空数组有这样的优势&#xff1a;(1)、不需要初始化&#xff0c;数组名直接就是所在的偏移&#xff1b;(2)、不占任何空间&#xff0c;指针需…

超全!深度学习在计算机视觉领域的应用一览

作者 | 黄浴&#xff0c;奇点汽车美研中心首席科学家兼总裁转载自知乎简单回顾的话&#xff0c;2006年Geoffrey Hinton的论文点燃了“这把火”&#xff0c;现在已经有不少人开始泼“冷水”了&#xff0c;主要是AI泡沫太大&#xff0c;而且深度学习不是包治百病的药方。计算机视…

SHAREPOINT2010数据库升级2013

在作TEST-SPCONTENT命令时&#xff0c;会提示认证方式不一样。 The [SharePoint - 80] web application is configured with claims authentication mode however the content database you are trying to attach is intended to be used against a windows classic authentic…

设计模式之简单工厂模式(Simply Factory)摘录

从设计模式的类型上来说&#xff0c;简单工厂模式是属于创建型模式&#xff0c;又叫静态工厂方法(Static Factory Method)模式&#xff0c;但不属于23种GOF设计模式之一。简单工厂模式是由一个工厂对象决定创建出哪一种产品类的实例。简单工厂模式是工厂模式家族中最简单实用的…

别得意,你只是假装收藏了而已

今天分享我在看罗振宇的《2018 时间的朋友》演讲视频记下的一些思考。跨年演讲中有过这样的一个来自印象笔记的片段&#xff0c;列举了几组对比来说明&#xff1a; 『你在朋友圈里又佛又丧&#xff0c;你在收藏夹里偷偷地积极向上。』 扎心了&#xff0c;这不就是说我吗&#x…

Exchange2003-2010迁移系列之四,配置第一台Exchange CAS/HUB服务器

配置第一台CAS/HUB关于Cas/hub的配置请大家详见前面关于Ex2010的部署&#xff08;两个配置基本相同在这里就不做详细的解说了&#xff09;下面关于Cas的配置在前面已经提到了但是下面是另一种新的方法大家就看看吧生产环境中部署Exchange2010服务器时&#xff0c;是需要按照一定…

设计模式之适配器模式(Adapter)摘录

23种GOF设计模式一般分为三大类&#xff1a;创建型模式、结构型模式、行为模式。 创建型模式抽象了实例化过程&#xff0c;它们帮助一个系统独立于如何创建、组合和表示它的那些对象。一个类创建型模式使用继承改变被实例化的类&#xff0c;而一个对象创建型模式将实例化委托给…

JAVA方法中的参数用final来修饰的效果

很多人都说在JAVA中用final来修饰方法参数的原因是防止方法参数在调用时被篡改&#xff0c;其实也就是这个原因&#xff0c;但理解起来可能会有歧义&#xff0c;我们需要注意的是&#xff0c;在final修饰的方法参数中&#xff0c;如果修饰的是基本类型&#xff0c;那么在这个方…