*/
private boolean verify(BigInteger slaveID, Proto.ClientMessageType msgType,
byte[] message)
{
// first, verify the signature matches the given slave ID
Mac mac;
synchronized (slaveIdToSecret) {
mac = slaveIdToSecret.get(slaveID);
}
if (mac == null) {
AppXrw.logger.warning("Rejected message from " + slaveID +
". MAC not found.");
return false;
}
mac.update(message, 0, message.length - 20);
// copy the signature into its own array for processing
byte[] signature = new byte[20];
System.arraycopy(message, message.length - 20, signature, 0, 20);
// compare the signatures
if (!Arrays.equals(signature, mac.doFinal())) {
AppXrw.logger.warning("Rejected message from " + slaveID +
". Signature mismatch.");
return false;
}