diff --git a/briar-api/src/org/briarproject/api/crypto/AuthenticatedCipher.java b/briar-api/src/org/briarproject/api/crypto/AuthenticatedCipher.java
index 1b857b64e177eba44cbd4b5fd8087f4de3e8f21d..1a6d955229509fc9888ff2e11f94eaf5500b8bc3 100644
--- a/briar-api/src/org/briarproject/api/crypto/AuthenticatedCipher.java
+++ b/briar-api/src/org/briarproject/api/crypto/AuthenticatedCipher.java
@@ -9,7 +9,7 @@ public interface AuthenticatedCipher {
 	 * Initializes this cipher with a key, an initialisation vector (IV) and
 	 * additional authenticated data (AAD).
 	 */
-	void init(int opmode, SecretKey key, byte[] iv, byte[] aad)
+	void init(boolean encrypt, SecretKey key, byte[] iv, byte[] aad)
 			throws GeneralSecurityException;
 
 	/** Encrypts or decrypts data in a single-part operation. */
diff --git a/briar-core/src/org/briarproject/crypto/AuthenticatedCipherImpl.java b/briar-core/src/org/briarproject/crypto/AuthenticatedCipherImpl.java
index 34c1379bbe9d1a1f9b5934f74ec47958bdeed665..93807087d263c1d5f3ad43b100ea304a907b0441 100644
--- a/briar-core/src/org/briarproject/crypto/AuthenticatedCipherImpl.java
+++ b/briar-core/src/org/briarproject/crypto/AuthenticatedCipherImpl.java
@@ -2,11 +2,8 @@ package org.briarproject.crypto;
 
 import java.security.GeneralSecurityException;
 
-import javax.crypto.Cipher;
-
 import org.briarproject.api.crypto.AuthenticatedCipher;
 import org.briarproject.api.crypto.SecretKey;
-
 import org.spongycastle.crypto.DataLengthException;
 import org.spongycastle.crypto.InvalidCipherTextException;
 import org.spongycastle.crypto.modes.AEADBlockCipher;
@@ -39,23 +36,12 @@ class AuthenticatedCipherImpl implements AuthenticatedCipher {
 		}
 	}
 
