net.ninthtest.crypto
Class MessageAuthenticationException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by java.security.ProviderException
                  extended by net.ninthtest.crypto.MessageAuthenticationException
All Implemented Interfaces:
Serializable

public class MessageAuthenticationException
extends ProviderException

A runtime exception used to indicate that MAC verification has failed.

This exception is thrown when message authentication for a combined cipher+MAC (e.g. Helix) fails, typically due to a mismatch between the expected MAC and the actual MAC.

Version:
1.0
Author:
Matthew Zipay (mattz@ninthtest.info)
See Also:
Serialized Form

Constructor Summary
MessageAuthenticationException(String message)
          Creates a new MessageAuthenticationException with the specified detail message.
MessageAuthenticationException(String message, byte[] expectedMac, byte[] actualMac)
          Creates a new MessageAuthenticationException with the specified detail message, and saving the expected and actual MACs for reference.
MessageAuthenticationException(String message, Throwable cause)
          Creates a new MessageAuthenticationException with the specified detail message and cause.
 
Method Summary
 byte[] getActualMac()
          Returns the MAC that was actually generated.
 byte[] getExpectedMac()
          Returns the MAC that was expected to be generated.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MessageAuthenticationException

public MessageAuthenticationException(String message)
Creates a new MessageAuthenticationException with the specified detail message.

Parameters:
message - the detail message describing this exception

MessageAuthenticationException

public MessageAuthenticationException(String message,
                                      byte[] expectedMac,
                                      byte[] actualMac)
Creates a new MessageAuthenticationException with the specified detail message, and saving the expected and actual MACs for reference.

Parameters:
message - the detail message describing this exception
expectedMac - the MAC that was expected to be generated
actualMac - the MAC that was actually generated

MessageAuthenticationException

public MessageAuthenticationException(String message,
                                      Throwable cause)
Creates a new MessageAuthenticationException with the specified detail message and cause.

Parameters:
message - the detail message describing this exception
cause - the throwable that caused this exception to be thrown, or null if the cause is nonexistent/unknown
Method Detail

getExpectedMac

public byte[] getExpectedMac()
Returns the MAC that was expected to be generated.

Returns:
a copy of the expected MAC

getActualMac

public byte[] getActualMac()
Returns the MAC that was actually generated.

Returns:
a copy of the actual MAC


Copyright © 2010-2014 Matthew Zipay. All Rights Reserved.