# eclipse-keypont/crypto11 architecture

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

- Interactive diagram: https://gitdiagram.com/eclipse-keypont/crypto11
- Repository: https://github.com/eclipse-keypont/crypto11

## Overview

Crypto11 is a Go library that adapts PKCS#11-backed keys and cryptographic operations to Go’s crypto interfaces. A caller configures a token context, then uses it to locate or create keys and certificates and perform cryptographic operations; symmetric crypto, HMAC, and random generation are additional capabilities. The graph reflects README capabilities and sampled implementation paths. Some internal call relationships are not visible in the excerpts, so those links are omitted rather than inferred.

Main entry points: [`crypto11.go`](https://github.com/eclipse-keypont/crypto11/blob/master/crypto11.go) (Token context), [`sessions.go`](https://github.com/eclipse-keypont/crypto11/blob/master/sessions.go) (Session pool), [`attributes.go`](https://github.com/eclipse-keypont/crypto11/blob/master/attributes.go) (Attribute templates), [`rsa.go`](https://github.com/eclipse-keypont/crypto11/blob/master/rsa.go) (RSA)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_context["Context and sessions"]
  node_context["Token context<br/>[crypto11.go]"]
  node_sessions["Session pool<br/>[sessions.go]"]
  node_pool["Resource pool<br/>[resource_pool.go]"]
end

subgraph group_keys["Keys and attributes"]
  node_attributes["Attribute templates<br/>[attributes.go]"]
  node_key_lookup["Key discovery<br/>[keys.go]"]
end

subgraph group_asymmetric["Asymmetric crypto"]
  node_rsa["RSA<br/>[rsa.go]"]
  node_ecdsa["ECDSA<br/>[ecdsa.go]"]
  node_dsa["DSA<br/>[dsa.go]"]
  node_mlkem["ML-KEM<br/>[mlkem.go]"]
  node_mlkem_kdf["ML-KEM KDF<br/>[mlkem_kdf.go]"]
end

subgraph group_symmetric["Symmetric crypto"]
  node_aead["AEAD<br/>[aead.go]"]
  node_blockmode["Block modes<br/>[blockmode.go]"]
  node_symmetric["Symmetric ciphers<br/>[symmetric.go]"]
  node_hmac["HMAC<br/>[hmac.go]"]
end

subgraph group_other["Certificates and utilities"]
  node_certificates["X.509 certificates<br/>[certificates.go]"]
  node_random["Random reader<br/>[rand.go]"]
  node_common["Crypto helpers<br/>[common.go]"]
  node_templates["Key templates<br/>[templates.go]"]
end

node_caller(("Go application"))
node_token[("PKCS&#35;11 token")]
node_bindings["PKCS&#35;11 bindings"]

node_caller -->|"configures"| node_context
node_context -->|"initializes module"| node_bindings
node_sessions -->|"uses"| node_pool
node_sessions -->|"opens sessions"| node_bindings
node_caller -->|"generates, signs"| node_rsa
node_caller -->|"generates, signs"| node_ecdsa
node_caller -->|"generates, signs"| node_dsa
node_caller -->|"encapsulates, decapsulates"| node_mlkem
node_caller -->|"uses cipher"| node_symmetric
node_caller -->|"uses modes"| node_blockmode
node_caller -->|"uses AEAD"| node_aead
node_caller -->|"uses HMAC"| node_hmac
node_caller -->|"imports, retrieves"| node_certificates
node_caller -->|"reads randomness"| node_random
node_caller -->|"finds keys"| node_key_lookup
node_rsa -->|"builds templates"| node_attributes
node_mlkem -->|"uses templates"| node_attributes
node_certificates -->|"builds templates"| node_attributes
node_context -->|"leases sessions"| node_sessions
node_bindings -->|"performs PKCS&#35;11 operations"| node_token

click node_context "https://github.com/eclipse-keypont/crypto11/blob/master/crypto11.go"
click node_sessions "https://github.com/eclipse-keypont/crypto11/blob/master/sessions.go"
click node_pool "https://github.com/eclipse-keypont/crypto11/blob/master/internal/pool/resource_pool.go"
click node_attributes "https://github.com/eclipse-keypont/crypto11/blob/master/attributes.go"
click node_key_lookup "https://github.com/eclipse-keypont/crypto11/blob/master/keys.go"
click node_rsa "https://github.com/eclipse-keypont/crypto11/blob/master/rsa.go"
click node_ecdsa "https://github.com/eclipse-keypont/crypto11/blob/master/ecdsa.go"
click node_dsa "https://github.com/eclipse-keypont/crypto11/blob/master/dsa.go"
click node_mlkem "https://github.com/eclipse-keypont/crypto11/blob/master/mlkem.go"
click node_mlkem_kdf "https://github.com/eclipse-keypont/crypto11/blob/master/mlkem_kdf.go"
click node_aead "https://github.com/eclipse-keypont/crypto11/blob/master/aead.go"
click node_blockmode "https://github.com/eclipse-keypont/crypto11/blob/master/blockmode.go"
click node_symmetric "https://github.com/eclipse-keypont/crypto11/blob/master/symmetric.go"
click node_hmac "https://github.com/eclipse-keypont/crypto11/blob/master/hmac.go"
click node_certificates "https://github.com/eclipse-keypont/crypto11/blob/master/certificates.go"
click node_random "https://github.com/eclipse-keypont/crypto11/blob/master/rand.go"
click node_common "https://github.com/eclipse-keypont/crypto11/blob/master/common.go"
click node_templates "https://github.com/eclipse-keypont/crypto11/blob/master/templates.go"

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_context,node_sessions,node_pool toneBlue
class node_attributes,node_key_lookup,node_token toneAmber
class node_rsa,node_ecdsa,node_dsa,node_mlkem,node_mlkem_kdf toneMint
class node_aead,node_blockmode,node_symmetric,node_hmac toneRose
class node_certificates,node_random,node_common,node_templates,node_caller,node_bindings toneIndigo
```

## Components

### Context and sessions

- [Token context](https://github.com/eclipse-keypont/crypto11/blob/master/crypto11.go): `crypto11.go`
- [Session pool](https://github.com/eclipse-keypont/crypto11/blob/master/sessions.go): `sessions.go`
- [Resource pool](https://github.com/eclipse-keypont/crypto11/blob/master/internal/pool/resource_pool.go): `internal/pool/resource_pool.go`

### Keys and attributes

- [Attribute templates](https://github.com/eclipse-keypont/crypto11/blob/master/attributes.go): `attributes.go`
- [Key discovery](https://github.com/eclipse-keypont/crypto11/blob/master/keys.go): `keys.go`

### Asymmetric crypto

- [RSA](https://github.com/eclipse-keypont/crypto11/blob/master/rsa.go): `rsa.go`
- [ECDSA](https://github.com/eclipse-keypont/crypto11/blob/master/ecdsa.go): `ecdsa.go`
- [DSA](https://github.com/eclipse-keypont/crypto11/blob/master/dsa.go): `dsa.go`
- [ML-KEM](https://github.com/eclipse-keypont/crypto11/blob/master/mlkem.go): `mlkem.go`
- [ML-KEM KDF](https://github.com/eclipse-keypont/crypto11/blob/master/mlkem_kdf.go): `mlkem_kdf.go`

### Symmetric crypto

- [AEAD](https://github.com/eclipse-keypont/crypto11/blob/master/aead.go): `aead.go`
- [Block modes](https://github.com/eclipse-keypont/crypto11/blob/master/blockmode.go): `blockmode.go`
- [Symmetric ciphers](https://github.com/eclipse-keypont/crypto11/blob/master/symmetric.go): `symmetric.go`
- [HMAC](https://github.com/eclipse-keypont/crypto11/blob/master/hmac.go): `hmac.go`

### Certificates and utilities

- [X.509 certificates](https://github.com/eclipse-keypont/crypto11/blob/master/certificates.go): `certificates.go`
- [Random reader](https://github.com/eclipse-keypont/crypto11/blob/master/rand.go): `rand.go`
- [Crypto helpers](https://github.com/eclipse-keypont/crypto11/blob/master/common.go): `common.go`
- [Key templates](https://github.com/eclipse-keypont/crypto11/blob/master/templates.go): `templates.go`

### Other components

- **Go application**
- **PKCS#11 token**
- **PKCS#11 bindings**

## Connections

- Go application → Token context: configures (evidence: `README.md`)
- Token context → PKCS#11 bindings: initializes module (evidence: `crypto11.go`)
- Session pool → Resource pool: uses (evidence: `sessions.go`)
- Session pool → PKCS#11 bindings: opens sessions (evidence: `sessions.go`)
- Go application → RSA: generates, signs (evidence: `README.md`)
- Go application → ECDSA: generates, signs (evidence: `README.md`)
- Go application → DSA: generates, signs (evidence: `README.md`)
- Go application → ML-KEM: encapsulates, decapsulates (evidence: `README.md`)
- Go application → Symmetric ciphers: uses cipher (evidence: `README.md`)
- Go application → Block modes: uses modes (evidence: `README.md`)
- Go application → AEAD: uses AEAD (evidence: `README.md`)
- Go application → HMAC: uses HMAC (evidence: `README.md`)
- Go application → X.509 certificates: imports, retrieves (evidence: `README.md`)
- Go application → Random reader: reads randomness (evidence: `README.md`)
- Go application → Key discovery: finds keys (evidence: `keys.go`)
- RSA → Attribute templates: builds templates (evidence: `rsa.go`)
- ML-KEM → Attribute templates: uses templates (evidence: `mlkem.go`)
- X.509 certificates → Attribute templates: builds templates (evidence: `certificates.go`)
- Token context → Session pool: leases sessions (evidence: `sessions.go`)
- PKCS#11 bindings → PKCS#11 token: performs PKCS#11 operations (evidence: `README.md`)
