public Priv3DES() { super.initVectorLength = INIT_VECTOR_LENGTH; super.protocolId = PROTOCOL_ID; super.protocolClass = PROTOCOL_CLASS; super.keyBytes = KEY_LENGTH; this.salt = Salt.getInstance(); cipherPool = new CipherPool(); }
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; }
@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; } }
cipherPool.offerCipher(alg);
@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; } }
cipherPool.offerCipher(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; }
public PrivDES() { super.initVectorLength = INIT_VECTOR_LENGTH; super.protocolId = PROTOCOL_ID; super.protocolClass = PROTOCOL_CLASS; super.keyBytes = KEY_LENGTH; this.salt = Salt.getInstance(); cipherPool = new CipherPool(); }
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; }
Cipher alg = doInit(encryptionKey, initVect); encryptedData = alg.doFinal(unencryptedData, offset, length); cipherPool.offerCipher(alg);
public Priv3DES() { super.initVectorLength = INIT_VECTOR_LENGTH; super.protocolId = PROTOCOL_ID; super.protocolClass = PROTOCOL_CLASS; super.keyBytes = KEY_LENGTH; this.salt = Salt.getInstance(); cipherPool = new CipherPool(); }
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; }
cipherPool.offerCipher(alg);
public PrivDES() { super.initVectorLength = INIT_VECTOR_LENGTH; super.protocolId = PROTOCOL_ID; super.protocolClass = PROTOCOL_CLASS; super.keyBytes = KEY_LENGTH; this.salt = Salt.getInstance(); cipherPool = new CipherPool(); }
Cipher alg; try { alg = cipherPool.reuseCipher(); if (alg == null) { alg = Cipher.getInstance(protocolId);
cipherPool.offerCipher(alg);
/** * Constructor. * * @param keyBytes * Length of key, must be 16, 24 or 32. * @throws IllegalArgumentException * if keyBytes is illegal */ public PrivAES(int keyBytes) { super.initVectorLength = INIT_VECTOR_LENGTH; super.protocolId = PROTOCOL_ID; super.protocolClass = PROTOCOL_CLASS; if ((keyBytes != 16) && (keyBytes != 24) && (keyBytes != 32)) { throw new IllegalArgumentException( "Only 128, 192 and 256 bit AES is allowed. Requested (" + (8 * keyBytes) + ")."); } this.keyBytes = keyBytes; this.salt = Salt.getInstance(); cipherPool = new CipherPool(); }
Cipher alg; try { alg = cipherPool.reuseCipher(); if (alg == null) { alg = Cipher.getInstance(protocolId);
Cipher alg = doInit(encryptionKey, initVect); encryptedData = alg.doFinal(unencryptedData, offset, length); cipherPool.offerCipher(alg);
/** * Constructor. * * @param keyBytes * Length of key, must be 16, 24 or 32. * @throws IllegalArgumentException * if keyBytes is illegal */ public PrivAES(int keyBytes) { super.initVectorLength = INIT_VECTOR_LENGTH; super.protocolId = PROTOCOL_ID; super.protocolClass = PROTOCOL_CLASS; if ((keyBytes != 16) && (keyBytes != 24) && (keyBytes != 32)) { throw new IllegalArgumentException( "Only 128, 192 and 256 bit AES is allowed. Requested (" + (8 * keyBytes) + ")."); } this.keyBytes = keyBytes; this.salt = Salt.getInstance(); cipherPool = new CipherPool(); }