@Test public void testFailedVerification() throws GeneralSecurityException { try { byte[] key = new byte[MAC_KEY_SIZE_IN_BYTES]; key[0] = 1; Poly1305.verifyMac(key, new byte[]{1}, new byte[MAC_TAG_SIZE_IN_BYTES]); fail("Expected GeneralSecurityException."); } catch (GeneralSecurityException e) { Truth.assertThat(e).hasMessageThat().containsMatch("invalid MAC"); } }
static void verifyMac(final byte[] key, byte[] data, byte[] mac) throws GeneralSecurityException { if (!Bytes.equal(computeMac(key, data), mac)) { throw new GeneralSecurityException("invalid MAC"); } }
Poly1305 { static void verifyMac(final byte[] key, byte[] data, byte[] mac) throws GeneralSecurityException { if (!Bytes.equal(computeMac(key, data), mac)) { throw new GeneralSecurityException("invalid MAC"); } } }
Poly1305 { static void verifyMac(final byte[] key, byte[] data, byte[] mac) throws GeneralSecurityException { if (!Bytes.equal(computeMac(key, data), mac)) { throw new GeneralSecurityException("invalid MAC"); } } private  Poly1305(); }
Poly1305 { static void verifyMac(final byte[] key, byte[] data, byte[] mac) throws GeneralSecurityException { if (!Bytes.equal(computeMac(key, data), mac)) { throw new GeneralSecurityException("invalid MAC"); } } private  Poly1305();  }
Poly1305 { static void verifyMac(final byte[] key, byte[] data, byte[] mac) throws GeneralSecurityException { if (!Bytes.equal(computeMac(key, data), mac)) { throw new GeneralSecurityException("invalid MAC"); } } private  Poly1305();  static final int MAC_TAG_SIZE_IN_BYTES; static final int MAC_KEY_SIZE_IN_BYTES; }