Skip to content
All work
Secure Coding · Systems C++
2025–26

Secure Password Manager (C++)

An AES-256-GCM credential vault in modern C++ built on real OpenSSL crypto

C++CryptographySecure CodingAES-256 Code
AES-256
GCM authenticated encryption
tampering detected
200k
PBKDF2 iterations
random per-vault salt
0
Plaintext at rest
master key never stored
C++17
OpenSSL EVP
CMake · CTest · -Wall

Context

The Secure Coding module (CSEC1003D) asks for correct, object-oriented, security-minded systems programming. Rather than a toy, I built a real vault: a crypto layer over OpenSSL’s EVP API, a vault/serialisation layer, and a thin CLI — with a CMake build and a CTest suite.

The problem

A password manager is only as trustworthy as its weakest cryptographic decision. The goal was to get every one right: authenticated encryption so tampering is detected, slow salted key derivation so the master password resists brute force, and unique nonces so identical vaults never leak equality.

My approach

AES-256-GCM provides confidentiality and integrity in one primitive; PBKDF2-HMAC-SHA256 (200k iterations, random per-vault salt) derives the key; a fresh random 96-bit IV is generated on every save. RAII wraps the OpenSSL contexts, sensitive buffers are cleansed, and the master password is read with terminal echo disabled.

Cryptographic design

Every choice is deliberate and documented.

  • AES-256-GCM: a modified vault fails the auth tag instead of decrypting to junk
  • PBKDF2-HMAC-SHA256 with a random salt: expensive brute-force, no rainbow tables
  • Fresh random 96-bit IV per save: GCM nonces never repeat under one key
  • Master password derived to a key and never stored — only salt + iterations persist

Proven, not just claimed

The test suite demonstrates the security properties: a wrong master password and a single flipped byte in the vault both fail with an authentication error, and grepping the vault file for a stored secret returns nothing — it is encrypted at rest.

Engineering discipline

Clean separation (crypto knows nothing about vaults; the CLI is thin), RAII around OpenSSL contexts so a context is freed exactly once even on error, OPENSSL_cleanse on key material, and a warnings-as-signal build (-Wall -Wextra -Wpedantic, zero warnings).

Outcome

A genuinely secure, tested systems-C++ project that backs the ‘I can build the code I defend’ claim — real authenticated encryption, sound key management, and a threat model that is honest about what it does and does not protect.