}
private void testExceptions()
throws Exception
{
Mac mac = null;
mac = Mac.getInstance("HmacSHA1", "BC");
byte [] b = {(byte)1, (byte)2, (byte)3, (byte)4, (byte)5};
SecretKeySpec sks = new SecretKeySpec(b, "HmacSHA1");
RC5ParameterSpec algPS = new RC5ParameterSpec(100, 100, 100);
try
{
mac.init(sks, algPS);
}
catch (InvalidAlgorithmParameterException e)
{
// ignore okay
}
try
{
mac.init(null, null);
}
catch (InvalidKeyException e)
{
// ignore okay
}
catch (InvalidAlgorithmParameterException e)
{
// ignore okay
}
try
{
mac.init(null);
}
catch (InvalidKeyException e)
{
// ignore okay
}