@Test public void testPrfUniformity() throws GeneralSecurityException { for (MacTestVector t : HMAC_TEST_VECTORS) { Prf prf = new PrfHmacJce(t.algName, new SecretKeySpec(t.key, "HMAC")); byte[] prBytes = prf.compute(t.tag, t.tag.length); TestUtil.ztestUniformString(prBytes); TestUtil.ztestAutocorrelationUniformString(prBytes); TestUtil.ztestCrossCorrelationUniformStrings(prBytes, t.tag); } }
@Override public byte[] compute(byte[] data, int outputLength) throws GeneralSecurityException { if (outputLength > maxOutputLength) { throw new InvalidAlgorithmParameterException("tag size too big"); } localMac.get().update(data); return Arrays.copyOf(localMac.get().doFinal(), outputLength); }
PrfHmacJce implements Prf { @Override public byte[] compute(byte[] data, int outputLength) throws GeneralSecurityException { if (outputLength > maxOutputLength) { throw new InvalidAlgorithmParameterException("tag size too big"); } localMac.get().update(data); return Arrays.copyOf(localMac.get().doFinal(), outputLength); } }
PrfHmacJce implements Prf { @Override public byte[] compute(byte[] data, int outputLength) throws GeneralSecurityException { if (outputLength > maxOutputLength) { throw new InvalidAlgorithmParameterException("tag size too big"); } localMac.get().update(data); return Arrays.copyOf(localMac.get().doFinal(), outputLength); } PrfHmacJce(String algorithm, java.security.Key key); }
PrfHmacJce implements Prf { @Override public byte[] compute(byte[] data, int outputLength) throws GeneralSecurityException { if (outputLength > maxOutputLength) { throw new InvalidAlgorithmParameterException("tag size too big"); } localMac.get().update(data); return Arrays.copyOf(localMac.get().doFinal(), outputLength); } PrfHmacJce(String algorithm, java.security.Key key); @Override byte[] compute(byte[] data, int outputLength); int getMaxOutputLength(); }
PrfHmacJce implements Prf { @Override public byte[] compute(byte[] data, int outputLength) throws GeneralSecurityException { if (outputLength > maxOutputLength) { throw new InvalidAlgorithmParameterException("tag size too big"); } localMac.get().update(data); return Arrays.copyOf(localMac.get().doFinal(), outputLength); } PrfHmacJce(String algorithm, java.security.Key key); @Override byte[] compute(byte[] data, int outputLength); int getMaxOutputLength();  }