package D;

import b0.AbstractC0399d;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

/* JADX INFO: loaded from: classes.dex */
final class a implements a0.f {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final a0.f f287a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final byte[] f288b;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private CipherInputStream f290d;

    public a(a0.f fVar, byte[] bArr, byte[] bArr2) {
        this.f287a = fVar;
        this.f288b = bArr;
        this.f289c = bArr2;
    }

    @Override // a0.f
    public long a(a0.h hVar) {
        try {
            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
            try {
                cipher.init(2, new SecretKeySpec(this.f288b, "AES"), new IvParameterSpec(this.f289c));
                this.f290d = new CipherInputStream(new a0.g(this.f287a, hVar), cipher);
                return -1L;
            } catch (InvalidAlgorithmParameterException e2) {
                throw new RuntimeException(e2);
            } catch (InvalidKeyException e3) {
                throw new RuntimeException(e3);
            }
        } catch (NoSuchAlgorithmException e4) {
            throw new RuntimeException(e4);
        } catch (NoSuchPaddingException e5) {
            throw new RuntimeException(e5);
        }
    }

    @Override // a0.f
    public void close() throws IOException {
        this.f290d.close();
        this.f290d = null;
        this.f287a.close();
    }

    @Override // a0.f
    public int read(byte[] bArr, int i2, int i3) throws IOException {
        AbstractC0399d.e(this.f290d != null);
        int i4 = this.f290d.read(bArr, i2, i3);
        if (i4 < 0) {
            return -1;
        }
        return i4;
    }
}