-	public void init(int opmode, SecretKey key, byte[] iv, byte[] aad)
+	public void init(boolean encrypt, SecretKey key, byte[] iv, byte[] aad)
 			throws GeneralSecurityException {
 		KeyParameter k = new KeyParameter(key.getEncoded());
 		AEADParameters params = new AEADParameters(k, macLength * 8, iv, aad);
 		try {
-			switch(opmode) {
-			case Cipher.ENCRYPT_MODE:
-			case Cipher.WRAP_MODE:
-				cipher.init(true, params);
-				break;
-			case Cipher.DECRYPT_MODE:
-			case Cipher.UNWRAP_MODE:
-				cipher.init(false, params);
-				break;
-			default:
-				throw new IllegalArgumentException();
-			}
+			cipher.init(encrypt, params);
 		} catch(IllegalArgumentException e) {
 			throw new GeneralSecurityException(e.getMessage());
 		}
diff --git a/briar-core/src/org/briarproject/crypto/CryptoComponentImpl.java b/briar-core/src/org/briarproject/crypto/CryptoComponentImpl.java
index 53507da122fdfa94bdec8d11ff52ace9548ac634..521a9cef07633eb784e896a4423970368f6cbc67 100644
--- a/briar-core/src/org/briarproject/crypto/CryptoComponentImpl.java
+++ b/briar-core/src/org/briarproject/crypto/CryptoComponentImpl.java
@@ -1,8 +1,6 @@
 package org.briarproject.crypto;
 
 import static java.util.logging.Level.INFO;
-import static javax.crypto.Cipher.DECRYPT_MODE;
-import static javax.crypto.Cipher.ENCRYPT_MODE;
 import static org.briarproject.api.invitation.InvitationConstants.CODE_BITS;
 import static org.briarproject.api.transport.TransportConstants.TAG_LENGTH;
 import static org.briarproject.crypto.EllipticCurveConstants.P;
@@ -238,7 +236,6 @@ class CryptoComponentImpl implements CryptoComponent {
 		ECPublicKeyParameters ecPub = ((Sec1PublicKey) pub).getKey();
 		ECDHCBasicAgreement agreement = new ECDHCBasicAgreement();
 		agreement.init(ecPriv);
-		// FIXME: Should we use another format for the shared secret?
 		return agreement.calculateAgreement(ecPub).toByteArray();
 	}
 
@@ -305,8 +302,8 @@ class CryptoComponentImpl implements CryptoComponent {
 	}
 
 	public AuthenticatedCipher getFrameCipher() {
-		AEADBlockCipher cipher = new GCMBlockCipher(new AESLightEngine());
-		return new AuthenticatedCipherImpl(cipher, MAC_BYTES);
+		AEADBlockCipher a = new GCMBlockCipher(new AESLightEngine());
+		return new AuthenticatedCipherImpl(a, MAC_BYTES);
 	}
 
 	public void encodeTag(byte[] tag, SecretKey tagKey, long connection) {
@@ -343,10 +340,10 @@ class CryptoComponentImpl implements CryptoComponent {
 		System.arraycopy(iv, 0, output, salt.length + 4, iv.length);
 		// Initialise the cipher and encrypt the plaintext
 		try {
-			AEADBlockCipher c = new GCMBlockCipher(new AESLightEngine());
-			AuthenticatedCipher cipher = new AuthenticatedCipherImpl(c,
+			AEADBlockCipher a = new GCMBlockCipher(new AESLightEngine());
+			AuthenticatedCipher cipher = new AuthenticatedCipherImpl(a,
 					MAC_BYTES);
-			cipher.init(ENCRYPT_MODE, key, iv, null);
+			cipher.init(true, key, iv, null);
 			int outputOff = salt.length + 4 + iv.length;
 			cipher.doFinal(input, 0, input.length, output, outputOff);
 			return output;
@@ -374,9 +371,9 @@ class CryptoComponentImpl implements CryptoComponent {
 		// Initialise the cipher
 		AuthenticatedCipher cipher;
 		try {
-			AEADBlockCipher c = new GCMBlockCipher(new AESLightEngine());
-			cipher = new AuthenticatedCipherImpl(c, MAC_BYTES);
-			cipher.init(DECRYPT_MODE, key, iv, null);
+			AEADBlockCipher a = new GCMBlockCipher(new AESLightEngine());
+			cipher = new AuthenticatedCipherImpl(a, MAC_BYTES);
+			cipher.init(false, key, iv, null);
 		} catch(GeneralSecurityException e) {
 			key.erase();
 			throw new RuntimeException(e);
diff --git a/briar-core/src/org/briarproject/transport/IncomingEncryptionLayer.java b/briar-core/src/org/briarproject/transport/IncomingEncryptionLayer.java
index ba8ca63b918c24066c400f8dd13c0184d4f99f23..e5e4381d8cfcccf4af9444bc798026687995edf5 100644
--- a/briar-core/src/org/briarproject/transport/IncomingEncryptionLayer.java
+++ b/briar-core/src/org/briarproject/transport/IncomingEncryptionLayer.java
@@ -1,6 +1,5 @@
 package org.briarproject.transport;
 
-import static javax.crypto.Cipher.DECRYPT_MODE;
 import static org.briarproject.api.transport.TransportConstants.AAD_LENGTH;
 import static org.briarproject.api.transport.TransportConstants.HEADER_LENGTH;
 import static org.briarproject.api.transport.TransportConstants.IV_LENGTH;
@@ -60,7 +59,7 @@ class IncomingEncryptionLayer implements FrameReader {
 		FrameEncoder.encodeIv(iv, frameNumber);
 		FrameEncoder.encodeAad(aad, frameNumber, plaintextLength);
 		try {
-			frameCipher.init(DECRYPT_MODE, frameKey, iv, aad);
+			frameCipher.init(false, frameKey, iv, aad);
 			int decrypted = frameCipher.doFinal(ciphertext, 0, ciphertextLength,
 					frame, 0);
 			if(decrypted != plaintextLength) throw new RuntimeException();
diff --git a/briar-core/src/org/briarproject/transport/OutgoingEncryptionLayer.java b/briar-core/src/org/briarproject/transport/OutgoingEncryptionLayer.java
index 4a53790151f2dcebc984d032b51273d6e6174bda..0a4552f38a4f3fabd441162e51456a9fc3bcb2cb 100644
--- a/briar-core/src/org/briarproject/transport/OutgoingEncryptionLayer.java
+++ b/briar-core/src/org/briarproject/transport/OutgoingEncryptionLayer.java
@@ -1,6 +1,5 @@
 package org.briarproject.transport;
 
-import static javax.crypto.Cipher.ENCRYPT_MODE;
 import static org.briarproject.api.transport.TransportConstants.AAD_LENGTH;
 import static org.briarproject.api.transport.TransportConstants.HEADER_LENGTH;
 import static org.briarproject.api.transport.TransportConstants.IV_LENGTH;
@@ -97,7 +96,7 @@ class OutgoingEncryptionLayer implements FrameWriter {
 		FrameEncoder.encodeIv(iv, frameNumber);
 		FrameEncoder.encodeAad(aad, frameNumber, plaintextLength);
 		try {
-			frameCipher.init(ENCRYPT_MODE, frameKey, iv, aad);
+			frameCipher.init(true, frameKey, iv, aad);
 			int encrypted = frameCipher.doFinal(frame, 0, plaintextLength,
 					ciphertext, 0);
 			if(encrypted != ciphertextLength) throw new RuntimeException();
diff --git a/briar-tests/src/org/briarproject/transport/IncomingEncryptionLayerTest.java b/briar-tests/src/org/briarproject/transport/IncomingEncryptionLayerTest.java
index cc1a38e1c0d1f778bd424650412e1b601277296f..8e1791785632439f24962584d36c03e6d41f06de 100644
--- a/briar-tests/src/org/briarproject/transport/IncomingEncryptionLayerTest.java
+++ b/briar-tests/src/org/briarproject/transport/IncomingEncryptionLayerTest.java
@@ -1,6 +1,5 @@
 package org.briarproject.transport;
 
-import static javax.crypto.Cipher.ENCRYPT_MODE;
 import static org.briarproject.api.transport.TransportConstants.AAD_LENGTH;
 import static org.briarproject.api.transport.TransportConstants.HEADER_LENGTH;
 import static org.briarproject.api.transport.TransportConstants.IV_LENGTH;
@@ -175,7 +174,7 @@ public class IncomingEncryptionLayerTest extends BriarTestCase {
 		byte[] ciphertext = new byte[frameLength];
 		FrameEncoder.encodeIv(iv, frameNumber);
 		FrameEncoder.encodeAad(aad, frameNumber, plaintext.length);
-		frameCipher.init(ENCRYPT_MODE, frameKey, iv, aad);
+		frameCipher.init(true, frameKey, iv, aad);
 		FrameEncoder.encodeHeader(plaintext, finalFrame, payloadLength);
 		if(badPadding) plaintext[HEADER_LENGTH + payloadLength] = 1;
 		frameCipher.doFinal(plaintext, 0, plaintext.length, ciphertext, 0);
diff --git a/briar-tests/src/org/briarproject/transport/OutgoingEncryptionLayerTest.java b/briar-tests/src/org/briarproject/transport/OutgoingEncryptionLayerTest.java
index 8a35ce732c6246555c6c055bd8703b733f2847e5..3a3598f3fadb9afd948b789c777a13058c409775 100644
--- a/briar-tests/src/org/briarproject/transport/OutgoingEncryptionLayerTest.java
+++ b/briar-tests/src/org/briarproject/transport/OutgoingEncryptionLayerTest.java
@@ -1,6 +1,5 @@
 package org.briarproject.transport;
 
-import static javax.crypto.Cipher.ENCRYPT_MODE;
 import static org.briarproject.api.transport.TransportConstants.AAD_LENGTH;
 import static org.briarproject.api.transport.TransportConstants.HEADER_LENGTH;
 import static org.briarproject.api.transport.TransportConstants.IV_LENGTH;
@@ -51,7 +50,7 @@ public class OutgoingEncryptionLayerTest extends BriarTestCase {
 		// Calculate the expected ciphertext
 		FrameEncoder.encodeIv(iv, 0);
 		FrameEncoder.encodeAad(aad, 0, plaintext.length);
-		frameCipher.init(ENCRYPT_MODE, frameKey, iv, aad);
+		frameCipher.init(true, frameKey, iv, aad);
 		FrameEncoder.encodeHeader(plaintext, false, payloadLength);
 		frameCipher.doFinal(plaintext, 0, plaintext.length, ciphertext, 0);
 		// Check that the actual tag and ciphertext match what's expected