Interface Mac

  • All Known Implementing Classes:
    LegacyFullMac, PrfMac

    public interface Mac
    Interface for Message Authentication Codes (MAC).

    Security guarantees

    Message Authentication Codes provide symmetric message authentication. Instances implementing this interface are secure against existential forgery under chosen plaintext attack, and can be deterministic or randomized. This interface should be used for authentication only, and not for other purposes like generation of pseudorandom bytes.

    Since:
    1.0.0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      byte[] computeMac​(byte[] data)
      Computes message authentication code (MAC) for data.
      void verifyMac​(byte[] mac, byte[] data)
      Verifies whether mac is a correct authentication code (MAC) for data.
    • Method Detail

      • computeMac

        byte[] computeMac​(byte[] data)
                   throws java.security.GeneralSecurityException
        Computes message authentication code (MAC) for data.
        Returns:
        MAC value
        Throws:
        java.security.GeneralSecurityException
      • verifyMac

        void verifyMac​(byte[] mac,
                       byte[] data)
                throws java.security.GeneralSecurityException
        Verifies whether mac is a correct authentication code (MAC) for data.
        Throws:
        java.security.GeneralSecurityException - if mac is not a correct MAC for data