I have been searching many websites for source code of AES whether it is ECB, CBC, CTR or any other method but can't find any. Can anyone please help me in getting the source code? I have to implement timing analysis on that code to see whether the code is leaky or non-leaky.

  • 2
    $\begingroup$ Do you have a specific target? Without it this is a broad question, with it, it may be off-topic! $\endgroup$
    – kelalaka
    Commented Dec 9, 2019 at 21:21
  • 3
    $\begingroup$ There are quite a few AES implementations out there, and some will have timing side channel leaks, and some won't. Which implementation are you interested in? $\endgroup$
    – poncho
    Commented Dec 9, 2019 at 21:26
  • 1
    $\begingroup$ AES with ECB, CBC, CTR is here and many other places. There's a simple 1-block AES-128 encryption in this answer. It will be leaky, or not, depending on platform and compilation parameters. $\endgroup$
    – fgrieu
    Commented Dec 9, 2019 at 22:34
  • $\begingroup$ there are literally thousands of code samples for AES out there, possibly millions, openssl, wifi, and the linux kernel are the most common, and that code is everywhere $\endgroup$ Commented Dec 10, 2019 at 0:38

2 Answers 2


As already mentioned in the comments to your question, implementations of AES are aplenty on Github, depending on the language you want to use and on the type of requirements you have, including the original ANSI C reference implementation.

However, if you are interested in timing analysis of AES implementations, you might as well want to take a look at the Dudect code.

Dudect comes from a paper named "Dude, is my code constant time?", it is a tool meant to detect timing discrepancies using Welch's t-test. It compares actual runs of a given source code against the null hypothesis that the code running is constant time.

It notably features as an example of variable time code a T-tables implementation of AES, which is a typical example of variable-time AES implementation. But it also bundles another example, which is a bitsliced constant-time AES implementation, to show the differences between variable time and constant time code.


I just wrote a Post on stack overflow; about AES There I step-by-step explaining how to compile them, use them, and where to get them.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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