### Question:
OmemoMessageBuilder { static void moveAuthTag(byte[] messageKey, byte[] cipherText, byte[] messageKeyWithAuthTag, byte[] cipherTextWithoutAuthTag) { if (messageKeyWithAuthTag.length != messageKey.length + 16) { throw new IllegalArgumentException("Length of messageKeyWithAuthTag must be length of messageKey + " + "length of AuthTag (16)"); } if (cipherTextWithoutAuthTag.length != cipherText.length - 16) { throw new IllegalArgumentException("Length of cipherTextWithoutAuthTag must be length of cipherText " + "- length of AuthTag (16)"); } System.arraycopy(messageKey, 0, messageKeyWithAuthTag, 0, 16); System.arraycopy(cipherText, 0, cipherTextWithoutAuthTag, 0, cipherTextWithoutAuthTag.length); System.arraycopy(cipherText, cipherText.length - 16, messageKeyWithAuthTag, 16, 16); } OmemoMessageBuilder(OmemoDevice userDevice,
                               OmemoTrustCallback callback,
                               OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> ratchet,
                               byte[] aesKey,
                               byte[] iv,
                               String message);  OmemoMessageBuilder(OmemoDevice userDevice,
                               OmemoTrustCallback callback,
                               OmemoRatchet<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_Sess, T_Addr, T_ECPub, T_Bundle, T_Ciph> ratchet,
                               String message); void addRecipient(OmemoDevice contactsDevice); OmemoElement finish(); static byte[] generateKey(String keyType, int keyLength); static byte[] generateIv();  }### Answer:
@Test public void testMoveAuthTag() { byte[] authTag = new byte[16]; System.arraycopy(cipherTextWithAuthTag, 35, authTag, 0, 16); byte[] messageKeyWithAuthTag = new byte[16 + 16]; byte[] cipherTextWithoutAuthTag = new byte[35]; OmemoMessageBuilder.moveAuthTag(messageKey, cipherTextWithAuthTag, messageKeyWithAuthTag, cipherTextWithoutAuthTag); byte[] checkCipherText = new byte[35]; System.arraycopy(cipherTextWithAuthTag, 0, checkCipherText, 0, 35); assertTrue(Arrays.equals(checkCipherText, cipherTextWithoutAuthTag)); byte[] checkMessageKey = new byte[16]; System.arraycopy(messageKeyWithAuthTag, 0, checkMessageKey, 0, 16); assertTrue(Arrays.equals(checkMessageKey, messageKey)); byte[] checkAuthTag = new byte[16]; System.arraycopy(messageKeyWithAuthTag, 16, checkAuthTag, 0, 16); assertTrue(Arrays.equals(checkAuthTag, authTag)); }
@Test(expected = IllegalArgumentException.class) public void testCheckIllegalMessageKeyWithAuthTagLength() { byte[] illegalMessageKey = new byte[16 + 15]; byte[] cipherTextWithoutAuthTag = new byte[35]; OmemoMessageBuilder.moveAuthTag(messageKey, cipherTextWithAuthTag, illegalMessageKey, cipherTextWithoutAuthTag); }
@Test(expected = IllegalArgumentException.class) public void testCheckIllegalCipherTextWithoutAuthTagLength() { byte[] messageKeyWithAuthTag = new byte[16 + 16]; byte[] illegalCipherTextWithoutAuthTag = new byte[39]; OmemoMessageBuilder.moveAuthTag(messageKey, cipherTextWithAuthTag, messageKeyWithAuthTag, illegalCipherTextWithoutAuthTag); }