// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.its;

import org.bouncycastle.util.Arrays;
import org.bouncycastle.oer.its.ieee1609dot2.basetypes.EccP256CurvePoint;
import org.bouncycastle.oer.its.ieee1609dot2.basetypes.EciesP256EncryptedKey;
import org.bouncycastle.oer.its.ieee1609dot2.PKRecipientInfo;
import org.bouncycastle.oer.its.ieee1609dot2.AesCcmCiphertext;
import org.bouncycastle.its.operator.ETSIDataDecryptor;
import org.bouncycastle.oer.its.ieee1609dot2.EncryptedData;
import org.bouncycastle.oer.its.ieee1609dot2.RecipientInfo;

public class ETSIRecipientInfo
{
    private final RecipientInfo recipientInfo;
    private final EncryptedData encryptedData;
    
    public ETSIRecipientInfo(final EncryptedData encryptedData, final RecipientInfo recipientInfo) {
        this.recipientInfo = recipientInfo;
        this.encryptedData = encryptedData;
    }
    
    public ETSIRecipientInfo(final RecipientInfo recipientInfo) {
        this.recipientInfo = recipientInfo;
        this.encryptedData = null;
    }
    
    public RecipientInfo getRecipientInfo() {
        return this.recipientInfo;
    }
    
    public EncryptedData getEncryptedData() {
        return this.encryptedData;
    }
    
    public byte[] getContent(final ETSIDataDecryptor etsiDataDecryptor) {
        if (0 != this.encryptedData.getCiphertext().getChoice()) {
            throw new IllegalArgumentException("Encrypted data is no AES 128 CCM");
        }
        final AesCcmCiphertext instance = AesCcmCiphertext.getInstance(this.encryptedData.getCiphertext().getSymmetricCiphertext());
        final EciesP256EncryptedKey instance2 = EciesP256EncryptedKey.getInstance(PKRecipientInfo.getInstance(this.recipientInfo.getRecipientInfo()).getEncKey().getEncryptedDataEncryptionKey());
        return etsiDataDecryptor.decrypt(Arrays.concatenate(EccP256CurvePoint.getInstance(instance2.getV()).getEncodedPoint(), instance2.getC().getOctets(), instance2.getT().getOctets()), instance.getCcmCiphertext().getContent(), instance.getNonce().getOctets());
    }
}
