/** * Returns an initialized cipher for the specified algorithm. The IV will be generated internally (for encryption). If decryption is requested, it will throw an exception. * * @param encryptionMethod the {@link EncryptionMethod} * @param key the key * @param encryptMode true for encrypt, false for decrypt * @return the initialized cipher * @throws Exception if there is a problem initializing the cipher or if decryption is requested */ @Override public Cipher getCipher(EncryptionMethod encryptionMethod, SecretKey key, boolean encryptMode) throws Exception { return getCipher(encryptionMethod, key, new byte[0], encryptMode); }
private Cipher initCipher(EncryptionMethod method, int mode, SecretKey key, byte[] ivBytes) throws EncryptionException { try { if (method == null || key == null || ivBytes == null) { throw new IllegalArgumentException("Missing critical information"); } return aesKeyedCipherProvider.getCipher(method, key, ivBytes, mode == Cipher.ENCRYPT_MODE); } catch (Exception e) { logger.error("Encountered an exception initializing the cipher", e); throw new EncryptionException(e); } }
masterCipher = masterCipherProvider.getCipher(EncryptionMethod.AES_GCM, masterKey, ivBytes, false); } catch (Exception e) { throw new KeyManagementException("Error building cipher to decrypt FileBaseKeyProvider definition at " + filepath, e);
/** * Returns an initialized cipher for the specified algorithm. The IV will be generated internally (for encryption). If decryption is requested, it will throw an exception. * * @param encryptionMethod the {@link EncryptionMethod} * @param key the key * @param encryptMode true for encrypt, false for decrypt * @return the initialized cipher * @throws Exception if there is a problem initializing the cipher or if decryption is requested */ @Override public Cipher getCipher(EncryptionMethod encryptionMethod, SecretKey key, boolean encryptMode) throws Exception { return getCipher(encryptionMethod, key, new byte[0], encryptMode); }
private Cipher initCipher(EncryptionMethod method, int mode, SecretKey key, byte[] ivBytes) throws EncryptionException { try { if (method == null || key == null || ivBytes == null) { throw new IllegalArgumentException("Missing critical information"); } return aesKeyedCipherProvider.getCipher(method, key, ivBytes, mode == Cipher.ENCRYPT_MODE); } catch (Exception e) { logger.error("Encountered an exception initializing the cipher", e); throw new EncryptionException(e); } }
masterCipher = masterCipherProvider.getCipher(EncryptionMethod.AES_GCM, masterKey, ivBytes, false); } catch (Exception e) { throw new KeyManagementException("Error building cipher to decrypt FileBaseKeyProvider definition at " + filepath, e);