java/com/tailscale/ipn: upgrade Android security to support Android 5.1

As luck would have it, there's a new version of the androidx.security
library available that support Android 5+. Use that, and adjust to the
incompatible API changes.

Fixes tailscale/tailscale#577

Signed-off-by: Elias Naur <mail@eliasnaur.com>
pull/3/head
Elias Naur 4 years ago
parent 3ced33d812
commit 39cb01da42

@ -23,7 +23,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 23
minSdkVersion 22
targetSdkVersion 29
versionCode 16
versionName System.getenv("VERSION")
@ -38,6 +38,6 @@ dependencies {
implementation 'com.google.android.gms:play-services-auth:18.0.0'
implementation "androidx.core:core:1.2.0"
implementation "androidx.browser:browser:1.2.0"
implementation "androidx.security:security-crypto:1.0.0-rc01"
implementation "androidx.security:security-crypto:1.1.0-alpha02"
implementation ':ipn@aar'
}

@ -25,7 +25,7 @@ import java.io.FileOutputStream;
import java.security.GeneralSecurityException;
import androidx.security.crypto.EncryptedSharedPreferences;
import androidx.security.crypto.MasterKeys;
import androidx.security.crypto.MasterKey;
import org.gioui.Gio;
@ -72,12 +72,14 @@ public class App extends Application {
}
private SharedPreferences getEncryptedPrefs() throws IOException, GeneralSecurityException {
String masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC);
MasterKey key = new MasterKey.Builder(this)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build();
return EncryptedSharedPreferences.create(
"secret_shared_prefs",
masterKeyAlias,
this,
"secret_shared_prefs",
key,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
);

Loading…
Cancel
Save