Skip to main content
Bitwarden implements end-to-end encryption with a zero-knowledge architecture, meaning the server never has access to unencrypted vault data. This guide explains the encryption implementation, key management, and cryptographic operations.

Encryption Architecture

Zero-Knowledge Design

Bitwarden’s security model ensures:
  • Client-side encryption: All encryption/decryption happens on the client
  • Server-blind storage: Server stores only encrypted data
  • Master password never transmitted: Used only locally to derive encryption keys
  • Account recovery requires user action: Server cannot decrypt user data

Encryption Types

Bitwarden supports multiple encryption schemes: Implementation: src/Core/Utilities/EncryptedStringAttribute.cs:14
Encryption Type Details:

Encrypted String Format

Structure:
Example:
Where:
  • 2 = Encryption type (AesCbc128_HmacSha256_B64)
  • abc123 = Base64-encoded IV
  • def456 = Base64-encoded ciphertext
  • ghi789 = Base64-encoded MAC
Validation: src/Core/Utilities/EncryptedStringAttribute.cs:60

User Encryption Keys

Account Encryption Versions

Bitwarden supports two account encryption schemes:

V1 Encryption (Legacy)

Key Derivation:
  1. Master Password → PBKDF2 → Master Key
  2. Master Key → HKDF → Encryption Key + MAC Key
  3. Master Key → PBKDF2 → Master Password Hash (for authentication)
Stored Keys:
  • Encrypted symmetric key
  • Public encryption key (RSA 2048-bit)
  • Private encryption key (encrypted with symmetric key)

V2 Encryption (Current)

Enhanced Features:
  • Separate signature keys (Ed25519 or RSA 2048-bit)
  • Improved key derivation
  • Support for trusted device encryption
  • Account recovery capabilities
Key Hierarchy:
Implementation: src/Core/KeyManagement/Models/Data/UserAccountKeysData.cs

Key Rotation

Bitwarden supports cryptographic key rotation: When to Rotate:
  • Master password change
  • Suspected key compromise
  • Compliance requirements
  • Migration to V2 encryption
Rotation Process:
1

Generate New Keys

Create new user key and asymmetric key pairs:
2

Re-encrypt Vault Data

Re-encrypt all ciphers, folders, and sends with new key:
3

Update Shares and Emergency Access

Re-encrypt shared items and emergency access keys:
4

Atomic Update

Update all keys in a single transaction to maintain consistency.
Implementation: src/Core/KeyManagement/Kdf/Implementations/ChangeKdfCommand.cs

Organization Encryption

Organization Keys

Key Structure:
Sharing Mechanism:
  1. Organization key encrypted with each user’s public key
  2. User decrypts org key with their private key
  3. User uses org key to decrypt organization items

Collection Encryption

Collections use the organization key:
Access Control:
  • Collection membership determines access
  • Encryption key shared via organization membership
  • Permissions enforced server-side
  • Data remains encrypted at rest

Data Protection Keys

ASP.NET Core Data Protection

Bitwarden uses Data Protection for server-side sensitive data: Configuration: src/Core/Settings/GlobalSettings.cs:548

Protected Data Types

Server-side protection for:
  • Temporary tokens (email verification, password reset)
  • Session state
  • Anti-forgery tokens
  • Organization sponsorship offers
  • Provider user invitations
  • Emergency access invitations
Token Factories: src/Core/Tokens/DataProtectorTokenFactory.cs

Data Protection Purposes

Purpose Strings:

Certificate Management

Identity Server Certificates

Signing Certificates:
Requirements:
  • RSA 2048-bit or higher
  • Valid for signing operations
  • Stored securely with restricted permissions

Data Protection Certificates

Configuration:
Certificate Generation:
Certificate Rotation:Rotating data protection certificates requires careful planning:
  1. Add new certificate alongside old certificate
  2. Allow grace period for token expiration
  3. Remove old certificate
  4. Never delete old certificates if encrypted data exists

Certificate Storage

Secure Storage:
Key Vault Integration: For production, store certificates in a key vault:

Encryption at Rest

Database Encryption

SQL Server Transparent Data Encryption (TDE):
1

Create Master Key

2

Create Certificate

3

Create Database Encryption Key

4

Enable TDE

5

Backup Certificate

Verification:

File Storage Encryption

Local Storage:
Azure Blob Storage:
Enable:
  • Storage Service Encryption (SSE)
  • Customer-managed keys (CMK) in Azure Key Vault
  • Private endpoints for secure access

Encryption Best Practices

Key Management

Key Generation

  • Use cryptographically secure random number generators
  • Generate keys with appropriate length (AES-256, RSA-2048+)
  • Never reuse keys across different purposes

Key Storage

  • Store keys encrypted when at rest
  • Use hardware security modules (HSM) for production
  • Implement key rotation policies
  • Backup encryption keys securely

Key Distribution

  • Use asymmetric encryption for key exchange
  • Validate recipient identity before sharing
  • Implement secure channel for key transmission
  • Audit all key access and distribution

Key Destruction

  • Securely delete keys when no longer needed
  • Use cryptographic erasure techniques
  • Maintain key destruction audit trail
  • Verify data encrypted with key is also destroyed

Cryptographic Operations

Do’s:
  • Use authenticated encryption (AES-GCM, AES-CBC + HMAC)
  • Generate unique IVs for each encryption operation
  • Use constant-time comparison for MACs
  • Implement proper error handling without leaking information
Don’ts:
  • Never roll your own crypto
  • Don’t use ECB mode
  • Don’t reuse IVs with the same key
  • Don’t use MD5 or SHA-1 for security purposes
  • Don’t store passwords in reversible encryption

Algorithm Selection

Recommended:

Troubleshooting Encryption Issues

Invalid Encryption String

Error: Invalid encryption string format Causes:
  • Corrupted database data
  • Incomplete migration
  • Incorrect encryption type
Diagnostic:

Key Mismatch Errors

Symptoms:
  • Cannot decrypt vault items
  • “Invalid key” errors
  • Items appear empty
Resolution:
  1. Verify user has correct encryption key
  2. Check for key rotation issues
  3. Validate organization membership
  4. Restore from backup if corruption detected

Certificate Issues

Error: Certificate not found or Invalid certificate Troubleshooting:

Migration to V2 Encryption

Migration Process

For users still on V1 encryption:
1

Check Current Version

2

Initiate Migration

User must log in to web vault and complete migration flow:
  • Verify master password
  • Generate new V2 keys
  • Re-encrypt vault data
3

Verify Migration

Feature Flags: