* randomly generated and stored with the host value to hash hosts during
* matching.
*/
private void generateHash() throws JSchException {
// Create random salt for session
MAC macsha1 = getMAC();
_salt = new byte[macsha1.getBlockSize()];
getRandom().fill(_salt, 0, _salt.length);
try { // Create the hashed host using salt and MAC-SHA1
synchronized( macsha1 ) { // MAC is not thread-safe
macsha1.init(_salt);
byte[] hostBytes = Util.str2byte(_host);
macsha1.update(hostBytes, 0, hostBytes.length);
_hashedHost = new byte[macsha1.getBlockSize()];
macsha1.doFinal(_hashedHost, 0);
}
} catch(Exception e) {
throw new JSchException("Failed to create HashedHostKey: " + e, e);
}