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

import java.nio.ByteBuffer;
import java.security.GeneralSecurityException;

/* JADX INFO: loaded from: classes2.dex */
public final class xd implements a7 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f21342a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Object f21343b;

    public xd(byte[] bArr, int i10) throws GeneralSecurityException {
        this.f21342a = i10;
        if (i10 == 1) {
            this.f21343b = new h8(bArr, 0);
        } else if (i10 == 2) {
            this.f21343b = new h8(bArr, 1);
        } else {
            if (!q9.y(2)) {
                throw new GeneralSecurityException("Can not use AES-GCM in FIPS-mode, as BoringCrypto module is not available.");
            }
            this.f21343b = new f8(bArr, true);
        }
    }

    @Override // com.google.android.gms.internal.pal.a7
    public final byte[] zza(byte[] bArr, byte[] bArr2) throws GeneralSecurityException {
        int i10 = this.f21342a;
        Object obj = this.f21343b;
        switch (i10) {
            case 0:
                return ((f8) obj).a(ie.a(12), bArr);
            case 1:
                ByteBuffer byteBufferAllocate = ByteBuffer.allocate(bArr.length + 28);
                byte[] bArrA = ie.a(12);
                byteBufferAllocate.put(bArrA);
                ((h8) obj).j(byteBufferAllocate, bArrA, bArr, bArr2);
                return byteBufferAllocate.array();
            default:
                ByteBuffer byteBufferAllocate2 = ByteBuffer.allocate(bArr.length + 40);
                byte[] bArrA2 = ie.a(24);
                byteBufferAllocate2.put(bArrA2);
                ((h8) obj).j(byteBufferAllocate2, bArrA2, bArr, bArr2);
                return byteBufferAllocate2.array();
        }
    }
}
