4.3 KiB
AES Block Cipher
AES-dust is a compact Implementation of the AES block cipher with support for 128 and 256-bit keys. The modes of encryption supported are Counter (CTR) and Electronic Code Book (ECB).
All code is intentionally optimized for size rather than speed making it suitable for resource constrained environments.
Files
All files with .s and .asm extensions are compatible with the GNU assembler (GAS) except for the files in the MSVC folder that will assemble with either NASM or YASM.
File | Description |
---|---|
aes.c | AES-128,AES-256 in C for 8-bit, 32-bit and 64-bit architectures. |
test.c | Monte Carlo test for AES-128, AES-256 in ECB mode. |
test2.c | Simple test unit for AES-128, AES-256 in ECB and CTR mode. |
asm/ax.asm | AES-128 in x86 assembly. |
asm/axx.asm | AES-128 in AMD64 assembly. |
asm/ax.s | AES-128 in ARM32 assembly. |
asm/axx.s | AES-128 in ARM64 assembly. |
Assembly
The below table shows code sizes for the hand written versions of AES-128
Architecture | ECB | CTR |
---|---|---|
x86 | 205 | 272 |
AMD64 | 253 | 339 |
ARM32 | 352 | |
ARM64 | 352 |
C generated assembly
The following table lists the size of assembly code generated by the GNU C compiler.
Architecture | ECB | CTR |
---|---|---|
x86 | 524 | 701 |
AMD64 | 451 | 682 |
ARM32 | 480 | 668 |
ARM64 | 640 | 940 |
The following table lists the size of assembly code generated by the Microsoft C compiler.
Architecture | ECB | CTR |
---|---|---|
x86 | 321 | 477 |
AMD64 | 486 | 673 |
ARM32 | 372 | 502 |
ARM64 | 536 | 880 |
Side channel attacks
AES was never intended to be resistant against side channel attacks. However, if you decide to use this code for an embedded project that requires a high level of security, first evaluate whether the code is sufficient against such attacks before including in your project.
Licensing information
Initially this was published with a BSD license. I decided to unlicense hoping more people would use and provide useful feedback.
This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to http://unlicense.org/