package o; import java.security.GeneralSecurityException; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.logging.Logger; import o.FdT; import o.InterfaceC17129uEO; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public class ZJJ implements wbW { private static final Logger c = Logger.getLogger(ZJJ.class.getName()); private static final byte[] e = {0}; /* loaded from: classes2.dex */ public static class IeS implements InterfaceC17126uCH { private final InterfaceC17129uEO.IeS b; private final FdT d; private final InterfaceC17129uEO.IeS e; /* synthetic */ IeS(FdT fdT, byte b) { this(fdT); } private IeS(FdT fdT) { this.d = fdT; if (!(!fdT.e.b.isEmpty())) { this.b = MWX.b; this.e = MWX.b; return; } InterfaceC17129uEO interfaceC17129uEO = UqK.d().a.get(); interfaceC17129uEO = interfaceC17129uEO == null ? UqK.d : interfaceC17129uEO; MWX.d(fdT); this.b = interfaceC17129uEO.d(); this.e = interfaceC17129uEO.d(); } @Override // o.InterfaceC17126uCH public final void a(byte[] bArr, byte[] bArr2) throws GeneralSecurityException { if (bArr.length <= 5) { throw new GeneralSecurityException("tag too short"); } byte[] copyOf = Arrays.copyOf(bArr, 5); byte[] copyOfRange = Arrays.copyOfRange(bArr, 5, bArr.length); List> list = this.d.c.get(new FdT.LWm(copyOf, (byte) 0)); if (list == null) { list = Collections.emptyList(); } for (FdT.HBt hBt : list) { byte[] a = hBt.c.equals(Umh.LEGACY) ? vil.a(bArr2, ZJJ.e) : bArr2; try { hBt.e.a(copyOfRange, a); int i = hBt.d; int length = a.length; return; } catch (GeneralSecurityException e) { ZJJ.c.info("tag prefix matches a key, but cannot verify: ".concat(String.valueOf(e))); } } List> list2 = this.d.c.get(new FdT.LWm(sPU.b, (byte) 0)); if (list2 == null) { list2 = Collections.emptyList(); } for (FdT.HBt hBt2 : list2) { try { hBt2.e.a(bArr, bArr2); int i2 = hBt2.d; int length2 = bArr2.length; return; } catch (GeneralSecurityException unused) { } } throw new GeneralSecurityException("invalid MAC"); } @Override // o.InterfaceC17126uCH public final byte[] d(byte[] bArr) throws GeneralSecurityException { if (this.d.a.c.equals(Umh.LEGACY)) { bArr = vil.a(bArr, ZJJ.e); } byte[][] bArr2 = new byte[2]; byte[] bArr3 = this.d.a.b; bArr2[0] = bArr3 == null ? null : Arrays.copyOf(bArr3, bArr3.length); bArr2[1] = this.d.a.e.d(bArr); byte[] a = vil.a(bArr2); int i = this.d.a.d; int length = bArr.length; return a; } } ZJJ() { } @Override // o.wbW public final Class c() { return InterfaceC17126uCH.class; } @Override // o.wbW public final Class e() { return InterfaceC17126uCH.class; } public static void a() throws GeneralSecurityException { Jtp.a(new ZJJ()); } @Override // o.wbW public final /* synthetic */ InterfaceC17126uCH d(FdT fdT) throws GeneralSecurityException { Iterator>> it = fdT.c.values().iterator(); while (it.hasNext()) { for (FdT.HBt hBt : it.next()) { if (hBt.a instanceof dUI) { dUI dui = (dUI) hBt.a; byte[] bArr = hBt.b; byte[] copyOf = bArr == null ? null : Arrays.copyOf(bArr, bArr.length); if (copyOf == null) { throw new NullPointerException("data must be non-null"); } int length = copyOf.length; if (copyOf == null) { throw new NullPointerException("data must be non-null"); } C1246Yua c1246Yua = new C1246Yua(copyOf, length); if (!c1246Yua.equals(dui.c())) { StringBuilder sb = new StringBuilder("Mac Key with parameters "); sb.append(dui.e()); sb.append(" has wrong output prefix ("); sb.append(dui.c()); sb.append(") instead of ("); sb.append(c1246Yua); sb.append(")"); throw new GeneralSecurityException(sb.toString()); } } } } return new IeS(fdT, (byte) 0); } }