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

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

import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.util.Arrays;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Object;

public class EciesP256EncryptedKey extends ASN1Object
{
    private final EccP256CurvePoint v;
    private final ASN1OctetString c;
    private final ASN1OctetString t;
    
    public EciesP256EncryptedKey(final EccP256CurvePoint v, final ASN1OctetString c, final ASN1OctetString t) {
        this.v = v;
        this.c = c;
        this.t = t;
    }
    
    public static EciesP256EncryptedKey getInstance(final Object o) {
        if (o instanceof EciesP256EncryptedKey) {
            return (EciesP256EncryptedKey)o;
        }
        if (o != null) {
            return new EciesP256EncryptedKey(ASN1Sequence.getInstance(o));
        }
        return null;
    }
    
    private EciesP256EncryptedKey(final ASN1Sequence asn1Sequence) {
        if (asn1Sequence.size() != 3) {
            throw new IllegalArgumentException("expected sequence size of 3");
        }
        this.v = EccP256CurvePoint.getInstance(asn1Sequence.getObjectAt(0));
        this.c = ASN1OctetString.getInstance(asn1Sequence.getObjectAt(1));
        this.t = ASN1OctetString.getInstance(asn1Sequence.getObjectAt(2));
    }
    
    public EccP256CurvePoint getV() {
        return this.v;
    }
    
    public ASN1OctetString getC() {
        return this.c;
    }
    
    public ASN1OctetString getT() {
        return this.t;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new DERSequence(new ASN1Encodable[] { this.v, this.c, this.t });
    }
    
    public static Builder builder() {
        return new Builder();
    }
    
    public static class Builder
    {
        private EccP256CurvePoint v;
        private ASN1OctetString c;
        private ASN1OctetString t;
        
        public Builder setV(final EccP256CurvePoint v) {
            this.v = v;
            return this;
        }
        
        public Builder setC(final ASN1OctetString c) {
            this.c = c;
            return this;
        }
        
        public Builder setC(final byte[] array) {
            this.c = new DEROctetString(Arrays.clone(array));
            return this;
        }
        
        public Builder setT(final ASN1OctetString t) {
            this.t = t;
            return this;
        }
        
        public Builder setT(final byte[] array) {
            this.t = new DEROctetString(Arrays.clone(array));
            return this;
        }
        
        public EciesP256EncryptedKey createEciesP256EncryptedKey() {
            return new EciesP256EncryptedKey(this.v, this.c, this.t);
        }
    }
}
