/* * crypto/crypto.h — TLS 1.3 (mbedTLS) and the media AEAD (libsodium). * * Design: docs/security.md. Control channel = TLS 1.3. Media = keys exported from the TLS * session (RFC 5705 / 8446) + per-frame ChaCha20-Poly1305 with a counter nonce and a * sliding-window replay filter. Encryption is MANDATORY — never add a plaintext path. * * STATUS: M0 stub. */ #ifndef VOICECAT_CRYPTO_CRYPTO_H #define VOICECAT_CRYPTO_CRYPTO_H #include #include namespace voicecat::crypto { // TLS 1.3 endpoint wrapper (mbedTLS). Provides the keying-material exporter that seeds // MediaCrypto, so the UDP path inherits the authenticated control session's trust. class TlsContext { public: // TODO(M1): client/server handshake; read/write; export_keying_material(label,...). }; // Per-frame media encryption. Abstracted so the backend (exported-key AEAD now; a DTLS 1.3 // backend later, if a permissive impl matures) is swappable without touching voice code. class MediaCrypto { public: virtual ~MediaCrypto() = default; // seal/open one voice frame; `aad` carries the routable header fields (e.g. ssrc). // Returns bytes written, or -1 on failure (replay/auth). TODO(M2). virtual long seal(const uint8_t* plain, size_t len, const uint8_t* aad, size_t aad_len, uint8_t* out, size_t out_cap) = 0; virtual long open(const uint8_t* sealed, size_t len, const uint8_t* aad, size_t aad_len, uint8_t* out, size_t out_cap) = 0; }; } // namespace voicecat::crypto #endif // VOICECAT_CRYPTO_CRYPTO_H