Exemple #1
0
 def p_encryption_key_request(self, c):
     self.event.on_encryption_key_request.fire(server_id=c.server_id, public_key=c.public_key, verify_token=c.verify_token)
     if config.USE_ENCRYPTION:
         self.cipher = encryption.make_aes(self.factory.client_key, self.factory.client_key)
         self.decipher = encryption.make_aes(self.factory.client_key, self.factory.client_key)
         public_key = encryption.load_pubkey(c.public_key)
         enc_shared_sercet = encryption.encrypt(self.factory.client_key, public_key)
         enc_4bytes = encryption.encrypt(c.verify_token, public_key)
         if config.ONLINE_LOGIN:
             yield self.do_auth(c.server_id, c.public_key)
         self.send_packet("encryption key response",
                          {"shared_length": len(enc_shared_sercet),
                          "shared_secret": enc_shared_sercet,
                          "token_length": len(enc_4bytes),
                          "token_secret": enc_4bytes})
     else:
         self.send_packet("client statuses", {"status": 0})
Exemple #2
0
 def p_encryption_key_request(self, c):
     if config.USE_ENCRYPTION:
         try:
             self.cipher = encryption.make_aes(self.factory.client_key, self.factory.client_key)
             self.decipher = encryption.make_aes(self.factory.client_key, self.factory.client_key)
             public_key = encryption.load_pubkey(c.public_key)
             enc_shared_sercet = encryption.encrypt(self.factory.client_key, public_key)
             enc_4bytes = encryption.encrypt(c.verify_token, public_key)
             if config.ONLINE_LOGIN:
                 yield self.do_auth(c.server_id, c.public_key)
             self.send_packet("encryption key response",
                              {"shared_length": len(enc_shared_sercet),
                              "shared_secret": enc_shared_sercet,
                              "token_length": len(enc_4bytes),
                              "token_secret": enc_4bytes})
         except ImportError:
             log.msg('PyCrypto not installed, skipping encryption.')
             self.send_packet("client statuses", {"status": 0})
     else:
         log.msg('USE_ENCRYPTION is False, skipping encryption.')
         self.send_packet("client statuses", {"status": 0})
Exemple #3
0
 def p_encryption_key_request(self, c):
     if config.USE_ENCRYPTION:
         try:
             import encryption
             key16 = encryption.get_random_bytes()
             self.cipher = encryption.make_aes(key16, key16)
             self.decipher = encryption.make_aes(key16, key16)
             public_key = encryption.load_pubkey(c.public_key)
             enc_shared_sercet = encryption.encrypt(key16, public_key)
             enc_4bytes = encryption.encrypt(c.verify_token, public_key)
             self.send_packet(
                 "encryption key response",
                 {"shared_length": len(enc_shared_sercet),
                  "shared_secret": enc_shared_sercet,
                  "token_length": len(enc_4bytes),
                  "token_secret": enc_4bytes})
         except ImportError:
             log.msg('PyCrypto not installed, skipping encryption.')
             self.send_packet("client statuses", {"status": 0})
     else:
         log.msg('USE_ENCRYPTION is False, skipping encryption.')
         self.send_packet("client statuses", {"status": 0})