PaddedBufferedBlockCipher aes = new PaddedBufferedBlockCipher(new CBCBlockCipher( new AESEngine())); CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key), iv); PaddedBufferedBlockCipher aes = new PaddedBufferedBlockCipher(new CBCBlockCipher( new AESEngine())); CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(key), iv);
protected BrokenJCEBlockCipher( BlockCipher engine, int pbeType, int pbeHash, int pbeKeySize, int pbeIvSize) { cipher = new PaddedBufferedBlockCipher(engine); this.pbeType = pbeType; this.pbeHash = pbeHash; this.pbeKeySize = pbeKeySize; this.pbeIvSize = pbeIvSize; }
BufferedGenericBlockCipher(org.spongycastle.crypto.BlockCipher cipher, BlockCipherPadding padding) { this.cipher = new PaddedBufferedBlockCipher(cipher, padding); }
BufferedGenericBlockCipher(BlockCipher cipher) { this.cipher = new PaddedBufferedBlockCipher(cipher); }
BufferedGenericBlockCipher(BlockCipher cipher, BlockCipherPadding padding) { this.cipher = new PaddedBufferedBlockCipher(cipher, padding); }
BufferedGenericBlockCipher(org.spongycastle.crypto.BlockCipher cipher) { this.cipher = new PaddedBufferedBlockCipher(cipher); }
protected BrokenJCEBlockCipher( BlockCipher engine, int pbeType, int pbeHash, int pbeKeySize, int pbeIvSize) { cipher = new PaddedBufferedBlockCipher(engine); this.pbeType = pbeType; this.pbeHash = pbeHash; this.pbeKeySize = pbeKeySize; this.pbeIvSize = pbeIvSize; }
BufferedGenericBlockCipher(org.spongycastle.crypto.BlockCipher cipher) { this.cipher = new PaddedBufferedBlockCipher(cipher); }
BufferedGenericBlockCipher(org.spongycastle.crypto.BlockCipher cipher, BlockCipherPadding padding) { this.cipher = new PaddedBufferedBlockCipher(cipher, padding); }
public BcPKCS12PBEOutputEncryptorBuilder(ASN1ObjectIdentifier algorithm, BlockCipher engine, ExtendedDigest pbeDigest) { this.algorithm = algorithm; this.engine = new PaddedBufferedBlockCipher(engine, new PKCS7Padding()); this.digest = pbeDigest; }
public BcPKCS12PBEOutputEncryptorBuilder(ASN1ObjectIdentifier algorithm, BlockCipher engine, ExtendedDigest pbeDigest) { this.algorithm = algorithm; this.engine = new PaddedBufferedBlockCipher(engine, new PKCS7Padding()); this.digest = pbeDigest; }
String decrypt(byte[] cryptoBytes, byte[] key, byte[] iv) { BlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESEngine())); cipher.init(false, new ParametersWithIV(new KeyParameter(key), iv)); byte[] out = new byte[cipher.getOutputSize(cryptoBytes.length)]; int offset = cipher.processBytes(cryptoBytes, 0, cryptoBytes.length, out, 0); cipher.doFinal(out, offset); return new String(out); }
public ECIESwithCipher(BlockCipher cipher, int ivLength) { super(new IESEngine(new ECDHBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA1()), new HMac(DigestFactory.createSHA1()), new PaddedBufferedBlockCipher(cipher)), ivLength); } }
/** Creates a new instance of AESCipher */ public AESCipher(boolean forEncryption, byte[] key, byte[] iv) { BlockCipher aes = new AESFastEngine(); BlockCipher cbc = new CBCBlockCipher(aes); bp = new PaddedBufferedBlockCipher(cbc); KeyParameter kp = new KeyParameter(key); ParametersWithIV piv = new ParametersWithIV(kp, iv); bp.init(forEncryption, piv); }
public IESwithDESedeCBC() { super(new IESEngine(new DHBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA1()), new HMac(DigestFactory.createSHA1()), new PaddedBufferedBlockCipher(new CBCBlockCipher(new DESedeEngine()))), 8); } }
public IESwithAESCBC() { super(new IESEngine(new DHBasicAgreement(), new KDF2BytesGenerator(DigestFactory.createSHA1()), new HMac(DigestFactory.createSHA1()), new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESEngine()))), 16); } }
/** * Create an encrypted output stream from an unencrypted output stream */ public static OutputStream getEncryptedOutputStream (OutputStream decryptedOutputStream, byte[] keyData, byte[] ivData) { final ParametersWithIV keyAndIV = new ParametersWithIV(new KeyParameter(keyData), ivData); PaddedBufferedBlockCipher pbbc = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine())); pbbc.init(true, keyAndIV); return new CipherOutputStream(decryptedOutputStream, pbbc); } }
/** * Create a decrypted input stream from an encrypted one */ public static InputStream getDecryptedInputStream (InputStream encryptedInputStream, byte[] keyData, byte[] ivData) { final ParametersWithIV keyAndIV = new ParametersWithIV(new KeyParameter(keyData), ivData); PaddedBufferedBlockCipher pbbc = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine())); pbbc.init(false, keyAndIV); return new CipherInputStream(encryptedInputStream, pbbc); }
/** * Get a cipher * * @param mode encryption or decryption * @param iv a 16 byte iv * @return an initialised Cipher */ PaddedBufferedBlockCipher getCipher(CMode mode, byte[] iv) { PaddedBufferedBlockCipher result = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine())); result.init(mode.getEncrypt(), new ParametersWithIV(new KeyParameter(getKey()), iv)); return result; }
public static byte[] decrypt(EncryptedData dataToDecrypt, KeyParameter aesKey) throws CryptoException { Util.checkNotNull(dataToDecrypt); Util.checkNotNull(aesKey); try { ParametersWithIV keyWithIv = new ParametersWithIV(new KeyParameter(aesKey.getKey()), dataToDecrypt.getInitialisationVector()); // Decrypt the validator. BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine())); cipher.init(false, keyWithIv); byte[] cipherBytes = dataToDecrypt.getEncryptedBytes(); byte[] decryptedBytes = new byte[cipher.getOutputSize(cipherBytes.length)]; final int length1 = cipher.processBytes(cipherBytes, 0, cipherBytes.length, decryptedBytes, 0); final int length2 = cipher.doFinal(decryptedBytes, length1); return Arrays.copyOf(decryptedBytes, length1 + length2); } catch (Exception e) { throw new CryptoException(); } }