privStruct.getPrime2(),
privStruct.getExponent1(),
privStruct.getExponent2(),
privStruct.getCoefficient());
AsymmetricBlockCipher cipher = new OAEPEncoding(new RSAEngine());
cipher.init(true, new ParametersWithRandom(pubParameters, new Rand()));
byte[] out;
byte[] input = new byte[]
{ (byte)0x54, (byte)0x85, (byte)0x9b, (byte)0x34, (byte)0x2c, (byte)0x49, (byte)0xea, (byte)0x2a };
try
{
out = cipher.processBlock(input, 0, input.length);
}
catch (Exception e)
{
return new SimpleTestResult(false, getName() + ": exception - " + e.toString());
}
for (int i = 0; i != output.length; i++)
{
if (out[i] != output[i])
{
return new SimpleTestResult(false, getName() + ": failed encryption");
}
}
cipher.init(false, privParameters);
try
{
out = cipher.processBlock(output, 0, output.length);
}
catch (Exception e)
{
return new SimpleTestResult(false, getName() + ": exception - " + e.toString());
}