当前位置: 首页>>代码示例>>Java>>正文


Java ParametersWithIV.getIV方法代码示例

本文整理汇总了Java中org.bouncycastle.crypto.params.ParametersWithIV.getIV方法的典型用法代码示例。如果您正苦于以下问题:Java ParametersWithIV.getIV方法的具体用法?Java ParametersWithIV.getIV怎么用?Java ParametersWithIV.getIV使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.crypto.params.ParametersWithIV的用法示例。


在下文中一共展示了ParametersWithIV.getIV方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
/**
 * Initialises the GMAC - requires a {@link ParametersWithIV} providing a {@link KeyParameter}
 * and a nonce.
 */
public void init(final CipherParameters params) throws IllegalArgumentException
{
    if (params instanceof ParametersWithIV)
    {
        final ParametersWithIV param = (ParametersWithIV)params;

        final byte[] iv = param.getIV();
        final KeyParameter keyParam = (KeyParameter)param.getParameters();

        // GCM is always operated in encrypt mode to calculate MAC
        cipher.init(true, new AEADParameters(keyParam, macSizeBits, iv));
    }
    else
    {
        throw new IllegalArgumentException("GMAC requires ParametersWithIV");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:GMac.java

示例2: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
public void init(
    boolean             forEncryption, //ignored by this CTR mode
    CipherParameters    params)
    throws IllegalArgumentException
{
    if (params instanceof ParametersWithIV)
    {
      ParametersWithIV ivParam = (ParametersWithIV)params;
      byte[]           iv      = ivParam.getIV();
      System.arraycopy(iv, 0, IV, 0, IV.length);

      reset();

      // if null it's an IV changed only.
      if (ivParam.getParameters() != null)
      {
        cipher.init(true, ivParam.getParameters());
      }
    }
    else
    {
        throw new IllegalArgumentException("SIC mode requires ParametersWithIV");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:SICBlockCipher.java

示例3: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
/**
 * initialise a Salsa20 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)
{
    /* 
    * Salsa20 encryption and decryption is completely
    * symmetrical, so the 'forEncryption' is 
    * irrelevant. (Like 90% of stream ciphers)
    */

    if (!(params instanceof ParametersWithIV))
    {
        throw new IllegalArgumentException("Salsa20 Init parameters must include an IV");
    }

    ParametersWithIV ivParams = (ParametersWithIV) params;

    byte[] iv = ivParams.getIV();

    if (iv == null || iv.length != 8)
    {
        throw new IllegalArgumentException("Salsa20 requires exactly 8 bytes of IV");
    }

    if (!(ivParams.getParameters() instanceof KeyParameter))
    {
        throw new IllegalArgumentException("Salsa20 Init parameters must include a key");
    }

    KeyParameter key = (KeyParameter) ivParams.getParameters();

    workingKey = key.getKey();
    workingIV = iv;

    setKey(workingKey, workingIV);
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:45,代码来源:Salsa20Engine.java

示例4: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
/**
 * Initialise the cipher and, possibly, the initialisation vector (IV).
 * If an IV isn't passed as part of the parameter, the IV will be all zeros.
 *
 * @param encrypting if true the cipher is initialised for
 *  encryption, if false for decryption.
 * @param params the key and other data required by the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean             encrypting,
    CipherParameters    params)
    throws IllegalArgumentException
{
    this.encrypting = encrypting;
    
    if (params instanceof ParametersWithIV)
    {
            ParametersWithIV ivParam = (ParametersWithIV)params;
            byte[]      iv = ivParam.getIV();

            if (iv.length != blockSize)
            {
                throw new IllegalArgumentException("initialisation vector must be the same length as block size");
            }

            System.arraycopy(iv, 0, IV, 0, iv.length);

            reset();

            cipher.init(encrypting, ivParam.getParameters());
    }
    else
    {
            reset();

            cipher.init(encrypting, params);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:41,代码来源:CBCBlockCipher.java

示例5: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
/**
 * Initialise the cipher and, possibly, the initialisation vector (IV).
 * If an IV isn't passed as part of the parameter, the IV will be all zeros.
 * An IV which is too short is handled in FIPS compliant fashion.
 *
 * @param encrypting if true the cipher is initialised for
 *  encryption, if false for decryption.
 * @param params the key and other data required by the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean             encrypting, //ignored by this OFB mode
    CipherParameters    params)
    throws IllegalArgumentException
{
    if (params instanceof ParametersWithIV)
    {
            ParametersWithIV ivParam = (ParametersWithIV)params;
            byte[]      iv = ivParam.getIV();

            if (iv.length < IV.length)
            {
                // prepend the supplied IV with zeros (per FIPS PUB 81)
                System.arraycopy(iv, 0, IV, IV.length - iv.length, iv.length); 
                for (int i = 0; i < IV.length - iv.length; i++)
                {
                    IV[i] = 0;
                }
            }
            else
            {
                System.arraycopy(iv, 0, IV, 0, IV.length);
            }

            reset();

            cipher.init(true, ivParam.getParameters());
    }
    else
    {
            reset();

            cipher.init(true, params);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:47,代码来源:OFBBlockCipher.java

示例6: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
/**
 * Initialise the cipher and, possibly, the initialisation vector (IV).
 * If an IV isn't passed as part of the parameter, the IV will be all zeros.
 * An IV which is too short is handled in FIPS compliant fashion.
 *
 * @param encrypting if true the cipher is initialised for
 *  encryption, if false for decryption.
 * @param params the key and other data required by the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean             encrypting,
    CipherParameters    params)
    throws IllegalArgumentException
{
    this.encrypting = encrypting;
    
    if (params instanceof ParametersWithIV)
    {
            ParametersWithIV ivParam = (ParametersWithIV)params;
            byte[]      iv = ivParam.getIV();

            if (iv.length < IV.length)
            {
                // prepend the supplied IV with zeros (per FIPS PUB 81)
                System.arraycopy(iv, 0, IV, IV.length - iv.length, iv.length);
                for (int i = 0; i < IV.length - iv.length; i++)
                {
                    IV[i] = 0;
                }
            }
            else
            {
                System.arraycopy(iv, 0, IV, 0, IV.length);
            }

            reset();

            cipher.init(true, ivParam.getParameters());
    }
    else
    {
            reset();

            cipher.init(true, params);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:49,代码来源:CFBBlockCipher.java

示例7: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
/**
 * initialise a VMPC 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 ParametersWithIV))
    {
        throw new IllegalArgumentException(
            "VMPC init parameters must include an IV");
    }

    ParametersWithIV ivParams = (ParametersWithIV) params;
    KeyParameter key = (KeyParameter) ivParams.getParameters();

    if (!(ivParams.getParameters() instanceof KeyParameter))
    {
        throw new IllegalArgumentException(
            "VMPC init parameters must include a key");
    }

    this.workingIV = ivParams.getIV();

    if (workingIV == null || workingIV.length < 1 || workingIV.length > 768)
    {
        throw new IllegalArgumentException("VMPC requires 1 to 768 bytes of IV");
    }

    this.workingKey = key.getKey();

    initKey(this.workingKey, this.workingIV);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:39,代码来源:VMPCEngine.java

示例8: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
public void init(CipherParameters params) throws IllegalArgumentException
{
    if (!(params instanceof ParametersWithIV))
    {
        throw new IllegalArgumentException(
            "VMPC-MAC Init parameters must include an IV");
    }

    ParametersWithIV ivParams = (ParametersWithIV) params;
    KeyParameter key = (KeyParameter) ivParams.getParameters();

    if (!(ivParams.getParameters() instanceof KeyParameter))
    {
        throw new IllegalArgumentException(
            "VMPC-MAC Init parameters must include a key");
    }

    this.workingIV = ivParams.getIV();

    if (workingIV == null || workingIV.length < 1 || workingIV.length > 768)
    {
        throw new IllegalArgumentException(
            "VMPC-MAC requires 1 to 768 bytes of IV");
    }

    this.workingKey = key.getKey();

    reset();

}
 
开发者ID:Appdome,项目名称:ipack,代码行数:31,代码来源:VMPCMac.java

示例9: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
/**
 * Initialise the cipher and, possibly, the initialisation vector (IV).
 * If an IV isn't passed as part of the parameter, the IV will be all zeros.
 * An IV which is too short is handled in FIPS compliant fashion.
 *
 * @param param the key and other data required by the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    CipherParameters    params)
    throws IllegalArgumentException
{
    if (params instanceof ParametersWithIV)
    {
            ParametersWithIV ivParam = (ParametersWithIV)params;
            byte[]      iv = ivParam.getIV();

            if (iv.length < IV.length)
            {
                System.arraycopy(iv, 0, IV, IV.length - iv.length, iv.length);
            }
            else
            {
                System.arraycopy(iv, 0, IV, 0, IV.length);
            }

            reset();

            cipher.init(true, ivParam.getParameters());
    }
    else
    {
            reset();

            cipher.init(true, params);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:39,代码来源:CFBBlockCipherMac.java

示例10: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
/**
 * Initialise the cipher and, possibly, the initialisation vector (IV).
 * If an IV isn't passed as part of the parameter, the IV will be all zeros.
 * An IV which is too short is handled in FIPS compliant fashion.
 *
 * @param forEncryption if true the cipher is initialised for
 *  encryption, if false for decryption.
 * @param params the key and other data required by the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean forEncryption,
    CipherParameters params)
    throws IllegalArgumentException
{
    this.forEncryption = forEncryption;
 
    if (params instanceof ParametersWithIV)
    {
            ParametersWithIV ivParam = (ParametersWithIV)params;
            byte[]      iv = ivParam.getIV();

            if (iv.length < IV.length)
            {
                // prepend the supplied IV with zeros (per FIPS PUB 81)
                System.arraycopy(iv, 0, IV, IV.length - iv.length, iv.length);
                for (int i = 0; i < IV.length - iv.length; i++)
                {
                        IV[i] = 0;
                }
            }
            else
            {
                System.arraycopy(iv, 0, IV, 0, IV.length);
            }

            reset();

            cipher.init(true, ivParam.getParameters());
    }
    else
    {
            reset();

            cipher.init(true, params);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:49,代码来源:PGPCFBBlockCipher.java

示例11: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
@Override
public void init(
        final boolean forEncryption, // not used for CTR mode
        final CipherParameters params) {
    final ParametersWithIV ivParams = (ParametersWithIV) params;
    final byte[] iv = ivParams.getIV();
    System.arraycopy(iv, 0, IV, 0, IV.length);
    reset();
    cipher.init(true, ivParams.getParameters());
}
 
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:11,代码来源:CtrBlockCipher.java

示例12: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
/**
 * Initialises the Poly1305 MAC.
 * 
 * @param params if used with a block cipher, then a {@link ParametersWithIV} containing a 128 bit
 *        nonce and a {@link KeyParameter} with a 256 bit key complying to the
 *        {@link Poly1305KeyGenerator Poly1305 key format}, otherwise just the
 *        {@link KeyParameter}.
 */
public void init(CipherParameters params)
    throws IllegalArgumentException
{
    byte[] nonce = null;

    if (cipher != null)
    {
        if (!(params instanceof ParametersWithIV))
        {
            throw new IllegalArgumentException("Poly1305 requires an IV when used with a block cipher.");
        }
        
        ParametersWithIV ivParams = (ParametersWithIV)params;
        nonce = ivParams.getIV();
        params = ivParams.getParameters();
    }

    if (!(params instanceof KeyParameter))
    {
        throw new IllegalArgumentException("Poly1305 requires a key.");
    }

    KeyParameter keyParams = (KeyParameter)params;

    setKey(keyParams.getKey(), nonce);

    reset();
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:37,代码来源:Poly1305.java

示例13: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
/**
 * Initialise the cipher and, possibly, the initialisation vector (IV).
 * If an IV isn't passed as part of the parameter, the IV will be all zeros.
 *
 * @param forEncryption if true the cipher is initialised for
 *  encryption, if false for decryption.
 * @param param the key and other data required by the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean             encrypting,
    CipherParameters    params)
    throws IllegalArgumentException
{
    this.encrypting = encrypting;
    
    if (params instanceof ParametersWithIV)
    {
            ParametersWithIV ivParam = (ParametersWithIV)params;
            byte[]      iv = ivParam.getIV();

            if (iv.length != blockSize)
            {
                throw new IllegalArgumentException("initialisation vector must be the same length as block size");
            }

            System.arraycopy(iv, 0, IV, 0, iv.length);

            reset();

            cipher.init(encrypting, ivParam.getParameters());
    }
    else
    {
            reset();

            cipher.init(encrypting, params);
    }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:41,代码来源:CBCBlockCipher.java

示例14: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
/**
 * Initialise the cipher and, possibly, the initialisation vector (IV).
 * If an IV isn't passed as part of the parameter, the IV will be all zeros.
 * An IV which is too short is handled in FIPS compliant fashion.
 *
 * @param forEncryption if true the cipher is initialised for
 *  encryption, if false for decryption.
 * @param param the key and other data required by the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean             encrypting,
    CipherParameters    params)
    throws IllegalArgumentException
{
    this.encrypting = encrypting;
    
    if (params instanceof ParametersWithIV)
    {
            ParametersWithIV ivParam = (ParametersWithIV)params;
            byte[]      iv = ivParam.getIV();

            if (iv.length < IV.length)
            {
	// prepend the supplied IV with zeros (per FIPS PUB 81)
                System.arraycopy(iv, 0, IV, IV.length - iv.length, iv.length); 
	for (int i = 0; i < IV.length - iv.length; i++)
	{
		IV[i] = 0;
	}
            }
            else
            {
                System.arraycopy(iv, 0, IV, 0, IV.length);
            }

            reset();

            cipher.init(true, ivParam.getParameters());
    }
    else
    {
            reset();

            cipher.init(true, params);
    }
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:49,代码来源:OFBBlockCipher.java

示例15: init

import org.bouncycastle.crypto.params.ParametersWithIV; //导入方法依赖的package包/类
/**
 * Initialize a Grain-128 cipher.
 *
 * @param forEncryption Whether or not we are for encryption.
 * @param params        The parameters required to set up the cipher.
 * @throws IllegalArgumentException If the params argument is inappropriate.
 */
public void init(boolean forEncryption, CipherParameters params)
    throws IllegalArgumentException
{
    /**
     * Grain encryption and decryption is completely symmetrical, so the
     * 'forEncryption' is irrelevant.
     */
    if (!(params instanceof ParametersWithIV))
    {
        throw new IllegalArgumentException(
            "Grain-128 Init parameters must include an IV");
    }

    ParametersWithIV ivParams = (ParametersWithIV)params;

    byte[] iv = ivParams.getIV();

    if (iv == null || iv.length != 12)
    {
        throw new IllegalArgumentException(
            "Grain-128  requires exactly 12 bytes of IV");
    }

    if (!(ivParams.getParameters() instanceof KeyParameter))
    {
        throw new IllegalArgumentException(
            "Grain-128 Init parameters must include a key");
    }

    KeyParameter key = (KeyParameter)ivParams.getParameters();

    /**
     * Initialize variables.
     */
    workingIV = new byte[key.getKey().length];
    workingKey = new byte[key.getKey().length];
    lfsr = new int[STATE_SIZE];
    nfsr = new int[STATE_SIZE];
    out = new byte[4];

    System.arraycopy(iv, 0, workingIV, 0, iv.length);
    System.arraycopy(key.getKey(), 0, workingKey, 0, key.getKey().length);

    setKey(workingKey, workingIV);
    initGrain();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:54,代码来源:Grain128Engine.java


注:本文中的org.bouncycastle.crypto.params.ParametersWithIV.getIV方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。