Skip to content

Commit

Permalink
Apply further suggestions from review
Browse files Browse the repository at this point in the history
  • Loading branch information
SailReal committed Nov 27, 2024
1 parent 4154a02 commit 19cd927
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import org.cryptomator.domain.UnverifiedVaultConfig
import org.cryptomator.domain.Vault
import org.cryptomator.domain.exception.BackendException
import org.cryptomator.domain.exception.CancellationException
import org.cryptomator.domain.exception.FatalBackendException
import org.cryptomator.domain.usecases.cloud.Flag
import org.cryptomator.domain.usecases.vault.UnlockToken
import org.cryptomator.util.crypto.HubDeviceCryptor
import java.security.SecureRandom
import java.text.ParseException

class HubkeyCryptoCloudProvider(
private val cryptoCloudContentRepositoryFactory: CryptoCloudContentRepositoryFactory, //
Expand All @@ -38,8 +40,14 @@ class HubkeyCryptoCloudProvider(
}

override fun unlock(vault: Vault, unverifiedVaultConfig: UnverifiedVaultConfig, vaultKeyJwe: String, userKeyJwe: String, cancelledFlag: Flag): Vault {
val vaultKey = JWEObject.parse(vaultKeyJwe)
val userKey = JWEObject.parse(userKeyJwe)
val vaultKey: JWEObject
val userKey: JWEObject
try {
vaultKey = JWEObject.parse(vaultKeyJwe)
userKey = JWEObject.parse(userKeyJwe)
} catch (e: ParseException) {
throw FatalBackendException("Failed to parse JWE strings", e)
}
val masterkey = HubDeviceCryptor.getInstance().decryptVaultKey(vaultKey, userKey)
val vaultConfig = verify(masterkey.encoded, unverifiedVaultConfig)
val vaultFormat = vaultConfig.vaultFormat
Expand Down

0 comments on commit 19cd927

Please sign in to comment.