package r6;

import java.util.Arrays;
import kotlin.jvm.internal.t;
import r6.a;

/* loaded from: classes.dex */
public abstract class c {
    public static final byte[] a(byte[] key, byte[] message, dn.a hashSupplier) {
        t.g(key, "key");
        t.g(message, "message");
        t.g(hashSupplier, "hashSupplier");
        return b(key, message, (a) hashSupplier.invoke());
    }

    public static final byte[] b(byte[] key, byte[] message, a hashFunction) {
        t.g(key, "key");
        t.g(message, "message");
        t.g(hashFunction, "hashFunction");
        byte[] c10 = c(key, hashFunction);
        byte[] d10 = d(c10, (byte) 54);
        byte[] d11 = d(c10, (byte) 92);
        a.C0806a.a(hashFunction, d10, 0, 0, 6, null);
        a.C0806a.a(hashFunction, message, 0, 0, 6, null);
        byte[] a10 = hashFunction.a();
        a.C0806a.a(hashFunction, d11, 0, 0, 6, null);
        a.C0806a.a(hashFunction, a10, 0, 0, 6, null);
        return hashFunction.a();
    }

    private static final byte[] c(byte[] bArr, a aVar) {
        int c10 = aVar.c();
        if (bArr.length > c10) {
            bArr = b.c(bArr, aVar);
        }
        if (bArr.length >= c10) {
            return bArr;
        }
        byte[] copyOf = Arrays.copyOf(bArr, c10);
        t.f(copyOf, "copyOf(...)");
        return copyOf;
    }

    private static final byte[] d(byte[] bArr, byte b10) {
        int length = bArr.length;
        byte[] bArr2 = new byte[length];
        for (int i10 = 0; i10 < length; i10++) {
            bArr2[i10] = (byte) (bArr[i10] ^ b10);
        }
        return bArr2;
    }
}
