Class PrfAesCmacConscrypt

  • All Implemented Interfaces:
    Prf

    @Immutable
    public final class PrfAesCmacConscrypt
    extends java.lang.Object
    implements Prf
    Prf implementation of AES-CMAC using Conscrypt.

    AES-CMAC is defined in RFC 4493 and standardized by NIST in 800-38B.

    This implementation here supports both 128-bit and 256-bit keys.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] compute​(byte[] data, int outputLength)
      Computes the PRF selected by the underlying key on input and returns the first outputLength bytes.
      static Prf create​(AesCmacPrfKey key)
      Returns a Prf primitive from an AesCmacPrfKey.
      • Methods inherited from class java.lang.Object

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

      • create

        public static Prf create​(AesCmacPrfKey key)
                          throws java.security.GeneralSecurityException
        Returns a Prf primitive from an AesCmacPrfKey.
        Throws:
        java.security.GeneralSecurityException
      • compute

        public byte[] compute​(byte[] data,
                              int outputLength)
                       throws java.security.GeneralSecurityException
        Description copied from interface: Prf
        Computes the PRF selected by the underlying key on input and returns the first outputLength bytes.
        Specified by:
        compute in interface Prf
        Parameters:
        data - the input to compute the PRF on.
        outputLength - the desired length of the output in bytes. When choosing this parameter keep the birthday paradox in mind. If you have 2^n different inputs that your system has to handle set the output length to ceil(n/4 + 4) This corresponds to 2*n + 32 bits, meaning a collision will occur with a probability less than 1:2^32. When in doubt, request a security review.
        Throws:
        java.security.GeneralSecurityException - if the algorithm fails or if the output of algorithm is less than outputLength.