Hasty Briefsbeta

Bilingual

How Bitwarden Encrypts and Decrypts Secrets

a day ago
  • Bitwarden encrypts all secrets (passwords, usernames, URLs, notes, etc.) on the client before sending to the server.
  • The master key is a 64-byte random sequence split into a 32-byte encryption key and a 32-byte MAC key.
  • Encrypted secrets are stored in version 2 format: initialization vector (iv), ciphertext, and MAC signature, all base64 encoded.
  • Decryption uses AES-256 in CBC mode with PKCS7 padding, and integrity is verified via HMAC-SHA256.
  • To decrypt the master key, the client derives keys from the user's email and passphrase using PBKDF2 (600,000 iterations) and HKDF-Expand.
  • The author provides complete Python code for both decryption and encryption of secrets.
  • The author plans to build a custom client that syncs with a Vaultwarden database but keeps secret management local.