public Proposal(SSHPacket packet) { this.packet = packet; final int savedPos = packet.rpos(); packet.rpos(packet.rpos() + 17); // Skip message ID & cookie kex = fromCommaString(packet.readString()); sig = fromCommaString(packet.readString()); c2sCipher = fromCommaString(packet.readString()); s2cCipher = fromCommaString(packet.readString()); c2sMAC = fromCommaString(packet.readString()); s2cMAC = fromCommaString(packet.readString()); c2sComp = fromCommaString(packet.readString()); s2cComp = fromCommaString(packet.readString()); packet.rpos(savedPos); }
public Proposal(Config config) { kex = Factory.Named.Util.getNames(config.getKeyExchangeFactories()); sig = Factory.Named.Util.getNames(config.getSignatureFactories()); c2sCipher = s2cCipher = Factory.Named.Util.getNames(config.getCipherFactories()); c2sMAC = s2cMAC = Factory.Named.Util.getNames(config.getMACFactories()); c2sComp = s2cComp = Factory.Named.Util.getNames(config.getCompressionFactories()); packet = new SSHPacket(Message.KEXINIT); // Put cookie packet.ensureCapacity(16); config.getRandomFactory().create().fill(packet.array(), packet.wpos(), 16); packet.wpos(packet.wpos() + 16); // Put algorithm lists packet.putString(toCommaString(kex)); packet.putString(toCommaString(sig)); packet.putString(toCommaString(c2sCipher)); packet.putString(toCommaString(s2cCipher)); packet.putString(toCommaString(c2sMAC)); packet.putString(toCommaString(s2cMAC)); packet.putString(toCommaString(c2sComp)); packet.putString(toCommaString(s2cComp)); packet.putString(""); packet.putString(""); packet.putBoolean(false); // Optimistic next packet does not follow packet.putInt(0); // "Reserved" for future by spec }