示例#1
0
    def test_encryption_hmac(self):
        message = b'My secret message'
        key = b'9' * 32
        hmac = b'3' * 16

        cyphertext = crypto.symmetric_encrypt_HMAC(message, key, hmac)
        dmessage = crypto.symmetric_decrypt_HMAC(cyphertext, key, hmac)

        self.assertEqual(message, dmessage)

        # failing HMAC check
        with self.assertRaises(RuntimeError):
            crypto.symmetric_decrypt_HMAC(cyphertext, key, b'4'*16)
示例#2
0
    def test_encryption_hmac(self):
        message = b'My secret message'
        key = b'9' * 32
        hmac = b'3' * 16

        cyphertext = crypto.symmetric_encrypt_HMAC(message, key, hmac)
        dmessage = crypto.symmetric_decrypt_HMAC(cyphertext, key, hmac)

        self.assertEqual(message, dmessage)

        # failing HMAC check
        with self.assertRaises(RuntimeError):
            crypto.symmetric_decrypt_HMAC(cyphertext, key, b'4' * 16)
示例#3
0
文件: cm.py 项目: jackma92/steam
    def _recv_messages(self):
        for message in self.connection:
            if not self.connected:
                break

            if self.channel_key:
                if self.channel_hmac:
                    try:
                        message = crypto.symmetric_decrypt_HMAC(
                            message, self.channel_key, self.channel_hmac)
                    except RuntimeError as e:
                        self._LOG.exception(e)
                        break
                else:
                    message = crypto.symmetric_decrypt(message,
                                                       self.channel_key)

            gevent.spawn(self._parse_message, message)
            self.idle()

        if not self._seen_logon and self.channel_secured:
            if self.wait_event('disconnected', timeout=5) is not None:
                return

        gevent.spawn(self.disconnect)
示例#4
0
文件: cm.py 项目: jaredballou/steam
    def _recv_messages(self):
        for message in self.connection:
            if not self.connected:
                break

            if self.channel_key:
                if self.channel_hmac:
                    try:
                        message = crypto.symmetric_decrypt_HMAC(message, self.channel_key, self.channel_hmac)
                    except RuntimeError as e:
                        self._LOG.exception(e)
                        break
                else:
                    message = crypto.symmetric_decrypt(message, self.channel_key)

            gevent.spawn(self._parse_message, message)
            gevent.idle()

        if not self._seen_logon and self.channel_secured:
            if self.wait_event('disconnected', timeout=5) is not None:
                return

        gevent.spawn(self.disconnect)