package p138.p176.p278.p279.p284.p285;

import android.annotation.TargetApi;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
import p138.p176.p278.p279.InterfaceC5176;

/* JADX INFO: renamed from: ދ.ހ.ހ.֏.ޙ.֏.ؠ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
@TargetApi(23)
public final class C5236 implements InterfaceC5176 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final SecretKey f15463;

    public C5236(String str) throws NoSuchAlgorithmException, IOException, KeyStoreException, CertificateException {
        KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
        keyStore.load(null);
        this.f15463 = (SecretKey) keyStore.getKey(str, null);
    }

    @Override // p138.p176.p278.p279.InterfaceC5176
    /* JADX INFO: renamed from: ֏ */
    public byte[] mo8647(byte[] bArr, byte[] bArr2) throws GeneralSecurityException {
        if (bArr.length > 2147483619) {
            throw new GeneralSecurityException("plaintext too long");
        }
        byte[] bArr3 = new byte[bArr.length + 12 + 16];
        Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
        cipher.init(1, this.f15463);
        cipher.updateAAD(bArr2);
        cipher.doFinal(bArr, 0, bArr.length, bArr3, 12);
        System.arraycopy(cipher.getIV(), 0, bArr3, 0, 12);
        return bArr3;
    }

    @Override // p138.p176.p278.p279.InterfaceC5176
    /* JADX INFO: renamed from: ؠ */
    public byte[] mo8648(byte[] bArr, byte[] bArr2) throws GeneralSecurityException {
        if (bArr.length < 28) {
            throw new GeneralSecurityException("ciphertext too short");
        }
        GCMParameterSpec gCMParameterSpec = new GCMParameterSpec(128, bArr, 0, 12);
        Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
        cipher.init(2, this.f15463, gCMParameterSpec);
        cipher.updateAAD(bArr2);
        return cipher.doFinal(bArr, 12, bArr.length - 12);
    }
}
