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

package org.bouncycastle.oer.its.ieee1609dot2.basetypes;

import org.bouncycastle.asn1.DERTaggedObject;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Choice;
import org.bouncycastle.asn1.ASN1Object;

public class EncryptionKey extends ASN1Object implements ASN1Choice
{
    public static final int publicOption = 0;
    public static final int symmetric = 1;
    private final int choice;
    private final ASN1Encodable encryptionKey;
    
    public static EncryptionKey getInstance(final Object o) {
        if (o instanceof EncryptionKey) {
            return (EncryptionKey)o;
        }
        if (o != null) {
            return new EncryptionKey(ASN1TaggedObject.getInstance(o, 128));
        }
        return null;
    }
    
    public EncryptionKey(final int n, final ASN1Encodable encryptionKey) {
        switch (this.choice = n) {
            case 0:
            case 1: {
                this.encryptionKey = encryptionKey;
                return;
            }
            default: {
                throw new IllegalArgumentException("invalid choice value " + n);
            }
        }
    }
    
    public static EncryptionKey publicOption(final PublicEncryptionKey publicEncryptionKey) {
        return new EncryptionKey(0, publicEncryptionKey);
    }
    
    public static EncryptionKey symmetric(final SymmetricEncryptionKey symmetricEncryptionKey) {
        return new EncryptionKey(1, symmetricEncryptionKey);
    }
    
    private EncryptionKey(final ASN1TaggedObject asn1TaggedObject) {
        this(asn1TaggedObject.getTagNo(), asn1TaggedObject.getExplicitBaseObject());
    }
    
    public int getChoice() {
        return this.choice;
    }
    
    public ASN1Encodable getEncryptionKey() {
        return this.encryptionKey;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new DERTaggedObject(this.choice, this.encryptionKey);
    }
}
