# mainakaruoya/py_rsa architecture

> Architecture diagram of the GitHub repository mainakaruoya/py_rsa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mainakaruoya/py_rsa
- Repository: https://github.com/mainakaruoya/py_rsa

## Overview

##### Data Flow and Interactions

a) Key Generation Flow:
- From rsa_primes.py to py_rsa.py:
- Public key tuple (n, e)
- Private key tuple (n, e, d, p, q)

b) Operation Flow:
- From rsa_cli.py to py_rsa.py:
- Encryption requests
- Signature requests
- From py_rsa.py back to rsa_cli.py:
- Encrypted output
- Digital signatures

##### Component Details
For each major component, include these elements:

a) py_rsa.py:
- RSAES-OAEP encryption scheme
- RSASSA-PSS signature scheme
- Primitive operations
- Standards compliance (PKCS #1 v2.2)

b) rsa_primes.py:
- NIST FIPS 186-5 compliance
- Provable prime generation
- Key pair creation
- Supported key sizes (2048, 3072, 4096 bits)

c) rsa_cli.py:
- Command-line interface
- Operation modes (encrypt, sign, both)
- Input validation
- Output formatting (using colorama)

##### Additional Elements

- Version/standard references:
- PKCS #1 v2.2
- NIST FIPS 186-5
- Supported key sizes
- Security considerations

##### Technical Details

- Supported message size limitations
- Key size options (2048, 3072, 4096 bits)
- Implementation constraints
- External dependency (colorama)

Remember to add a note about the implementation being for educational/demonstration purposes, not for production use, as mentioned in the disclaimer.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph CLI
        CLI[Command Line Interface]:::cli
        CMD[Command Parsing]:::cli
        UI[User Interaction]:::cli
        OC[Operation Coordination]:::cli
        
        CLI --> CMD
        CMD --> UI
        UI --> OC
    end

    subgraph RSA_Core[RSA Core Module]
        OAEP[RSAES-OAEP Encryption]:::core
        PSS[RSASSA-PSS Signature]:::core
        PRIM[RSA Primitives]:::core
        PKCS[PKCS #1 v2.2 Compliance]:::core
        
        OAEP --> PRIM
        PSS --> PRIM
        PRIM --> PKCS
    end

    subgraph Prime_Gen[Prime Generation]
        PG[Prime Generation]:::prime
        KP[Key Pair Creation]:::prime
        KF[Key Format]:::prime
        NIST[NIST FIPS 186-5]:::prime
        
        PG --> KP
        KP --> KF
        PG --> NIST
    end

    OC --> OAEP
    OC --> PSS
    KF --> PRIM

    subgraph Key_Sizes[Supported Key Sizes]
        K2048[2048 bits]:::info
        K3072[3072 bits]:::info
        K4096[4096 bits]:::info
    end

    subgraph Note[Important Notes]
        EDU[Educational Use Only]:::warning
        SEC[Security Considerations]:::warning
    end

    classDef cli fill:#FFA500,stroke:#333,stroke-width:2px
    classDef core fill:#3498db,stroke:#333,stroke-width:2px
    classDef prime fill:#2ecc71,stroke:#333,stroke-width:2px
    classDef info fill:#95a5a6,stroke:#333,stroke-width:2px
    classDef warning fill:#e74c3c,stroke:#333,stroke-width:2px

    click CLI "https://github.com/mainakaruoya/py_rsa/blob/main/rsa_cli.py"
    click OAEP "https://github.com/mainakaruoya/py_rsa/blob/main/py_rsa.py"
    click PSS "https://github.com/mainakaruoya/py_rsa/blob/main/py_rsa.py"
    click PRIM "https://github.com/mainakaruoya/py_rsa/blob/main/py_rsa.py"
    click PG "https://github.com/mainakaruoya/py_rsa/blob/main/rsa_primes.py"
    click KP "https://github.com/mainakaruoya/py_rsa/blob/main/rsa_primes.py"
    click KF "https://github.com/mainakaruoya/py_rsa/blob/main/rsa_primes.py"
```
