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.

I want to write AES from scratch without using the built in libraries of java. I know there are hundreds of AES programs (and websites) out there but I can't seem to find a site that gives me the details I think I would/should need to write my own Java program.

I know that AES has S-boxes like DES has. Were would I look for them? Also, I would like more info on the AES "counter mode".

share|improve this question
    
Just a note: For productive use, you often want to use existing implementations instead of creating your own, since they probably are better shielded against side-channel attacks, and might also be more efficient (e.g. might use AES-specific instructions on modern processors). For learning about the internal workings it is a good idea to implement it yourself, though. –  Paŭlo Ebermann Sep 29 '11 at 23:50
1  
For reference, a Java implementation of FIPS AES can be found in the Bouncy Castle open source project: bouncycastle.org/specifications.html –  Gary Rowe Sep 30 '11 at 15:24
    
My python implementation of AES is supposed to be very easy to read, and it's got a good few comments. For what it's worth, it might help you or someone else implementing aes: code.google.com/p/zs-crypto/source/browse/zs/cipher/aes.py. A tip: read this code together with the wikipedia articles on AES. Most of the maths turns out to be really straightforward. –  Stefano Palazzo Nov 9 '11 at 9:17
    
Thanks will do I really want to start learning Python. –  Dennis Hayden Nov 10 '11 at 14:46

2 Answers 2

up vote 10 down vote accepted

The AES standard is reasonably clear, and (theoretically) sufficient to implement the AES itself. For block cipher modes of operation (including counter mode), see NIST Special Publication 800-38A.

share|improve this answer
    
This is great thanks for your help! –  Dennis Hayden Sep 29 '11 at 13:59

One thing I would like to add to Thomas's answer: when implementing a cipher, it's useful to have a test vector with the cipher intermediate states (if you get it right the first time, you don't need it; if you get a detail wrong, it makes finding that detail a lot easier).

The document http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf has all those intermediate states (both for the key expansion and the actual block encrypt operations; the decrypt is just a reversal of the encrypt operations, so they don't need to spell it out explicitly).

share|improve this answer
    
While I do thanks you for the help. Thomas Pornin first link is the same as the one you posted. –  Dennis Hayden Sep 29 '11 at 15:42
1  
Oops, I missed that his 'The AES standard' was a link... –  poncho Sep 29 '11 at 20:51

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.