fix: remove android.util.Base64 from RecoveryKeyManager for portability (batch v0.2.16)
- Replace android.util.Base64 with java.util.Base64 in RecoveryKeyManager - Crypto layer now has zero Android SDK dependencies — portable to iOS/shared testing
This commit is contained in:
parent
c1f7e6f7f9
commit
2e2c79be3d
|
|
@ -1,6 +1,6 @@
|
|||
package app.closer.crypto
|
||||
|
||||
import android.util.Base64
|
||||
import java.util.Base64
|
||||
import com.google.crypto.tink.KeysetHandle
|
||||
import com.google.crypto.tink.aead.AesGcmKeyManager
|
||||
import com.google.crypto.tink.subtle.AesGcmJce
|
||||
|
|
@ -46,8 +46,8 @@ class RecoveryKeyManager @Inject constructor() {
|
|||
val keysetBytes = serializeKeyset(keyset)
|
||||
val cipherBytes = AesGcmJce(wrapKey).encrypt(keysetBytes, WRAP_AAD)
|
||||
return WrappedKey(
|
||||
cipherB64 = Base64.encodeToString(cipherBytes, Base64.NO_WRAP),
|
||||
saltB64 = Base64.encodeToString(salt, Base64.NO_WRAP),
|
||||
cipherB64 = Base64.getEncoder().encodeToString(cipherBytes),
|
||||
saltB64 = Base64.getEncoder().encodeToString(salt),
|
||||
params = PARAMS_TAG
|
||||
)
|
||||
}
|
||||
|
|
@ -57,8 +57,8 @@ class RecoveryKeyManager @Inject constructor() {
|
|||
* (wrapped as GeneralSecurityException) if the phrase is wrong.
|
||||
*/
|
||||
fun unwrap(wrapped: WrappedKey, phrase: String): KeysetHandle {
|
||||
val salt = Base64.decode(wrapped.saltB64, Base64.NO_WRAP)
|
||||
val cipher = Base64.decode(wrapped.cipherB64, Base64.NO_WRAP)
|
||||
val salt = Base64.getDecoder().decode(wrapped.saltB64)
|
||||
val cipher = Base64.getDecoder().decode(wrapped.cipherB64)
|
||||
val wrapKey = deriveKey(phrase, salt)
|
||||
val keysetBytes = AesGcmJce(wrapKey).decrypt(cipher, WRAP_AAD)
|
||||
return deserializeKeyset(keysetBytes)
|
||||
|
|
|
|||
Loading…
Reference in New Issue