mirror of
https://github.com/ThunderEX/py-kms.git
synced 2025-04-18 07:44:00 +03:00
fix compatibility with py2.6 on Windows
This commit is contained in:
parent
6f5dc384da
commit
a075ff3012
@ -6,7 +6,7 @@ from structure import Structure
|
||||
|
||||
|
||||
# v4 AES Key
|
||||
key = bytearray([0x05, 0x3D, 0x83, 0x07, 0xF9, 0xE5, 0xF0, 0x88, 0xEB, 0x5E, 0xA6, 0x68, 0x6C, 0xF0, 0x37, 0xC7, 0xE4, 0xEF, 0xD2, 0xD6])
|
||||
key = b'\x05\x3D\x83\x07\xF9\xE5\xF0\x88\xEB\x5E\xA6\x68\x6C\xF0\x37\xC7\xE4\xEF\xD2\xD6'
|
||||
|
||||
# Xor Buffer
|
||||
def xorBuffer(source, offset, destination, size):
|
||||
|
@ -52,7 +52,7 @@ class kmsRequestV5(kmsBase):
|
||||
('hash', '32s'),
|
||||
)
|
||||
|
||||
key = bytearray([ 0xCD, 0x7E, 0x79, 0x6F, 0x2A, 0xB2, 0x5D, 0xCB, 0x55, 0xFF, 0xC8, 0xEF, 0x83, 0x64, 0xC4, 0x70 ])
|
||||
key = b'\xCD\x7E\x79\x6F\x2A\xB2\x5D\xCB\x55\xFF\xC8\xEF\x83\x64\xC4\x70'
|
||||
|
||||
v6 = False
|
||||
|
||||
@ -80,7 +80,7 @@ class kmsRequestV5(kmsBase):
|
||||
|
||||
def encryptResponse(self, request, decrypted, response):
|
||||
randomSalt = bytearray(os.urandom(16))
|
||||
result = hashlib.sha256(randomSalt).digest()
|
||||
result = hashlib.sha256(bytes(randomSalt)).digest()
|
||||
|
||||
iv = bytearray(request['message']['salt'])
|
||||
|
||||
|
@ -28,7 +28,7 @@ class kmsRequestV6(kmsRequestV5):
|
||||
('hmac', '16s'),
|
||||
)
|
||||
|
||||
key = bytearray([ 0xA9, 0x4A, 0x41, 0x95, 0xE2, 0x01, 0x43, 0x2D, 0x9B, 0xCB, 0x46, 0x04, 0x05, 0xD8, 0x4A, 0x21 ])
|
||||
key = b'\xA9\x4A\x41\x95\xE2\x01\x43\x2D\x9B\xCB\x46\x04\x05\xD8\x4A\x21'
|
||||
|
||||
v6 = True
|
||||
|
||||
@ -36,7 +36,7 @@ class kmsRequestV6(kmsRequestV5):
|
||||
|
||||
def encryptResponse(self, request, decrypted, response):
|
||||
randomSalt = bytearray(os.urandom(16))
|
||||
result = hashlib.sha256(randomSalt).digest()
|
||||
result = hashlib.sha256(bytes(randomSalt)).digest()
|
||||
|
||||
SaltC = bytearray(request['message']['salt'])
|
||||
DSaltC = bytearray(decrypted['salt'])
|
||||
|
@ -91,6 +91,9 @@ def main():
|
||||
IOError, # py < 3.3
|
||||
):
|
||||
server = socketserver.TCPServer((config['ip'], config['port']), kmsServer)
|
||||
except AttributeError: # py < 2.7
|
||||
print("Python version too old to call socket.inet_pton, use IP v4 only")
|
||||
server = socketserver.TCPServer((config['ip'], config['port']), kmsServer)
|
||||
else:
|
||||
server = V6Server((config['ip'], config['port']), kmsServer)
|
||||
server.timeout = 5
|
||||
|
Loading…
x
Reference in New Issue
Block a user