diff --git a/crypto/test/src/crypto/prng/test/CtrDrbgTest.cs b/crypto/test/src/crypto/prng/test/CtrDrbgTest.cs
index 1fd051294..2471bba8c 100644
--- a/crypto/test/src/crypto/prng/test/CtrDrbgTest.cs
+++ b/crypto/test/src/crypto/prng/test/CtrDrbgTest.cs
@@ -340,7 +340,7 @@ namespace Org.BouncyCastle.Crypto.Prng.Test
output = new byte[tv.GetExpectedValue(0).Length];
- d.Generate(output, tv.GetAdditionalInput(0), tv.PredictionResistance);
+ d.Generate(output, 0, output.Length, tv.GetAdditionalInput(0), tv.PredictionResistance);
byte[] expected = tv.GetExpectedValue(0);
@@ -351,7 +351,7 @@ namespace Org.BouncyCastle.Crypto.Prng.Test
output = new byte[tv.GetExpectedValue(0).Length];
- d.Generate(output, tv.GetAdditionalInput(1), tv.PredictionResistance);
+ d.Generate(output, 0, output.Length, tv.GetAdditionalInput(1), tv.PredictionResistance);
expected = tv.GetExpectedValue(1);
if (!AreEqual(expected, output))
@@ -368,7 +368,7 @@ namespace Org.BouncyCastle.Crypto.Prng.Test
output = new byte[tv.GetExpectedValue(0).Length];
- drbg.Generate(output, tv.GetAdditionalInput(0), tv.PredictionResistance);
+ drbg.Generate(output, 0, output.Length, tv.GetAdditionalInput(0), tv.PredictionResistance);
// Exception tests
try
diff --git a/crypto/test/src/crypto/prng/test/HMacDrbgTest.cs b/crypto/test/src/crypto/prng/test/HMacDrbgTest.cs
index f523cc4d7..9e2ae7b90 100644
--- a/crypto/test/src/crypto/prng/test/HMacDrbgTest.cs
+++ b/crypto/test/src/crypto/prng/test/HMacDrbgTest.cs
@@ -414,7 +414,7 @@ namespace Org.BouncyCastle.Crypto.Prng.Test
byte[] output = new byte[tv.GetExpectedValue(0).Length];
- d.Generate(output, tv.GetAdditionalInput(0), tv.PredictionResistance);
+ d.Generate(output, 0, output.Length, tv.GetAdditionalInput(0), tv.PredictionResistance);
byte[] expected = tv.GetExpectedValue(0);
@@ -425,7 +425,7 @@ namespace Org.BouncyCastle.Crypto.Prng.Test
output = new byte[tv.GetExpectedValue(0).Length];
- d.Generate(output, tv.GetAdditionalInput(1), tv.PredictionResistance);
+ d.Generate(output, 0, output.Length, tv.GetAdditionalInput(1), tv.PredictionResistance);
expected = tv.GetExpectedValue(1);
if (!AreEqual(expected, output))
diff --git a/crypto/test/src/crypto/prng/test/HashDrbgTest.cs b/crypto/test/src/crypto/prng/test/HashDrbgTest.cs
index e043f03da..29929c613 100644
--- a/crypto/test/src/crypto/prng/test/HashDrbgTest.cs
+++ b/crypto/test/src/crypto/prng/test/HashDrbgTest.cs
@@ -356,7 +356,7 @@ namespace Org.BouncyCastle.Crypto.Prng.Test
byte[] output = new byte[tv.GetExpectedValue(0).Length];
- d.Generate(output, tv.GetAdditionalInput(0), tv.PredictionResistance);
+ d.Generate(output, 0, output.Length, tv.GetAdditionalInput(0), tv.PredictionResistance);
byte[] expected = tv.GetExpectedValue(0);
@@ -367,7 +367,7 @@ namespace Org.BouncyCastle.Crypto.Prng.Test
output = new byte[tv.GetExpectedValue(0).Length];
- d.Generate(output, tv.GetAdditionalInput(1), tv.PredictionResistance);
+ d.Generate(output, 0, output.Length, tv.GetAdditionalInput(1), tv.PredictionResistance);
expected = tv.GetExpectedValue(1);
if (!AreEqual(expected, output))
diff --git a/crypto/test/src/crypto/test/DSATest.cs b/crypto/test/src/crypto/test/DSATest.cs
index b81ef511f..f9f601ed8 100644
--- a/crypto/test/src/crypto/test/DSATest.cs
+++ b/crypto/test/src/crypto/test/DSATest.cs
@@ -592,16 +592,16 @@ namespace Org.BouncyCastle.Crypto.Tests
{
}
- public override void NextBytes(byte[] bytes)
+ public override void NextBytes(byte[] buf, int off, int len)
{
if (first)
{
- base.NextBytes(bytes);
+ base.NextBytes(buf, off, len);
first = false;
}
else
{
- bytes[bytes.Length - 1] = 2;
+ buf[off + len - 1] = 2;
}
}
}
diff --git a/crypto/test/src/crypto/test/GOST3410Test.cs b/crypto/test/src/crypto/test/GOST3410Test.cs
index 93c234ca1..130fdaf92 100644
--- a/crypto/test/src/crypto/test/GOST3410Test.cs
+++ b/crypto/test/src/crypto/test/GOST3410Test.cs
@@ -239,7 +239,7 @@ namespace Org.BouncyCastle.Crypto.Tests
get { return "Gost3410-TEST1-1024"; }
}
- private class SecureRandomImpl1 : SecureRandom
+ private class SecureRandomImpl1 : SecureRandomImpl
{
bool firstInt = true;
@@ -266,7 +266,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom init_random = new SecureRandomImpl1();
- private class SecureRandomImpl2 : SecureRandom
+ private class SecureRandomImpl2 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -291,7 +291,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom random = new SecureRandomImpl2();
- private class SecureRandomImpl3 : SecureRandom
+ private class SecureRandomImpl3 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -386,7 +386,7 @@ namespace Org.BouncyCastle.Crypto.Tests
get { return "Gost3410-TEST2-1024"; }
}
- private class SecureRandomImpl4 : SecureRandom
+ private class SecureRandomImpl4 : SecureRandomImpl
{
bool firstLong = true;
@@ -413,7 +413,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom init_random = new SecureRandomImpl4();
- private class SecureRandomImpl5 : SecureRandom
+ private class SecureRandomImpl5 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -438,7 +438,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom random = new SecureRandomImpl5();
- private class SecureRandomImpl6 : SecureRandom
+ private class SecureRandomImpl6 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -533,7 +533,7 @@ namespace Org.BouncyCastle.Crypto.Tests
get { return "Gost3410-AParam"; }
}
- private class SecureRandomImpl7 : SecureRandom
+ private class SecureRandomImpl7 : SecureRandomImpl
{
bool firstLong = true;
@@ -560,7 +560,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom init_random = new SecureRandomImpl7();
- private class SecureRandomImpl8 : SecureRandom
+ private class SecureRandomImpl8 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -585,7 +585,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom random = new SecureRandomImpl8();
- private class SecureRandomImpl9 : SecureRandom
+ private class SecureRandomImpl9 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -680,7 +680,7 @@ namespace Org.BouncyCastle.Crypto.Tests
get { return "Gost3410-BParam"; }
}
- private class SecureRandomImpl10 : SecureRandom
+ private class SecureRandomImpl10 : SecureRandomImpl
{
bool firstLong = true;
@@ -706,7 +706,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom init_random = new SecureRandomImpl10();
- private class SecureRandomImpl11 : SecureRandom
+ private class SecureRandomImpl11 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -731,7 +731,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom random = new SecureRandomImpl11();
- private class SecureRandomImpl12 : SecureRandom
+ private class SecureRandomImpl12 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -826,7 +826,7 @@ namespace Org.BouncyCastle.Crypto.Tests
get { return "Gost3410-CParam"; }
}
- private class SecureRandomImpl13 : SecureRandom
+ private class SecureRandomImpl13 : SecureRandomImpl
{
bool firstLong = true;
@@ -852,7 +852,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom init_random = new SecureRandomImpl13();
- private class SecureRandomImpl14 : SecureRandom
+ private class SecureRandomImpl14 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -877,7 +877,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom random = new SecureRandomImpl14();
- private class SecureRandomImpl15 : SecureRandom
+ private class SecureRandomImpl15 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -972,7 +972,7 @@ namespace Org.BouncyCastle.Crypto.Tests
get { return "Gost3410-DParam"; }
}
- private class SecureRandomImpl16 : SecureRandom
+ private class SecureRandomImpl16 : SecureRandomImpl
{
bool firstLong = true;
@@ -999,7 +999,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom init_random = new SecureRandomImpl16();
- private class SecureRandomImpl17 : SecureRandom
+ private class SecureRandomImpl17 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -1024,7 +1024,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom random = new SecureRandomImpl17();
- private class SecureRandomImpl18 : SecureRandom
+ private class SecureRandomImpl18 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -1119,7 +1119,7 @@ namespace Org.BouncyCastle.Crypto.Tests
get { return "Gost3410-AExParam"; }
}
- private class SecureRandomImpl19 : SecureRandom
+ private class SecureRandomImpl19 : SecureRandomImpl
{
bool firstLong = true;
@@ -1145,7 +1145,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom init_random = new SecureRandomImpl19();
- private class SecureRandomImpl20 : SecureRandom
+ private class SecureRandomImpl20 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -1170,7 +1170,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom random = new SecureRandomImpl20();
- private class SecureRandomImpl21 : SecureRandom
+ private class SecureRandomImpl21 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -1265,7 +1265,7 @@ namespace Org.BouncyCastle.Crypto.Tests
get { return "Gost3410-BExParam"; }
}
- private class SecureRandomImpl22 : SecureRandom
+ private class SecureRandomImpl22 : SecureRandomImpl
{
bool firstLong = true;
@@ -1291,7 +1291,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom init_random = new SecureRandomImpl22();
- private class SecureRandomImpl23 : SecureRandom
+ private class SecureRandomImpl23 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -1316,7 +1316,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom random = new SecureRandomImpl23();
- private class SecureRandomImpl24 : SecureRandom
+ private class SecureRandomImpl24 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -1411,7 +1411,7 @@ namespace Org.BouncyCastle.Crypto.Tests
get { return "Gost3410-CExParam"; }
}
- private class SecureRandomImpl25 : SecureRandom
+ private class SecureRandomImpl25 : SecureRandomImpl
{
bool firstLong = true;
@@ -1437,7 +1437,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom init_random = new SecureRandomImpl25();
- private class SecureRandomImpl26 : SecureRandom
+ private class SecureRandomImpl26 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -1462,7 +1462,7 @@ namespace Org.BouncyCastle.Crypto.Tests
};
SecureRandom random = new SecureRandomImpl26();
- private class SecureRandomImpl27 : SecureRandom
+ private class SecureRandomImpl27 : SecureRandomImpl
{
public override void NextBytes(byte[] bytes)
{
@@ -1591,5 +1591,15 @@ namespace Org.BouncyCastle.Crypto.Tests
Assert.AreEqual(Name + ": Okay", resultText);
}
+
+ internal class SecureRandomImpl : SecureRandom
+ {
+ public override void NextBytes(byte[] buf, int off, int len)
+ {
+ byte[] bytes = new byte[len];
+ NextBytes(bytes);
+ bytes.CopyTo(buf, off);
+ }
+ }
}
}
diff --git a/crypto/test/src/crypto/test/OAEPTest.cs b/crypto/test/src/crypto/test/OAEPTest.cs
index 37faff740..b2cbde8b3 100644
--- a/crypto/test/src/crypto/test/OAEPTest.cs
+++ b/crypto/test/src/crypto/test/OAEPTest.cs
@@ -293,10 +293,14 @@ namespace Org.BouncyCastle.Crypto.Tests
this.seed = seed;
}
- public override void NextBytes(
- byte[] bytes)
+ public override void NextBytes(byte[] buf)
{
- Array.Copy(seed, 0, bytes, 0, bytes.Length);
+ NextBytes(buf, 0, buf.Length);
+ }
+
+ public override void NextBytes(byte[] buf, int off, int len)
+ {
+ Array.Copy(seed, 0, buf, off, len);
}
}
diff --git a/crypto/test/src/crypto/test/PSSBlindTest.cs b/crypto/test/src/crypto/test/PSSBlindTest.cs
index 0abb8d87d..1cd74bb70 100644
--- a/crypto/test/src/crypto/test/PSSBlindTest.cs
+++ b/crypto/test/src/crypto/test/PSSBlindTest.cs
@@ -36,10 +36,14 @@ namespace Org.BouncyCastle.Crypto.Tests
this.vals = vals;
}
- public override void NextBytes(
- byte[] bytes)
+ public override void NextBytes(byte[] buf)
{
- Array.Copy(vals, 0, bytes, 0, vals.Length);
+ NextBytes(buf, 0, buf.Length);
+ }
+
+ public override void NextBytes(byte[] buf, int off, int len)
+ {
+ Array.Copy(vals, 0, buf, off, len);
}
}
diff --git a/crypto/test/src/crypto/test/PSSTest.cs b/crypto/test/src/crypto/test/PSSTest.cs
index 6375269a4..aeaf85a53 100644
--- a/crypto/test/src/crypto/test/PSSTest.cs
+++ b/crypto/test/src/crypto/test/PSSTest.cs
@@ -32,10 +32,14 @@ namespace Org.BouncyCastle.Crypto.Tests
this.vals = vals;
}
- public override void NextBytes(
- byte[] bytes)
+ public override void NextBytes(byte[] buf)
{
- Array.Copy(vals, 0, bytes, 0, vals.Length);
+ NextBytes(buf, 0, buf.Length);
+ }
+
+ public override void NextBytes(byte[] buf, int off, int len)
+ {
+ Array.Copy(vals, 0, buf, off, len);
}
}
diff --git a/crypto/test/src/crypto/test/RC2WrapTest.cs b/crypto/test/src/crypto/test/RC2WrapTest.cs
index 9471ba6c9..7d98ee9af 100644
--- a/crypto/test/src/crypto/test/RC2WrapTest.cs
+++ b/crypto/test/src/crypto/test/RC2WrapTest.cs
@@ -22,10 +22,14 @@ namespace Org.BouncyCastle.Crypto.Tests
private class RFCRandom
: SecureRandom
{
- public override void NextBytes(
- byte[] nextBytes)
+ public override void NextBytes(byte[] buf)
{
- Array.Copy(Hex.Decode("4845cce7fd1250"), 0, nextBytes, 0, nextBytes.Length);
+ NextBytes(buf, 0, buf.Length);
+ }
+
+ public override void NextBytes(byte[] buf, int off, int len)
+ {
+ Array.Copy(Hex.Decode("4845cce7fd1250"), 0, buf, off, len);
}
}
diff --git a/crypto/test/src/pqc/crypto/lms/HSSTests.cs b/crypto/test/src/pqc/crypto/lms/HSSTests.cs
index 0d01e5d1f..2045f7693 100644
--- a/crypto/test/src/pqc/crypto/lms/HSSTests.cs
+++ b/crypto/test/src/pqc/crypto/lms/HSSTests.cs
@@ -731,15 +731,20 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms
class HSSSecureRandom
: SecureRandom
{
- public override void NextBytes(byte[] bytes)
+ public override void NextBytes(byte[] buf)
{
- for (int t = 0; t < bytes.Length; t++)
+ NextBytes(buf, 0, buf.Length);
+ }
+
+ public override void NextBytes(byte[] buf, int off, int len)
+ {
+ for (int t = 0; t < len; t++)
{
- bytes[t] = 1;
+ buf[off + t] = 1;
}
}
}
-
+
[Test]
public void TestSignUnitExhaustion()
{
diff --git a/crypto/test/src/pqc/crypto/test/NistSecureRandom.cs b/crypto/test/src/pqc/crypto/test/NistSecureRandom.cs
index 0ca8dd990..aac73c4ee 100644
--- a/crypto/test/src/pqc/crypto/test/NistSecureRandom.cs
+++ b/crypto/test/src/pqc/crypto/test/NistSecureRandom.cs
@@ -69,14 +69,17 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests
reseed_counuter = 1;
}
- public override void NextBytes(byte[] x)
+ public override void NextBytes(byte[] buf)
+ {
+ NextBytes(buf, 0, buf.Length);
+ }
+
+ public override void NextBytes(byte[] buf, int off, int len)
{
byte[] block = new byte[16];
int i = 0;
- int xlen = x.Length;
-
- while (xlen > 0)
+ while (len > 0)
{
for (int j = 15; j >= 0; j--)
{
@@ -93,16 +96,16 @@ namespace Org.BouncyCastle.Pqc.Crypto.Tests
AES256_ECB(key, v, block, 0);
- if (xlen > 15)
+ if (len > 15)
{
- Array.Copy(block, 0, x, i, block.Length);
+ Array.Copy(block, 0, buf, off + i, block.Length);
i += 16;
- xlen -= 16;
+ len -= 16;
}
else
{
- Array.Copy(block, 0, x, i, xlen);
- xlen = 0;
+ Array.Copy(block, 0, buf, off + i, len);
+ len = 0;
}
}
diff --git a/crypto/test/src/test/BlockCipherTest.cs b/crypto/test/src/test/BlockCipherTest.cs
index b57d62d94..d0e5e20b3 100644
--- a/crypto/test/src/test/BlockCipherTest.cs
+++ b/crypto/test/src/test/BlockCipherTest.cs
@@ -402,18 +402,21 @@ namespace Org.BouncyCastle.Tests
(byte)0xc2, (byte)0xf0, (byte)0x6c, (byte)0xb5, (byte)0x8f
};
- public override void NextBytes(
- byte[] bytes)
+ public override void NextBytes(byte[] buf)
{
- int offset = 0;
+ NextBytes(buf, 0, buf.Length);
+ }
- while ((offset + seed.Length) < bytes.Length)
+ public override void NextBytes(byte[] buf, int off, int len)
+ {
+ int pos = 0;
+ while ((pos + seed.Length) < len)
{
- Array.Copy(seed, 0, bytes, offset, seed.Length);
- offset += seed.Length;
+ Array.Copy(seed, 0, buf, off + pos, seed.Length);
+ pos += seed.Length;
}
- Array.Copy(seed, 0, bytes, offset, bytes.Length- offset);
+ Array.Copy(seed, 0, buf, off + pos, len - pos);
}
}
diff --git a/crypto/test/src/test/DESedeTest.cs b/crypto/test/src/test/DESedeTest.cs
index 04d8725ae..39d55e424 100644
--- a/crypto/test/src/test/DESedeTest.cs
+++ b/crypto/test/src/test/DESedeTest.cs
@@ -46,25 +46,28 @@ namespace Org.BouncyCastle.Tests
: SecureRandom
{
private byte[] seed =
- {
- (byte)0xaa, (byte)0xfd, (byte)0x12, (byte)0xf6, (byte)0x59,
- (byte)0xca, (byte)0xe6, (byte)0x34, (byte)0x89, (byte)0xb4,
- (byte)0x79, (byte)0xe5, (byte)0x07, (byte)0x6d, (byte)0xde,
- (byte)0xc2, (byte)0xf0, (byte)0x6c, (byte)0xb5, (byte)0x8f
- };
+ {
+ (byte)0xaa, (byte)0xfd, (byte)0x12, (byte)0xf6, (byte)0x59,
+ (byte)0xca, (byte)0xe6, (byte)0x34, (byte)0x89, (byte)0xb4,
+ (byte)0x79, (byte)0xe5, (byte)0x07, (byte)0x6d, (byte)0xde,
+ (byte)0xc2, (byte)0xf0, (byte)0x6c, (byte)0xb5, (byte)0x8f
+ };
- public override void NextBytes(
- byte[] bytes)
+ public override void NextBytes(byte[] buf)
{
- int offset = 0;
+ NextBytes(buf, 0, buf.Length);
+ }
- while ((offset + seed.Length) < bytes.Length)
+ public override void NextBytes(byte[] buf, int off, int len)
+ {
+ int pos = 0;
+ while ((pos + seed.Length) < len)
{
- Array.Copy(seed, 0, bytes, offset, seed.Length);
- offset += seed.Length;
+ Array.Copy(seed, 0, buf, off + pos, seed.Length);
+ pos += seed.Length;
}
- Array.Copy(seed, 0, bytes, offset, bytes.Length - offset);
+ Array.Copy(seed, 0, buf, off + pos, len - pos);
}
}
diff --git a/crypto/test/src/test/DSATest.cs b/crypto/test/src/test/DSATest.cs
index b4868c52f..95b46c2bf 100644
--- a/crypto/test/src/test/DSATest.cs
+++ b/crypto/test/src/test/DSATest.cs
@@ -829,16 +829,21 @@ namespace Org.BouncyCastle.Tests
{
}
- public override void NextBytes(byte[] bytes)
+ public override void NextBytes(byte[] buf)
+ {
+ NextBytes(buf, 0, buf.Length);
+ }
+
+ public override void NextBytes(byte[] buf, int off, int len)
{
if (first)
{
- base.NextBytes(bytes);
+ base.NextBytes(buf, off, len);
first = false;
}
else
{
- bytes[bytes.Length - 1] = 2;
+ buf[off + len - 1] = 2;
}
}
}
diff --git a/crypto/test/src/test/PSSTest.cs b/crypto/test/src/test/PSSTest.cs
index ab8f0f690..fa6f54e31 100644
--- a/crypto/test/src/test/PSSTest.cs
+++ b/crypto/test/src/test/PSSTest.cs
@@ -33,10 +33,17 @@ namespace Org.BouncyCastle.Tests
this.vals = vals;
}
- public override void NextBytes(
- byte[] bytes)
+ public override void NextBytes(byte[] buf)
{
- vals.CopyTo(bytes, 0);
+ NextBytes(buf, 0, buf.Length);
+ }
+
+ public override void NextBytes(byte[] buf, int off, int len)
+ {
+ if (vals.Length > len)
+ throw new InvalidOperationException();
+
+ vals.CopyTo(buf, off);
}
}
diff --git a/crypto/test/src/test/RSATest.cs b/crypto/test/src/test/RSATest.cs
index 267472d91..94c1fb816 100644
--- a/crypto/test/src/test/RSATest.cs
+++ b/crypto/test/src/test/RSATest.cs
@@ -39,18 +39,21 @@ namespace Org.BouncyCastle.Tests
(byte)0xc2, (byte)0xf0, (byte)0x6c, (byte)0xb5, (byte)0x8f
};
- public override void NextBytes(
- byte[] bytes)
+ public override void NextBytes(byte[] buf)
{
- int offset = 0;
+ NextBytes(buf, 0, buf.Length);
+ }
- while ((offset + seed.Length) < bytes.Length)
+ public override void NextBytes(byte[] buf, int off, int len)
+ {
+ int pos = 0;
+ while ((pos + seed.Length) < len)
{
- seed.CopyTo(bytes, offset);
- offset += seed.Length;
+ seed.CopyTo(buf, off + pos);
+ pos += seed.Length;
}
- Array.Copy(seed, 0, bytes, offset, bytes.Length - offset);
+ Array.Copy(seed, 0, buf, off + pos, len - pos);
}
}
diff --git a/crypto/test/src/util/test/FixedSecureRandom.cs b/crypto/test/src/util/test/FixedSecureRandom.cs
index 682b3eefa..be5b25347 100644
--- a/crypto/test/src/util/test/FixedSecureRandom.cs
+++ b/crypto/test/src/util/test/FixedSecureRandom.cs
@@ -211,21 +211,15 @@ namespace Org.BouncyCastle.Utilities.Test
public override byte[] GenerateSeed(int numBytes)
{
- return SecureRandom.GetNextBytes(this, numBytes);
+ return GetNextBytes(this, numBytes);
}
- public override void NextBytes(
- byte[] buf)
+ public override void NextBytes(byte[] buf)
{
- Array.Copy(_data, _index, buf, 0, buf.Length);
-
- _index += buf.Length;
+ NextBytes(buf, 0, buf.Length);
}
- public override void NextBytes(
- byte[] buf,
- int off,
- int len)
+ public override void NextBytes(byte[] buf, int off, int len)
{
Array.Copy(_data, _index, buf, off, len);
@@ -243,11 +237,16 @@ namespace Org.BouncyCastle.Utilities.Test
byte[] data = Hex.Decode("01020304ffffffff0506070811111111");
int index = 0;
- public override void NextBytes(byte[] bytes)
+ public override void NextBytes(byte[] buf)
+ {
+ NextBytes(buf, 0, buf.Length);
+ }
+
+ public override void NextBytes(byte[] buf, int off, int len)
{
- Array.Copy(data, index, bytes, 0, bytes.Length);
+ Array.Copy(data, index, buf, off, len);
- index += bytes.Length;
+ index += len;
}
}
|