public boolean isAuthentic(byte[] authenticationKey, byte[] message, int messageOffset, int messageLength, ByteArrayWindow digest) { // copy digest from message ByteArrayWindow origDigest = new ByteArrayWindow(new byte[authenticationCodeLength], 0, authenticationCodeLength); System.arraycopy(digest.getValue(), digest.getOffset(), origDigest.getValue(), 0, authenticationCodeLength); // use the authenticate() method to recalculate the digest if (!authenticate(authenticationKey, message, messageOffset, messageLength, digest)) { return false; } return digest.equals(origDigest, authenticationCodeLength); }
public boolean isAuthentic(byte[] authenticationKey, byte[] message, int messageOffset, int messageLength, ByteArrayWindow digest) { // copy digest from message ByteArrayWindow origDigest = new ByteArrayWindow(new byte[authenticationCodeLength], 0, authenticationCodeLength); System.arraycopy(digest.getValue(), digest.getOffset(), origDigest.getValue(), 0, authenticationCodeLength); // use the authenticate() method to recalculate the digest if (!authenticate(authenticationKey, message, messageOffset, messageLength, digest)) { return false; } return digest.equals(origDigest, authenticationCodeLength); }
public boolean isAuthentic(byte[] authenticationKey, byte[] message, int messageOffset, int messageLength, ByteArrayWindow digest) { // copy digest from message ByteArrayWindow origDigest = new ByteArrayWindow(new byte[MESSAGE_AUTHENTICATION_CODE_LENGTH], 0, MESSAGE_AUTHENTICATION_CODE_LENGTH); System.arraycopy(digest.getValue(), digest.getOffset(), origDigest.getValue(), 0, MESSAGE_AUTHENTICATION_CODE_LENGTH); // use the authenticate() method to recalculate the digest if (!authenticate(authenticationKey, message, messageOffset, messageLength, digest)) { return false; } return digest.equals(origDigest, 12); }