package o; import java.security.GeneralSecurityException; import java.security.InvalidAlgorithmParameterException; import java.util.Arrays; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import o.uAf; /* renamed from: o.yNf, reason: case insensitive filesystem */ /* loaded from: classes2.dex */ public final class C17618yNf implements InterfaceC16851roi { private static uAf.RVV a = uAf.RVV.ALGORITHM_NOT_FIPS; private final SecretKey b; private byte[] c; private byte[] e; public C17618yNf(byte[] bArr) throws GeneralSecurityException { ifG.e(bArr.length); SecretKeySpec secretKeySpec = new SecretKeySpec(bArr, "AES"); this.b = secretKeySpec; if (!a.d()) { throw new GeneralSecurityException("Can not use AES-CMAC in FIPS-mode."); } Cipher e = YYT.a.e("AES/ECB/NoPadding"); e.init(1, secretKeySpec); byte[] c = UKk.c(e.doFinal(new byte[16])); this.c = c; this.e = UKk.c(c); } @Override // o.InterfaceC16851roi public final byte[] c(byte[] bArr, int i) throws GeneralSecurityException { byte[] c; if (i > 16) { throw new InvalidAlgorithmParameterException("outputLength too large, max is 16 bytes"); } if (!a.d()) { throw new GeneralSecurityException("Can not use AES-CMAC in FIPS-mode."); } Cipher e = YYT.a.e("AES/ECB/NoPadding"); e.init(1, this.b); int max = Math.max(1, (int) Math.ceil(bArr.length / 16.0d)); if ((max << 4) == bArr.length) { c = vil.c(bArr, (max - 1) << 4, this.c, 0, 16); } else { byte[] copyOfRange = Arrays.copyOfRange(bArr, (max - 1) << 4, bArr.length); if (copyOfRange.length >= 16) { throw new IllegalArgumentException("x must be smaller than a block."); } byte[] copyOf = Arrays.copyOf(copyOfRange, 16); copyOf[copyOfRange.length] = Byte.MIN_VALUE; byte[] bArr2 = this.e; if (copyOf.length != bArr2.length) { throw new IllegalArgumentException("The lengths of x and y should match."); } c = vil.c(copyOf, 0, bArr2, 0, copyOf.length); } byte[] bArr3 = new byte[16]; for (int i2 = 0; i2 < max - 1; i2++) { bArr3 = e.doFinal(vil.c(bArr3, 0, bArr, i2 << 4, 16)); } if (c.length == bArr3.length) { return Arrays.copyOf(e.doFinal(vil.c(c, 0, bArr3, 0, c.length)), i); } throw new IllegalArgumentException("The lengths of x and y should match."); } }