package oa;

import com.google.android.gms.measurement.internal.c2;
import com.google.crypto.tink.proto.OutputPrefixType;
import da.k;
import java.security.GeneralSecurityException;
import java.util.Arrays;

/* JADX INFO: loaded from: classes2.dex */
public final class e implements k {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final byte[] f31454d = {0};

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final k f31455a;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final byte[] f31457c;

    public e(k kVar, OutputPrefixType outputPrefixType, byte[] bArr) {
        this.f31455a = kVar;
        this.f31456b = outputPrefixType;
        this.f31457c = bArr;
    }

    @Override // da.k
    public final void a(byte[] bArr, byte[] bArr2) throws GeneralSecurityException {
        if (bArr.length < 10) {
            throw new GeneralSecurityException("tag too short");
        }
        OutputPrefixType outputPrefixType = OutputPrefixType.LEGACY;
        OutputPrefixType outputPrefixType2 = this.f31456b;
        if (outputPrefixType2.equals(outputPrefixType)) {
            bArr2 = c2.f(bArr2, f31454d);
        }
        byte[] bArr3 = new byte[0];
        if (!outputPrefixType2.equals(OutputPrefixType.RAW)) {
            byte[] bArrCopyOf = Arrays.copyOf(bArr, 5);
            bArr = Arrays.copyOfRange(bArr, 5, bArr.length);
            bArr3 = bArrCopyOf;
        }
        if (!Arrays.equals(this.f31457c, bArr3)) {
            throw new GeneralSecurityException("wrong prefix");
        }
        this.f31455a.a(bArr, bArr2);
    }

    @Override // da.k
    public final byte[] b(byte[] bArr) throws GeneralSecurityException {
        if (this.f31456b.equals(OutputPrefixType.LEGACY)) {
            bArr = c2.f(bArr, f31454d);
        }
        return c2.f(this.f31457c, this.f31455a.b(bArr));
    }
}
