# kokke/tiny-aes-c architecture

> Architecture diagram of the GitHub repository kokke/tiny-aes-c, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kokke/tiny-aes-c
- Repository: https://github.com/kokke/tiny-aes-c

## Overview

##### Main Components
- Core AES Library:
- This includes the main implementation files: aes.c (the core logic), aes.h (C header exposing the API), and aes.hpp (C++ wrapper for convenience).
- That these files provide the cryptographic algorithms and mode-of-operation functionalities.
- Test Suite:
- Files such as test.c, test.cpp, and the content within the test_package directory represent various ways to verify the library’s functionality.
- That this suite verifies compatibility across C and C++ uses.
- Build & Packaging Infrastructure:
- Build scripts like CMakeLists.txt and Makefile indicate multiple build system options.
- Package configuration files such as conanfile.py (for Conan package management) and library.json/library.properties (for other ecosystem integrations) signal that this project is designed for integration into larger systems.
- Continuous Integration (CI) Configuration:
- The presence of directories like .github/workflows with configuration files (e.g., c-cpp.yml) show how automated builds and tests are executed.

##### Relationships and Data Flow
- That client code (or test applications) makes calls to the public AES API provided in aes.h/aes.hpp.
- That the Build System processes these source files (via CMake, Make, or Conan) to produce a library binary.
- Demonstrate that test suites use the AES library to validate encryption and decryption operations.

##### Architectural Patterns and Design Principles
- Modular Design: Separate source and header files neatly divide the implementation from the interface.
- Configurability: The API design allows compile-time toggling of AES key sizes and operational modes (using preprocessor definitions such as AES192 and AES256), representing a flexible architecture.

##### Relevant Technologies and Tools
- Languages: C (and C++ for users leveraging aes.hpp).
- Build Tools: CMake, Make, and Conan for packaging and dependency management.
- CI/CD: GitHub Actions workflows (as seen in .github/workflows) which manage automated builds and testing.
- Deployment Environments: Embedded systems (ARM, AVR, x86) as referenced by the provided compilation examples.

##### Detail Orchestration
- Compile-time configuration options (defines like CBC, CTR, ECB) as annotations around the AES Core Library.
- Integration with external package managers (Conan) and repository metadata files, indicating that the library is designed to be easily consumed by other projects.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        Client["Client/Application Code"]:::client
    end

    subgraph "Core AES Library"
        A_C_Impl["C Implementation"]:::core
        A_C_API["C API"]:::core
        A_CPP["C++ Wrapper"]:::core
    end

    subgraph "Test Suite"
        TestC["Test (C)"]:::test
        TestCPP["Test (C++)"]:::test
        TestPkg["Test Package"]:::test
    end

    subgraph "Build & Packaging"
        BuildScripts["Build Scripts"]:::build
        PackageConfig["Package Config"]:::build
    end

    subgraph "CI/CD Pipeline"
        CI["CI/CD Pipeline"]:::ci
        WorkflowCfg["Workflow Config"]:::ci
    end

    %% Relationships
    Client -->|"callsAPI"| A_C_API
    Client -->|"callsAPI"| A_CPP

    BuildScripts -->|"builds"| A_C_Impl
    BuildScripts -->|"builds"| A_C_API
    BuildScripts -->|"builds"| A_CPP
    BuildScripts -->|"builds"| TestC
    BuildScripts -->|"builds"| TestCPP
    BuildScripts -->|"builds"| TestPkg

    CI -->|"triggers"| BuildScripts
    CI -->|"triggers"| PackageConfig
    CI -->|"manages"| WorkflowCfg

    %% Click Events for Core AES Library
    click A_C_Impl "https://github.com/kokke/tiny-aes-c/blob/master/aes.c"
    click A_C_API "https://github.com/kokke/tiny-aes-c/blob/master/aes.h"
    click A_CPP "https://github.com/kokke/tiny-aes-c/blob/master/aes.hpp"

    %% Click Events for Test Suite
    click TestC "https://github.com/kokke/tiny-aes-c/blob/master/test.c"
    click TestCPP "https://github.com/kokke/tiny-aes-c/blob/master/test.cpp"
    click TestPkg "https://github.com/kokke/tiny-aes-c/tree/master/test_package"

    %% Click Events for Build & Packaging
    click BuildScripts "https://github.com/kokke/tiny-aes-c/blob/master/CMakeLists.txt"
    click PackageConfig "https://github.com/kokke/tiny-aes-c/blob/master/conanfile.py"

    %% Click Events for CI/CD Configuration
    click CI "https://github.com/kokke/tiny-aes-c/tree/master/.github/workflows"
    click WorkflowCfg "https://github.com/kokke/tiny-aes-c/blob/master/.github/workflows/c-cpp.yml"

    %% Styles
    classDef client fill:#FFFFC1,stroke:#333,stroke-width:2px;
    classDef core fill:#C1E1C1,stroke:#333,stroke-width:2px;
    classDef test fill:#E1C1C1,stroke:#333,stroke-width:2px;
    classDef build fill:#C1C1E1,stroke:#333,stroke-width:2px;
    classDef ci fill:#FFE1C1,stroke:#333,stroke-width:2px;
```
