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

package org.bouncycastle.oer.its.ieee1609dot2;

import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.oer.its.ieee1609dot2.basetypes.EciesP256EncryptedKey;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Choice;
import org.bouncycastle.asn1.ASN1Object;

public class EncryptedDataEncryptionKey extends ASN1Object implements ASN1Choice
{
    public static final int eciesNistP256 = 0;
    public static final int eciesBrainpoolP256r1 = 1;
    private final int choice;
    private final ASN1Encodable encryptedDataEncryptionKey;
    
    public EncryptedDataEncryptionKey(final int choice, final ASN1Encodable encryptedDataEncryptionKey) {
        this.choice = choice;
        this.encryptedDataEncryptionKey = encryptedDataEncryptionKey;
    }
    
    private EncryptedDataEncryptionKey(final ASN1TaggedObject asn1TaggedObject) {
        this.choice = asn1TaggedObject.getTagNo();
        switch (asn1TaggedObject.getTagNo()) {
            case 0:
            case 1: {
                this.encryptedDataEncryptionKey = EciesP256EncryptedKey.getInstance(asn1TaggedObject.getExplicitBaseObject());
                return;
            }
            default: {
                throw new IllegalArgumentException("invalid choice value " + asn1TaggedObject.getTagNo());
            }
        }
    }
    
    public static EncryptedDataEncryptionKey getInstance(final Object o) {
        if (o instanceof EncryptedDataEncryptionKey) {
            return (EncryptedDataEncryptionKey)o;
        }
        if (o != null) {
            return new EncryptedDataEncryptionKey(ASN1TaggedObject.getInstance(o, 128));
        }
        return null;
    }
    
    public int getChoice() {
        return this.choice;
    }
    
    public ASN1Encodable getEncryptedDataEncryptionKey() {
        return this.encryptedDataEncryptionKey;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new DERTaggedObject(this.choice, this.encryptedDataEncryptionKey);
    }
    
    public static EncryptedDataEncryptionKey eciesNistP256(final EciesP256EncryptedKey eciesP256EncryptedKey) {
        return new EncryptedDataEncryptionKey(0, eciesP256EncryptedKey);
    }
    
    public static EncryptedDataEncryptionKey eciesBrainpoolP256r1(final EciesP256EncryptedKey eciesP256EncryptedKey) {
        return new EncryptedDataEncryptionKey(1, eciesP256EncryptedKey);
    }
}
