@Override public boolean isSupported() { Cipher alg; try { alg = cipherPool.reuseCipher(); if (alg == null) { Cipher.getInstance("DESede/CBC/NoPadding"); } return true; } catch (NoSuchPaddingException e) { return false; } catch (NoSuchAlgorithmException e) { return false; } }
@Override public boolean isSupported() { Cipher alg; try { alg = cipherPool.reuseCipher(); if (alg == null) { Cipher.getInstance("DESede/CBC/NoPadding"); } return true; } catch (NoSuchPaddingException e) { return false; } catch (NoSuchAlgorithmException e) { return false; } }
protected Cipher doInit(byte[] encryptionKey, byte[] initVect) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, InvalidAlgorithmParameterException { // now do CFB encryption of the plaintext Cipher alg = cipherPool.reuseCipher(); if (alg == null) { alg = Cipher.getInstance(protocolId); } SecretKeySpec key = new SecretKeySpec(encryptionKey, 0, keyBytes, protocolClass); IvParameterSpec ivSpec = new IvParameterSpec(initVect); alg.init(Cipher.ENCRYPT_MODE, key, ivSpec); return alg; }
protected Cipher doInit(byte[] encryptionKey, byte[] initVect) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, InvalidAlgorithmParameterException { // now do CFB encryption of the plaintext Cipher alg = cipherPool.reuseCipher(); if (alg == null) { alg = Cipher.getInstance(protocolId); } SecretKeySpec key = new SecretKeySpec(encryptionKey, 0, keyBytes, protocolClass); IvParameterSpec ivSpec = new IvParameterSpec(initVect); alg.init(Cipher.ENCRYPT_MODE, key, ivSpec); return alg; }
protected byte[] doDecrypt(byte[] cryptedData, int offset, int length, byte[] decryptionKey, byte[] iv) { byte[] decryptedData = null; try { Cipher alg = cipherPool.reuseCipher(); if (alg == null) { alg = Cipher.getInstance(protocolId); } SecretKeySpec key = new SecretKeySpec(decryptionKey, 0, keyBytes, protocolClass); IvParameterSpec ivSpec = new IvParameterSpec(iv); alg.init(Cipher.DECRYPT_MODE, key, ivSpec); decryptedData = alg.doFinal(cryptedData, offset, length); cipherPool.offerCipher(alg); } catch (Exception e) { logger.error(e); if (logger.isDebugEnabled()) { e.printStackTrace(); } } return decryptedData; }
protected byte[] doDecrypt(byte[] cryptedData, int offset, int length, byte[] decryptionKey, byte[] iv) { byte[] decryptedData = null; try { Cipher alg = cipherPool.reuseCipher(); if (alg == null) { alg = Cipher.getInstance(protocolId); } SecretKeySpec key = new SecretKeySpec(decryptionKey, 0, keyBytes, protocolClass); IvParameterSpec ivSpec = new IvParameterSpec(iv); alg.init(Cipher.DECRYPT_MODE, key, ivSpec); decryptedData = alg.doFinal(cryptedData, offset, length); cipherPool.offerCipher(alg); } catch (Exception e) { logger.error(e); if (logger.isDebugEnabled()) { e.printStackTrace(); } } return decryptedData; }
Cipher alg; try { alg = cipherPool.reuseCipher(); if (alg == null) { alg = Cipher.getInstance(protocolId);
Cipher alg; try { alg = cipherPool.reuseCipher(); if (alg == null) { alg = Cipher.getInstance(protocolId);