# youssef-fd/hardware-rsa-cryptoprocessor architecture

> Architecture diagram of the GitHub repository youssef-fd/hardware-rsa-cryptoprocessor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/youssef-fd/hardware-rsa-cryptoprocessor
- Repository: https://github.com/youssef-fd/hardware-rsa-cryptoprocessor

## Overview

This repository is an educational, synchronous VHDL RSA cryptoprocessor. After reset, the top-level controller generates a key, then accepts encryption or decryption requests and returns a result through a shared modular-exponentiation datapath. Key generation coordinates candidate generation, primality testing, and private-exponent derivation; the arithmetic path uses iterative Montgomery multiplication. The graph follows relationships documented in the README; source excerpts were unavailable, and some README-named files differ from the supplied tree, so paths use the tree’s corresponding RTL files.

Main entry points: [`hdl/TOP_LEVEL.vhd`](https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/TOP_LEVEL.vhd) (RSA controller), [`hdl/RSA_KEYGEN.vhd`](https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/RSA_KEYGEN.vhd) (Key coordinator), [`hdl/RSA_BEHAVIOUR.vhd`](https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/RSA_BEHAVIOUR.vhd) (RSA operation wrapper), [`hdl/MOD_MONTGOMERY_EXP.vhd`](https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/MOD_MONTGOMERY_EXP.vhd) (Modular exponentiator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Control and interface"]
  node_top["RSA controller<br/>[TOP_LEVEL.vhd]"]
  node_rsa["RSA operation wrapper<br/>[RSA_BEHAVIOUR.vhd]"]
end

subgraph group_keygen["Key generation"]
  node_keygen["Key coordinator<br/>[RSA_KEYGEN.vhd]"]
  node_random["Candidate generator<br/>[RANDOM_GEN.vhd]"]
  node_miller["Primality tester<br/>[MILLER_RABIN.vhd]"]
  node_gcd["Private exponent solver<br/>[EXT_GCD.vhd]"]
end

subgraph group_arithmetic["RSA arithmetic"]
  node_exp["Modular exponentiator"]
  node_mult["Montgomery multiplier"]
  node_pkg["RSA parameters<br/>[RSA_PKG.vhd]"]
end

node_user(("Requester"))

node_user -->|"requests operation"| node_top
node_top -->|"returns result"| node_user
node_top -->|"generates keys"| node_keygen
node_top -->|"launches operation"| node_rsa
node_keygen -->|"generates candidates"| node_random
node_keygen -->|"tests candidates"| node_miller
node_keygen -->|"derives exponent"| node_gcd
node_rsa -->|"starts exponentiation"| node_exp
node_exp -->|"performs multiplication"| node_mult

click node_top "https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/TOP_LEVEL.vhd"
click node_rsa "https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/RSA_BEHAVIOUR.vhd"
click node_keygen "https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/RSA_KEYGEN.vhd"
click node_random "https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/RANDOM_GEN.vhd"
click node_miller "https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/MILLER_RABIN.vhd"
click node_gcd "https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/EXT_GCD.vhd"
click node_exp "https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/MOD_MONTGOMERY_EXP.vhd"
click node_mult "https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/MONTGOMERY_MULT.vhd"
click node_pkg "https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/RSA_PKG.vhd"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_top,node_rsa toneBlue
class node_keygen,node_random,node_miller,node_gcd toneAmber
class node_exp,node_mult,node_pkg,node_user toneMint
```

## Components

### Control and interface

- [RSA controller](https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/TOP_LEVEL.vhd): `hdl/TOP_LEVEL.vhd`
- [RSA operation wrapper](https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/RSA_BEHAVIOUR.vhd): `hdl/RSA_BEHAVIOUR.vhd`

### Key generation

- [Key coordinator](https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/RSA_KEYGEN.vhd): `hdl/RSA_KEYGEN.vhd`
- [Candidate generator](https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/RANDOM_GEN.vhd): `hdl/RANDOM_GEN.vhd`
- [Primality tester](https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/MILLER_RABIN.vhd): `hdl/MILLER_RABIN.vhd`
- [Private exponent solver](https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/EXT_GCD.vhd): `hdl/EXT_GCD.vhd`

### RSA arithmetic

- [Modular exponentiator](https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/MOD_MONTGOMERY_EXP.vhd): `hdl/MOD_MONTGOMERY_EXP.vhd`
- [Montgomery multiplier](https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/hdl/MONTGOMERY_MULT.vhd): `hdl/MONTGOMERY_MULT.vhd`
- [RSA parameters](https://github.com/youssef-fd/hardware-rsa-cryptoprocessor/blob/main/RSA_PKG.vhd): `RSA_PKG.vhd`

### Other components

- **Requester**

## Connections

- Requester → RSA controller: requests operation (evidence: `README.md`)
- RSA controller → Requester: returns result (evidence: `README.md`)
- RSA controller → Key coordinator: generates keys (evidence: `README.md`)
- RSA controller → RSA operation wrapper: launches operation (evidence: `README.md`)
- Key coordinator → Candidate generator: generates candidates (evidence: `README.md`)
- Key coordinator → Primality tester: tests candidates (evidence: `README.md`)
- Key coordinator → Private exponent solver: derives exponent (evidence: `README.md`)
- RSA operation wrapper → Modular exponentiator: starts exponentiation (evidence: `README.md`)
- Modular exponentiator → Montgomery multiplier: performs multiplication (evidence: `README.md`)
