Files
Jared Snider b58657797c KM/PM-44091 - Rename LegacyCompatKeyService.makeMasterKey() email parameter to salt (#23466)
* Rename makeMasterKey email parameter to salt

LegacyCompatKeyService.makeMasterKey took an `email: string`, but not every
valid master password salt is a valid email. Rename the parameter to
`salt: MasterPasswordSalt` so the signature matches what the value actually is.

Email-derived callers now produce the salt through MasterPasswordService.emailToSalt
rather than passing a raw email:
  - PasswordLoginStrategy (both non-SDK prelogin branches)
  - KeyConnectorService.convertNewSsoUserToKeyConnectorV1
  - DefaultChangeEmailService (legacy path)
  - SetInitialPasswordComponent, replacing a hand-rolled trim().toLowerCase()

Server-supplied salts (prelogin response, saltForUser$) assert at the call site,
matching how MasterPasswordUnlockResponse already reaches MasterPasswordSalt.

makeMasterKey keeps normalizing its input. Callers can reach MasterPasswordSalt by
type assertion, so normalization is not guaranteed upstream, and MasterPasswordService
normalizes defensively for the same reason.

* Use the resolved salt from PasswordInputResult when setting an initial password

InputPasswordComponent already resolves the salt through saltForUser$ and emits
it on the result. Deriving it again from this.email gave the legacy set-password
request a second, independent source. The two agree today, but they stop agreeing
once salt is disconnected from email.

Matches the other four call sites in this component and the guidance on
saltForUser$ to keep salt resolution inside that bottleneck.

* PM-44091 - Keep key rotation salt typed as MasterPasswordSalt

saltForUser$ already emits MasterPasswordSalt, but getCryptographicStateForUser,
MasterPasswordAuthenticationAndUnlockData, and makeServerMasterKeyAuthenticationHash
widened it to string, which forced an assertion before makeMasterKey. Narrow all
three so the salt keeps its type from saltForUser$ through to makeMasterKey.
2026-10-26 20:09:19 +00:00
..

legacy-crypto

Owned by: key-management

Deprecated crypto primitives being retired in favour of the SDK.

Do not import this package

@bitwarden/legacy-crypto is a restricted import, enforced by no-restricted-imports in the root eslint.config.mjs. Nothing new may depend on it. If you need a cryptographic operation, implement it in the SDK and/or contact the Key Management team.

Existing call sites will be migrated to it.

If you want to build a cryptographic feature, do not base it on the legacy crypto module. Build an sdk shim instead, that exposes the functionality you need.