package p138.p329.p357.p359;

import com.hierynomus.security.SecurityException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Provider;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.ShortBufferException;
import javax.crypto.spec.SecretKeySpec;
import p138.p329.p357.InterfaceC6308;

/* JADX INFO: renamed from: ދ.ށ.އ.ރ.֏, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C6327 implements InterfaceC6308 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public Cipher f17663;

    public C6327(String str, Provider provider, String str2) throws SecurityException {
        try {
            if (provider != null) {
                this.f17663 = Cipher.getInstance(str, provider);
            } else if (str2 != null) {
                this.f17663 = Cipher.getInstance(str, str2);
            } else {
                this.f17663 = Cipher.getInstance(str);
            }
        } catch (NoSuchAlgorithmException e) {
            e = e;
            throw new SecurityException(e);
        } catch (NoSuchProviderException e2) {
            e = e2;
            throw new SecurityException(e);
        } catch (NoSuchPaddingException e3) {
            e = e3;
            throw new SecurityException(e);
        }
    }

    @Override // p138.p329.p357.InterfaceC6308
    /* JADX INFO: renamed from: ֏ */
    public int mo9541(byte[] bArr, int i) throws SecurityException {
        try {
            return this.f17663.doFinal(bArr, i);
        } catch (BadPaddingException | IllegalBlockSizeException | ShortBufferException e) {
            throw new SecurityException(e);
        }
    }

    @Override // p138.p329.p357.InterfaceC6308
    /* JADX INFO: renamed from: ֏ */
    public int mo9542(byte[] bArr, int i, int i2, byte[] bArr2, int i3) throws SecurityException {
        try {
            return this.f17663.update(bArr, i, i2, bArr2, i3);
        } catch (ShortBufferException e) {
            throw new SecurityException(e);
        }
    }

    @Override // p138.p329.p357.InterfaceC6308
    /* JADX INFO: renamed from: ֏ */
    public void mo9543(InterfaceC6308.EnumC6309 enumC6309, byte[] bArr) throws SecurityException {
        try {
            if (InterfaceC6308.EnumC6309.DECRYPT == enumC6309) {
                this.f17663.init(2, new SecretKeySpec(bArr, this.f17663.getAlgorithm().split("/")[0]));
            } else {
                this.f17663.init(1, new SecretKeySpec(bArr, this.f17663.getAlgorithm().split("/")[0]));
            }
        } catch (InvalidKeyException e) {
            throw new SecurityException(e);
        }
    }
}
