Data protection method, data protection device and microcontroller
By grouping and randomly shuffling the input data to generate random data, a lookup table is formed, which solves the problem of easy data theft from the microcontroller's internal memory and achieves high data security and fast data recovery.
Patent Information
- Application Number
- CN202211190404.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2021-12-30
- Filing Date
- 2022-09-28
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2042-09-28
AI Technical Summary
The code and data in the internal memory of traditional microcontrollers are easily stolen, and there is a lack of effective data protection measures.
The input data is grouped and randomly shuffled to generate random data. The correspondence between the original starting address and the new starting address is recorded to form a lookup table, which is stored in memory to achieve data protection.
It significantly improves the security of memory data, ensures data confidentiality, and enables rapid restoration of data requests from the central processing unit.
Smart Images

Figure CN116415312B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a data protection method, and more particularly to a data protection method for preventing data theft. Background Technology
[0002] Traditional microcontrollers typically have an internal memory. This internal memory stores code and data in plaintext machine code. However, the code and data in the internal memory are easily stolen. Summary of the Invention
[0003] An embodiment of the present invention provides a data protection method, comprising: dividing an input data into multiple clusters to generate multiple clusters; recording an original starting address and a data size of each cluster; randomly shuffling the multiple clusters to generate random data; recording a new starting address of each cluster of the random data; compiling the original starting address of each cluster, the data length of the multiple clusters, and the new starting address of each cluster into a lookup table, wherein the lookup table records the correspondence between the original starting address and the new starting address after random shuffling of each cluster; storing the random data in a memory; and storing the lookup table in a memory controller.
[0004] Another embodiment of the present invention provides a data protection device, including a shuffling circuit, a memory, and a memory controller. The shuffling circuit divides an input data into groups to generate multiple data groups, and records the original starting address and data size of each data group. The shuffling circuit randomly shuffles the data groups to generate random data, and records a new starting address for each data group of the random data. The shuffling circuit compiles the original starting address, the data length of the data groups, and the new starting address into a lookup table. The lookup table records the correspondence between the original starting address and the new starting address after random shuffling for each data group. The memory stores the random data. The memory controller stores the lookup table.
[0005] Another embodiment of the present invention provides a microcontroller including a memory and a memory controller. The memory stores random data. The random data has multiple clusters. The memory controller stores a lookup table. The lookup table records multiple original addresses, the data size of each cluster, and a random address in the memory where each cluster is located. The memory controller selects a specified random address from the lookup table based on a read address, and reads the memory according to the specified random address to obtain a specified cluster of data. The specified random address corresponds to a specified address among the multiple original addresses. The specified address is the same as the read address.
[0006] The data protection method of the present invention can be implemented by the data protection device of the present invention, which is hardware or firmware capable of performing specified functions, or it can be implemented by code recorded in a recording medium and combined with specified hardware. When the code is loaded and executed by an electronic device, processor, computer or machine, the electronic device, processor, computer or machine becomes a data protection device for implementing the present invention.
[0007] This invention can significantly improve the security of data stored in the memory. Furthermore, because the microcontroller stores a lookup table, it can quickly reconstruct the data that the central processing unit (CPU) wants to fetch, thus ensuring data confidentiality. Attached Figure Description
[0008] Figure 1 This is a flowchart illustrating the data protection method of the present invention.
[0009] Figure 2A This is a schematic diagram of the original machine code plaintext of the present invention.
[0010] Figure 2B This is a schematic diagram of the random data of the present invention.
[0011] Figure 2C This is a schematic diagram of the lookup table of the present invention.
[0012] Figure 2D This is a schematic diagram of the memory.
[0013] Figure 3 This is a schematic diagram of the microcontroller of the present invention.
[0014] Figure 4 This is a schematic diagram of the data protection device of the present invention.
[0015] Figure 5 This is another schematic diagram of the data protection device of the present invention.
[0016] Icon labels:
[0017] S111~S117: Steps
[0018] DIN: Input data
[0019] RDA: Random Data
[0020] 200, 230, 312, 430, 534: Memory
[0021] 211–216: Clustered Data
[0022] 220: Lookup Table
[0023] Blocks 231-233
[0024] 300, 530: Microcontrollers
[0025] 310, 420, 533: Memory controller
[0026] 311: Decoding Circuit
[0027] 320, 531: Central Processing Unit
[0028] 330: Instruction Bus
[0029] 340, 440: Data bus
[0030] 350: Memory bus
[0031] 360, 532: Decryption circuit
[0032] EDA: Encrypted Data
[0033] DDA: Decrypting Data
[0034] 400, 500: Data protection devices
[0035] 410, 510: Disassemble the circuit Detailed Implementation
[0036] To make the objectives, features, and advantages of this invention more apparent and understandable, embodiments are provided below in conjunction with the accompanying drawings for detailed description. This specification provides different embodiments to illustrate the technical features of different implementations of the invention. The configuration of the elements in the embodiments is for illustrative purposes only and is not intended to limit the invention. Furthermore, the repetition of some reference numerals in the accompanying drawings is for simplification and does not imply any correlation between different embodiments.
[0037] Figure 1 This is a schematic flowchart of the data protection method of the present invention. The data protection method of the present invention can be implemented in a microcontroller unit (MCU). First, an input data is grouped to generate multiple grouped data (step S111). In a possible embodiment, the input data is data with consecutive addresses.
[0038] Figure 2AThis is a schematic diagram of the original machine code plaintext of the present invention. The input data DIN may be stored in a memory 200. In this embodiment, the input data DIN is divided into clusters 211 to 216. The present invention does not limit the data length of each cluster. In one possible embodiment, the data length of one cluster of data 211 to 216 is different from the data length of another cluster of data 211 to 216. For example, cluster 211 has four bytes of data, and cluster 213 has eight bytes of data. In some embodiments, the data length of one cluster of data 211 to 216 is the same as the data length of another cluster of data 211 to 216. For example, clusters 211 and 212 have four bytes of data.
[0039] Next, record the original starting address and data size of each data segment (step S112). Figure 2A For example, the original starting address (or original address) of cluster data 211 is 0x1800, the original starting address of cluster data 212 is 0x1804, the original starting address of cluster data 213 is 0x1808, the original starting address of cluster data 214 is 0x1810, the original starting address of cluster data 215 is 0x1818, and the original starting address of cluster data 216 is 0x181C. Furthermore, the data length of cluster data 211, 212, 215, and 216 is four bits, while the data length of cluster data 213 and 214 is eight bits.
[0040] Then, the order of the cluster data 211 to 216 is randomly shuffled to generate random data (step S113). Figure 2B This is a schematic diagram of the random data of the present invention. As shown in the figure, after random shuffling, the arrangement order of the random data RDA is cluster data 214, 212, 215, 216, 211, and 213. Compared to Figure 2A Before random shuffling, the input data DIN is arranged in the order of 211 to 216.
[0041] Next, record a new starting address for each randomly shuffled data group (step S114). For example... Figure 2B As shown, after random shuffling, the new starting address (or random address) of cluster data 214 is 0x1800, the new starting address of cluster data 212 is 0x1808, the new starting address of cluster data 215 is 0x180C, the new starting address of cluster data 216 is 0x1810, the new starting address of cluster data 211 is 0x1814, and the new starting address of cluster data 213 is 0x1818. In this example, the randomly shuffled cluster data is still stored in memory 200.
[0042] Next, the original starting address, data length, and new starting address of the clustered data 211 to 216 are compiled into a lookup table (step S115). Figure 2C This is a schematic diagram of the lookup table of the present invention. As shown in the figure, the lookup table 220 records the correspondence between the original starting address, data length, and new starting address after random shuffling of cluster data 211 to 216. Taking cluster data 211 as an example, the original address of cluster data 211 is 0x1800, and the data length is 4 bytes. After the random shuffling operation, the new starting address of cluster data 211 is 0x1814.
[0043] Based on the new starting address of each data group, random data is stored in a memory (step S116). Figure 2D This is a schematic diagram of the memory. As shown, memory 230 has blocks 231 to 233. In one possible embodiment, memory 230 is a flash memory. The present invention does not limit the number of blocks in memory 230. In other embodiments, memory 230 has more or fewer blocks. In this embodiment, block 231 has a start address of 0x0000 and an end address of 0x17FF. Block 232 has a start address of 0x1800 and an end address of 0x18FF. Block 233 has a start address of 0x1900 and an end address of 0x1FFF.
[0044] In some embodiments, random data is stored in block 232. As shown in the figure, the starting address of cluster data 214 is 0x1800, the starting address of cluster data 212 is 0x1808, the starting address of cluster data 215 is 0x180C, the starting address of cluster data 216 is 0x1810, the starting address of cluster data 211 is 0x1814, and the starting address of cluster data 213 is 0x1818.
[0045] Then, the lookup table is stored in a memory controller (step S117). In one possible embodiment, the memory controller, based on the lookup table, ... Figure 2B The random data RDA shown is written into memory 230. In this example, when the memory controller receives a read instruction, it enters a read mode. In read mode, the memory controller decodes the read instruction to generate a read address (0x1800). The memory controller uses lookup table 220 to find a new starting address (e.g., 0x1814) corresponding to the read address. The memory controller reads memory 230 and outputs a subset of data (e.g., 211) corresponding to the new starting address (e.g., 0x1814).
[0046] In some embodiments, after the lookup table is generated in step S115, an encryption operation is performed to encrypt the lookup table. The encrypted lookup table can be referred to as encrypted data. In this example, the memory controller performs a decryption operation to decrypt the encrypted data. The memory controller stores the decrypted restored data (i.e., the lookup table). In one possible embodiment, the decryption operation is performed by a decryption circuit. The decryption circuit may be integrated into the memory controller or independent of the memory controller.
[0047] In some embodiments, step S115 involves arranging cluster data 211-216 using a binary tree search method to accelerate the memory controller's search for the lookup table. In this example, the arranged result is the lookup table. In other embodiments, step S115 may arrange cluster data 211-216 sequentially according to their data size. For example, since the data size of cluster data 211, 212, 215, and 216 is lower than that of cluster data 213 and 214, the lookup table records cluster data such as 211, 212, 215, and 216 first, and then records cluster data 213 and 214. In this embodiment, step S115 arranges the cluster data 211-216 according to their original starting addresses. Figure 2C For example, the lookup table records the original address, data volume, and new starting address of the cluster data 211 to 216 in sequence.
[0048] Figure 3 This is a schematic diagram of the microcontroller of the present invention. The microcontroller 300 of the present invention has a data protection function to prevent the code and data stored in the internal memory from being stolen. In this embodiment, the microcontroller 300 includes a memory 230 and a memory controller 310.
[0049] The memory 230 has blocks 231 to 233. In this embodiment, random data RDA is stored in block 232. The memory controller 310 is used to access the memory 230. In some embodiments, the memory controller 310 accesses the memory 230 via a memory bus 350. In this embodiment, the memory controller 310 includes a decoding circuit 311 and a memory 312.
[0050] Memory 312 stores a lookup table 220. For example... Figure 2CAs shown, lookup table 220 records the original address, data size, and new starting address (or random address) of clustered data 211-216. Decoding circuit 311 is coupled to an instruction bus 330 and a data bus 340. Decoding circuit 311 decodes an access instruction provided by instruction bus 330. In one possible embodiment, when the access instruction is a read instruction, decoding circuit 311 decodes the read instruction to obtain a read address. Decoding circuit 311 uses this read address as an original starting address and searches for a new starting address and data size corresponding to the original starting address in lookup table 220. Decoding circuit 311 reads memory 230 according to the new starting address and data size to obtain a specified clustered data.
[0051] by Figure 2C and Figure 2D For example, suppose the read address is 0x1800. In this example, the decoding circuit 311 determines the address based on the lookup table 220 (e.g., ...). Figure 2C As shown in the diagram, it is known that read address 0x1800 corresponds to the new starting address 0x1814. Therefore, the decoding circuit 311 reads the clustered data (e.g., 211) at address 0x1814 of the memory 230. In one possible embodiment, the decoding circuit 311 outputs the clustered data 211 to a central processing unit 320 via the data bus 340. In other embodiments, the central processing unit 320 outputs a read instruction to the decoding circuit 311 via the instruction bus 330.
[0052] The present invention does not limit the source of the lookup table 220. In one possible embodiment, the lookup table 220 is provided by an external circuit (not shown) outside the microcontroller 300. The decoding circuit 311 may receive the lookup table 220 via the data bus 340 and write the lookup table 220 into the memory 312.
[0053] In another possible embodiment, to improve the security of lookup table 220, an external circuit performs an encryption operation on lookup table 220 to generate encrypted data EDA. In this example, microcontroller 300 also includes a decryption circuit 360. Decryption circuit 360 performs a decoding operation on encrypted data EDA to generate decrypted data (i.e., lookup table 220) DDA. Decryption circuit 311 receives decrypted data DDA via data bus 340 and writes decrypted data DDA into memory 312.
[0054] In other embodiments, the decryption circuit 360 is integrated into the memory controller 310. In this example, the decryption circuit 360 receives encrypted data EDA via the data bus 340 and provides decrypted data DDA to the decoding circuit 311. In another possible embodiment, the decryption circuit 360 may receive encrypted data EDA via other input / output interfaces (not shown). In some embodiments, the decryption circuit 360 may be integrated into the decoding circuit 311. In this example, the decryption circuit 360 may receive encrypted data EDA via the data bus 340 or other input / output interfaces.
[0055] Figure 4 This is a schematic diagram of the data protection device of the present invention. As shown, the data protection device 400 includes a data fragmentation circuit 410, a memory controller 420, and a memory 430. The data fragmentation circuit 410 groups an input data DIN to generate multiple data fragments, and records the original starting address of each data fragment and the data size of each data fragment. Figure 2A For example, the breakup circuit 410 divides the input data DIN into groups to generate grouped data 211 to 216. In this example, the breakup circuit 410 records the original starting address and data size of the grouped data 211.
[0056] The shuffling circuit 410 randomly shuffles the cluster data 211-216 to generate a random data RDA, and records a new starting address for each cluster data in the random data RDA. In this example, the shuffling circuit 410 compiles the original starting addresses of the cluster data 211-216, the data lengths of the cluster data 211-216, and the new starting addresses of the cluster data 211-216 into a lookup table 220. Figure 2C As shown, lookup table 220 records the correspondence between the original starting address of each data group and the new starting address after random shuffling.
[0057] The memory controller 420 stores a lookup table 220 and writes random data RDA to the memory 430 according to the lookup table 220. In one possible embodiment, the memory controller 420 receives the random data RDA and the lookup table 220 via a data bus 440. In another possible embodiment, the memory controller 420 receives an access instruction (such as a write instruction or a read instruction) via an instruction bus. In this example, the data protection device 400 also includes a central processing unit (not shown). In this example, the central processing unit may provide a read instruction or a write instruction to the memory controller 420 via the instruction bus.
[0058] When the memory controller 420 receives a write instruction, it writes random data RDA into the memory 430 according to the new starting address recorded in the lookup table 220. When the memory controller 420 receives a read instruction, it decodes the read instruction to generate a read address. The memory controller 420 uses the lookup table 220 to determine the corresponding new starting address. The memory controller 420 reads the corresponding cluster data stored at the new starting address in the memory 430 and outputs the corresponding cluster data.
[0059] In this embodiment, the memory controller 420 includes a decoding circuit 421 and a memory 422. In a possible embodiment, the memory controller 420 and the memory 430 are integrated into a microcontroller. In this example, the breakdown circuit 410 is independent of the microcontroller. Because the characteristics of the decoding circuit 421 and the memory 422 are similar... Figure 3 The characteristics of the decoding circuit 311 and the memory 312 are not described in detail here.
[0060] In some embodiments, the memory controller 420 further includes a fast look-up engine. The fast look-up engine (not shown) searches for the new starting address corresponding to the read address in lookup table 220. Additionally, since the characteristics of memory 430 are similar to... Figure 3 The characteristics of the memory 230 will not be elaborated further.
[0061] Figure 5 This is another schematic diagram of the data protection device of the present invention. The data protection device 500 includes a breakup circuit 510, an encryption circuit 520, and a microcontroller 530. Since the characteristics of the breakup circuit 510 are the same as... Figure 4 The characteristics of the break-down circuit 410 will not be described further. The encryption circuit 520 encrypts the lookup table 220 to generate encrypted data EDA. In one possible embodiment, the encryption circuit 520 is independent of the microcontroller 530. In other embodiments, the encryption circuit 520 and the break-down circuit 510 may also be within the microcontroller 530.
[0062] In this embodiment, the microcontroller 530 includes a central processing unit 531, a decryption circuit 532, a memory controller 533, and a memory 534. The central processing unit 531 may provide a read instruction or a write instruction to the memory controller 533 via an instruction bus 535. Because the characteristics of the central processing unit 531 are similar to... Figure 3 The features of the 320 central processing unit will not be elaborated further.
[0063] The decryption circuit 532 decrypts the encrypted data EDA to restore the lookup table 220, and stores the restored lookup table 220 in the memory controller 533. In one possible embodiment, the decryption circuit 532 is located within the microcontroller 530. Because the characteristics of the decryption circuit 532 are similar to... Figure 3 The characteristics of the decryption circuit 360 are not described in detail here.
[0064] The memory controller 533 receives an access instruction (such as a read instruction or a write instruction) via the instruction bus 535, and receives random data RDA and lookup table 220 via the data bus 536. Because the characteristics of the memory controller 420 are similar to... Figure 3 The memory controller 310 and Figure 4 The memory controller 420 will not be described further. Additionally, the characteristics of memory 534 are similar to... Figure 3 The characteristics of the memory 230 will not be elaborated further.
[0065] Because the memory 534 in the microcontroller 530 stores randomly arranged clustered data, and the data length of each cluster may differ from the length of another cluster, the security of the data stored in the memory 534 can be significantly improved. Furthermore, because the microcontroller 530 stores a lookup table, the data that the central processing unit (CPU) wants to fetch can be quickly retrieved, ensuring data confidentiality.
[0066] The data protection method of the present invention, or a specified form thereof, or a portion thereof, may exist in the form of code. The code may be stored on physical media, such as floppy disks, optical discs, hard disks, or any other machine-readable (e.g., computer-readable) storage media, or may be a computer program product, not limited to an external form. When the code is loaded and executed by a machine, such as a computer, that machine becomes a data protection device for the present invention. The code may also be transmitted via some transmission medium, such as wires or cables, optical fibers, or any transmission method. When the code is received, loaded, and executed by a machine, such as a computer, that machine becomes a data protection device for the present invention. When implemented in a general-purpose processing unit, the code, in conjunction with the processing unit, provides a unique device that operates similarly to the specified logic circuitry.
[0067] Unless otherwise defined, all terms herein (including technical and scientific terms) are as commonly understood by those skilled in the art. Furthermore, unless expressly stated otherwise, definitions of terms in general dictionaries should be interpreted as consistent with their meaning in the context of their relevant technical field, and not as idealized or overly formal expressions. While terms such as "first," "second," etc., may be used to describe various elements, these elements should not be limited by these terms. These terms are merely used to distinguish one element from another.
[0068] While the present invention has been described above with reference to preferred embodiments, it is not intended to limit the invention. Those skilled in the art can make modifications and refinements without departing from the spirit and scope of the invention. For example, the systems, apparatus, or methods described in the embodiments of the present invention can be implemented in physical embodiments using hardware, software, or a combination of hardware and software. Therefore, the scope of protection of the present invention shall be determined by the scope of the claims.
Claims
1. A data protection method, characterized in that, include: Storing input data in a first memory; The input data is grouped to generate multiple grouped data. Record the original starting address of each data cluster and the data volume of each data cluster. The multiple clusters of data are randomly shuffled to generate random data. The random data is stored in the first memory to replace the input data; Record a new starting address for each subgroup of random data; The original starting address of each data group, the data length of the multiple data groups, and the new starting address of each data group are compiled into a lookup table. The lookup table records the correspondence between the original starting address and the new starting address after random shuffling for each data group. The data corresponding to a consecutive address starting from a new starting address in the lookup table is the same as the data corresponding to a consecutive address starting from the original starting address. The random data is stored in a second memory. as well as The lookup table is stored in a memory controller.
2. The data protection method as described in claim 1, characterized in that, The data length of a first cluster of the multiple cluster data is different from the data length of a second cluster of the multiple cluster data.
3. The data protection method as described in claim 1, characterized in that, The step of storing the lookup table in the memory controller includes: Encrypt the lookup table to generate encrypted data; Decrypt the encrypted data to generate a decrypted version; and The restored data is stored in the memory controller.
4. The data protection method as described in claim 1, characterized in that, Also includes: Receive a read command; Decode the read instruction to generate a read address; By using this lookup table, we can find the corresponding new starting address for the read address; Read the corresponding cluster data stored at the corresponding new starting address in the second memory; and Output the corresponding cluster data.
5. A data protection device, characterized in that, include: A scattering circuit divides an input data stored in a first memory into groups to generate multiple groups of data. The system records the original starting address and data size of each data group. The shuffling circuit randomly shuffles the multiple data groups to generate random data, which is stored in the first memory to replace the input data. The system also records a new starting address for each data group of the random data. The shuffling circuit compiles the original starting address of each data group, the data length of the multiple data groups, and the new starting address of each data group into a lookup table. The lookup table records the correspondence between the original starting address and the new starting address after random shuffling for each data group. The data corresponding to consecutive addresses starting from a new starting address in the lookup table is the same as the data corresponding to consecutive addresses starting from the original starting address. A second memory for storing the random data; and A memory controller stores the lookup table.
6. The data protection device as described in claim 5, characterized in that, The second memory and the memory controller are integrated into a microcontroller (MCU), while the breakup circuit is independent of the microcontroller.
7. The data protection device as described in claim 6, characterized in that, Also includes: An encryption circuit encrypts the lookup table to generate encrypted data; as well as A decryption circuit decrypts the encrypted data to restore the lookup table and stores the restored lookup table in the memory controller.
8. A microcontroller, characterized in that, include: A shuffling circuit divides input data stored in a first memory into multiple data groups, and records the original starting address and data size of each data group. The shuffling circuit randomly shuffles the multiple data groups to generate random data, stores the random data in the first memory to replace the input data, and records a new starting address for each data group of the random data. The shuffling circuit compiles the original starting address of each data group, the data length of the multiple data groups, and the new starting address of each data group into a lookup table. The lookup table records the correspondence between the original starting address and the new starting address of each data group. The data corresponding to consecutive addresses starting from a new starting address in the lookup table is the same as the data corresponding to consecutive addresses starting from the original starting address. A second memory for storing the random data, the random data having multiple data clusters; and A memory controller stores the lookup table, which records multiple original addresses, the amount of data in the multiple data clusters, and a random address in the second memory for each data cluster. The memory controller selects a specified random address from a lookup table based on a read address, and reads the second memory based on the specified random address to obtain a specified cluster of data from the multiple clusters of data. The specified random address corresponds to one of the multiple original addresses, and the specified address is the same as the read address.
9. The microcontroller as described in claim 8, characterized in that, Also includes: A central processing unit provides the read address and receives the specified cluster data.
10. The microcontroller as claimed in claim 8, characterized in that, Also includes: A decryption circuit decrypts encrypted data to generate the lookup table and provides the lookup table to the memory controller.
Citation Information
Patent Citations
System and method for routing-based internet security
US20120166582A1
Authorization-based messaging
US20200004975A1
