A method and system for remotely comparing embedded device files

By randomly removing file contents and calculating verification codes in embedded devices, the problem of falsely reporting file verification codes by embedded devices is solved, effective remote comparison of embedded device files is realized, and communication traffic consumption is reduced.

CN116094741BActive Publication Date: 2025-05-13CHINA ELECTRIC POWER RESEARCH INSTITUTE CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210803743.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-07
Publication Date
2025-05-13
Estimated Expiration
2042-07-07

AI Technical Summary

Technical Problem

The prior art cannot effectively prevent embedded devices from falsely reporting file verification codes, resulting in the remote master station not being able to find that the files in the device have been replaced, and it consumes communication traffic by bytes, and cannot be implemented when there are too many or large files.

Method used

The remote master station sends the file to be compared to the embedded device. The remote master station removes the content of the preset length at the random location of the file, calculates the verification code, and sends the file name, random location and preset length to the embedded device. The embedded device determines the file based on the file name and calculates the verification code. The remote master station performs comparison to determine the normality of the file.

Benefits of technology

Effectively prevent the device from recording the initial verification code, so that the main station cannot find that the files in the device have been replaced, reducing the consumption of communication traffic and solving the problem of file comparison that cannot be implemented when there are too many or large files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116094741B_ABST
    Figure CN116094741B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for remotely comparing files of an embedded device, wherein the method comprises: a remote main station sends a file to be compared to an embedded device, and the remote main station and the embedded device store the file to be compared and a corresponding file name; the remote main station removes a first file content of a preset length at a random position of the file to be compared, and calculates a first check code of the first remaining file content; the remote main station sends the file name, the random position and the preset length of the file to be compared to the embedded device; the embedded device removes a second file content of a preset length based on the random position of the file to be compared, and calculates a second check code of the second remaining file content; the remote main station obtains the second file content and the second check code, and performs a consistency comparison between the first file content and the second file content, and performs a consistency comparison between the first check code and the second check code; when the comparison results are all consistent, it is determined that the file to be compared stored in the embedded device is normal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of embedded device software management, and more specifically, to a method and system for remotely comparing embedded device files. Background Art

[0002] In embedded devices, internal files sometimes need to be verified by a remote master station, which is currently mainly verified by calculating the file's MD5, SHA1, CRC32, etc. However, this method cannot prevent embedded devices from falsifying the original verification code, making the remote master station believe that the embedded device file is intact.

[0003] The existing technical solution is to directly record the MD5, SHA1, CRC32, etc. of the file, or read the file by byte and compare directly. If the embedded device is unwilling to report the file status truthfully, it will record the calculated values ​​of the initial MD5, SHA1, CRC32, etc., so that the master station cannot find that the file in the device has been changed; comparing by byte consumes communication traffic and cannot be implemented when there are many files or the files are very large.

[0004] Therefore, a technology is needed to achieve remote comparison of embedded device files. Summary of the invention

[0005] The technical solution of the present invention provides a method and system for remotely comparing embedded device files, so as to solve the problem of how to remotely compare embedded device files.

[0006] In order to solve the above problem, the present invention provides a method for remotely comparing embedded device files, the method comprising:

[0007] The remote main station sends the file to be compared to the embedded device, and the remote main station and the embedded device store the file to be compared and the corresponding file name;

[0008] The remote master station removes a first file content of a preset length at a random position of the file to be compared, and calculates a first check code of the first remaining file content;

[0009] The remote host station sends the file name, random position and preset length of the file to be compared to the embedded device;

[0010] The embedded device determines the stored file to be compared based on the file name, removes a second file content of a preset length based on a random position of the file to be compared, and calculates a second check code of the second remaining file content;

[0011] The remote master station obtains the second file content and the second verification code, and performs a consistency comparison between the first file content and the second file content, and performs a consistency comparison between the first verification code and the second verification code;

[0012] When the comparison results of the first file content and the second file content and the first verification code and the second verification code are all consistent, it is determined that the file to be compared stored in the embedded device is normal.

[0013] Preferably, it also includes:

[0014] When the comparison result between the first file content and the second file content or the first verification code and the second verification code is inconsistent, it is determined that the file to be compared stored in the embedded device is abnormal.

[0015] Preferably, the remote master station executes the method of remotely comparing the embedded device files at a preset time period or at any time.

[0016] Preferably, there are multiple files to be compared.

[0017] Preferably, the preset length is one byte.

[0018] Based on another aspect of the present invention, the present invention provides a system for remotely comparing embedded device files, the system comprising: a remote master station and an embedded device;

