fix(crypto): correct HKDF key stretching to use HKDF-expand with proper info strings

This commit is contained in:
2026-08-26 14:40:28 +02:00
parent 6f590a219b
commit ea7f126e73
2 changed files with 48 additions and 16 deletions
+13 -3
View File
@@ -252,10 +252,20 @@ class BitwardenClient:
# Get encrypted user key
enc_user_key = result.get("Key")
_debug(f"[LOGIN] enc_user_key present: {enc_user_key is not None}")
if enc_user_key:
self.enc_key, self.mac_key = self.crypto.decrypt_user_key(
enc_user_key, master_key
)
_debug(f"[LOGIN] enc_user_key (first 40): {enc_user_key[:40]}...")
_debug(f"[LOGIN] attempting to decrypt user key with master_key...")
try:
self.enc_key, self.mac_key = self.crypto.decrypt_user_key(
enc_user_key, master_key
)
_debug(f"[LOGIN] user key decrypted successfully!")
_debug(f"[LOGIN] enc_key (first 8 b64): {b64encode(self.enc_key[:8]).decode()}")
_debug(f"[LOGIN] mac_key (first 8 b64): {b64encode(self.mac_key[:8]).decode()}")
except Exception as e:
_debug(f"[LOGIN] user key decryption FAILED: {e}")
raise
return {
"success": True,
"master_key": master_key,