Search in sources :

Example 1 with TwofishEngine

use of org.bouncycastle.crypto.engines.TwofishEngine in project syncany by syncany.

the class TwofishGcmCipherSpec method newCipherInputStream.

@Override
public InputStream newCipherInputStream(InputStream underlyingInputStream, byte[] secretKey, byte[] iv) throws CipherException {
    AEADBlockCipher cipher = new GCMBlockCipher(new TwofishEngine());
    cipher.init(false, new AEADParameters(new KeyParameter(secretKey), MAC_SIZE, iv));
    return new org.bouncycastle.crypto.io.CipherInputStream(underlyingInputStream, cipher);
}
Also used : AEADParameters(org.bouncycastle.crypto.params.AEADParameters) KeyParameter(org.bouncycastle.crypto.params.KeyParameter) TwofishEngine(org.bouncycastle.crypto.engines.TwofishEngine) GCMBlockCipher(org.bouncycastle.crypto.modes.GCMBlockCipher) AEADBlockCipher(org.bouncycastle.crypto.modes.AEADBlockCipher)

Example 2 with TwofishEngine

use of org.bouncycastle.crypto.engines.TwofishEngine in project syncany by syncany.

the class TwofishGcmCipherSpec method newCipherOutputStream.

@Override
public OutputStream newCipherOutputStream(OutputStream underlyingOutputStream, byte[] secretKey, byte[] iv) throws CipherException {
    AEADBlockCipher cipher = new GCMBlockCipher(new TwofishEngine());
    cipher.init(true, new AEADParameters(new KeyParameter(secretKey), MAC_SIZE, iv));
    return new org.bouncycastle.crypto.io.CipherOutputStream(underlyingOutputStream, cipher);
}
Also used : AEADParameters(org.bouncycastle.crypto.params.AEADParameters) KeyParameter(org.bouncycastle.crypto.params.KeyParameter) TwofishEngine(org.bouncycastle.crypto.engines.TwofishEngine) GCMBlockCipher(org.bouncycastle.crypto.modes.GCMBlockCipher) AEADBlockCipher(org.bouncycastle.crypto.modes.AEADBlockCipher)

Aggregations

TwofishEngine (org.bouncycastle.crypto.engines.TwofishEngine)2 AEADBlockCipher (org.bouncycastle.crypto.modes.AEADBlockCipher)2 GCMBlockCipher (org.bouncycastle.crypto.modes.GCMBlockCipher)2 AEADParameters (org.bouncycastle.crypto.params.AEADParameters)2 KeyParameter (org.bouncycastle.crypto.params.KeyParameter)2