73 lines
2.7 KiB
Java
73 lines
2.7 KiB
Java
|
package com.google.android.gms.internal.p002firebaseauthapi;
|
||
|
|
||
|
import android.util.Log;
|
||
|
import java.io.IOException;
|
||
|
import java.security.GeneralSecurityException;
|
||
|
import java.security.KeyStore;
|
||
|
import java.security.KeyStoreException;
|
||
|
import java.util.Arrays;
|
||
|
import java.util.Locale;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public final class zzfp implements zzbk {
|
||
|
private static final String zza = "zzfp";
|
||
|
private KeyStore zzb;
|
||
|
|
||
|
public zzfp() throws GeneralSecurityException {
|
||
|
try {
|
||
|
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
|
||
|
keyStore.load(null);
|
||
|
this.zzb = keyStore;
|
||
|
} catch (IOException | GeneralSecurityException e) {
|
||
|
throw new IllegalStateException(e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.google.android.gms.internal.p002firebaseauthapi.zzbk
|
||
|
public final zzap zza(String str) throws GeneralSecurityException {
|
||
|
zzfo zzfoVar;
|
||
|
synchronized (this) {
|
||
|
zzfoVar = new zzfo(zzqs.zza("android-keystore://", str), this.zzb);
|
||
|
byte[] zza2 = zzqq.zza(10);
|
||
|
byte[] bArr = new byte[0];
|
||
|
if (!Arrays.equals(zza2, zzfoVar.zza(zzfoVar.zzb(zza2, bArr), bArr))) {
|
||
|
throw new KeyStoreException("cannot use Android Keystore: encryption/decryption of non-empty message and empty aad returns an incorrect result");
|
||
|
}
|
||
|
}
|
||
|
return zzfoVar;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.android.gms.internal.p002firebaseauthapi.zzbk
|
||
|
public final boolean zzb(String str) {
|
||
|
boolean startsWith;
|
||
|
synchronized (this) {
|
||
|
startsWith = str.toLowerCase(Locale.US).startsWith("android-keystore://");
|
||
|
}
|
||
|
return startsWith;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final boolean zzc(String str) throws GeneralSecurityException {
|
||
|
boolean containsAlias;
|
||
|
synchronized (this) {
|
||
|
String zza2 = zzqs.zza("android-keystore://", str);
|
||
|
try {
|
||
|
containsAlias = this.zzb.containsAlias(zza2);
|
||
|
} catch (NullPointerException unused) {
|
||
|
Log.w(zza, "Keystore is temporarily unavailable, wait 20ms, reinitialize Keystore and try again.");
|
||
|
try {
|
||
|
Thread.sleep(20L);
|
||
|
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
|
||
|
this.zzb = keyStore;
|
||
|
keyStore.load(null);
|
||
|
} catch (IOException e) {
|
||
|
throw new GeneralSecurityException(e);
|
||
|
} catch (InterruptedException unused2) {
|
||
|
}
|
||
|
return this.zzb.containsAlias(zza2);
|
||
|
}
|
||
|
}
|
||
|
return containsAlias;
|
||
|
}
|
||
|
}
|