[0019] The remote main station is used to send the file to be compared to the embedded device, and the remote main station and the embedded device store the file to be compared and the corresponding file name; the remote main station removes the first file content of a preset length at a random position of the file to be compared, and calculates a first check code of the first remaining file content; the remote main station sends the file name, random position and preset length of the file to be compared to the embedded device; the remote main station obtains the second file content and the second check code, and performs a consistency comparison between the first file content and the second file content, and the first check code and the second check code; when the comparison results of the first file content and the second file content and the first check code and the second check code are all consistent, it is determined that the file to be compared stored in the embedded device is normal;

[0020] The embedded device is used to determine the stored file to be compared based on the file name, remove the second file content of a preset length based on the random position of the file to be compared, and calculate the second check code of the second remaining file content.

[0021] Preferably, the remote master station is further used for:

[0022] When the comparison result between the first file content and the second file content or the first verification code and the second verification code is inconsistent, it is determined that the file to be compared stored in the embedded device is abnormal.

[0023] Preferably, the remote master station executes the method of remotely comparing the embedded device files at a preset time period or at any time.

[0024] Preferably, there are multiple files to be compared.

[0025] Preferably, the preset length is one byte.

[0026] The technical solution of the present invention provides a method and system for remotely comparing files of an embedded device, wherein the method comprises: a remote main station sends a file to be compared to an embedded device, and the remote main station and the embedded device store the file to be compared and the corresponding file name; the remote main station removes a first file content of a preset length at a random position of the file to be compared, and calculates a first check code of the first remaining file content; the remote main station sends the file name, random position and preset length of the file to be compared to the embedded device; the embedded device determines a stored file to be compared based on the file name, removes a second file content of a preset length based on a random position of the file to be compared, and calculates a second check code of the second remaining file content; the remote main station obtains the second file content and the second check code, and performs a consistency comparison between the first file content and the second file content, and performs a consistency comparison between the first check code and the second check code; when the comparison results between the first file content and the second file content and between the first check code and the second check code are all consistent, it is determined that the file to be compared stored in the embedded device is normal. The technical solution of the present invention provides an embedded device file remote comparison method and system, which can effectively prevent the device from recording the calculated values ​​of the initial MD5, SHA1, CRC32, etc., so that the main station cannot find that the file in the device has been replaced; it can solve the problem of consuming communication traffic by byte comparison and being unable to implement file comparison when there are many files or the files are very large. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] A more complete understanding of exemplary embodiments of the present invention may be obtained by referring to the following drawings:

[0028] Figure 1 A flowchart of a method for remotely comparing embedded device files according to a preferred embodiment of the present invention;

[0029] Figure 2 A flowchart of a remote comparison method for embedded device files according to a preferred embodiment of the present invention;

[0030] Figure 3It is a schematic diagram of the principle of the remote comparison process of embedded device files according to the preferred embodiment of the present invention;

[0031] Figure 4 The figure is a structural diagram of a system for remotely comparing embedded device files according to a preferred embodiment of the present invention. DETAILED DESCRIPTION

[0032] Now, exemplary embodiments of the present invention are described with reference to the accompanying drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. These embodiments are provided to disclose the present invention in detail and completely and to fully convey the scope of the present invention to those skilled in the art. The terms used in the exemplary embodiments shown in the accompanying drawings are not intended to limit the present invention. In the accompanying drawings, the same units / elements are marked with the same reference numerals.

[0033] Unless otherwise specified, the terms (including technical terms) used herein have the commonly understood meanings to those skilled in the art. In addition, it is understood that the terms defined in commonly used dictionaries should be understood to have the same meanings as those in the context of the relevant fields, and should not be understood as idealized or overly formal meanings.

[0034] Figure 1 The present invention is a flowchart of a method for remotely comparing files of an embedded device according to a preferred embodiment of the present invention. The present invention provides a method for remotely comparing files of an embedded device, which prevents the device from recording the calculated values ​​of the initial MD5, SHA1, CRC32, etc., so that the main station cannot find that the files in the device have been replaced; the present invention can solve the problem that the communication traffic cannot be consumed by comparing by bytes, and the file comparison cannot be implemented when there are many files or the files are very large.

[0035] like Figure 1 As shown, the present invention provides a method for remotely comparing embedded device files, the method comprising:

[0036] Step 101: The remote master station sends the file to be compared to the embedded device, and the remote master station and the embedded device store the file to be compared and the corresponding file name;

[0037] Preferably, there are multiple files to be compared.

[0038] The remote master station of the present invention sends the file to the embedded device, and backs up the file at the remote master station. The file type of the file to be compared of the present invention is not limited, and the method of the present invention is applicable to various files.

[0039] Step 102: The remote master station removes a first file content of a preset length at a random position of the file to be compared, and calculates a first check code of the first remaining file content;

[0040] Preferably, the preset length is one byte.

[0041] The remote master station of the present invention records and removes the content of a predetermined length from a random position of the backup file, and calculates the check code of the remaining part of the file. The content of the predetermined length of the present invention is one-byte content. The remote master station records and removes the content of a predetermined length, such as one-byte content, from a random position of the backup file, and records the random position at the same time, and then calculates the check code of the remaining part of the file. The system pre-sets a check program compiled according to the check formula derived from the check method. After the system uses the check program to calculate the input body code to obtain the check result, the check result is compared with the check code of the input code to detect whether the input is correct. If the two are consistent, it means that the code is correct. If they are inconsistent, it means that the code input is incorrect. Figure 3 shown.

[0042] Step 103: The remote host station sends the file name, random position and preset length of the file to be compared to the embedded device;

[0043] Step 104: the embedded device determines the stored file to be compared based on the file name, removes the second file content of a preset length based on a random position of the file to be compared, and calculates a second check code of the second remaining file content;

[0044] The remote main station of the present invention sends the above file name and random position to the embedded device, and the embedded device records and cuts out the content of the predetermined length at the same position of the file, and calculates the check code of the remaining part of the file.

[0045] Step 105: The remote master station obtains the second file content and the second check code, and performs a consistency comparison between the first file content and the second file content, and performs a consistency comparison between the first check code and the second check code;

[0046] Step 106: When the comparison results of the first file content and the second file content and the first verification code and the second verification code are consistent, it is determined that the file to be compared stored in the embedded device is normal.

[0047] Preferably, it also includes:

[0048] When the comparison result between the first file content and the second file content or the first verification code and the second verification code is inconsistent, it is determined that the file to be compared stored in the embedded device is abnormal.

[0049] Preferably, the remote host station executes the method of remotely comparing the embedded device files at a preset time period or at any time.

[0050] The remote master station reads the content of the predetermined length and the calculated check code extracted from the embedded device, and compares them with the content of the predetermined length and the check code stored locally in the remote master station. If they are consistent, the file in the embedded device is normal; if they are inconsistent, the file in the embedded device is abnormal.

[0051] The remote master station of the present invention verifies the consistency of the file in the embedded device at any time as needed. The remote master station and the embedded device of the present invention randomly remove a byte content of the file and change the remaining byte content of the file; the removed byte is directly compared, and the remaining bytes are compared with the check code, so that the file is completely compared. When proofreading the file, by changing the file content, the result of each verification is different, which can prevent the device from remembering the initial check code and also make the communication data very small.

[0052] The present invention provides a remote comparison method for embedded device files, the method comprising: a remote master station sends a file to an embedded device, and backs up the file at the remote master station; the remote master station records and extracts content of a predetermined length from a random position of the backup file, and calculates a check code for the remaining part of the file; the remote master station sends the above file name and random position to the embedded device, and the embedded device records and extracts content of a predetermined length at the same position of the file, and calculates a check code for the remaining part of the file; the remote master station reads the above-extracted content of the predetermined length and the calculated check code of the embedded device, and compares them with the content of the predetermined length and the check code locally stored in the remote master station. If they are consistent, the file in the embedded device is normal; if they are inconsistent, the file in the embedded device is abnormal. When proofreading a file, the present invention changes the file content so that the result of each check is different, which can prevent the device from remembering the initial check code and also makes the communication data very small. Figure 2 shown.

[0053] The following is a further description of the embodiments of the present invention.

[0054] For example, the remote master and embedded device both have the same file test, and the file content is 00 11 22 3344 55 66 77 88 99; when the master starts the verification, it randomly removes the fourth byte 33, and calculates the remaining verification code aabb of 00 11 22 44 55 66 77 88 99 according to the agreed algorithm. Then the master sends the file name test and the position 4 of the removed byte to the device. The device removes the fourth byte 33, calculates the remaining verification code aabb of 00 11 22 44 55 66 7788 99 according to the agreed algorithm, and replies 33 and aabb to the master. The remote master compares 33 and aabb and they are the same, indicating that the file contents are consistent; if the device file content changes, the replied 33 or aabb will be different.

[0055] Figure 4 This is a system structure diagram for remotely comparing embedded device files according to a preferred embodiment of the present invention. Figure 4 As shown, the present invention provides a system for remotely comparing embedded device files, the system comprising: a remote master station and an embedded device;

