byte[] Es2c;
byte[] MACc2s;
byte[] MACs2c;
byte[] K = kex.getK();
byte[] H = kex.getH();
Digest hash = kex.getHash();
Cipher s2ccipher;
Cipher c2scipher;
Mac s2cmac;
Mac c2smac;
Compression s2ccomp;
Compression c2scomp;
if (sessionId == null) {
sessionId = new byte[H.length];
System.arraycopy(H, 0, sessionId, 0, H.length);
}
Buffer buffer = new Buffer();
buffer.putMPInt(K);
buffer.putRawBytes(H);
buffer.putByte((byte) 0x41);
buffer.putRawBytes(sessionId);
int pos = buffer.available();
byte[] buf = buffer.array();
hash.update(buf, 0, pos);
IVc2s = hash.digest();
int j = pos - sessionId.length - 1;
buf[j]++;
hash.update(buf, 0, pos);
IVs2c = hash.digest();
buf[j]++;
hash.update(buf, 0, pos);
Ec2s = hash.digest();
buf[j]++;
hash.update(buf, 0, pos);
Es2c = hash.digest();
buf[j]++;
hash.update(buf, 0, pos);
MACc2s = hash.digest();
buf[j]++;
hash.update(buf, 0, pos);
MACs2c = hash.digest();
s2ccipher = NamedFactory.Utils.create(factoryManager.getCipherFactories(), negotiated[SshConstants.PROPOSAL_ENC_ALGS_STOC]);
Es2c = resizeKey(Es2c, s2ccipher.getBlockSize(), hash, K, H);
s2ccipher.init(isServer ? Cipher.Mode.Encrypt : Cipher.Mode.Decrypt, Es2c, IVs2c);