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?
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++)
{
resultLen += this.processBlock(in, inOff, out, outOff + resultLen);
@@ -803,9 +803,7 @@ public final class Arrays
int newLength = to - from;
if (newLength < 0)
{
StringBuffer sb = new StringBuffer(from);
sb.append(" > ").append(to);
throw new IllegalArgumentException(sb.toString());
throw new IllegalArgumentException(from + " > " + to);
}
return newLength;
}
@@ -23,16 +23,32 @@ public final class Strings {
}
}
public static String toLowerCase(String str) {
char[] charArray = str.toCharArray();
boolean z = false;
for (int i = 0; i != charArray.length; i++) {
char c = charArray[i];
if ('A' <= c && 'Z' >= c) {
charArray[i] = (char) ((c - 'A') + 97);
z = true;
/**
* A locale independent version of toLowerCase.
*
* @param string input to be converted
* @return a US ASCII lowercase version
*/
public static String toLowerCase(String string)
{
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;
}
}