# amanmaurya-406/rsa architecture

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

- Interactive diagram: https://gitdiagram.com/amanmaurya-406/rsa
- Repository: https://github.com/amanmaurya-406/rsa

## Overview

This is a menu-driven C RSA utility. Its main workflow dispatches key generation, file encryption/decryption, and message signing/verification; key generation writes PEM keys, while key loading decodes them for cryptographic operations. ASN.1 serialization supports key encoding, and file reading and SHA-512 are supporting runtime capabilities. The graph follows calls visible in the excerpts and documented features; some implementation details, including cipher and hash internals, were not excerpted, so their internal relationships are omitted.

Main entry points: [`src/main.c`](https://github.com/amanmaurya-406/rsa/blob/main/src/main.c) (Menu dispatcher), [`src/encodeKey.c`](https://github.com/amanmaurya-406/rsa/blob/main/src/encodeKey.c) (PEM key codec), [`src/RSA_generateKey.c`](https://github.com/amanmaurya-406/rsa/blob/main/src/RSA_generateKey.c) (RSA key generation), [`src/RSA_cipher.c`](https://github.com/amanmaurya-406/rsa/blob/main/src/RSA_cipher.c) (RSA encryption)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application workflow"]
  node_main["Menu dispatcher<br/>[main.c]"]
end

subgraph group_keys["Key management"]
  node_keygen["RSA key generation<br/>[RSA_generateKey.c]"]
  node_keycodec["PEM key codec<br/>[encodeKey.c]"]
  node_keyfiles["PEM key files"]
end

subgraph group_crypto["RSA operations"]
  node_cipher["RSA encryption<br/>[RSA_cipher.c]"]
  node_signverify["Signature operations<br/>[signAndVerify.c]"]
  node_sha["SHA-512 hashing<br/>[sha512.c]"]
end

subgraph group_support["Data and encoding"]
  node_asn1["ASN.1 encoding<br/>[asn1.c]"]
  node_fileio["File reading<br/>[readFile.c]"]
  node_messagefiles["Message and cipher files"]
end

node_user(("CLI user"))

node_user -->|"selects action"| node_main
node_main -->|"generates keys"| node_keygen
node_keygen -->|"writes PEM"| node_keycodec
node_keycodec -->|"serializes key"| node_asn1
node_main -->|"loads keys"| node_keycodec
node_keygen -->|"stores key"| node_keyfiles
node_keycodec -->|"reads and writes"| node_keyfiles
node_main -->|"encrypts or decrypts"| node_cipher
node_main -->|"reads message"| node_fileio
node_main -->|"signs or verifies"| node_signverify
node_main -->|"uses message files"| node_messagefiles

click node_main "https://github.com/amanmaurya-406/rsa/blob/main/src/main.c"
click node_keygen "https://github.com/amanmaurya-406/rsa/blob/main/src/RSA_generateKey.c"
click node_keycodec "https://github.com/amanmaurya-406/rsa/blob/main/src/encodeKey.c"
click node_asn1 "https://github.com/amanmaurya-406/rsa/blob/main/src/asn1.c"
click node_cipher "https://github.com/amanmaurya-406/rsa/blob/main/src/RSA_cipher.c"
click node_signverify "https://github.com/amanmaurya-406/rsa/blob/main/src/signAndVerify.c"
click node_sha "https://github.com/amanmaurya-406/rsa/blob/main/src/sha512.c"
click node_fileio "https://github.com/amanmaurya-406/rsa/blob/main/src/readFile.c"

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_main,node_user toneBlue
class node_keygen,node_keycodec,node_keyfiles toneAmber
class node_cipher,node_signverify,node_sha toneMint
class node_asn1,node_fileio,node_messagefiles toneRose
```

## Components

### Application workflow

- [Menu dispatcher](https://github.com/amanmaurya-406/rsa/blob/main/src/main.c): `src/main.c`

### Key management

- [RSA key generation](https://github.com/amanmaurya-406/rsa/blob/main/src/RSA_generateKey.c): `src/RSA_generateKey.c`
- [PEM key codec](https://github.com/amanmaurya-406/rsa/blob/main/src/encodeKey.c): `src/encodeKey.c`
- **PEM key files**

### RSA operations

- [RSA encryption](https://github.com/amanmaurya-406/rsa/blob/main/src/RSA_cipher.c): `src/RSA_cipher.c`
- [Signature operations](https://github.com/amanmaurya-406/rsa/blob/main/src/signAndVerify.c): `src/signAndVerify.c`
- [SHA-512 hashing](https://github.com/amanmaurya-406/rsa/blob/main/src/sha512.c): `src/sha512.c`

### Data and encoding

- [ASN.1 encoding](https://github.com/amanmaurya-406/rsa/blob/main/src/asn1.c): `src/asn1.c`
- [File reading](https://github.com/amanmaurya-406/rsa/blob/main/src/readFile.c): `src/readFile.c`
- **Message and cipher files**

### Other components

- **CLI user**

## Connections

- CLI user → Menu dispatcher: selects action (evidence: `src/main.c`)
- Menu dispatcher → RSA key generation: generates keys (evidence: `src/main.c`)
- RSA key generation → PEM key codec: writes PEM (evidence: `src/RSA_generateKey.c`)
- PEM key codec → ASN.1 encoding: serializes key (evidence: `src/encodeKey.c`)
- Menu dispatcher → PEM key codec: loads keys (evidence: `src/main.c`)
- RSA key generation → PEM key files: stores key (evidence: `src/RSA_generateKey.c`)
- PEM key codec → PEM key files: reads and writes (evidence: `src/encodeKey.c`)
- Menu dispatcher → RSA encryption: encrypts or decrypts (evidence: `src/main.c`)
- Menu dispatcher → File reading: reads message (evidence: `src/main.c`)
- Menu dispatcher → Signature operations: signs or verifies (evidence: `src/main.c`)
- Menu dispatcher → Message and cipher files: uses message files (evidence: `src/main.c`)
