Java 8 IvParameterSpec - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 IvParameterSpec class.

This code example shows how to use the following methods:
        char[]  password,
        String  dekAlgName,
        byte[]  iv)
        throws IOException 
    { 
        AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv);
        String                 alg;
        String                 blockMode = "CBC";
        String                 padding = "PKCS5Padding";
        Key                    sKey;
 
        // Figure out block mode and padding. 
        if (dekAlgName.endsWith("-CFB"))
        { 
            blockMode = "CFB";
            padding = "NoPadding";
        } 
        if (dekAlgName.endsWith("-ECB") ||
            "DES-EDE".equals(dekAlgName) ||
            "DES-EDE3".equals(dekAlgName))
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
		byte[] iv = new byte[]
     	{ 
     	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00 
     	}; 
	     
		AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv);
    	 
		SecretKeySpec skeySpec = new SecretKeySpec(m_dbKeyData, "AES");  
		m_encryptCipher = Cipher.getInstance("AES/CBC/NoPadding");  
		m_encryptCipher.init(Cipher.ENCRYPT_MODE, skeySpec, paramSpec);
 
		m_decryptCipher = Cipher.getInstance("AES/CBC/NoPadding");  
		m_decryptCipher.init(Cipher.DECRYPT_MODE, skeySpec, paramSpec);
		 
        Logger.T(TAG, "RhoCrypt context initialized for partition: " + szPartition);
    } 
 
    public boolean db_encrypt( String szPartition, ByteBuffer dataIn, ByteBuffer dataOut )
    { 
        try 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getIV
        } 
 
        if (params instanceof javax.crypto.spec.IvParameterSpec)
        { 
            IvParameterSpec iv = (IvParameterSpec) params;
            param = new ParametersWithIV(param, iv.getIV());
        } 
 
        if (param instanceof KeyParameter && ivSize != 0)
        { 
            iv = new byte[ivSize];
            random.nextBytes(iv);
            param = new ParametersWithIV(param, iv);
        } 
 
        switch (opmode)
        { 
        case Cipher.WRAP_MODE:
            wrapEngine.init(true, param);
            break; 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
      Cipher cipher = Cipher.getInstance("AES/CTR/NoPadding");
 
      byte[] ivBytes = new byte[16];
      Conversions.mediumToByteArray(ivBytes, 0, counter);
		 
      IvParameterSpec iv = new IvParameterSpec(ivBytes);
      cipher.init(mode, key, iv);
		 
      return cipher;
    } catch (NoSuchAlgorithmException e) {
      throw new IllegalArgumentException("AES Not Supported!");
    } catch (NoSuchPaddingException e) {
      throw new IllegalArgumentException("NoPadding Not Supported!");
    } catch (InvalidKeyException e) {
      Log.w("SessionCipher", e);
      throw new IllegalArgumentException("Invaid Key?");
    } catch (InvalidAlgorithmParameterException e) {
      Log.w("SessionCipher", e);
      throw new IllegalArgumentException("Bad IV?");
    } 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
      throw new InvalidEncryptedSignalException("Message shorter than IV length."); 
 
    System.arraycopy(messageBytes, IV_OFFSET, ivBytes, 0, ivBytes.length);
 
    Cipher cipher      = Cipher.getInstance("AES/CBC/PKCS5Padding");
    IvParameterSpec iv = new IvParameterSpec(ivBytes);
    cipher.init(Cipher.DECRYPT_MODE, cipherKey, iv);
 
    return cipher;
  } 
 
  public byte[] getPlaintext() throws InvalidEncryptedSignalException { 
    try { 
      byte[] messageBytes = Base64.decode(this.message);
 
      if (!isValidVersion(messageBytes))
        throw new InvalidEncryptedSignalException("Unknown version: " + 
                                                  (byte)messageBytes[VERSION_OFFSET]);
 
      if (!verifyMac(messageBytes))
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        char[]  password,
        String  dekAlgName,
        byte[]  iv)
        throws IOException 
    { 
        AlgorithmParameterSpec paramSpec = new IvParameterSpec(iv);
        String                 alg;
        String                 blockMode = "CBC";
        String                 padding = "PKCS5Padding";
        Key                    sKey;
 
        // Figure out block mode and padding. 
        if (dekAlgName.endsWith("-CFB"))
        { 
            blockMode = "CFB";
            padding = "NoPadding";
        } 
        if (dekAlgName.endsWith("-ECB") ||
            "DES-EDE".equals(dekAlgName) ||
            "DES-EDE3".equals(dekAlgName))
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    private static final byte[] parameterData = new byte[] { 
        (byte) 0x04, (byte) 0x08, (byte) 0x68, (byte) 0xC8, 
        (byte) 0xFF, (byte) 0x64, (byte) 0x72, (byte) 0xF5 }; 
 
    public AlgorithmParametersTestDESede() { 
        super("DESede", new AlgorithmParameterSymmetricHelper("DESede", "CBC/PKCS5PADDING", 112), new IvParameterSpec(parameterData)); 
    } 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    private static final byte[] parameterData = new byte[] { 
        (byte) 0x04, (byte) 0x08, (byte) 0x68, (byte) 0xC8, 
        (byte) 0xFF, (byte) 0x64, (byte) 0x72, (byte) 0xF5 }; 
 
    public AlgorithmParametersTestDES() { 
        super("DES", new AlgorithmParameterSymmetricHelper("DES", "CBC/PKCS5PADDING", 56), new IvParameterSpec(parameterData)); 
    } 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        (byte) 0xFF, (byte) 0x64, (byte) 0x72, (byte) 0xF5, 
        (byte) 0x04, (byte) 0x08, (byte) 0x68, (byte) 0xC8, 
        (byte) 0xFF, (byte) 0x64, (byte) 0x72, (byte) 0xF5 }; 
 
    public AlgorithmParametersTestAES() { 
        super("AES", new AlgorithmParameterSymmetricHelper("AES", "CBC/PKCS5PADDING", 128), new IvParameterSpec(parameterData)); 
    } 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
    @Override 
    void initializeCipher(Cipher cipher, int opmode, Key key) throws GeneralSecurityException {
        byte[] iv = new byte[16];
        secureRandom.nextBytes(iv);
        AlgorithmParameterSpec params = new IvParameterSpec(iv);
        cipher.init(opmode, key, params);
    } 
 
    int getKeyLength() { 
        return 128; // XXX policy files 
    } 
         
    @Override 
    Key getLocalKey(boolean init) throws IOException, GeneralSecurityException {
         
        byte [] rawKey = null;
        try { 
            if (init) {
                // generate a new key 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Java 8 IvParameterSpec Questions & Answers:

See Code Examples for Java 8 IvParameterSpec Methods: