Verify checksum for incoming message.

    :param message: incoming message
    :param previous_csum: accumulated checksum value

    :return return True if message checksum type is None
    or checksum is correct
428961
def verify_checksum(message, previous_csum=0):
    
    if message.message_type in CHECKSUM_MSG_TYPES:
        csum = compute_checksum(
            message.checksum[0],
            message.args,
            previous_csum,
        )

        if csum == message.checksum[1]:
            return True
        else:
            return False
    else:
        return True
69351
def _flush_message_buffer(self):
        
        while True:
            message_bytes = self.transport.receive()

            # there were no messages receives, so break from the loop
            if message_bytes is None:
                break

            # check if the message is encrypted and decrypt if necessary
            if message_bytes[:4] == b"\xfdSMB":
                message = SMB2TransformHeader()
                message.unpack(message_bytes)
                message_bytes = self._decrypt(message)

            # now retrieve message(s) from response
            is_last = False
            session_id = None
            while not is_last:
                next_command = struct.unpack("<L", message_bytes[20:24])[0]
                header_length = \
                    next_command if next_command != 0 else len(message_bytes)
                header_bytes = message_bytes[:header_length]
                message = SMB2HeaderResponse()
                message.unpack(header_bytes)

                flags = message['flags']
                if not flags.has_flag(Smb2Flags.SMB2_FLAGS_RELATED_OPERATIONS):
                    session_id = message['session_id'].get_value()

                self._verify(message, session_id)
                message_id = message['message_id'].get_value()
                request = self.outstanding_requests.get(message_id, None)
                if not request:
                    error_msg = "Received response with an unknown message " \
                                "ID: %d" % message_id
                    raise smbprotocol.exceptions.SMBException(error_msg)

                # add the upper credit limit based on the credits granted by
                # the server
                credit_response = message['credit_response'].get_value()
                self.sequence_window['high'] += \
                    credit_response if credit_response > 0 else 1

                request.response = message
                self.outstanding_requests[message_id] = request

                message_bytes = message_bytes[header_length:]
                is_last = next_command == 0
755037
function verifyChecksum(fileName, checksum) {
  return kew.resolve(hasha.fromFile(fileName, {algorithm: 'sha256'})).then(function (hash) {
    var result = checksum == hash
    if (result) {
      console.log('Verified checksum of previously downloaded file')
    } else {
      console.log('Checksum did not match')
    }
    return result
  }).fail(function (err) {
    console.error('Failed to verify checksum: ', err)
    return false
  })
}
1087687
private boolean verifyHelloMessage(byte[] helloMsg) {
		if (sdpHelloHashReceived != null) {
			String hash = calculateSHA256Hash(helloMsg, 0, helloMsg.length);
			boolean hashesMatched = hash.toUpperCase().equals(
					sdpHelloHashReceived.toUpperCase());
			if (platform.getLogger().isEnabled()) {
				if (hashesMatched) {
					logString("verifyHelloMessage() Hello hash verified OK.");
				} else {
					logString("verifyHelloMessage() Hello hash does NOT match  hash= '"
							+ hash
							+ "' expected (SDP) = '"
							+ sdpHelloHashReceived + "'");
				}
			}
			return hashesMatched;
		} else {
			return true;
		}
	}
363386
def _has_message(self):
        
        sep = protocol.MINIMAL_LINE_SEPARATOR.encode(self.encoding)
        return sep in self._receive_buffer
29334
private static byte calculateChecksum(byte[] buffer) {
		byte checkSum = (byte)0xFF;
		for (int i=1; i<buffer.length-1; i++) {
			checkSum = (byte) (checkSum ^ buffer[i]);
		}
		logger.trace(String.format("Calculated checksum = 0x%02X", checkSum));
		return checkSum;
	}
