當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。