# bmwcarit/mococrw architecture

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

- Interactive diagram: https://gitdiagram.com/bmwcarit/mococrw
- Repository: https://github.com/bmwcarit/mococrw

## Overview

MoCOCrW is a C++14/17 wrapper library that exposes OpenSSL-backed cryptographic and X.509 functionality through end-user APIs. A typical consumer chooses a key or certificate operation, invokes the relevant API, and receives cryptographic data or processed X.509 objects. The map preserves the README’s major feature areas and a separate OpenSSL abstraction layer. Source excerpts are partial, so relationships between feature modules are shown only where documented or evidenced by the index.

Main entry points: [`src/openssl_wrap.cpp`](https://github.com/bmwcarit/mococrw/blob/openssl3/src/openssl_wrap.cpp) (OpenSSL Wrappers), [`src/asymmetric_crypto_ctx.cpp`](https://github.com/bmwcarit/mococrw/blob/openssl3/src/asymmetric_crypto_ctx.cpp) (Asymmetric Contexts), [`src/symmetric_crypto.cpp`](https://github.com/bmwcarit/mococrw/blob/openssl3/src/symmetric_crypto.cpp) (AES Ciphers), [`src/dilithium.cpp`](https://github.com/bmwcarit/mococrw/blob/openssl3/src/dilithium.cpp) (Dilithium Keys)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_keys["Keys and Signatures"]
  node_key["Key Management<br/>[key.cpp]"]
  node_asym["Asymmetric Contexts"]
  node_dilithium["Dilithium Keys<br/>[dilithium.cpp]"]
  node_hsm["HSM Access<br/>[hsm.cpp]"]
end

subgraph group_crypto["Crypto Primitives"]
  node_hash["Hashing<br/>[hash.cpp]"]
  node_symmetric["AES Ciphers"]
  node_kdf["Key Derivation<br/>[kdf.cpp]"]
  node_mac["Message Authentication<br/>[mac.cpp]"]
  node_ecies["ECIES<br/>[ecies.cpp]"]
  node_padding["Signature Padding<br/>[padding_mode.cpp]"]
end

subgraph group_pki["X.509 and PKI"]
  node_x509["Certificate Processing<br/>[x509.cpp]"]
  node_ca["CA Operations<br/>[ca.cpp]"]
  node_crl["Revocation Lists<br/>[crl.cpp]"]
  node_csr["Certificate Requests<br/>[csr.cpp]"]
  node_dn["Distinguished Names"]
  node_pkcs12["PKCS&#35;12<br/>[pkcs12.cpp]"]
end

subgraph group_openssl["OpenSSL Abstraction"]
  node_bio["BIO I/O<br/>[bio.cpp]"]
  node_wrap["OpenSSL Wrappers<br/>[openssl_wrap.cpp]"]
  node_lib["OpenSSL Calls<br/>[openssl_lib.cpp]"]
end

subgraph group_support["Shared Support"]
  node_asn1["ASN.1 Time<br/>[asn1time.cpp]"]
  node_util["Utilities<br/>[util.cpp]"]
  node_memory["Sensitive Memory"]
end

node_consumer(("Library Consumer"))
node_openssl["OpenSSL"]

node_consumer -->|"uses APIs"| node_key
node_consumer -->|"uses APIs"| node_asym
node_consumer -->|"uses APIs"| node_symmetric
node_consumer -->|"uses APIs"| node_x509
node_wrap -->|"dispatches calls"| node_lib
node_wrap -->|"wraps calls"| node_openssl
node_dilithium -.->|"uses contexts"| node_asym
node_ecies -.->|"uses cipher"| node_symmetric

click node_key "https://github.com/bmwcarit/mococrw/blob/openssl3/src/key.cpp"
click node_asym "https://github.com/bmwcarit/mococrw/blob/openssl3/src/asymmetric_crypto_ctx.cpp"
click node_dilithium "https://github.com/bmwcarit/mococrw/blob/openssl3/src/dilithium.cpp"
click node_hsm "https://github.com/bmwcarit/mococrw/blob/openssl3/src/hsm.cpp"
click node_hash "https://github.com/bmwcarit/mococrw/blob/openssl3/src/hash.cpp"
click node_symmetric "https://github.com/bmwcarit/mococrw/blob/openssl3/src/symmetric_crypto.cpp"
click node_kdf "https://github.com/bmwcarit/mococrw/blob/openssl3/src/kdf.cpp"
click node_mac "https://github.com/bmwcarit/mococrw/blob/openssl3/src/mac.cpp"
click node_ecies "https://github.com/bmwcarit/mococrw/blob/openssl3/src/ecies.cpp"
click node_padding "https://github.com/bmwcarit/mococrw/blob/openssl3/src/padding_mode.cpp"
click node_x509 "https://github.com/bmwcarit/mococrw/blob/openssl3/src/x509.cpp"
click node_ca "https://github.com/bmwcarit/mococrw/blob/openssl3/src/ca.cpp"
click node_crl "https://github.com/bmwcarit/mococrw/blob/openssl3/src/crl.cpp"
click node_csr "https://github.com/bmwcarit/mococrw/blob/openssl3/src/csr.cpp"
click node_dn "https://github.com/bmwcarit/mococrw/blob/openssl3/src/distinguished_name.cpp"
click node_pkcs12 "https://github.com/bmwcarit/mococrw/blob/openssl3/src/pkcs12.cpp"
click node_bio "https://github.com/bmwcarit/mococrw/blob/openssl3/src/bio.cpp"
click node_wrap "https://github.com/bmwcarit/mococrw/blob/openssl3/src/openssl_wrap.cpp"
click node_lib "https://github.com/bmwcarit/mococrw/blob/openssl3/src/openssl_lib.cpp"
click node_asn1 "https://github.com/bmwcarit/mococrw/blob/openssl3/src/asn1time.cpp"
click node_util "https://github.com/bmwcarit/mococrw/blob/openssl3/src/util.cpp"
click node_memory "https://github.com/bmwcarit/mococrw/blob/openssl3/src/symmetric_memory.cpp"

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_key,node_asym,node_dilithium,node_hsm toneBlue
class node_hash,node_symmetric,node_kdf,node_mac,node_ecies,node_padding toneAmber
class node_x509,node_ca,node_crl,node_csr,node_dn,node_pkcs12 toneMint
class node_bio,node_wrap,node_lib toneRose
class node_asn1,node_util,node_memory,node_consumer,node_openssl toneIndigo
```

## Components

### Keys and Signatures

- [Key Management](https://github.com/bmwcarit/mococrw/blob/openssl3/src/key.cpp): `src/key.cpp`
- [Asymmetric Contexts](https://github.com/bmwcarit/mococrw/blob/openssl3/src/asymmetric_crypto_ctx.cpp): `src/asymmetric_crypto_ctx.cpp`
- [Dilithium Keys](https://github.com/bmwcarit/mococrw/blob/openssl3/src/dilithium.cpp): `src/dilithium.cpp`
- [HSM Access](https://github.com/bmwcarit/mococrw/blob/openssl3/src/hsm.cpp): `src/hsm.cpp`

### Crypto Primitives

- [Hashing](https://github.com/bmwcarit/mococrw/blob/openssl3/src/hash.cpp): `src/hash.cpp`
- [AES Ciphers](https://github.com/bmwcarit/mococrw/blob/openssl3/src/symmetric_crypto.cpp): `src/symmetric_crypto.cpp`
- [Key Derivation](https://github.com/bmwcarit/mococrw/blob/openssl3/src/kdf.cpp): `src/kdf.cpp`
- [Message Authentication](https://github.com/bmwcarit/mococrw/blob/openssl3/src/mac.cpp): `src/mac.cpp`
- [ECIES](https://github.com/bmwcarit/mococrw/blob/openssl3/src/ecies.cpp): `src/ecies.cpp`
- [Signature Padding](https://github.com/bmwcarit/mococrw/blob/openssl3/src/padding_mode.cpp): `src/padding_mode.cpp`

### X.509 and PKI

- [Certificate Processing](https://github.com/bmwcarit/mococrw/blob/openssl3/src/x509.cpp): `src/x509.cpp`
- [CA Operations](https://github.com/bmwcarit/mococrw/blob/openssl3/src/ca.cpp): `src/ca.cpp`
- [Revocation Lists](https://github.com/bmwcarit/mococrw/blob/openssl3/src/crl.cpp): `src/crl.cpp`
- [Certificate Requests](https://github.com/bmwcarit/mococrw/blob/openssl3/src/csr.cpp): `src/csr.cpp`
- [Distinguished Names](https://github.com/bmwcarit/mococrw/blob/openssl3/src/distinguished_name.cpp): `src/distinguished_name.cpp`
- [PKCS#12](https://github.com/bmwcarit/mococrw/blob/openssl3/src/pkcs12.cpp): `src/pkcs12.cpp`

### OpenSSL Abstraction

- [BIO I/O](https://github.com/bmwcarit/mococrw/blob/openssl3/src/bio.cpp): `src/bio.cpp`
- [OpenSSL Wrappers](https://github.com/bmwcarit/mococrw/blob/openssl3/src/openssl_wrap.cpp): `src/openssl_wrap.cpp`
- [OpenSSL Calls](https://github.com/bmwcarit/mococrw/blob/openssl3/src/openssl_lib.cpp): `src/openssl_lib.cpp`

### Shared Support

- [ASN.1 Time](https://github.com/bmwcarit/mococrw/blob/openssl3/src/asn1time.cpp): `src/asn1time.cpp`
- [Utilities](https://github.com/bmwcarit/mococrw/blob/openssl3/src/util.cpp): `src/util.cpp`
- [Sensitive Memory](https://github.com/bmwcarit/mococrw/blob/openssl3/src/symmetric_memory.cpp): `src/symmetric_memory.cpp`

### Other components

- **Library Consumer**
- **OpenSSL**

## Connections

- Library Consumer → Key Management: uses APIs
- Library Consumer → Asymmetric Contexts: uses APIs
- Library Consumer → AES Ciphers: uses APIs
- Library Consumer → Certificate Processing: uses APIs
- OpenSSL Wrappers → OpenSSL Calls: dispatches calls (evidence: `src/openssl_wrap.cpp`)
- OpenSSL Wrappers → OpenSSL: wraps calls
- Dilithium Keys → Asymmetric Contexts: uses contexts
- ECIES → AES Ciphers: uses cipher
