当前位置: 首页>>代码示例>>Python>>正文


Python Message.add方法代码示例

本文整理汇总了Python中ssh.message.Message.add方法的典型用法代码示例。如果您正苦于以下问题:Python Message.add方法的具体用法?Python Message.add怎么用?Python Message.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ssh.message.Message的用法示例。


在下文中一共展示了Message.add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _parse_kexdh_init

# 需要导入模块: from ssh.message import Message [as 别名]
# 或者: from ssh.message.Message import add [as 别名]
 def _parse_kexdh_init(self, m):
     # server mode
     self.e = m.get_mpint()
     if (self.e < 1) or (self.e > P - 1):
         raise SSHException('Client kex "e" is out of range')
     K = pow(self.e, self.x, P)
     key = str(self.transport.get_server_key())
     # okay, build up the hash H of (V_C || V_S || I_C || I_S || K_S || e || f || K)
     hm = Message()
     hm.add(self.transport.remote_version, self.transport.local_version,
            self.transport.remote_kex_init, self.transport.local_kex_init)
     hm.add_string(key)
     hm.add_mpint(self.e)
     hm.add_mpint(self.f)
     hm.add_mpint(K)
     H = SHA.new(str(hm)).digest()
     self.transport._set_K_H(K, H)
     # sign it
     sig = self.transport.get_server_key().sign_ssh_data(self.transport.rng, H)
     # send reply
     m = Message()
     m.add_byte(chr(_MSG_KEXDH_REPLY))
     m.add_string(key)
     m.add_mpint(self.f)
     m.add_string(str(sig))
     self.transport._send_message(m)
     self.transport._activate_outbound()
开发者ID:BlueMoon3000,项目名称:election-2016,代码行数:29,代码来源:kex_group1.py

示例2: _parse_kexdh_gex_reply

# 需要导入模块: from ssh.message import Message [as 别名]
# 或者: from ssh.message.Message import add [as 别名]
 def _parse_kexdh_gex_reply(self, m):
     host_key = m.get_string()
     self.f = m.get_mpint()
     sig = m.get_string()
     if (self.f < 1) or (self.f > self.p - 1):
         raise SSHException('Server kex "f" is out of range')
     K = pow(self.f, self.x, self.p)
     # okay, build up the hash H of (V_C || V_S || I_C || I_S || K_S || min || n || max || p || g || e || f || K)
     hm = Message()
     hm.add(self.transport.local_version, self.transport.remote_version,
            self.transport.local_kex_init, self.transport.remote_kex_init,
            host_key)
     if not self.old_style:
         hm.add_int(self.min_bits)
     hm.add_int(self.preferred_bits)
     if not self.old_style:
         hm.add_int(self.max_bits)
     hm.add_mpint(self.p)
     hm.add_mpint(self.g)
     hm.add_mpint(self.e)
     hm.add_mpint(self.f)
     hm.add_mpint(K)
     self.transport._set_K_H(K, SHA.new(str(hm)).digest())
     self.transport._verify_key(host_key, sig)
     self.transport._activate_outbound()
开发者ID:bendavis78,项目名称:ssh,代码行数:27,代码来源:kex_gex.py

示例3: _parse_kexdh_gex_init

