Java 类org.bouncycastle.crypto.params.ParametersWithSBox 实例源码

项目:ipack    文件:GOST3411Digest.java   
public void reset(Memoable other)
{
    GOST3411Digest t = (GOST3411Digest)other;

    this.sBox = t.sBox;
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();

    System.arraycopy(t.H, 0, this.H, 0, t.H.length);
    System.arraycopy(t.L, 0, this.L, 0, t.L.length);
    System.arraycopy(t.M, 0, this.M, 0, t.M.length);
    System.arraycopy(t.Sum, 0, this.Sum, 0, t.Sum.length);
    System.arraycopy(t.C[1], 0, this.C[1], 0, t.C[1].length);
    System.arraycopy(t.C[2], 0, this.C[2], 0, t.C[2].length);
    System.arraycopy(t.C[3], 0, this.C[3], 0, t.C[3].length);
    System.arraycopy(t.xBuf, 0, this.xBuf, 0, t.xBuf.length);

    this.xBufOff = t.xBufOff;
    this.byteCount = t.byteCount;
}
项目:gwt-crypto    文件:GOST3411Digest.java   
public void reset(Memoable other)
{
    GOST3411Digest t = (GOST3411Digest)other;

    this.sBox = t.sBox;
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();

    System.arraycopy(t.H, 0, this.H, 0, t.H.length);
    System.arraycopy(t.L, 0, this.L, 0, t.L.length);
    System.arraycopy(t.M, 0, this.M, 0, t.M.length);
    System.arraycopy(t.Sum, 0, this.Sum, 0, t.Sum.length);
    System.arraycopy(t.C[1], 0, this.C[1], 0, t.C[1].length);
    System.arraycopy(t.C[2], 0, this.C[2], 0, t.C[2].length);
    System.arraycopy(t.C[3], 0, this.C[3], 0, t.C[3].length);
    System.arraycopy(t.xBuf, 0, this.xBuf, 0, t.xBuf.length);

    this.xBufOff = t.xBufOff;
    this.byteCount = t.byteCount;
}
项目:gwt-crypto    文件:GCFBBlockCipher.java   
public void init(boolean forEncryption, CipherParameters params)
    throws IllegalArgumentException
{
    counter = 0;
    cfbEngine.init(forEncryption, params);

    this.forEncryption = forEncryption;

    if (params instanceof ParametersWithIV)
    {
        params = ((ParametersWithIV)params).getParameters();
    }

    if (params instanceof ParametersWithRandom)
    {
        params = ((ParametersWithRandom)params).getParameters();
    }

    if (params instanceof ParametersWithSBox)
    {
        params = ((ParametersWithSBox)params).getParameters();
    }

    key = (KeyParameter)params;
}
项目:Aki-SSL    文件:GOST3411Digest.java   
public void reset(Memoable other)
{
    GOST3411Digest t = (GOST3411Digest)other;

    this.sBox = t.sBox;
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();

    System.arraycopy(t.H, 0, this.H, 0, t.H.length);
    System.arraycopy(t.L, 0, this.L, 0, t.L.length);
    System.arraycopy(t.M, 0, this.M, 0, t.M.length);
    System.arraycopy(t.Sum, 0, this.Sum, 0, t.Sum.length);
    System.arraycopy(t.C[1], 0, this.C[1], 0, t.C[1].length);
    System.arraycopy(t.C[2], 0, this.C[2], 0, t.C[2].length);
    System.arraycopy(t.C[3], 0, this.C[3], 0, t.C[3].length);
    System.arraycopy(t.xBuf, 0, this.xBuf, 0, t.xBuf.length);

    this.xBufOff = t.xBufOff;
    this.byteCount = t.byteCount;
}
项目:Aki-SSL    文件:GCFBBlockCipher.java   
public void init(boolean forEncryption, CipherParameters params)
    throws IllegalArgumentException
{
    counter = 0;
    cfbEngine.init(forEncryption, params);

    this.forEncryption = forEncryption;

    if (params instanceof ParametersWithIV)
    {
        params = ((ParametersWithIV)params).getParameters();
    }

    if (params instanceof ParametersWithRandom)
    {
        params = ((ParametersWithRandom)params).getParameters();
    }

    if (params instanceof ParametersWithSBox)
    {
        params = ((ParametersWithSBox)params).getParameters();
    }

    key = (KeyParameter)params;
}
项目:TinyTravelTracker    文件:GOST3411Digest.java   
public void reset(Memoable other)
{
    GOST3411Digest t = (GOST3411Digest)other;

    this.sBox = t.sBox;
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();

    System.arraycopy(t.H, 0, this.H, 0, t.H.length);
    System.arraycopy(t.L, 0, this.L, 0, t.L.length);
    System.arraycopy(t.M, 0, this.M, 0, t.M.length);
    System.arraycopy(t.Sum, 0, this.Sum, 0, t.Sum.length);
    System.arraycopy(t.C[1], 0, this.C[1], 0, t.C[1].length);
    System.arraycopy(t.C[2], 0, this.C[2], 0, t.C[2].length);
    System.arraycopy(t.C[3], 0, this.C[3], 0, t.C[3].length);
    System.arraycopy(t.xBuf, 0, this.xBuf, 0, t.xBuf.length);

    this.xBufOff = t.xBufOff;
    this.byteCount = t.byteCount;
}
项目:TinyTravelTracker    文件:GCFBBlockCipher.java   
public void init(boolean forEncryption, CipherParameters params)
    throws IllegalArgumentException
{
    counter = 0;
    cfbEngine.init(forEncryption, params);

    this.forEncryption = forEncryption;

    if (params instanceof ParametersWithIV)
    {
        params = ((ParametersWithIV)params).getParameters();
    }

    if (params instanceof ParametersWithRandom)
    {
        params = ((ParametersWithRandom)params).getParameters();
    }

    if (params instanceof ParametersWithSBox)
    {
        params = ((ParametersWithSBox)params).getParameters();
    }

    key = (KeyParameter)params;
}
项目:CryptMeme    文件:GOST3411Digest.java   
public void reset(Memoable other)
{
    GOST3411Digest t = (GOST3411Digest)other;

    this.sBox = t.sBox;
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();

    System.arraycopy(t.H, 0, this.H, 0, t.H.length);
    System.arraycopy(t.L, 0, this.L, 0, t.L.length);
    System.arraycopy(t.M, 0, this.M, 0, t.M.length);
    System.arraycopy(t.Sum, 0, this.Sum, 0, t.Sum.length);
    System.arraycopy(t.C[1], 0, this.C[1], 0, t.C[1].length);
    System.arraycopy(t.C[2], 0, this.C[2], 0, t.C[2].length);
    System.arraycopy(t.C[3], 0, this.C[3], 0, t.C[3].length);
    System.arraycopy(t.xBuf, 0, this.xBuf, 0, t.xBuf.length);

    this.xBufOff = t.xBufOff;
    this.byteCount = t.byteCount;
}
项目:CryptMeme    文件:GCFBBlockCipher.java   
public void init(boolean forEncryption, CipherParameters params)
    throws IllegalArgumentException
{
    counter = 0;
    cfbEngine.init(forEncryption, params);

    this.forEncryption = forEncryption;

    if (params instanceof ParametersWithIV)
    {
        params = ((ParametersWithIV)params).getParameters();
    }

    if (params instanceof ParametersWithRandom)
    {
        params = ((ParametersWithRandom)params).getParameters();
    }

    if (params instanceof ParametersWithSBox)
    {
        params = ((ParametersWithSBox)params).getParameters();
    }

    key = (KeyParameter)params;
}
项目:irma_future_id    文件:GOST3411Digest.java   
public void reset(Memoable other)
{
    GOST3411Digest t = (GOST3411Digest)other;

    this.sBox = t.sBox;
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();

    System.arraycopy(t.H, 0, this.H, 0, t.H.length);
    System.arraycopy(t.L, 0, this.L, 0, t.L.length);
    System.arraycopy(t.M, 0, this.M, 0, t.M.length);
    System.arraycopy(t.Sum, 0, this.Sum, 0, t.Sum.length);
    System.arraycopy(t.C[1], 0, this.C[1], 0, t.C[1].length);
    System.arraycopy(t.C[2], 0, this.C[2], 0, t.C[2].length);
    System.arraycopy(t.C[3], 0, this.C[3], 0, t.C[3].length);
    System.arraycopy(t.xBuf, 0, this.xBuf, 0, t.xBuf.length);

    this.xBufOff = t.xBufOff;
    this.byteCount = t.byteCount;
}
项目:irma_future_id    文件:GCFBBlockCipher.java   
public void init(boolean forEncryption, CipherParameters params)
    throws IllegalArgumentException
{
    counter = 0;
    cfbEngine.init(forEncryption, params);

    this.forEncryption = forEncryption;

    if (params instanceof ParametersWithIV)
    {
        params = ((ParametersWithIV)params).getParameters();
    }

    if (params instanceof ParametersWithRandom)
    {
        params = ((ParametersWithRandom)params).getParameters();
    }

    if (params instanceof ParametersWithSBox)
    {
        params = ((ParametersWithSBox)params).getParameters();
    }

    key = (KeyParameter)params;
}
项目:bc-java    文件:GOST3411Digest.java   
public void reset(Memoable other)
{
    GOST3411Digest t = (GOST3411Digest)other;

    this.sBox = t.sBox;
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();

    System.arraycopy(t.H, 0, this.H, 0, t.H.length);
    System.arraycopy(t.L, 0, this.L, 0, t.L.length);
    System.arraycopy(t.M, 0, this.M, 0, t.M.length);
    System.arraycopy(t.Sum, 0, this.Sum, 0, t.Sum.length);
    System.arraycopy(t.C[1], 0, this.C[1], 0, t.C[1].length);
    System.arraycopy(t.C[2], 0, this.C[2], 0, t.C[2].length);
    System.arraycopy(t.C[3], 0, this.C[3], 0, t.C[3].length);
    System.arraycopy(t.xBuf, 0, this.xBuf, 0, t.xBuf.length);

    this.xBufOff = t.xBufOff;
    this.byteCount = t.byteCount;
}
项目:bc-java    文件:GCFBBlockCipher.java   
public void init(boolean forEncryption, CipherParameters params)
    throws IllegalArgumentException
{
    counter = 0;
    cfbEngine.init(forEncryption, params);

    this.forEncryption = forEncryption;

    if (params instanceof ParametersWithIV)
    {
        params = ((ParametersWithIV)params).getParameters();
    }

    if (params instanceof ParametersWithRandom)
    {
        params = ((ParametersWithRandom)params).getParameters();
    }

    if (params instanceof ParametersWithSBox)
    {
        params = ((ParametersWithSBox)params).getParameters();
    }

    key = (KeyParameter)params;
}
项目:ipack    文件:GOST28147Engine.java   
/**
 * initialise an GOST28147 cipher.
 *
 * @param forEncryption whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           forEncryption,
    CipherParameters  params)
{
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        byte[] sBox = param.getSBox();
        if (sBox.length != Sbox_Default.length)
        {
            throw new IllegalArgumentException("invalid S-box passed to GOST28147 init");
        }
        this.S = Arrays.clone(sBox);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(forEncryption,
                    ((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(forEncryption,
                              ((KeyParameter)params).getKey());
    }
    else if (params != null)
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:ipack    文件:GOST28147Mac.java   
public void init(
    CipherParameters params)
    throws IllegalArgumentException
{
    reset();
    buf = new byte[blockSize];
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        System.arraycopy(param.getSBox(), 0, this.S, 0, param.getSBox().length);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(((KeyParameter)params).getKey());
    }
    else
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:ipack    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:ipack    文件:GOST3411Digest.java   
/**
 * Constructor to allow use of a particular sbox with GOST28147
 * @see GOST28147Engine#getSBox(String)
 */
