<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->

# API Reference — Detecting Side-Channel Attacks

## CPU Vulnerability Status

```bash
grep -r . /sys/devices/system/cpu/vulnerabilities/
```

### Common Entries

| Vulnerability | File |
|---|---|
| Spectre v1 | `spectre_v1` |
| Spectre v2 | `spectre_v2` |
| Meltdown | `meltdown` |
| MDS | `mds` |
| TSX Async Abort | `tsx_async_abort` |

## perf — Cache Profiling

```bash
perf stat -e cache-misses,cache-references <command>
perf record -e cache-misses -p <pid> -- sleep <seconds>
```

## Constant-Time APIs

| Language | Safe Comparison |
|---|---|
| Python | `hmac.compare_digest()` |
| Go | `crypto/subtle.ConstantTimeCompare()` |
| C | `CRYPTO_memcmp()` (OpenSSL) |
| Java | `MessageDigest.isEqual()` |

## Agent Script

```bash
node agent.js cpu-vulns
node agent.js timing --iterations 10000
node agent.js audit ./src
node agent.js cache "openssl speed -evp aes-256-gcm"
```