# 需要导入模块: from ssh.message import Message [as 别名]
# 或者: from ssh.message.Message import add [as 别名]
 def _parse_kexdh_gex_init(self, m):
     self.e = m.get_mpint()
     if (self.e < 1) or (self.e > self.p - 1):
         raise SSHException('Client kex "e" is out of range')
     self._generate_x()
     self.f = pow(self.g, self.x, self.p)
     K = pow(self.e, self.x, self.p)
     key = str(self.transport.get_server_key())
     # okay, build up the hash H of (V_C || V_S || I_C || I_S || K_S || min || n || max || p || g || e || f || K)
     hm = Message()
     hm.add(self.transport.remote_version, self.transport.local_version,
            self.transport.remote_kex_init, self.transport.local_kex_init,
            key)
     if not self.old_style:
         hm.add_int(self.min_bits)
     hm.add_int(self.preferred_bits)
     if not self.old_style:
         hm.add_int(self.max_bits)
     hm.add_mpint(self.p)
     hm.add_mpint(self.g)
     hm.add_mpint(self.e)
     hm.add_mpint(self.f)
     hm.add_mpint(K)
     H = SHA.new(str(hm)).digest()
     self.transport._set_K_H(K, H)
     # sign it
     sig = self.transport.get_server_key().sign_ssh_data(self.transport.rng, H)
     # send reply
     m = Message()
     m.add_byte(chr(_MSG_KEXDH_GEX_REPLY))
     m.add_string(key)
     m.add_mpint(self.f)
     m.add_string(str(sig))
     self.transport._send_message(m)
     self.transport._activate_outbound()
开发者ID:bendavis78,项目名称:ssh,代码行数:37,代码来源:kex_gex.py

示例4: test_3_add

# 需要导入模块: from ssh.message import Message [as 别名]
# 或者: from ssh.message.Message import add [as 别名]
 def test_3_add(self):
     msg = Message()
     msg.add(5)
     msg.add(0x1122334455L)
     msg.add(True)
     msg.add('cat')
     msg.add(['a', 'b'])
     self.assertEquals(str(msg), self.__d)
开发者ID:DouglasTurk,项目名称:ssh,代码行数:10,代码来源:test_message.py

示例5: test_3_add

# 需要导入模块: from ssh.message import Message [as 别名]
# 或者: from ssh.message.Message import add [as 别名]
 def test_3_add(self):
     msg = Message()
     msg.add(5)
     msg.add(0x1122334455)
     msg.add(True)
     msg.add(b'cat')
     msg.add([b'a', b'b'])
     self.assertEquals(bytes(msg), self.__d)
开发者ID:bobbyi,项目名称:ssh,代码行数:10,代码来源:test_message.py

示例6: _send_server_version

# 需要导入模块: from ssh.message import Message [as 别名]
# 或者: from ssh.message.Message import add [as 别名]
 def _send_server_version(self):
     # winscp will freak out if the server sends version info before the
     # client finishes sending INIT.
     t, data = self._read_packet()
     if t != CMD_INIT:
         raise SFTPError('Incompatible sftp protocol')
     version = struct.unpack('>I', data[:4])[0]
     # advertise that we support "check-file"
     extension_pairs = [ 'check-file', 'md5,sha1' ]
     msg = Message()
     msg.add_int(_VERSION)
     msg.add(*extension_pairs)
     self._send_packet(CMD_VERSION, str(msg))
     return version
开发者ID:BlueMoon3000,项目名称:election-2016,代码行数:16,代码来源:sftp.py

示例7: _parse_kexdh_reply

# 需要导入模块: from ssh.message import Message [as 别名]
# 或者: from ssh.message.Message import add [as 别名]
 def _parse_kexdh_reply(self, m):
     # client mode
     host_key = m.get_string()
     self.f = m.get_mpint()
     if (self.f < 1) or (self.f > P - 1):
         raise SSHException('Server kex "f" is out of range')
     sig = m.get_string()
     K = pow(self.f, self.x, P)
     # okay, build up the hash H of (V_C || V_S || I_C || I_S || K_S || e || f || K)
     hm = Message()
     hm.add(self.transport.local_version, self.transport.remote_version,
            self.transport.local_kex_init, self.transport.remote_kex_init)
     hm.add_string(host_key)
     hm.add_mpint(self.e)
     hm.add_mpint(self.f)
     hm.add_mpint(K)
     self.transport._set_K_H(K, SHA.new(str(hm)).digest())
     self.transport._verify_key(host_key, sig)
     self.transport._activate_outbound()
开发者ID:BlueMoon3000,项目名称:election-2016,代码行数:21,代码来源:kex_group1.py


注:本文中的ssh.message.Message.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。