code: private static boolean
  verify(Mac mac, byte [] signature, boolean truncation_ok) {
          byte [] expected = mac.doFinal();
          if (truncation_ok && signature.length < expected.length) {
                  byte [] truncated = new byte[signature.length];
                  System.arraycopy(expected, 0, truncated, 0, truncated.length);
                  expected = truncated;
          }
          return Arrays.equals(signature, expected);
  }
docs: Verifies the data (computes the secure hash and compares it to the input)
  @param mac The HMAC generator
  @param signature The signature to compare against
  @param truncation_ok If true, the signature may be truncated; only the
  number of bytes in the provided signature are compared.
  @return true if the signature matches, false otherwise