AES-NI in Laymen's Terms

What is AES-NI - first answer
AES-NI are a set of six new instructions introduced by Intel when we introduced the new 2010 Intel® Core™ processor family code named Westmere. AES-NI stands for Advanced Encryption Standard - New Instructions. These instructions implement hardware accelerated versions of certain compute intensive steps used in the AES (RijnDael) algorithm.

Okay - so what is the Advanced Encryption Standard (AES)?

AES is a standard that defines how to encrypt plain text using an encryption key. It is implemented with the RijnDael (pronounced Rhine Dahl) algorithm. One cool thing about AES is that even though this algorithm is completely open for examination, it is possible to encrypt a plain text message with it that is very, very difficult to break. This is possible because the algorithm takes the plain text message you want to encyrpt, and merges it in a certain way with a secret key. As long as the key is kept private, the encrypted message has proven to be safe from being broken, at least to this point in time. So the algorithm is completley known, but as long as the key is protected, messages encoded with it are virtually safe from eves dropping.

So who cares?
So what kind of software developers might use AES? and who might benefit from the new AES-NI? There may be more than you think at first: developers who write code that that use secure socket layer (SSL), database engines, whole disk encryption applications, files compression applications, VoIP, instant messaging, email, virtualization software, electronic payment systems, virtual private networks, and list goes on. To learn more about who might use AES see this wiki article on AES instruction set or this article on AES-NI analysis on Tom's Hardware.

So how does AES (Rijndael) work?
To understand how the AES (Rijndael) algorithm works I highly recommend that you look at Jeff Moser's "A Stick Figure Guide to the Advanced Encryption Standard (AES) - A play in 4 acts". This creative, stick figure, cartoon approach is the best method I have seen for communicating how AES works - five stars Mr. Moser!

My stick figure image below is an icon tribute to the excellent efforts of Mr. Moser in laying bare the essense of AES.

AES Stick Figure

Thanks Mr. Moser!

What is AES-NI - second answer
Now consider that the six AES-NI from Intel provide two instructions to accelerate encrypting a round, two instructions for decryping a round, and two more instructions to accelerate the generation of round keys. In summary, the six new instructions provide a faster way to crunch through the Rijndael algorithm (AES). Curious to know more? Read more about it in my friend, Jeff Rott's, blog. Jeff wrote an excellent blog on Intel® Advanced Encryption Standard Instructions (AES-NI), in which he introduces the six instructions, describes the benefits, and introduces ways to actually implement these in your code (plus references).

So how can you implement AES-NI in your code?
As long as you are using one of the following compilers (or later) you can get direct access to the instructions:
AES-NI are supported by version 11 of the Intel C/C++ compiler, and also by Microsoft* Visual Studio* 2008 Service Pack 1 and by gcc version 4.4.
You can implement it the hard way using MASM or inline assembly. Or you can make it easier on yourself and use compiler intrinsics (just be sure to include wmmintrin.h or intrin.h). See Martyn Corden's Post here on Compiling with AES-NI. Another approach is to use a library such as OpenSSL or Intel's IPP to implement AES-NI - Jeff has references ;-)

If you really want to dig in and see the reference and code snippets read Intel's Shay Gueron's in-depth whitepaper called "Intel® Advanced Encryption Standard (AES) Instructions Set". See Shay's abstract and whitepaper link here.

Finally - if you want a complete understanding of AES, much more than you will find in a Wiki article or blog, then check out the following book. "The Design of Rijndael" is the definitive book on the subject, written by the Rijndael creators.

 

 

 

Optimization Notice
Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804

分类:
如需更全面地了解编译器优化,请参阅优化注意事项