decrypt(payload, 0, decr, 0, sessionKey, iv, payload.length);
if (decr == null) {
_log.error("Error decrypting the data - payload " + payload.length + " decrypted to null");
return null;
}
<BUG>int cur = 0;
byte h[] = _context.sha().calculateHash(iv).getData();
for (int i = 0; i < Hash.HASH_LENGTH; i++) {
if (decr[i] != h[i]) {
_log.error("Hash does not match [key=" + sessionKey + " / iv =" + DataHelper.toString(iv, iv.length)</BUG>
+ "]", new Exception("Hash error"));

decrypt(payload, 0, decr, 0, sessionKey, iv, payload.length);
if (decr == null) {
_log.error("Error decrypting the data - payload " + payload.length + " decrypted to null");
return null;
}
byte h[] = SimpleByteCache.acquire(Hash.HASH_LENGTH);
_context.sha().calculateHash(iv, 0, 16, h, 0);
boolean eq = DataHelper.eq(decr, 0, h, 0, Hash.HASH_LENGTH);
SimpleByteCache.release(h);
if (!eq) {
_log.error("Hash does not match [key=" + sessionKey + " / iv =" + DataHelper.toString(iv, iv.length)
