|
@ -884,9 +884,7 @@ class auth_chain_f(auth_chain_e): |
|
|
self.key_change_interval = int(server_info.protocol_param.split('#')[1]) # config are in second |
|
|
self.key_change_interval = int(server_info.protocol_param.split('#')[1]) # config are in second |
|
|
except: |
|
|
except: |
|
|
self.key_change_interval = 60 * 60 * 24 # a day by second |
|
|
self.key_change_interval = 60 * 60 * 24 # a day by second |
|
|
|
|
|
self.key_change_datetime_key = int(int(time.time()) / self.key_change_interval) |
|
|
def on_recv_auth_data(self, utc_time): |
|
|
|
|
|
self.key_change_datetime_key = int(utc_time / self.key_change_interval) |
|
|
|
|
|
self.key_change_datetime_key_bytes = [] # big bit first list |
|
|
self.key_change_datetime_key_bytes = [] # big bit first list |
|
|
for i in range(7, -1, -1): # big-ending compare to c |
|
|
for i in range(7, -1, -1): # big-ending compare to c |
|
|
self.key_change_datetime_key_bytes.append((self.key_change_datetime_key >> (8 * i)) & 0xFF) |
|
|
self.key_change_datetime_key_bytes.append((self.key_change_datetime_key >> (8 * i)) & 0xFF) |
|
@ -898,13 +896,9 @@ class auth_chain_f(auth_chain_e): |
|
|
random = xorshift128plus() |
|
|
random = xorshift128plus() |
|
|
# key xor with key_change_datetime_key |
|
|
# key xor with key_change_datetime_key |
|
|
new_key = bytearray(key) |
|
|
new_key = bytearray(key) |
|
|
new_key_str = '' |
|
|
|
|
|
for i in range(0, 8): |
|
|
for i in range(0, 8): |
|
|
new_key[i] ^= self.key_change_datetime_key_bytes[i] |
|
|
new_key[i] ^= self.key_change_datetime_key_bytes[i] |
|
|
new_key_str += chr(new_key[i]) |
|
|
random.init_from_bin(new_key) |
|
|
for i in range(8, len(new_key)): |
|
|
|
|
|
new_key_str += chr(new_key[i]) |
|
|
|
|
|
random.init_from_bin(to_bytes(new_key_str)) |
|
|
|
|
|
# 补全数组长为12~24-1 |
|
|
# 补全数组长为12~24-1 |
|
|
list_len = random.next() % (8 + 16) + (4 + 8) |
|
|
list_len = random.next() % (8 + 16) + (4 + 8) |
|
|
for i in range(0, list_len): |
|
|
for i in range(0, list_len): |
|
|