Skip to content

Commit

Permalink
Replace .substring() with getChars: decrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
altr-benjamin committed Nov 19, 2024
1 parent 1aaed7b commit 855ccb9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/privacylogistics/FF3Cipher.java
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 855ccb9

Please sign in to comment.