From 855ccb9c67efea01dcaa05a3db259bdec69e569f Mon Sep 17 00:00:00 2001 From: Benjamin Dod Date: Tue, 19 Nov 2024 14:24:49 -0500 Subject: [PATCH] Replace `.substring()` with `getChars`: decrypt --- src/main/java/com/privacylogistics/FF3Cipher.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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",