code: func (s *streamPacketCipher) writePacket(seqNum uint32, w io.Writer, rand io.Reader, packet []byte) error {
  	if len(packet) > maxPacket {
  		return errors.New("ssh: packet too large")
  	}
  
  	paddingLength := packetSizeMultiple - (prefixLen+len(packet))%packetSizeMultiple
  	if paddingLength < 4 {
  		paddingLength += packetSizeMultiple
  	}
  
  	length := len(packet) + 1 + paddingLength
  	binary.BigEndian.PutUint32(s.prefix[:], uint32(length))
  	s.prefix[4] = byte(paddingLength)
  	padding := s.padding[:paddingLength]
  	if _, err := io.ReadFull(rand, padding); err != nil {
  		return err
  	}
  
  	if s.mac != nil {
  		s.mac.Reset()
  		binary.BigEndian.PutUint32(s.seqNumBytes[:], seqNum)
  		s.mac.Write(s.seqNumBytes[:])
  		s.mac.Write(s.prefix[:])
  		s.mac.Write(packet)
  		s.mac.Write(padding)
  	}
  
  	s.cipher.XORKeyStream(s.prefix[:], s.prefix[:])
  	s.cipher.XORKeyStream(packet, packet)
  	s.cipher.XORKeyStream(padding, padding)
  
  	if _, err := w.Write(s.prefix[:]); err != nil {
  		return err
  	}
  	if _, err := w.Write(packet); err != nil {
  		return err
  	}
  	if _, err := w.Write(padding); err != nil {
  		return err
  	}
  
  	if s.mac != nil {
  		s.macResult = s.mac.Sum(s.macResult[:0])
  		if _, err := w.Write(s.macResult); err != nil {
  			return err
  		}
  	}
  
  	return nil
  }
docs: // writePacket encrypts and sends a packet of data to the writer argument