From 61c316ca4e04fed7ecc3e92ae167dae2a58df427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garci=CC=81a?= Date: Fri, 8 Dec 2023 13:24:33 +0100 Subject: [PATCH] Add missing hashPurpose to mobile demo apps --- .../com/bitwarden/myapplication/MainActivity.kt | 10 ++++++---- languages/swift/iOS/App/ContentView.swift | 14 +++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt b/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt index 3c03c6bca..b41b12b8c 100644 --- a/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt +++ b/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentActivity import com.bitwarden.core.DateTime import com.bitwarden.core.Folder +import com.bitwarden.core.HashPurpose import com.bitwarden.core.InitOrgCryptoRequest import com.bitwarden.core.InitUserCryptoMethod import com.bitwarden.core.InitUserCryptoRequest @@ -58,9 +59,9 @@ import javax.net.ssl.X509TrustManager /** * IMPORTANT: This file is provided only for the purpose of demostrating the use of the SDK functionality. - * It hasn't gone through a throrough security review and should not be considered production ready. It also doesn't - * handle a lot of errors and edge cases that a production application would need to deal with. - * Developers are encouraged to review and improve the code as needed to meet their security requirements. + * It hasn't gone through a throrough security review and should not be considered production ready. It also doesn't + * handle a lot of errors and edge cases that a production application would need to deal with. + * Developers are encouraged to review and improve the code as needed to meet their security requirements. * Additionally, we recommend to consult with security experts and conduct thorough testing before using the code in production. */ @@ -181,7 +182,8 @@ class MainActivity : FragmentActivity() { prelogin_body.kdfParallelism!! ) } - val masterPasswordHash = client.auth().hashPassword(EMAIL, PASSWORD, kdf) + val masterPasswordHash = + client.auth().hashPassword(EMAIL, PASSWORD, kdf, HashPurpose.SERVER_AUTHORIZATION) ///////////////////////////// Login ///////////////////////////// diff --git a/languages/swift/iOS/App/ContentView.swift b/languages/swift/iOS/App/ContentView.swift index 5df7dc3fd..c2b488b8f 100644 --- a/languages/swift/iOS/App/ContentView.swift +++ b/languages/swift/iOS/App/ContentView.swift @@ -10,9 +10,9 @@ import SwiftUI /** * IMPORTANT: This file is provided only for the purpose of demostrating the use of the SDK functionality. - * It hasn't gone through a throrough security review and should not be considered production ready. It also doesn't - * handle a lot of errors and edge cases that a production application would need to deal with. - * Developers are encouraged to review and improve the code as needed to meet their security requirements. + * It hasn't gone through a throrough security review and should not be considered production ready. It also doesn't + * handle a lot of errors and edge cases that a production application would need to deal with. + * Developers are encouraged to review and improve the code as needed to meet their security requirements. * Additionally, we recommend to consult with security experts and conduct thorough testing before using the code in production. */ @@ -49,8 +49,8 @@ struct ContentView: View { Button(action: { Task { do { - try await clientExamplePassword(clientAuth: client.auth(), clientCrypto: client.crypto(), setupBiometrics: setupBiometrics) - try await decryptVault(clientCrypto: client.crypto(), clientVault: client.vault()) + try await clientExamplePassword(clientAuth: client.auth(), clientCrypto: client.crypto(), setupBiometrics: setupBiometrics) + try await decryptVault(clientCrypto: client.crypto(), clientVault: client.vault()) } catch { print("ERROR:", error) } @@ -64,7 +64,7 @@ struct ContentView: View { Button(action: { Task { do { - try await clientExampleBiometrics(clientCrypto: client.crypto()) + try await clientExampleBiometrics(clientCrypto: client.crypto()) try await decryptVault(clientCrypto: client.crypto(), clientVault: client.vault()) } catch { print("ERROR:", error) @@ -117,7 +117,7 @@ struct ContentView: View { } let passwordHash = try await clientAuth.hashPassword( - email: EMAIL, password: PASSWORD, kdfParams: kdf) + email: EMAIL, password: PASSWORD, kdfParams: kdf, purpose: .serverAuthorization) ///////////////////////////// Login /////////////////////////////