# jc-lab/korea-forge architecture

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

- Interactive diagram: https://gitdiagram.com/jc-lab/korea-forge
- Repository: https://github.com/jc-lab/korea-forge

## Overview

##### Project Type and Purpose
This is a native JavaScript cryptographic library (node-forge) that implements TLS and various cryptographic tools. The project is structured as a modular library with multiple cryptographic components.

##### Main Components

Core Components:
- Cryptographic Primitives
- PKI Infrastructure
- Message Digests
- Utilities
- Transport Protocols

##### High-Level Architecture Layer

- Node-Forge                   |

- Core API   |  | Browser Bundle  |     |

##### Functional Components Layer

- Cryptographic |  |      PKI      |  |   Transport   |
- Primitives   |  | Infrastructure|  |   Protocols   |

- Ciphers     |  |  Certificate  |  |     TLS      |
- AES/DES/RC2  |  |   Handling    |  |     SSH      |

##### Support Services Layer

- Message     |  |    Random     |  |   Utility    |
- Digests     |  |   Number      |  |   Services   |
- SHA/MD5/HMAC  |  |  Generation   |  |              |

Design Guidelines:

##### Component Details
- Version information
- Supported algorithms
- Browser/Node.js compatibility

##### Integration Points

- Integration    |
- Points       |

- Node.js API   |
- Browser API   |
- WebWorkers    |
- Flash (legacy)|

##### Security Layer

- Security      |
- Controls      |

- PRNG           |
- Key Management |
- Validation     |

Important Elements to Highlight:

##### Module Dependencies
- How different cryptographic modules interact
- Optional dependencies
- Core vs. extended functionality

##### Data Flow
- Encryption/Decryption paths
- Certificate processing
- Key management

##### API Interfaces
- Public API endpoints
- Internal module communication
- External service integration

##### Cross-Platform Support
- Browser compatibility
- Node.js integration
- WebWorker support

- Modular architecture
- Cryptographic isolation
- Clear dependency chains
- Security boundaries
- Platform compatibility

- Line types
- Version information
- Security considerations

This system design should provide a clear understanding of the forge library's architecture while highlighting its security-focused nature and modular design.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph NodeForge["Node-Forge Library"]
        Core["Core API"]:::core
        Bundle["Browser Bundle"]:::core
    end

    subgraph CryptoPrimitives["Cryptographic Primitives"]
        direction TB
        CipherCore["Cipher Core"]:::crypto
        AES["AES"]:::crypto
        DES["DES"]:::crypto
        RC2["RC2"]:::crypto
        CipherModes["Cipher Modes"]:::crypto
    end

    subgraph PKI["PKI Infrastructure"]
        direction TB
        PKICore["PKI Core"]:::pki
        X509["X.509 Certificates"]:::pki
        PKCS1["PKCS#1"]:::pki
        PKCS7["PKCS#7"]:::pki
        PKCS12["PKCS#12"]:::pki
        PEM["PEM Encoding"]:::pki
    end

    subgraph Transport["Transport Protocols"]
        direction TB
        TLS["TLS"]:::transport
        TLSSocket["TLS Socket"]:::transport
        SSH["SSH"]:::transport
        Socket["Socket Core"]:::transport
    end

    subgraph MessageDigests["Message Digests"]
        direction TB
        MDCore["Message Digest Core"]:::digest
        MD5["MD5"]:::digest
        SHA1["SHA1"]:::digest
        SHA256["SHA256"]:::digest
        SHA512["SHA512"]:::digest
        HMAC["HMAC"]:::digest
    end

    subgraph Support["Support Services"]
        direction TB
        Random["Random Number Generation"]:::support
        PRNG["PRNG"]:::support
        Utils["Utility Functions"]:::support
        Prime["Prime Number Operations"]:::support
        ASN1["ASN.1 Handling"]:::support
    end

    Core --> CryptoPrimitives
    Core --> PKI
    Core --> Transport
    Core --> MessageDigests
    Core --> Support
    Bundle --> Core

    %% Component Mappings
    click Core "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/forge.js"
    click Bundle "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/index.all.js"
    click CipherCore "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/cipher.js"
    click AES "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/aes.js"
    click DES "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/des.js"
    click RC2 "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/rc2.js"
    click CipherModes "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/cipherModes.js"
    click PKICore "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/pki.js"
    click X509 "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/x509.js"
    click PKCS1 "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/pkcs1.js"
    click PKCS7 "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/pkcs7.js"
    click PKCS12 "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/pkcs12.js"
    click PEM "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/pem.js"
    click TLS "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/tls.js"
    click TLSSocket "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/tlssocket.js"
    click SSH "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/ssh.js"
    click Socket "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/socket.js"
    click MDCore "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/md.js"
    click MD5 "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/md5.js"
    click SHA1 "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/sha1.js"
    click SHA256 "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/sha256.js"
    click SHA512 "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/sha512.js"
    click HMAC "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/hmac.js"
    click Random "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/random.js"
    click PRNG "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/prng.js"
    click Utils "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/util.js"
    click Prime "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/prime.js"
    click ASN1 "https://github.com/jc-lab/korea-forge/blob/jclab-main/lib/asn1.js"

    classDef core fill:#2d5c8f,stroke:#1a3550,color:white
    classDef crypto fill:#4a90e2,stroke:#2171c7,color:white
    classDef pki fill:#2ecc71,stroke:#27ae60,color:white
    classDef transport fill:#e67e22,stroke:#d35400,color:white
    classDef digest fill:#9b59b6,stroke:#8e44ad,color:white
    classDef support fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Cryptographic Primitives"]:::crypto
        L3["PKI Infrastructure"]:::pki
        L4["Transport Protocols"]:::transport
        L5["Message Digests"]:::digest
        L6["Support Services"]:::support
    end
```
