Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ interface AuthSdkSource {
): Result<String>

/**
* Creates a hashed password provided the given [email], [password], [kdf], and [purpose].
* Creates a hashed password provided the given [salt], [password], [kdf], and [purpose].
*/
suspend fun hashPassword(
email: String,
salt: String,
password: String,
kdf: Kdf,
purpose: HashPurpose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,15 @@ class AuthSdkSourceImpl(
}

override suspend fun hashPassword(
email: String,
salt: String,
password: String,
kdf: Kdf,
purpose: HashPurpose,
): Result<String> = runCatchingWithLogs {
useClient {
// Under the hood, the "email" parameter is the salt.
auth().hashPassword(
email = email,
email = salt,
password = password,
kdfParams = kdf,
purpose = purpose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ internal class AuthRepositoryImpl(
userStateManager.hasPendingAccountDeletion = true
return authSdkSource
.hashPassword(
email = profile.email,
salt = profile.email,
password = masterPassword,
kdf = profile.toSdkParams(),
purpose = HashPurpose.SERVER_AUTHORIZATION,
Expand Down Expand Up @@ -524,7 +524,7 @@ internal class AuthRepositoryImpl(
.preLogin(email = email)
.flatMap {
authSdkSource.hashPassword(
email = email,
salt = email,
password = password,
kdf = it.kdfParams.toSdkParams(),
purpose = HashPurpose.SERVER_AUTHORIZATION,
Expand Down Expand Up @@ -981,7 +981,7 @@ internal class AuthRepositoryImpl(
val currentPasswordHash = currentPassword?.let { password ->
authSdkSource
.hashPassword(
email = profile.email,
salt = profile.email,
password = password,
kdf = profile.toSdkParams(),
purpose = HashPurpose.SERVER_AUTHORIZATION,
Expand Down Expand Up @@ -1705,7 +1705,7 @@ internal class AuthRepositoryImpl(
// Save the master password hash.
authSdkSource
.hashPassword(
email = email,
salt = email,
password = it,
kdf = profile.toSdkParams(),
purpose = HashPurpose.LOCAL_AUTHORIZATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ internal class VaultLockManagerImpl(
// Save the master password hash.
authSdkSource
.hashPassword(
email = email,
salt = email,
password = password,
kdf = kdf,
purpose = HashPurpose.LOCAL_AUTHORIZATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,22 +337,22 @@ class AuthSdkSourceTest {
coEvery {
sdkClientManager.singleUseClient(block = capture(slot))
} coAnswers { slot.captured(client) }
val email = "email"
val salt = "salt"
val password = "password"
val kdf = mockk<Kdf>()
val purpose = mockk<HashPurpose>()
val expectedResult = "hashedPassword"
coEvery {
clientAuth.hashPassword(
email = email,
email = salt,
password = password,
kdfParams = kdf,
purpose = purpose,
)
} returns expectedResult

val result = authSkdSource.hashPassword(
email = email,
salt = salt,
password = password,
kdf = kdf,
purpose = purpose,
Expand All @@ -363,7 +363,7 @@ class AuthSdkSourceTest {
)
coVerify {
clientAuth.hashPassword(
email = email,
email = salt,
password = password,
kdfParams = kdf,
purpose = purpose,
Expand Down
Loading
Loading