def createKmsRequest(): # Update the call ID config['call_id'] += 1 # KMS Protocol Major Version if config['KMSProtocolMajorVersion'] == 4: handler = kmsRequestV4(None, config) elif config['KMSProtocolMajorVersion'] == 5: handler = kmsRequestV5(None, config) elif config['KMSProtocolMajorVersion'] == 6: handler = kmsRequestV6(None, config) else: return None requestBase = createKmsRequestBase() return handler.generateRequest(requestBase)
def generateKmsResponseData(data, config): version = GenericRequestHeader(data)['versionMajor'] currentDate = time.strftime("%a %b %d %H:%M:%S %Y") if version == 4: print("Received V%d request on %s." % (version, currentDate)) messagehandler = kmsRequestV4.kmsRequestV4(data, config) elif version == 5: print("Received V%d request on %s." % (version, currentDate)) messagehandler = kmsRequestV5.kmsRequestV5(data, config) elif version == 6: print("Received V%d request on %s." % (version, currentDate)) messagehandler = kmsRequestV6.kmsRequestV6(data, config) else: print("Unhandled KMS version.", version) messagehandler = kmsRequestUnknown.kmsRequestUnknown(data, config) return messagehandler.executeRequestLogic()
def generateKmsResponseData(data, config): version = kmsBase.GenericRequestHeader(data)["versionMajor"] currentDate = datetime.datetime.now().ctime() if version == 4: print "Received V%d request on %s." % (version, currentDate) messagehandler = kmsRequestV4.kmsRequestV4(data, config) messagehandler.executeRequestLogic() elif version == 5: print "Received V%d request on %s." % (version, currentDate) messagehandler = kmsRequestV5.kmsRequestV5(data, config) messagehandler.executeRequestLogic() elif version == 6: print "Received V%d request on %s." % (version, currentDate) messagehandler = kmsRequestV6.kmsRequestV6(data, config) messagehandler.executeRequestLogic() else: print "Unhandled KMS version.", version messagehandler = kmsRequestUnknown.kmsRequestUnknown(data, config) return messagehandler.getResponse()
def generateKmsResponseData(data, config): version = kmsBase.GenericRequestHeader(data)['versionMajor'] currentDate = datetime.datetime.now().ctime() if version == 4: print "Received V%d request on %s." % (version, currentDate) messagehandler = kmsRequestV4.kmsRequestV4(data, config) messagehandler.executeRequestLogic() elif version == 5: print "Received V%d request on %s." % (version, currentDate) messagehandler = kmsRequestV5.kmsRequestV5(data, config) messagehandler.executeRequestLogic() elif version == 6: print "Received V%d request on %s." % (version, currentDate) messagehandler = kmsRequestV6.kmsRequestV6(data, config) messagehandler.executeRequestLogic() else: print "Unhandled KMS version.", version messagehandler = kmsRequestUnknown.kmsRequestUnknown(data, config) return messagehandler.getResponse()
def readKmsResponseV6(data): response = kmsRequestV6.ResponseV5(data) decrypted = kmsRequestV6(data, config).decryptResponse(response) message = decrypted['message'] return message