public static Cipher createCipher( CipherSpec cipherSpec, int cipherInitMode, SecretKey secretKey, byte[] iv) throws CipherException { logger.log(Level.INFO, "Creating cipher using " + cipherSpec + " ..."); try { if (cipherSpec.needsUnlimitedStrength()) { CipherUtil.enableUnlimitedStrength(); } Cipher cipher = Cipher.getInstance(cipherSpec.getAlgorithm(), PROVIDER); cipher.init(cipherInitMode, secretKey, new IvParameterSpec(iv)); return cipher; } catch (Exception e) { throw new CipherException(e); } }
public static SecretKey createSecretKey(CipherSpec cipherSpec, String password, byte[] salt) throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException { return createSecretKey(cipherSpec.getAlgorithm(), cipherSpec.getKeySize(), password, salt); }