[0056] The remote main station 401 is used to send the file to be compared to the embedded device, and the remote main station and the embedded device store the file to be compared and the corresponding file name; the remote main station removes the first file content of the preset length at a random position of the file to be compared, and calculates the first check code of the first remaining file content; the remote main station sends the file name, random position and preset length of the file to be compared to the embedded device; the remote main station obtains the second file content and the second check code, and performs a consistency comparison between the first file content and the second file content, and the first check code and the second check code; when the comparison results of the first file content and the second file content and the first check code and the second check code are all consistent, it is determined that the file to be compared stored in the embedded device is normal;

[0057] The embedded device 402 is used to determine the stored file to be compared based on the file name, remove the second file content of a preset length based on the random position of the file to be compared, and calculate the second check code of the second remaining file content.

[0058] Preferably, the remote master station 401 is further used for:

[0059] When the comparison result between the first file content and the second file content or the first verification code and the second verification code is inconsistent, it is determined that the file to be compared stored in the embedded device is abnormal.

[0060] Preferably, the remote host station 401 executes the method of remotely comparing the embedded device files at a preset time period or at any time.

[0061] Preferably, there are multiple files to be compared.

[0062] Preferably, the preset length is one byte.

[0063] A system for remotely comparing embedded device files in a preferred embodiment of the present invention corresponds to a method for remotely comparing embedded device files in a preferred embodiment of the present invention, and will not be described in detail herein.

[0064] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The schemes in the embodiments of the present invention may be implemented in various computer languages, for example, object-oriented programming language Java and literal scripting language JavaScript, etc.

[0065] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0066] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0067] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0068] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0069] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

[0070] The invention has been described above with reference to a few embodiments. However, it is readily apparent to a person skilled in the art that other embodiments than the ones disclosed above are equally within the scope of the invention, as defined by the appended patent claims.

[0071] Generally, all terms used in the claims are to be interpreted according to their ordinary meaning in the technical field, unless explicitly defined otherwise herein. All references to "a / / the [means, component, etc.]" are to be openly interpreted as at least one instance of a means, component, etc., unless explicitly stated otherwise. The steps of any method disclosed herein do not necessarily have to be performed in the exact order disclosed, unless explicitly stated otherwise.

Claims

1. A method for remotely comparing embedded device files, the method comprising: The remote main station sends the file to be compared to the embedded device, and the remote main station and the embedded device store the file to be compared and the corresponding file name; The remote master station removes a first file content of a preset length at a random position of the file to be compared, and calculates a first check code of the first remaining file content; the preset length is one byte; The remote host station sends the file name, random position and preset length of the file to be compared to the embedded device; The embedded device determines the stored file to be compared based on the file name, removes a second file content of a preset length based on a random position of the file to be compared, and calculates a second check code of the second remaining file content; The remote host station obtains the second file content and the second verification code, and performs consistency comparison between the first file content and the second file content, and the first verification code and the second verification code; the remote host station performs the method of remotely comparing the embedded device file at a preset time period or at any time; When the comparison results of the first file content and the second file content and the first verification code and the second verification code are all consistent, it is determined that the file to be compared stored in the embedded device is normal.

2. The method according to claim 1, further comprising: When the comparison result between the first file content and the second file content or the first verification code and the second verification code is inconsistent, it is determined that the file to be compared stored in the embedded device is abnormal.

3. According to the method of claim 1, there are multiple files to be compared.

4. A system for remotely comparing embedded device files, the system comprising: Remote master stations and embedded devices; The remote master station is used to send the file to be compared to the embedded device, and the remote master station and the embedded device store the file to be compared and the corresponding file name; the remote master station removes the first file content of a preset length at a random position of the file to be compared, and calculates the first check code of the first remaining file content; the preset length is one byte; the remote master station sends the file name, random position and preset length of the file to be compared to the embedded device; the remote master station obtains the second file content and the second check code, and compares the first file content with the second file content for consistency, and the first check code with the second check code for consistency; the remote master station executes the method of remotely comparing embedded device files according to a preset time period or at any time; when the comparison results of the first file content with the second file content and the first check code with the second check code are consistent, it is determined that the file to be compared stored in the embedded device is normal; The embedded device is used to determine the stored file to be compared based on the file name, remove the second file content of a preset length based on the random position of the file to be compared, and calculate the second check code of the second remaining file content.

5. The system according to claim 4, wherein the remote master station is further configured to: When the comparison result between the first file content and the second file content or the first verification code and the second verification code is inconsistent, it is determined that the file to be compared stored in the embedded device is abnormal. The system according to claim 4 , wherein the number of files to be compared is multiple.

Citation Information

Patent Citations

  • Method and system for file processing

    CN102541991A

  • Embedded device file remote comparison method and system

    CN116167094A