List of usage examples for org.bouncycastle.crypto.engines ChaChaEngine ChaChaEngine
public ChaChaEngine()
From source file:at.archistar.crypto.symmetric.ChaCha20Encryptor.java
@Override public byte[] encrypt(byte[] data, byte[] randomKeyBytes) throws IOException, InvalidKeyException, InvalidAlgorithmParameterException, InvalidCipherTextException, ImpossibleException { ChaChaEngine cipher = new ChaChaEngine(); cipher.init(true, new ParametersWithIV(new KeyParameter(randomKeyBytes), randomIvBytes)); byte[] result = new byte[data.length]; cipher.processBytes(data, 0, data.length, result, 0); return result; }
From source file:at.archistar.crypto.symmetric.ChaCha20Encryptor.java
@Override public byte[] decrypt(byte[] data, byte[] randomKeyBytes) throws InvalidKeyException, InvalidAlgorithmParameterException, IOException, ImpossibleException, IllegalStateException, InvalidCipherTextException { ChaChaEngine cipher = new ChaChaEngine(); cipher.init(false, new ParametersWithIV(new KeyParameter(randomKeyBytes), randomIvBytes)); byte[] result = new byte[data.length]; cipher.processBytes(data, 0, data.length, result, 0); return result; }
From source file:ch.lamacrypt.internal.crypto.CPCipher.java
License:Open Source License
public CPCipher() throws IOException { this.cipher = new ChaChaEngine(); this.mac = new Poly1305(); }
From source file:freenet.crypt.EncryptedRandomAccessBufferType.java
License:GNU General Public License
/** * Returns an instance of the SkippingStreamCipher the goes with the current enum value. *///from ww w. j ava2 s .c o m public final SkippingStreamCipher get() { return new ChaChaEngine(); }
From source file:shadowsocks.crypto.Chacha20Crypto.java
License:Apache License
@Override protected StreamCipher createCipher(byte[] iv, boolean encrypt) throws CryptoException { StreamCipher c;/*from ww w .ja v a 2 s .c om*/ if (mName.equals(CIPHER_CHACHA20_IETF)) { c = new ChaCha7539Engine(); } else { c = new ChaChaEngine(); } ParametersWithIV parameterIV = new ParametersWithIV(new KeyParameter(mKey), iv, 0, mIVLength); c.init(encrypt, parameterIV); return c; }