# tongsuo-project/tongsuo architecture

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

- Interactive diagram: https://gitdiagram.com/tongsuo-project/tongsuo
- Repository: https://github.com/tongsuo-project/tongsuo

## Overview

Tongsuo is a cryptographic foundation library: applications use it for cryptographic operations and secure communications, protecting data in transit, use, and storage. Its documented capabilities include commercial and international algorithms, post-quantum cryptography, homomorphic encryption, zero-knowledge proofs, certificate services, and TLS/TLCP/QUIC. The graph preserves these product branches and representative CLI entry points. The supplied excerpts do not show most implementation call paths, so unverified relationships are dashed; paths identify implementations from the tree, not inspected source.

Main entry points: [`crypto/evp/evp_lib.c`](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/evp/evp_lib.c) (Crypto API), [`ssl/ssl_lib.c`](https://github.com/tongsuo-project/tongsuo/blob/master/ssl/ssl_lib.c) (TLS and TLCP), [`apps/openssl.c`](https://github.com/tongsuo-project/tongsuo/blob/master/apps/openssl.c) (OpenSSL CLI), [`apps/s_client.c`](https://github.com/tongsuo-project/tongsuo/blob/master/apps/s_client.c) (TLS client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Applications"]
  node_cli["OpenSSL CLI<br/>[openssl.c]"]
  node_tlsclient["TLS client<br/>[s_client.c]"]
  node_tlsserver["TLS server<br/>[s_server.c]"]
end

subgraph group_crypto["Cryptographic Primitives"]
  node_evp["Crypto API<br/>[evp_lib.c]"]
  node_symmetric["Symmetric ciphers<br/>[e_aes.c]"]
  node_hashes["Hash functions<br/>[sha256.c]"]
  node_sm2["SM2<br/>[sm2_sign.c]"]
  node_sm3["SM3<br/>[sm3.c]"]
  node_sm4["SM4<br/>[sm4.c]"]
  node_rsa["RSA<br/>[rsa_lib.c]"]
end

subgraph group_advanced["Advanced Cryptography"]
  node_postquantum["Post-quantum algorithms<br/>[ml_kem.c]"]
  node_ecelgamal["EC-ElGamal<br/>[ec_elgamal_crypt.c]"]
  node_paillier["Paillier<br/>[paillier_crypt.c]"]
  node_bulletproofs["Bulletproofs<br/>[bulletproofs.c]"]
end

subgraph group_trust["Identity and Trust"]
  node_certs["X.509 certificates<br/>[x509_vfy.c]"]
  node_cmp["CMP enrollment<br/>[cmp_client.c]"]
  node_cms["CMS messaging<br/>[cms_lib.c]"]
end

subgraph group_transport["Secure Transport"]
  node_tls["TLS and TLCP<br/>[ssl_lib.c]"]
  node_quic["QUIC<br/>[quic_engine.c]"]
end

node_application(("Using application"))

node_application -.->|"invokes"| node_cli
node_application -.->|"starts"| node_tlsclient
node_application -.->|"starts"| node_tlsserver
node_cli -.->|"uses crypto"| node_evp
node_tlsclient -.->|"establishes"| node_tls
node_tlsserver -.->|"accepts"| node_tls
node_evp -.->|"offers algorithms"| node_symmetric
node_evp -.->|"offers algorithms"| node_hashes
node_evp -.->|"offers algorithms"| node_sm2
node_evp -.->|"offers algorithms"| node_sm3
node_evp -.->|"offers algorithms"| node_sm4
node_evp -.->|"offers algorithms"| node_rsa
node_evp -.->|"offers algorithms"| node_postquantum
node_application -.->|"uses homomorphic encryption"| node_ecelgamal
node_application -.->|"uses homomorphic encryption"| node_paillier
node_application -.->|"uses proofs"| node_bulletproofs
node_application -.->|"uses certificate services"| node_certs
node_application -.->|"uses enrollment"| node_cmp
node_application -.->|"uses secure messaging"| node_cms
node_application -.->|"uses transport"| node_quic
node_tls -.->|"provides protocol API"| node_quic

click node_cli "https://github.com/tongsuo-project/tongsuo/blob/master/apps/openssl.c"
click node_tlsclient "https://github.com/tongsuo-project/tongsuo/blob/master/apps/s_client.c"
click node_tlsserver "https://github.com/tongsuo-project/tongsuo/blob/master/apps/s_server.c"
click node_evp "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/evp/evp_lib.c"
click node_symmetric "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/evp/e_aes.c"
click node_hashes "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/sha/sha256.c"
click node_sm2 "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/sm2/sm2_sign.c"
click node_sm3 "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/sm3/sm3.c"
click node_sm4 "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/sm4/sm4.c"
click node_rsa "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/rsa/rsa_lib.c"
click node_postquantum "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/ml_kem/ml_kem.c"
click node_ecelgamal "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/ec/ec_elgamal_crypt.c"
click node_paillier "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/paillier/paillier_crypt.c"
click node_bulletproofs "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/zkp/bulletproofs/bulletproofs.c"
click node_certs "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/x509/x509_vfy.c"
click node_cmp "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/cmp/cmp_client.c"
click node_cms "https://github.com/tongsuo-project/tongsuo/blob/master/crypto/cms/cms_lib.c"
click node_tls "https://github.com/tongsuo-project/tongsuo/blob/master/ssl/ssl_lib.c"
click node_quic "https://github.com/tongsuo-project/tongsuo/blob/master/ssl/quic/quic_engine.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_cli,node_tlsclient,node_tlsserver toneBlue
class node_evp,node_symmetric,node_hashes,node_sm2,node_sm3,node_sm4,node_rsa toneAmber
class node_postquantum,node_ecelgamal,node_paillier,node_bulletproofs toneMint
class node_certs,node_cmp,node_cms toneRose
class node_tls,node_quic,node_application toneIndigo
```

## Components

### Applications

- [OpenSSL CLI](https://github.com/tongsuo-project/tongsuo/blob/master/apps/openssl.c): `apps/openssl.c`
- [TLS client](https://github.com/tongsuo-project/tongsuo/blob/master/apps/s_client.c): `apps/s_client.c`
- [TLS server](https://github.com/tongsuo-project/tongsuo/blob/master/apps/s_server.c): `apps/s_server.c`

### Cryptographic Primitives

- [Crypto API](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/evp/evp_lib.c): `crypto/evp/evp_lib.c`
- [Symmetric ciphers](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/evp/e_aes.c): `crypto/evp/e_aes.c`
- [Hash functions](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/sha/sha256.c): `crypto/sha/sha256.c`
- [SM2](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/sm2/sm2_sign.c): `crypto/sm2/sm2_sign.c`
- [SM3](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/sm3/sm3.c): `crypto/sm3/sm3.c`
- [SM4](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/sm4/sm4.c): `crypto/sm4/sm4.c`
- [RSA](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/rsa/rsa_lib.c): `crypto/rsa/rsa_lib.c`

### Advanced Cryptography

- [Post-quantum algorithms](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/ml_kem/ml_kem.c): `crypto/ml_kem/ml_kem.c`
- [EC-ElGamal](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/ec/ec_elgamal_crypt.c): `crypto/ec/ec_elgamal_crypt.c`
- [Paillier](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/paillier/paillier_crypt.c): `crypto/paillier/paillier_crypt.c`
- [Bulletproofs](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/zkp/bulletproofs/bulletproofs.c): `crypto/zkp/bulletproofs/bulletproofs.c`

### Identity and Trust

- [X.509 certificates](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/x509/x509_vfy.c): `crypto/x509/x509_vfy.c`
- [CMP enrollment](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/cmp/cmp_client.c): `crypto/cmp/cmp_client.c`
- [CMS messaging](https://github.com/tongsuo-project/tongsuo/blob/master/crypto/cms/cms_lib.c): `crypto/cms/cms_lib.c`

### Secure Transport

- [TLS and TLCP](https://github.com/tongsuo-project/tongsuo/blob/master/ssl/ssl_lib.c): `ssl/ssl_lib.c`
- [QUIC](https://github.com/tongsuo-project/tongsuo/blob/master/ssl/quic/quic_engine.c): `ssl/quic/quic_engine.c`

### Other components

- **Using application**

## Connections

- Using application → OpenSSL CLI: invokes
- Using application → TLS client: starts
- Using application → TLS server: starts
- OpenSSL CLI → Crypto API: uses crypto
- TLS client → TLS and TLCP: establishes
- TLS server → TLS and TLCP: accepts
- Crypto API → Symmetric ciphers: offers algorithms
- Crypto API → Hash functions: offers algorithms
- Crypto API → SM2: offers algorithms
- Crypto API → SM3: offers algorithms
- Crypto API → SM4: offers algorithms
- Crypto API → RSA: offers algorithms
- Crypto API → Post-quantum algorithms: offers algorithms
- Using application → EC-ElGamal: uses homomorphic encryption
- Using application → Paillier: uses homomorphic encryption
- Using application → Bulletproofs: uses proofs
- Using application → X.509 certificates: uses certificate services
- Using application → CMP enrollment: uses enrollment
- Using application → CMS messaging: uses secure messaging
- Using application → QUIC: uses transport
- TLS and TLCP → QUIC: provides protocol API
