package com.google.firebase.auth.internal; import android.content.Context; import android.util.Base64; import com.google.android.gms.internal.p002firebaseauthapi.zzaq; import com.google.android.gms.internal.p002firebaseauthapi.zzau; import com.google.android.gms.internal.p002firebaseauthapi.zzei; import com.google.android.gms.internal.p002firebaseauthapi.zzen; import com.google.android.gms.internal.p002firebaseauthapi.zzfl; import com.google.android.gms.internal.p002firebaseauthapi.zzfn; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.GeneralSecurityException; /* loaded from: classes2.dex */ public final class zzk { private static zzk zza; private final String zzb; private final zzfn zzc; private zzk(Context context, String str, boolean z) { zzfn zzfnVar; this.zzb = str; try { zzei.zza(); zzfl zzflVar = new zzfl(); zzflVar.zzf(context, "GenericIdpKeyset", String.format("com.google.firebase.auth.api.crypto.%s", str)); zzflVar.zzd(zzen.zza); zzflVar.zze(String.format("android-keystore://firebear_master_key_id.%s", str)); zzfnVar = zzflVar.zzg(); } catch (IOException | GeneralSecurityException e) { e.getMessage(); zzfnVar = null; } this.zzc = zzfnVar; } public static zzk zza(Context context, String str) { zzk zzkVar = zza; if (zzkVar == null || !com.google.android.gms.internal.p002firebaseauthapi.zzu.zza(zzkVar.zzb, str)) { zza = new zzk(context, str, true); } return zza; } public final String zzb(String str) { String str2; zzfn zzfnVar = this.zzc; if (zzfnVar != null) { try { synchronized (zzfnVar) { str2 = new String(((zzau) this.zzc.zza().zze(zzau.class)).zza(Base64.decode(str, 8), null), "UTF-8"); } return str2; } catch (UnsupportedEncodingException | GeneralSecurityException e) { e.getMessage(); } } return null; } public final String zzc() { if (this.zzc == null) { return null; } ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); com.google.android.gms.internal.p002firebaseauthapi.zzbj zza2 = zzaq.zza(byteArrayOutputStream); try { synchronized (this.zzc) { this.zzc.zza().zzb().zzg(zza2); } return Base64.encodeToString(byteArrayOutputStream.toByteArray(), 8); } catch (IOException | GeneralSecurityException e) { e.getMessage(); return null; } } }