Ejemplo n.º 1
0
    def __init__(self, **keys):

        if len(keys) == 1:
            self.rsAddr = PayloadIPMIv15.extract_rsAddr(keys['data'])
            self.netFn, self.rsLUN = PayloadIPMIv15.extract_netFn_rsLUN(
                keys['data'])
            self.checksum1 = PayloadIPMIv15.extract_checksum1(keys['data'])
            self.rqAddr = PayloadIPMIv15.extract_rqAddr(keys['data'])
            self.rqSeq, self.rqLUN = PayloadIPMIv15.extract_rqSeq_rqLUN(
                keys['data'])
            self.command = PayloadIPMIv15.extract_command(keys['data'])
            self.request_data = PayloadIPMIv15.extract_request_data(
                keys['data'])
            self.checksum2 = PayloadIPMIv15.extract_checksum2(keys['data'])
        elif len(keys) == 8:
            self.rsAddr = keys['rsAddr']
            self.netFn = keys['netFn']
            self.rsLUN = keys['rsLUN']
            self.checksum1 = IPMIHelper.two_complement_checksum(keys['rsAddr'] \
                                + self.hex_netFN_rsLUN())
            self.rqAddr = keys['rqAddr']
            self.rqSeq = keys['rqSeq']
            self.rqLUN = keys['rqLUN']
            self.command = keys['command']
            self.request_data = keys['request_data']
            self.checksum2 = IPMIHelper.two_complement_checksum(keys['rqAddr'] \
                                + self.hex_rqSeq_rqLUN() \
                                + keys['command'] \
                                + keys['request_data'])
        else:
            raise AttributeError(
                "Only 1 and 8 arguments constructor exists for PayloadIPMIv15 class."
            )
Ejemplo n.º 2
0
    def extract_checksum1(data):
        checksum = data[4:6]
        calculated_checksum = IPMIHelper.two_complement_checksum(data[0:4])

        if checksum == calculated_checksum:
            return checksum
        else:
            raise AttributeError(
                "Extracted checksum1 vs calculated checksum mismatch.")
Ejemplo n.º 3
0
    def extract_checksum2(data):
        checksum = data[len(data) - 2:]
        calculated_checksum = IPMIHelper.two_complement_checksum(
            data[6:len(data) - 2])

        if checksum == calculated_checksum:
            return checksum
        else:
            raise AttributeError(
                "Extracted checksum2 vs calculated checksum mismatch.")
Ejemplo n.º 4
0
    def __init__(self, **keys):

        if len(keys) == 2:
            self.iv = PayloadIPMIMessage.extract_iv(keys['data'])
            self.SIK = keys['SIK']
            self.decrypted_payload = self.decrypt_payload()
            self.rsAddr = PayloadIPMIMessage.extract_rsAddr(
                self.decrypted_payload)
            self.netFn, self.rsLUN = PayloadIPMIMessage.extract_netFn_rsLUN(
                self.decrypted_payload)
            self.checksum1 = PayloadIPMIMessage.extract_checksum1(
                self.decrypted_payload)
            self.rqAddr = PayloadIPMIMessage.extract_rqAddr(
                self.decrypted_payload)
            self.rqSeq, self.rqLUN = PayloadIPMIMessage.extract_rqSeq_rqLUN(
                self.decrypted_payload)
            self.command = PayloadIPMIMessage.extract_command(
                self.decrypted_payload)
            self.request_data = PayloadIPMIMessage.extract_request_data(
                self.decrypted_payload)
            self.checksum2 = PayloadIPMIMessage.extract_checksum2(
                self.decrypted_payload)
        elif len(keys) == 8:
            self.iv = PayloadIPMIMessage.generate_iv()
            self.SIK = keys['SIK']
            self.rsAddr = keys['rsAddr']
            self.netFn = keys['netFn']
            self.rsLUN = keys['rsLUN']
            self.checksum1 = IPMIHelper.two_complement_checksum(keys['rsAddr'] \
                                + self.hex_netFN_rsLUN())
            self.rqAddr = keys['rqAddr']
            self.rqSeq = keys['rqSeq']
            self.rqLUN = keys['rqLUN']
            self.command = keys['command']
            self.request_data = keys['request_data']
            self.checksum2 = IPMIHelper.two_complement_checksum(keys['rqAddr'] \
                                + self.hex_rqSeq_rqLUN() \
                                + keys['command'] \
                                + keys['request_data'])
        else:
            raise AttributeError(
                "Only 1 and 8 arguments constructor exists for PayloadIPMIv15 class."
            )