1048304
protected function calculateChecksum() {
        // Calculating Checksum
        // Consider the right-most digit of the message to be in an "even" position,
        // and assign odd/even to each character moving from right to left
        // Even Position = 3, Odd Position = 1
        // Multiply it by the number
        // Add all of that and do 10-(?mod10)
        $even = true;
        $this->checksumValue = 0;
        $c = strlen($this->text);
        for ($i = $c; $i > 0; $i--) {
            if ($even === true) {
                $multiplier = 3;
                $even = false;
            } else {
                $multiplier = 1;
                $even = true;
            }

            $this->checksumValue += $this->keys[$this->text[$i - 1]] * $multiplier;
        }

        $this->checksumValue = (10 - $this->checksumValue % 10) % 10;
    }
730959
public static function isProtocolMessage(Message $message)
    {
        // Temporary check to maintain BC with legacy Messages.
        if (is_numeric($message->peek()) && $message->peek() < 100) {
            return true;
        }

        return false;
    }
487574
def match(self, message: Message) -> bool:
        
        if self.template:
            return self.template.match(message)
        return True
441491
def verify(self, signature):
        
        prehashed_digest = self._hasher.finalize()
        self.key.verify(
            signature=signature,
            data=prehashed_digest,
            signature_algorithm=ec.ECDSA(Prehashed(self.algorithm.signing_hash_type())),
        )
914775
def verify_checksum(response, expecting)
      if verify_checksums
        if Crc16.ekm_crc16_matches?(response[1..-3], expecting)
          @logger.debug "Checksum matches"
        else
          @logger.error "CRC16 Checksum doesn't match. Expecting #{expecting} but was #{Crc16.crc16(response)}"
          #raise EkmOmnimeterError, "Checksum doesn't match"
        end
      end
    end
557698
def Verify(self, message, signature):
    """"""
    siglen = len(signature)
    if siglen == 20:
      hash_algorithm = hashes.SHA1()
    elif siglen == 32:
      hash_algorithm = hashes.SHA256()
    else:
      raise VerificationError("Invalid signature length %d." % siglen)

    h = hmac.HMAC(self.key, hash_algorithm, backend=openssl.backend)
    h.update(message)
    try:
      h.verify(signature)
      return True
    except exceptions.InvalidSignature as e:
      raise VerificationError(e)
609721
def verify_message(self, key_or_address, signature, message=None, msg_hash=None):
        
        if isinstance(key_or_address, str):
            # they gave us a private key or a public key already loaded.
            key = self._network.parse.address(key_or_address)
        else:
            key = key_or_address

        try:
            msg_hash = self.hash_for_signing(message) if message is not None else msg_hash
            pair, is_compressed = self.pair_for_message_hash(signature, msg_hash)
        except EncodingError:
            return False
        return self.pair_matches_key(pair, key, is_compressed)
624715
def _CheckFieldMaskMessage(message):
  """"""
  message_descriptor = message.DESCRIPTOR
  if (message_descriptor.name != 'FieldMask' or
      message_descriptor.file.name != 'google/protobuf/field_mask.proto'):
    raise ValueError('Message {0} is not a FieldMask.'.format(
        message_descriptor.full_name))
984488
def message_checksum(msg):
    ''''''
    from .mavcrc import x25crc
    crc = x25crc()
    crc.accumulate_str(msg.name + ' ')
    # in order to allow for extensions the crc does not include
    # any field extensions
    crc_end = msg.base_fields()
    for i in range(crc_end):
        f = msg.ordered_fields[i]
        crc.accumulate_str(f.type + ' ')
        crc.accumulate_str(f.name + ' ')
        if f.array_length:
            crc.accumulate([f.array_length])
    return (crc.crc&0xFF) ^ (crc.crc>>8)
316308
def verify_download_checksum(build_file, checksum_file, attempt: 0)
      expected = File.read(checksum_file)
      actual = Digest::MD5.file(build_file).hexdigest
      if actual != expected
        log.error("GitHub fie #{build_file} checksum should be #{expected} " \
                  "but was #{actual}.")
        backup_failed_github_file(build_file, attempt)
        raise "Checksum for #{build_file} could not be verified."
      end

      log.info('Verified downloaded file checksum.')
    end
518440
def verifymessage(self, address, signature, message):
        """"""
        return self.req("verifymessage", [address, signature, message])