throw new CHKDecodeException("Invalid size: "+size);
}
// Check the hash.
Mac hmac = Mac.getInstance("HmacSHA256", hmacProvider);
hmac.init(new SecretKeySpec(cryptoKey, "HmacSHA256"));
hmac.update(plaintext); // plaintext includes lengthBytes
byte[] hashCheck = hmac.doFinal();
if(!Arrays.equals(hash, hashCheck)) {
throw new CHKDecodeException("HMAC is wrong, wrong decryption key?");
}
return Key.decompress(dontCompress ? false : key.isCompressed(), plaintext, size, bf,