# apple/corecrypto architecture

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

- Interactive diagram: https://gitdiagram.com/apple/corecrypto
- Repository: https://github.com/apple/corecrypto

## Overview

corecrypto is a low-level cryptographic library used by Apple security frameworks and intended for varied environments, not a direct app-facing API. A typical use begins when a framework requests a cryptographic operation; the corresponding module performs it and returns bytes, keys, or a verification result. The repository includes symmetric and asymmetric cryptography, hashing, derivation and randomness, encoding, post-quantum algorithms, and FIPS self-tests. The README documents these capabilities and intended use; sampled source is limited, so detailed calls between algorithm modules are not inferred.

Main entry points: [`cc/corecrypto/cc.h`](https://github.com/apple/corecrypto/blob/main/cc/corecrypto/cc.h) (Core interfaces), [`cc_fips/src/fipspost_post.c`](https://github.com/apple/corecrypto/blob/main/cc_fips/src/fipspost_post.c) (FIPS self-tests), [`cc/src`](https://github.com/apple/corecrypto/tree/main/cc/src) (Runtime utilities), [`ccaes/src`](https://github.com/apple/corecrypto/tree/main/ccaes/src) (AES modes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Core runtime"]
  node_api["Core interfaces<br/>[cc.h]"]
  node_runtimecore["Runtime utilities"]
end

subgraph group_symmetric["Symmetric crypto"]
  node_aes["AES modes"]
  node_chacha["ChaCha20-Poly1305"]
  node_othercipher["Other ciphers"]
end

subgraph group_publickey["Public-key crypto"]
  node_ec["Elliptic curves"]
  node_dh["Diffie-Hellman"]
  node_rsa["RSA"]
  node_ecies["ECIES"]
  node_hpke["HPKE<br/>[cchpke.c]"]
  node_kem["Key encapsulation"]
  node_mldsa["ML-DSA"]
  node_mlkem["ML-KEM"]
  node_he["Homomorphic encryption"]
end

subgraph group_foundations["Crypto foundations"]
  node_hash["Hash and digest"]
  node_mac["MAC and KDF"]
  node_random["Random generation"]
  node_encoding["Encoding and ASN.1"]
end

subgraph group_assurance["Validation and assurance"]
  node_fips["FIPS self-tests<br/>[fipspost_post.c]"]
  node_posttests["Algorithm POSTs"]
end

node_frameworks(("Security frameworks"))

node_frameworks -->|"requests operation"| node_api
node_api -->|"dispatches crypto"| node_aes
node_api -->|"dispatches crypto"| node_chacha
node_api -->|"dispatches crypto"| node_othercipher
node_api -->|"dispatches crypto"| node_ec
node_api -->|"dispatches crypto"| node_dh
node_api -->|"dispatches crypto"| node_rsa
node_api -->|"dispatches crypto"| node_ecies
node_api -->|"dispatches crypto"| node_hpke
node_api -->|"dispatches crypto"| node_kem
node_api -->|"dispatches crypto"| node_mldsa
node_api -->|"dispatches crypto"| node_mlkem
node_api -->|"dispatches crypto"| node_hash
node_api -->|"dispatches crypto"| node_mac
node_api -->|"dispatches crypto"| node_random
node_api -->|"dispatches crypto"| node_encoding
node_api -->|"dispatches crypto"| node_he
node_api -->|"uses runtime"| node_runtimecore
node_fips -->|"runs checks"| node_posttests

click node_api "https://github.com/apple/corecrypto/blob/main/cc/corecrypto/cc.h"
click node_runtimecore "https://github.com/apple/corecrypto/tree/main/cc/src"
click node_aes "https://github.com/apple/corecrypto/tree/main/ccaes/src"
click node_chacha "https://github.com/apple/corecrypto/blob/main/ccchacha20poly1305/src/ccchacha20poly1305.c"
click node_othercipher "https://github.com/apple/corecrypto/tree/main/ccblowfish/src"
click node_ec "https://github.com/apple/corecrypto/tree/main/ccec/src"
click node_dh "https://github.com/apple/corecrypto/tree/main/ccdh/src"
click node_rsa "https://github.com/apple/corecrypto/tree/main/ccrsa/src"
click node_ecies "https://github.com/apple/corecrypto/tree/main/ccecies/src"
click node_hpke "https://github.com/apple/corecrypto/blob/main/cchpke/src/cchpke.c"
click node_kem "https://github.com/apple/corecrypto/tree/main/cckem/src"
click node_mldsa "https://github.com/apple/corecrypto/tree/main/ccmldsa/src"
click node_mlkem "https://github.com/apple/corecrypto/tree/main/ccmlkem/src"
click node_hash "https://github.com/apple/corecrypto/tree/main/ccdigest/src"
click node_mac "https://github.com/apple/corecrypto/tree/main/cchmac/src"
click node_random "https://github.com/apple/corecrypto/tree/main/cckprng/src"
click node_encoding "https://github.com/apple/corecrypto/tree/main/ccder/src"
click node_he "https://github.com/apple/corecrypto/tree/main/cche/src"
click node_fips "https://github.com/apple/corecrypto/blob/main/cc_fips/src/fipspost_post.c"
click node_posttests "https://github.com/apple/corecrypto/tree/main/cc_fips/src"

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_api,node_runtimecore toneBlue
class node_aes,node_chacha,node_othercipher toneAmber
class node_ec,node_dh,node_rsa,node_ecies,node_hpke,node_kem,node_mldsa,node_mlkem,node_he toneMint
class node_hash,node_mac,node_random,node_encoding toneRose
class node_fips,node_posttests,node_frameworks toneIndigo
```

## Components

### Core runtime

- [Core interfaces](https://github.com/apple/corecrypto/blob/main/cc/corecrypto/cc.h): `cc/corecrypto/cc.h`
- [Runtime utilities](https://github.com/apple/corecrypto/tree/main/cc/src): `cc/src`

### Symmetric crypto

- [AES modes](https://github.com/apple/corecrypto/tree/main/ccaes/src): `ccaes/src`
- [ChaCha20-Poly1305](https://github.com/apple/corecrypto/blob/main/ccchacha20poly1305/src/ccchacha20poly1305.c): `ccchacha20poly1305/src/ccchacha20poly1305.c`
- [Other ciphers](https://github.com/apple/corecrypto/tree/main/ccblowfish/src): `ccblowfish/src`

### Public-key crypto

- [Elliptic curves](https://github.com/apple/corecrypto/tree/main/ccec/src): `ccec/src`
- [Diffie-Hellman](https://github.com/apple/corecrypto/tree/main/ccdh/src): `ccdh/src`
- [RSA](https://github.com/apple/corecrypto/tree/main/ccrsa/src): `ccrsa/src`
- [ECIES](https://github.com/apple/corecrypto/tree/main/ccecies/src): `ccecies/src`
- [HPKE](https://github.com/apple/corecrypto/blob/main/cchpke/src/cchpke.c): `cchpke/src/cchpke.c`
- [Key encapsulation](https://github.com/apple/corecrypto/tree/main/cckem/src): `cckem/src`
- [ML-DSA](https://github.com/apple/corecrypto/tree/main/ccmldsa/src): `ccmldsa/src`
- [ML-KEM](https://github.com/apple/corecrypto/tree/main/ccmlkem/src): `ccmlkem/src`
- [Homomorphic encryption](https://github.com/apple/corecrypto/tree/main/cche/src): `cche/src`

### Crypto foundations

- [Hash and digest](https://github.com/apple/corecrypto/tree/main/ccdigest/src): `ccdigest/src`
- [MAC and KDF](https://github.com/apple/corecrypto/tree/main/cchmac/src): `cchmac/src`
- [Random generation](https://github.com/apple/corecrypto/tree/main/cckprng/src): `cckprng/src`
- [Encoding and ASN.1](https://github.com/apple/corecrypto/tree/main/ccder/src): `ccder/src`

### Validation and assurance

- [FIPS self-tests](https://github.com/apple/corecrypto/blob/main/cc_fips/src/fipspost_post.c): `cc_fips/src/fipspost_post.c`
- [Algorithm POSTs](https://github.com/apple/corecrypto/tree/main/cc_fips/src): `cc_fips/src`

### Other components

- **Security frameworks**

## Connections

- Security frameworks → Core interfaces: requests operation
- Core interfaces → AES modes: dispatches crypto
- Core interfaces → ChaCha20-Poly1305: dispatches crypto
- Core interfaces → Other ciphers: dispatches crypto
- Core interfaces → Elliptic curves: dispatches crypto
- Core interfaces → Diffie-Hellman: dispatches crypto
- Core interfaces → RSA: dispatches crypto
- Core interfaces → ECIES: dispatches crypto
- Core interfaces → HPKE: dispatches crypto
- Core interfaces → Key encapsulation: dispatches crypto
- Core interfaces → ML-DSA: dispatches crypto
- Core interfaces → ML-KEM: dispatches crypto
- Core interfaces → Hash and digest: dispatches crypto
- Core interfaces → MAC and KDF: dispatches crypto
- Core interfaces → Random generation: dispatches crypto
- Core interfaces → Encoding and ASN.1: dispatches crypto
- Core interfaces → Homomorphic encryption: dispatches crypto
- Core interfaces → Runtime utilities: uses runtime
- FIPS self-tests → Algorithm POSTs: runs checks
