// 
// 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.DEROctetString;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Choice;
import org.bouncycastle.asn1.ASN1Object;

public class SymmetricEncryptionKey extends ASN1Object implements ASN1Choice
{
    public static final int aes128ccm = 0;
    private final int choice;
    private final ASN1Encodable symmetricEncryptionKey;
    
    public SymmetricEncryptionKey(final int choice, final ASN1Encodable symmetricEncryptionKey) {
        this.choice = choice;
        this.symmetricEncryptionKey = symmetricEncryptionKey;
    }
    
    private SymmetricEncryptionKey(final ASN1TaggedObject asn1TaggedObject) {
        this.choice = asn1TaggedObject.getTagNo();
        if (this.choice != 0) {
            throw new IllegalArgumentException("invalid choice value " + this.choice);
        }
        final ASN1OctetString instance = ASN1OctetString.getInstance(asn1TaggedObject.getExplicitBaseObject());
        if (instance.getOctets().length != 16) {
            throw new IllegalArgumentException("aes128ccm string not 16 bytes");
        }
        this.symmetricEncryptionKey = instance;
    }
    
    public static SymmetricEncryptionKey getInstance(final Object o) {
        if (o instanceof SymmetricEncryptionKey) {
            return (SymmetricEncryptionKey)o;
        }
        if (o != null) {
            return new SymmetricEncryptionKey(ASN1TaggedObject.getInstance(o, 128));
        }
        return null;
    }
    
    public static SymmetricEncryptionKey aes128ccm(final byte[] array) {
        return new SymmetricEncryptionKey(0, new DEROctetString(array));
    }
    
    public static SymmetricEncryptionKey aes128ccm(final ASN1OctetString asn1OctetString) {
        return new SymmetricEncryptionKey(0, asn1OctetString);
    }
    
    public int getChoice() {
        return this.choice;
    }
    
    public ASN1Encodable getSymmetricEncryptionKey() {
        return this.symmetricEncryptionKey;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new DERTaggedObject(this.choice, this.symmetricEncryptionKey);
    }
}
