Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

Newer Intel and AMD processors have hardware support for implementing AES using the instruction set AES-NI (instructions AESENC, AESKEYGENASSIST etc). Do you know of any clean example implementation using these instructions? In assembly (x86-64 or 32) or using wmmintrin.h (I use gcc and gas, but nasm is ok too).

I found a couple of implementations but they were cluttered with ifdefs and hard to follow macros. It would be nice to begin with a clean and easy to read implementation of, say, encrypting just one block using AES 128 and then build on from there.

share|improve this question
2  
Might be one of those questions that should be transferred to stackoverflow.... –  owlstead Apr 12 '12 at 10:19
    
I found this one: stackoverflow.com/questions/4609677/… But it was closed because the question was not formulated as a question (and still not answered). –  Albert Veli Apr 12 '12 at 11:42
    
What I mean is that this question could in that case be merged with the already existing one on the same subject. –  Albert Veli Apr 12 '12 at 12:31
    
I would not know how to do that. I can edit the original question or I can transfer this one, but I would not know how to merge... –  owlstead Apr 13 '12 at 1:25
add comment

1 Answer 1

Have you looked at the OpenSSL implementation? At a quick glance, it looks reasonably clean to me.

You can find the OpenSSL source here. Within the source, there are several implementations in the directory "\crypto\aes\asm\". The standard x64 is in file "aesni-x86_64.pl". The assembly is generated by Perl, code, however, but it looks like it's pretty straight forward to read.

share|improve this answer
    
Thanks! It looks good. I will try to compile code to expand key and encrypt/decrypt a block this weekend. –  Albert Veli Apr 13 '12 at 9:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.