public GOST3411Digest(byte[] sBoxParam)
{
    sBox = Arrays.clone(sBoxParam);
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:gwt-crypto    文件:GOST28147Engine.java   
/**
 * initialise an GOST28147 cipher.
 *
 * @param forEncryption whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           forEncryption,
    CipherParameters  params)
{
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        byte[] sBox = param.getSBox();
        if (sBox.length != Sbox_Default.length)
        {
            throw new IllegalArgumentException("invalid S-box passed to GOST28147 init");
        }
        this.S = Arrays.clone(sBox);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(forEncryption,
                    ((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(forEncryption,
                              ((KeyParameter)params).getKey());
    }
    else if (params != null)
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:gwt-crypto    文件:GOST28147Mac.java   
public void init(
    CipherParameters params)
    throws IllegalArgumentException
{
    reset();
    buf = new byte[blockSize];
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        System.arraycopy(param.getSBox(), 0, this.S, 0, param.getSBox().length);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(((KeyParameter)params).getKey());
    }
    else
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:gwt-crypto    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:gwt-crypto    文件:GOST3411Digest.java   
/**
 * Constructor to allow use of a particular sbox with GOST28147
 * @see GOST28147Engine#getSBox(String)
 */
public GOST3411Digest(byte[] sBoxParam)
{
    sBox = Arrays.clone(sBoxParam);
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:Aki-SSL    文件:GOST28147Engine.java   
/**
 * initialise an GOST28147 cipher.
 *
 * @param forEncryption whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           forEncryption,
    CipherParameters  params)
{
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        byte[] sBox = param.getSBox();
        if (sBox.length != Sbox_Default.length)
        {
            throw new IllegalArgumentException("invalid S-box passed to GOST28147 init");
        }
        this.S = Arrays.clone(sBox);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(forEncryption,
                    ((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(forEncryption,
                              ((KeyParameter)params).getKey());
    }
    else if (params != null)
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:Aki-SSL    文件:GOST28147Mac.java   
public void init(
    CipherParameters params)
    throws IllegalArgumentException
{
    reset();
    buf = new byte[blockSize];
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        System.arraycopy(param.getSBox(), 0, this.S, 0, param.getSBox().length);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(((KeyParameter)params).getKey());
    }
    else
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:Aki-SSL    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:Aki-SSL    文件:GOST3411Digest.java   
/**
 * Constructor to allow use of a particular sbox with GOST28147
 * @see GOST28147Engine#getSBox(String)
 */
public GOST3411Digest(byte[] sBoxParam)
{
    sBox = Arrays.clone(sBoxParam);
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:TinyTravelTracker    文件:GOST28147Engine.java   
/**
 * initialise an GOST28147 cipher.
 *
 * @param forEncryption whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           forEncryption,
    CipherParameters  params)
{
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        byte[] sBox = param.getSBox();
        if (sBox.length != Sbox_Default.length)
        {
            throw new IllegalArgumentException("invalid S-box passed to GOST28147 init");
        }
        this.S = Arrays.clone(sBox);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(forEncryption,
                    ((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(forEncryption,
                              ((KeyParameter)params).getKey());
    }
    else if (params != null)
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:TinyTravelTracker    文件:GOST28147Mac.java   
public void init(
    CipherParameters params)
    throws IllegalArgumentException
{
    reset();
    buf = new byte[blockSize];
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        System.arraycopy(param.getSBox(), 0, this.S, 0, param.getSBox().length);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(((KeyParameter)params).getKey());
    }
    else
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:TinyTravelTracker    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:TinyTravelTracker    文件:GOST3411Digest.java   
/**
 * Constructor to allow use of a particular sbox with GOST28147
 * @see GOST28147Engine#getSBox(String)
 */
public GOST3411Digest(byte[] sBoxParam)
{
    sBox = Arrays.clone(sBoxParam);
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:CryptMeme    文件:GOST28147Engine.java   
/**
 * initialise an GOST28147 cipher.
 *
 * @param forEncryption whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           forEncryption,
    CipherParameters  params)
{
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        byte[] sBox = param.getSBox();
        if (sBox.length != Sbox_Default.length)
        {
            throw new IllegalArgumentException("invalid S-box passed to GOST28147 init");
        }
        this.S = Arrays.clone(sBox);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(forEncryption,
                    ((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(forEncryption,
                              ((KeyParameter)params).getKey());
    }
    else if (params != null)
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:CryptMeme    文件:GOST28147Mac.java   
public void init(
    CipherParameters params)
    throws IllegalArgumentException
{
    reset();
    buf = new byte[blockSize];
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        System.arraycopy(param.getSBox(), 0, this.S, 0, param.getSBox().length);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(((KeyParameter)params).getKey());
    }
    else
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:CryptMeme    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:CryptMeme    文件:GOST3411Digest.java   
/**
 * Constructor to allow use of a particular sbox with GOST28147
 * @see GOST28147Engine#getSBox(String)
 */
public GOST3411Digest(byte[] sBoxParam)
{
    sBox = Arrays.clone(sBoxParam);
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:irma_future_id    文件:GOST28147Engine.java   
/**
 * initialise an GOST28147 cipher.
 *
 * @param forEncryption whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           forEncryption,
    CipherParameters  params)
{
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        byte[] sBox = param.getSBox();
        if (sBox.length != Sbox_Default.length)
        {
            throw new IllegalArgumentException("invalid S-box passed to GOST28147 init");
        }
        this.S = Arrays.clone(sBox);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(forEncryption,
                    ((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(forEncryption,
                              ((KeyParameter)params).getKey());
    }
    else if (params != null)
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:irma_future_id    文件:GOST28147Mac.java   
public void init(
    CipherParameters params)
    throws IllegalArgumentException
{
    reset();
    buf = new byte[blockSize];
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        System.arraycopy(param.getSBox(), 0, this.S, 0, param.getSBox().length);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(((KeyParameter)params).getKey());
    }
    else
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:irma_future_id    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:irma_future_id    文件:GOST3411Digest.java   
/**
 * Constructor to allow use of a particular sbox with GOST28147
 * @see GOST28147Engine#getSBox(String)
 */
public GOST3411Digest(byte[] sBoxParam)
{
    sBox = Arrays.clone(sBoxParam);
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}
项目:bc-java    文件:GOST28147Engine.java   
/**
 * initialise an GOST28147 cipher.
 *
 * @param forEncryption whether or not we are for encryption.
 * @param params the parameters required to set up the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean           forEncryption,
    CipherParameters  params)
{
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        byte[] sBox = param.getSBox();
        if (sBox.length != Sbox_Default.length)
        {
            throw new IllegalArgumentException("invalid S-box passed to GOST28147 init");
        }
        this.S = Arrays.clone(sBox);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(forEncryption,
                    ((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(forEncryption,
                              ((KeyParameter)params).getKey());
    }
    else if (params != null)
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:bc-java    文件:GOST28147Mac.java   
public void init(
    CipherParameters params)
    throws IllegalArgumentException
{
    reset();
    buf = new byte[blockSize];
    if (params instanceof ParametersWithSBox)
    {
        ParametersWithSBox   param = (ParametersWithSBox)params;

        //
        // Set the S-Box
        //
        System.arraycopy(param.getSBox(), 0, this.S, 0, param.getSBox().length);

        //
        // set key if there is one
        //
        if (param.getParameters() != null)
        {
            workingKey = generateWorkingKey(((KeyParameter)param.getParameters()).getKey());
        }
    }
    else if (params instanceof KeyParameter)
    {
        workingKey = generateWorkingKey(((KeyParameter)params).getKey());
    }
    else
    {
       throw new IllegalArgumentException("invalid parameter passed to GOST28147 init - " + params.getClass().getName());
    }
}
项目:bc-java    文件:GOST3411Digest.java   
/**
 * Standard constructor
 */
public GOST3411Digest()
{
    sBox = GOST28147Engine.getSBox("D-A");
    cipher.init(true, new ParametersWithSBox(null, sBox));

    reset();
}