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

package org.bouncycastle.jcajce.spec;

import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
import org.bouncycastle.util.Arrays;
import java.security.PrivateKey;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
import java.security.spec.AlgorithmParameterSpec;

public class KEMExtractSpec extends KEMKDFSpec implements AlgorithmParameterSpec
{
    private static final byte[] EMPTY_OTHER_INFO;
    private static AlgorithmIdentifier DefKdf;
    private final PrivateKey privateKey;
    private final byte[] encapsulation;
    
    private KEMExtractSpec(final PrivateKey privateKey, final byte[] array, final String s, final int n, final AlgorithmIdentifier algorithmIdentifier, final byte[] array2) {
        super(algorithmIdentifier, array2, s, n);
        this.privateKey = privateKey;
        this.encapsulation = Arrays.clone(array);
    }
    
    public KEMExtractSpec(final PrivateKey privateKey, final byte[] array, final String s) {
        this(privateKey, array, s, 256);
    }
    
    public KEMExtractSpec(final PrivateKey privateKey, final byte[] array, final String s, final int n) {
        this(privateKey, array, s, n, KEMExtractSpec.DefKdf, KEMExtractSpec.EMPTY_OTHER_INFO);
    }
    
    public byte[] getEncapsulation() {
        return Arrays.clone(this.encapsulation);
    }
    
    public PrivateKey getPrivateKey() {
        return this.privateKey;
    }
    
    static {
        EMPTY_OTHER_INFO = new byte[0];
        KEMExtractSpec.DefKdf = new AlgorithmIdentifier(X9ObjectIdentifiers.id_kdf_kdf3, new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256));
    }
    
    public static final class Builder
    {
        private final PrivateKey privateKey;
        private final byte[] encapsulation;
        private final String algorithmName;
        private final int keySizeInBits;
        private AlgorithmIdentifier kdfAlgorithm;
        private byte[] otherInfo;
        
        public Builder(final PrivateKey privateKey, final byte[] array, final String algorithmName, final int keySizeInBits) {
            this.privateKey = privateKey;
            this.encapsulation = Arrays.clone(array);
            this.algorithmName = algorithmName;
            this.keySizeInBits = keySizeInBits;
            this.kdfAlgorithm = new AlgorithmIdentifier(X9ObjectIdentifiers.id_kdf_kdf3, new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256));
            this.otherInfo = KEMExtractSpec.EMPTY_OTHER_INFO;
        }
        
        public Builder withNoKdf() {
            this.kdfAlgorithm = null;
            return this;
        }
        
        public Builder withKdfAlgorithm(final AlgorithmIdentifier kdfAlgorithm) {
            this.kdfAlgorithm = kdfAlgorithm;
            return this;
        }
        
        public Builder withOtherInfo(final byte[] array) {
            this.otherInfo = ((array == null) ? KEMExtractSpec.EMPTY_OTHER_INFO : Arrays.clone(array));
            return this;
        }
        
        public KEMExtractSpec build() {
            return new KEMExtractSpec(this.privateKey, this.encapsulation, this.algorithmName, this.keySizeInBits, this.kdfAlgorithm, this.otherInfo, null);
        }
    }
}
