< Back to projects

AES-128-CBC in x86-64 Assembly

M1 SI Solo April-May 2025 Completed

Advanced x86 assembly course project, solo (AUTHORS.md: "Mustapha HILALOGLU 3SIJ"). A complete implementation of AES-128 in CBC mode, written entirely in x86-64 assembly (NASM), with no libc dependency - direct Linux syscalls (open/read/write) for all file I/O. This is not a crackme: it is a full low-level cryptographic implementation, built from the SBOX and key schedule up to a working command-line encrypt/decrypt tool.

AES-128-CBC block chaining flow Plaintext block N IV / prev. cipher block XOR AES round function x10 SubBytes (SBOX) ShiftRows MixColumns AddRoundKey (Rcon expansion) Ciphertext block N feeds into XOR for block N+1 (chaining)
CBC chaining: each plaintext block is XORed with the previous ciphertext block (or the IV for the first block) before the AES round function, implemented entirely as hand-written x86-64 instructions.

Context

Built iteratively over about three weeks: pre_prod/ (April 29, first prototype), extra_chiffrement_aes_cbc/ (May 7, 4634 lines, a modular version with separate SBOX, key generation, MixColumn and CBC modules plus a makefile), advenced_encryption_standard/ (May 10, 1286 lines), aes_cbc_modulaire/ and aes_cbc_folder/ (May 12, final modular version with encrypt/decrypt/main split into separate files), and finally aes_ni_encrypt_decrypt/aes_program.s (May 12, 528 lines) - the most complete version, with an interactive menu (Encrypt/Decrypt/Exit), file reading, user-supplied key/IV input, and Rcon-based key expansion. A demo video (Projet_ASM_SM_MH_2.mp4) was recorded in May 2025.

What was implemented

  • Full AES round pipeline in raw assembly: SubBytes via a hand-coded SBOX lookup table, ShiftRows, MixColumns (GF(2^8) arithmetic), and AddRoundKey.
  • Key expansion with Rcon constants, generating all round keys from the 128-bit key.
  • CBC mode chaining logic, with user-supplied key and IV.
  • File I/O and program control entirely through direct Linux syscalls (open, read, write) - no libc, no external crypto library.
  • An interactive menu (encrypt / decrypt / exit) driving the whole program.

Tech stack

x86-64 Assembly (NASM) AES-128-CBC Linux syscalls No libc Low-level cryptography

Status

Completed and submitted. The final version compiles and runs as a standalone command-line tool, encrypting and decrypting files with a user-supplied key and IV, entirely in assembly.