Class PrfMac

  • All Implemented Interfaces:
    Mac

    @Immutable
    public class PrfMac
    extends java.lang.Object
    implements Mac
    Class that provides the functionality expressed by the Mac primitive using a Prf implementation.
    • Constructor Summary

      Constructors 
      Constructor Description
      PrfMac​(Prf wrappedPrf, int tagSize)
      Wrap wrappedPrf in a Mac primitive with the specified tagSize
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] computeMac​(byte[] data)
      Computes message authentication code (MAC) for data.
      static Mac create​(AesCmacKey key)
      Creates an object implementing the Mac interface using an AesCmac underneath.
      static Mac create​(HmacKey key)
      Creates an object implementing the Mac interface using an Hmac underneath.
      void verifyMac​(byte[] mac, byte[] data)
      Verifies whether mac is a correct authentication code (MAC) for data.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PrfMac

        public PrfMac​(Prf wrappedPrf,
                      int tagSize)
               throws java.security.GeneralSecurityException
        Wrap wrappedPrf in a Mac primitive with the specified tagSize
        Throws:
        java.security.GeneralSecurityException
    • Method Detail

      • create

        public static Mac create​(AesCmacKey key)
                          throws java.security.GeneralSecurityException
        Creates an object implementing the Mac interface using an AesCmac underneath.
        Throws:
        java.security.GeneralSecurityException
      • create

        public static Mac create​(HmacKey key)
                          throws java.security.GeneralSecurityException
        Creates an object implementing the Mac interface using an Hmac underneath.
        Throws:
        java.security.GeneralSecurityException
      • computeMac

        public byte[] computeMac​(byte[] data)
                          throws java.security.GeneralSecurityException
        Description copied from interface: Mac
        Computes message authentication code (MAC) for data.
        Specified by:
        computeMac in interface Mac
        Returns:
        MAC value
        Throws:
        java.security.GeneralSecurityException
      • verifyMac

        public void verifyMac​(byte[] mac,
                              byte[] data)
                       throws java.security.GeneralSecurityException
        Description copied from interface: Mac
        Verifies whether mac is a correct authentication code (MAC) for data.
        Specified by:
        verifyMac in interface Mac
        Throws:
        java.security.GeneralSecurityException - if mac is not a correct MAC for data