backport upstream BouncyCastle fixes

aligned with bcgit/bc-java@7b094ad188
This commit is contained in:
Thomas Kuehne
2026-03-17 00:00:31 +01:00
committed by José Rebelo
parent 3e48a41aae
commit fde8563b4a
3 changed files with 34 additions and 14 deletions
@@ -19,8 +19,14 @@ public abstract class DefaultMultiBlockCipher
// TODO check if the underlying cipher supports the multiblock interface and call it directly? // TODO check if the underlying cipher supports the multiblock interface and call it directly?
int resultLen = 0; int resultLen = 0;
int blockSize = this.getMultiBlockSize(); int blockSize = this.getBlockSize();
int len = blockCount * blockSize;
if (in == out)
{
in = new byte[len];
System.arraycopy(out, inOff, in, 0, len);
inOff = 0;
}
for (int i = 0; i != blockCount; i++) for (int i = 0; i != blockCount; i++)
{ {
resultLen += this.processBlock(in, inOff, out, outOff + resultLen); resultLen += this.processBlock(in, inOff, out, outOff + resultLen);
@@ -803,9 +803,7 @@ public final class Arrays
int newLength = to - from; int newLength = to - from;
if (newLength < 0) if (newLength < 0)
{ {
StringBuffer sb = new StringBuffer(from); throw new IllegalArgumentException(from + " > " + to);
sb.append(" > ").append(to);
throw new IllegalArgumentException(sb.toString());
} }
return newLength; return newLength;
} }
@@ -23,16 +23,32 @@ public final class Strings {
} }
} }
public static String toLowerCase(String str) { /**
char[] charArray = str.toCharArray(); * A locale independent version of toLowerCase.
boolean z = false; *
for (int i = 0; i != charArray.length; i++) { * @param string input to be converted
char c = charArray[i]; * @return a US ASCII lowercase version
if ('A' <= c && 'Z' >= c) { */
charArray[i] = (char) ((c - 'A') + 97); public static String toLowerCase(String string)
z = true; {
boolean changed = false;
char[] chars = string.toCharArray();
for (int i = 0; i != chars.length; i++)
{
char ch = chars[i];
if ('A' <= ch && 'Z' >= ch)
{
changed = true;
chars[i] = (char)(ch - 'A' + 'a');
} }
} }
return z ? new String(charArray) : str;
if (changed)
{
return new String(chars);
}
return string;
} }
} }