diff --git a/src/main/java/com/privacylogistics/FF3Cipher.java b/src/main/java/com/privacylogistics/FF3Cipher.java index c85480c..02f0c59 100644 --- a/src/main/java/com/privacylogistics/FF3Cipher.java +++ b/src/main/java/com/privacylogistics/FF3Cipher.java @@ -312,8 +312,10 @@ public String decrypt(String ciphertext, byte[] tweak) throws BadPaddingExceptio int v = n - u; // Split the message - char[] A = ciphertext.substring(0, u).toCharArray(); - char[] B = ciphertext.substring(u).toCharArray(); + char[] A = new char[u]; + char[] B = new char[v]; + ciphertext.getChars(0, u, A, 0); + ciphertext.getChars(u, ciphertext.length(), B, 0); if ((tweak.length != TWEAK_LEN) && (tweak.length != TWEAK_LEN_NEW)) { throw new IllegalArgumentException(String.format("tweak length %d is invalid: tweak must be 56 or 64 bits",