package com.google.android.gms.internal.p002firebaseauthapi;

import com.google.android.gms.internal.p002firebaseauthapi.zzju;
import java.security.GeneralSecurityException;
import java.security.spec.EllipticCurve;
import javax.annotation.Nullable;
/* compiled from: com.google.firebase:firebase-auth@@23.1.0 */
/* renamed from: com.google.android.gms.internal.firebase-auth-api.zzke  reason: invalid package */
/* loaded from: classes3.dex */
public final class zzke extends zzkr {
    private final zzju zza;
    private final zzzc zzb;
    private final zzzc zzc;
    @Nullable
    private final Integer zzd;

    @Override // com.google.android.gms.internal.p002firebaseauthapi.zzbp
    @Nullable
    public final Integer zza() {
        return this.zzd;
    }

    public final zzju zzb() {
        return this.zza;
    }

    @Override // com.google.android.gms.internal.p002firebaseauthapi.zzkr
    public final zzzc zzc() {
        return this.zzc;
    }

    public final zzzc zzd() {
        return this.zzb;
    }

    public static zzke zza(zzju zzjuVar, zzzc zzzcVar, @Nullable Integer num) throws GeneralSecurityException {
        EllipticCurve curve;
        zzzc zzb;
        zzju.zze zzf = zzjuVar.zzf();
        if (!zzf.equals(zzju.zze.zzc) && num == null) {
            throw new GeneralSecurityException("'idRequirement' must be non-null for " + String.valueOf(zzf) + " variant.");
        } else if (zzf.equals(zzju.zze.zzc) && num != null) {
            throw new GeneralSecurityException("'idRequirement' must be null for NO_PREFIX variant.");
        } else {
            zzju.zzf zze = zzjuVar.zze();
            int zza = zzzcVar.zza();
            String str = "Encoded public key byte length for " + String.valueOf(zze) + " must be %d, not " + zza;
            if (zze == zzju.zzf.zza) {
                if (zza != 65) {
                    throw new GeneralSecurityException(String.format(str, 65));
                }
            } else if (zze == zzju.zzf.zzb) {
                if (zza != 97) {
                    throw new GeneralSecurityException(String.format(str, 97));
                }
            } else if (zze == zzju.zzf.zzc) {
                if (zza != 133) {
                    throw new GeneralSecurityException(String.format(str, 133));
                }
            } else if (zze != zzju.zzf.zzd) {
                throw new GeneralSecurityException("Unable to validate public key length for " + String.valueOf(zze));
            } else if (zza != 32) {
                throw new GeneralSecurityException(String.format(str, 32));
            }
            if (zze == zzju.zzf.zza || zze == zzju.zzf.zzb || zze == zzju.zzf.zzc) {
                if (zze == zzju.zzf.zza) {
                    curve = zzmk.zza.getCurve();
                } else if (zze == zzju.zzf.zzb) {
                    curve = zzmk.zzb.getCurve();
                } else if (zze == zzju.zzf.zzc) {
                    curve = zzmk.zzc.getCurve();
                } else {
                    throw new IllegalArgumentException("Unable to determine NIST curve type for " + String.valueOf(zze));
                }
                zzmk.zza(zzyb.zza(curve, zzyd.UNCOMPRESSED, zzzcVar.zzb()), curve);
            }
            zzju.zze zzf2 = zzjuVar.zzf();
            if (zzf2 == zzju.zze.zzc) {
                zzb = zzog.zza;
            } else if (num == null) {
                throw new IllegalStateException("idRequirement must be non-null for HpkeParameters.Variant " + String.valueOf(zzf2));
            } else if (zzf2 == zzju.zze.zzb) {
                zzb = zzog.zza(num.intValue());
            } else if (zzf2 == zzju.zze.zza) {
                zzb = zzog.zzb(num.intValue());
            } else {
                throw new IllegalStateException("Unknown HpkeParameters.Variant: " + String.valueOf(zzf2));
            }
            return new zzke(zzjuVar, zzzcVar, zzb, num);
        }
    }

    private zzke(zzju zzjuVar, zzzc zzzcVar, zzzc zzzcVar2, @Nullable Integer num) {
        this.zza = zzjuVar;
        this.zzb = zzzcVar;
        this.zzc = zzzcVar2;
        this.zzd = num;
    }
}
