Random peripheral mapping apparatus and method for microcontroller
By introducing a random peripheral mapping device and method into the microcontroller to generate and update random peripheral addresses, the problem of fixed addresses being vulnerable to attacks is solved, and the protection capability of security applications is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUADA SEMICON CO LTD
- Filing Date
- 2021-12-10
- Publication Date
- 2026-07-14
Smart Images

Figure CN116257893B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of embedded security function microcontroller technology, and more particularly to a random peripheral mapping device and method for a microcontroller. Background Technology
[0002] A microcontroller is a single-chip microcomputer that integrates the main components of a microcomputer onto a single chip. Its applications are ubiquitous, spanning various fields. Examples include motor control, barcode readers / scanners, consumer electronics, gaming devices, telephones, HVAC, building security and access control, industrial control and automation, and white goods (washing machines, microwave ovens), etc.
[0003] Existing microcontrollers typically use fixed peripheral addresses. Due to the specific peripheral functions of existing microcontrollers, the addresses of peripherals accessing software and running software on the microcontroller are always fixed. Therefore, if external parties track the software's operational status and use disassembly techniques, it is relatively easy to obtain the software's operation steps or core operational flow, allowing for targeted attacks and cracking of the product. This design of microcontrollers poses a significant risk when applied to products with high security requirements. Summary of the Invention
[0004] The technical problem to be solved by the present invention is that the peripheral addresses of existing microprocessors are designed in a fixed manner, which makes the products using existing microprocessors extremely vulnerable to targeted attacks and cracking, thereby increasing the security risks of the products.
[0005] To address the aforementioned technical problems, this invention provides a random peripheral mapping device for a microcontroller, comprising a data loading module, an advanced encryption module, and a mapping table generation module connected in sequence.
[0006] The data loading module is used to provide random data with a user identifier and transmit the random data to the advanced encryption module.
[0007] The advanced encryption module is used to generate mapping table primitives based on the random data and transmit the mapping table primitives to the mapping table generation module.
[0008] The mapping table generation module is used to generate a peripheral mapping table based on the mapping table primitives, so as to provide random peripheral addresses for the microcontroller to run software or access software.
[0009] Preferably, the data loading module includes an identification code generation unit and a true random number generator;
[0010] The identification code generation unit is used to generate a unique user identification code based on user information, which serves as the user identifier.
[0011] The true random number generator is used to generate true random numbers;
[0012] The random data includes the true random number and the user's unique identifier.
[0013] Preferably, the data loading module further includes a key generation module;
[0014] The key generation module is used to generate a user key based on user-defined information;
[0015] At this time, the random data includes the true random number, the user's unique identifier, and the user key.
[0016] Preferably, the mapping table generation module includes a mapping table generation unit and a peripheral address memory and a peripheral remapping logic control unit, which are respectively connected to the mapping table generation circuit.
[0017] The mapping table generation unit is used to generate a peripheral fake address mapping table and a peripheral true fake address mapping table based on the mapping table primitives, and send the peripheral fake address mapping table to the peripheral address memory and the peripheral true fake address mapping table to the peripheral remapping logic control unit.
[0018] The peripheral address memory is used to provide peripheral fake addresses to the peripheral remapping logic control unit and the microcontroller running software or access software based on the peripheral fake address mapping table;
[0019] The peripheral remapping logic control unit is used to query the corresponding peripheral real address in the peripheral real address mapping table based on the peripheral fake address, and to find the corresponding peripheral based on the peripheral real address to perform data storage operation or read operation.
[0020] Preferably, the peripheral true / false address mapping table includes some or all of the microcontroller's peripheral true addresses.
[0021] Preferably, the device is triggered when the microcontroller is reset or powered on.
[0022] To address the aforementioned technical problems, this invention provides a method for random peripheral mapping of a microcontroller, comprising:
[0023] The microcontroller is reset or powered on;
[0024] The data loading module in the random peripheral mapping device of the microcontroller generates random data with a user identifier and transmits the random data to the advanced encryption module in the random peripheral mapping device of the microcontroller.
[0025] The advanced encryption module in the random peripheral mapping device of the microcontroller generates a mapping table primitive based on the random data and transmits the mapping table primitive to the mapping table generation module in the random peripheral mapping device of the microcontroller.
[0026] The mapping table generation module in the random peripheral mapping device of the microcontroller generates a peripheral mapping table based on the mapping table primitives, so as to provide random peripheral addresses for the microcontroller to run software or access software.
[0027] Preferably, the data loading module generates random data with user identifiers including:
[0028] The identification code generation unit in the data loading module generates a unique user identification code based on user information to serve as the user identifier;
[0029] The true random number generator in the data loading module generates true random numbers;
[0030] The data loading module generates the random data based on the user's unique identification code and the true random number.
[0031] Preferably, the data loading module further includes generating random data with user identifiers, including:
[0032] The key generation module in the data loading module generates a user key based on user-defined information;
[0033] At this time, the data loading module generates the random data based on the user password, the user's unique identification code, and the true random number.
[0034] Preferably, the step of generating a peripheral mapping table in the random peripheral mapping device of the microcontroller to provide random peripheral addresses for running software or accessing software includes:
[0035] The mapping table generation unit in the mapping table generation module generates a peripheral fake address mapping table and a peripheral true fake address mapping table based on the mapping table primitives, and sends the peripheral fake address mapping table to the peripheral address memory, and sends the peripheral true fake address mapping table to the peripheral remapping logic control unit in the mapping table generation module.
[0036] The peripheral address memory in the mapping table generation module provides peripheral fake addresses to the peripheral remapping logic control unit and microcontroller running software or access software in the mapping table generation module based on the peripheral fake address mapping table;
[0037] The peripheral remapping logic control unit in the mapping table generation module queries the corresponding peripheral real address in the peripheral real address mapping table based on the peripheral fake address, and performs data storage or reading operations based on the peripheral real address.
[0038] Compared with the prior art, one or more embodiments of the above solutions may have the following advantages or beneficial effects:
[0039] The random peripheral mapping device for microcontrollers provided in this invention provides random peripheral addresses to the microcontroller's running software or access software through a mapping table generation module. This frees the software from limiting operations on peripherals to fixed addresses, significantly increasing the difficulty of attacking and cracking the microcontroller and its running software in embedded security applications. This has greater application value for products requiring embedded security features. Furthermore, the device uses microcontroller reset or power-on as a trigger signal, ensuring that the peripheral addresses are updated every time a product using the device is reset and restarted. This further increases the difficulty of cracking the software or product, providing greater security for the microcontroller and its application products.
[0040] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the description, claims, and drawings. Attached Figure Description
[0041] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with the embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0042] Figure 1 A schematic diagram of the random peripheral mapping device of the microcontroller according to Embodiment 1 of the present invention is shown;
[0043] Figure 2 This diagram illustrates an example of the default peripheral distribution in an existing system according to Embodiment 1 of the present invention.
[0044] Figure 3 This diagram illustrates the random peripheral distribution of Embodiment 1 of the present invention.
[0045] Figure 4 A schematic flowchart of the random peripheral mapping method for a microcontroller according to Embodiment 2 of the present invention is shown. Detailed Implementation
[0046] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings and examples, so that the process of how the present invention uses technical means to solve technical problems and achieve technical effects can be fully understood and implemented accordingly. It should be noted that, as long as there is no conflict, the various embodiments and features in the various embodiments of the present invention can be combined with each other, and the resulting technical solutions are all within the protection scope of the present invention.
[0047] Existing microcontrollers typically use fixed peripheral addresses. Due to the specific peripheral functions of existing microcontrollers, the addresses of peripherals accessing software and running software on the microcontroller are always fixed. Therefore, if external parties track the software's operational status and use disassembly techniques, it is relatively easy to obtain the software's operation steps or core operational flow, allowing for targeted attacks and cracking of the product. This design of microcontrollers poses a significant risk when applied to products with high security requirements.
[0048] Example One
[0049] To address the technical problems existing in the prior art, embodiments of the present invention provide a random peripheral mapping device for a microcontroller.
[0050] Figure 1 A schematic diagram of the random peripheral mapping device structure of the microcontroller according to Embodiment 1 of the present invention is shown; Reference Figure 1 As shown, the random peripheral mapping device of the microcontroller in this embodiment of the invention includes a data loading module, an advanced encryption module, and a mapping table generation module, which are connected in sequence.
[0051] The data loading module primarily provides random data with user identifiers and transmits the random data to the advanced encryption module. Further, the data loading module includes an identification code generation unit and a true random number generator. The identification code generation unit generates a unique user identification code based on user information, which serves as the user identifier. The true random number generator generates truly random numbers. The true random numbers and the unique user identification code constitute the random data; the unique user identification code identifies the user, and the setting of the true random numbers ensures that the final random data possesses randomness and uncertainty.
[0052] Furthermore, to enhance the user's leading role, the data loading module in this embodiment may also include a key generation module. This module is primarily used for user-defined key generation and addition to random data, making the random data more targeted and secure, while also meeting the user's need to participate in security settings. The data loading module supports user-defined private keys for the microcontroller, allowing users to define peripheral addresses for their proprietary products. Furthermore, if a user-defined key is added to the random data, no one other than the user can know the composition of the random data, including the manufacturer of the device, thus increasing the difficulty of attacking and cracking the microcontroller's operating software and functions. In this case, the generated random data also includes the user key.
[0053] However, it should be noted that although the device in this embodiment of the invention is equipped with a key generation module, users of the microcontroller are not required to define keys when using it. If the user does not have a need for a custom key, the key generation module can be left idle. That is, the key generation module is a user-selectable module.
[0054] The advanced encryption module is primarily used to generate mapping table primitives based on the random data generated by the data loading module, and then transmits the mapping table primitives to the mapping table generation module. In this embodiment, the advanced encryption module is mainly implemented using the Advanced Encryption Standard (AES) algorithm, but it can also be other general-purpose algorithm units to achieve the diffusion of mapping table primitive data.
[0055] The mapping table generation module is mainly used to generate peripheral mapping tables based on mapping table primitives, providing random peripheral addresses for the microcontroller to run or access software. Specifically, the mapping table generation module includes a mapping table generation unit, a peripheral address memory, and a peripheral remapping logic control unit, wherein the peripheral address memory and the peripheral remapping logic control unit are respectively connected to the mapping table generation unit. Further, the mapping table generation unit receives mapping table primitives sent by the advanced encryption module, and generates a peripheral fake address mapping table and a peripheral true / false address mapping table based on the mapping table primitives. The peripheral fake address mapping table and the peripheral true / false address mapping table constitute the peripheral mapping table. Then, the mapping table generation unit sends the peripheral fake address mapping table to the peripheral address memory and the peripheral true / false address mapping table to the peripheral remapping logic control unit. The peripheral fake address mapping table includes microprocessor peripheral fake address data, and the peripheral true / false address mapping table includes microprocessor peripheral true address and peripheral fake address mapping relationship data.
[0056] Furthermore, the peripheral address memory receives and stores the peripheral dummy address mapping table. When needed, it sends the peripheral dummy address to the peripheral remapping logic control unit and the microcontroller's runtime or access software based on the peripheral dummy address mapping table. After receiving the peripheral dummy address, the peripheral remapping logic control unit looks up the corresponding peripheral real address in the peripheral real / dummy address mapping table, and then finds the corresponding peripheral based on the peripheral real address, performing data storage or retrieval operations as required.
[0057] It should be noted that the peripheral true / false address mapping table includes some microcontroller peripheral true addresses, and may also include all microcontroller peripheral true addresses. That is, the device in this embodiment supports randomly setting only some microcontroller peripheral addresses, while the microcontroller peripheral addresses can be set to fixed peripheral addresses. Figure 2 This diagram illustrates an example of the default peripheral distribution in an existing system according to Embodiment 1 of the present invention. Figure 3 This diagram illustrates the random peripheral distribution of Embodiment 1 of the present invention; see reference. Figure 2 and Figure 3 As can be seen, the device in the embodiments of the present invention can achieve the purpose of making the microcontroller randomly connected to peripherals.
[0058] Furthermore, in this embodiment of the invention, the random peripheral mapping device of the microcontroller is set to be triggered upon reset or power-on. That is, the peripheral address of the microcontroller is updated every time the microcontroller is reset or powered on. This makes the peripheral address situation different at different times running the same software on the same microcontroller and between different software on the same microcontroller. Therefore, the data obtained by reverse engineering the microcontroller using the device of this embodiment of the invention is uncertain, which greatly increases the difficulty of attacking and cracking the microcontroller and its running software in embedded security applications. This has greater application value for products that require embedded security functions.
[0059] Furthermore, the settings for reset or power-on triggering in the random peripheral mapping device allow the peripheral addresses accessed by the software to be randomized after each power-on or reset in the same microcontroller using the device of the present invention; at the same time, the peripheral addresses accessed by the software to be randomized in different microcontrollers of the same product; however, although the peripheral addresses are random in various situations, they are all bound to a unique identification code, so they still have correspondence.
[0060] The random peripheral mapping device for microcontrollers provided in this invention provides random peripheral addresses to the microcontroller's running software or access software through a mapping table generation module. This means that the software's operations on peripherals are no longer limited to fixed addresses, greatly increasing the difficulty of attacking and cracking the microcontroller and its running software in embedded security applications. This has greater application value for products requiring embedded security features. Furthermore, this invention uses microcontroller reset or power-on as a trigger signal, ensuring that the peripheral addresses are updated every time a product using this device is reset and restarted. This further increases the difficulty of cracking the software or product, providing greater security for the microcontroller and its application products.
[0061] Example Two
[0062] To address the technical problems existing in the prior art, embodiments of the present invention provide a method for random peripheral mapping of a microcontroller.
[0063] It should be noted that the random peripheral mapping device for the microcontroller in this embodiment is implemented based on the random peripheral mapping device for the microcontroller disclosed in Embodiment 1. That is, the modules or units in the random peripheral mapping device for the microcontroller used in this embodiment all have the functional structure described in Embodiment 1.
[0064] Figure 4 This diagram illustrates a flow chart of a random peripheral mapping method for a microcontroller according to Embodiment 2 of the present invention. (Refer to...) Figure 4 As shown, the random peripheral mapping method for a microcontroller according to an embodiment of the present invention includes the following steps.
[0065] In step S201, the microcontroller is reset or powered on.
[0066] Specifically, when the microcontroller is reset or powered on during use, the random peripheral mapping device in the microcontroller is triggered.
[0067] In step S202, the data loading module in the microcontroller's random peripheral mapping device generates random data with a user identifier and transmits the random data to the advanced encryption module in the microcontroller's random peripheral mapping device.
[0068] Specifically, after the random peripheral mapping device is triggered, the data loading module in the random peripheral mapping device generates random data with a user identifier. Further, the identification code generation unit in the data loading module generates a unique user identification code based on user information, which serves as the user identifier; the true random number generator in the data loading module generates a true random number; then, the data loading module generates random data based on the generated unique user identification code and the true random number. The data loading module then transmits the random data to the advanced encryption module in the microcontroller's random peripheral mapping device.
[0069] Furthermore, during the generation of the user's unique identifier and the true random number, the user can simultaneously generate a user key based on custom information using the key generation module within the data loading module. The data loading module then generates random data using the user's unique identifier, the true random number, and the user key. The data loading module then transmits the random data to the advanced encryption module in the microcontroller's random peripheral mapping device.
[0070] In step S203, the advanced encryption module in the random peripheral mapping device of the microcontroller generates a mapping table primitive based on random data and transmits the mapping table primitive to the mapping table generation module in the random peripheral mapping device of the microcontroller.
[0071] Specifically, after receiving random data, the advanced encryption module in the microcontroller's random peripheral mapping device generates a mapping table primitive based on the random data. The generated mapping table primitive is then transmitted to the mapping table generation module in the microcontroller's random peripheral mapping device.
[0072] In step S204, the mapping table generation module in the microcontroller's random peripheral mapping device generates a peripheral mapping table based on the mapping table primitives, so as to provide random peripheral addresses for the microcontroller to run software or access software.
[0073] Specifically, after the mapping table generation module in the microcontroller's random peripheral mapping device obtains the mapping table primitives, the mapping table generation unit in the mapping table generation module generates a peripheral fake address mapping table and a peripheral true / false address mapping table based on the mapping table primitives. It then sends the peripheral fake address mapping table to the peripheral address memory and the peripheral true / false address mapping table to the peripheral remapping logic control unit in the mapping table generation module. After obtaining the peripheral fake address mapping table, the peripheral address memory in the mapping table generation module provides peripheral fake addresses sequentially to the peripheral remapping logic control unit and the microcontroller's runtime software or access software. After obtaining the peripheral fake address, the peripheral remapping logic control unit in the mapping table generation module queries the corresponding peripheral true address in the peripheral true / false address mapping table based on the peripheral fake address, and then searches for the corresponding peripheral based on the peripheral true address to perform data storage or retrieval operations. Simultaneously, the microcontroller's runtime software or access software obtains the peripheral fake address, i.e., the random peripheral address.
[0074] The random peripheral mapping method for microcontrollers provided in this invention provides random peripheral addresses to the microcontroller's running software or access software through a mapping table generation module. This makes the software's operation of peripherals no longer limited to fixed addresses, greatly increasing the difficulty of attacking and cracking the microcontroller and its running software in embedded security applications. It has greater application value for products requiring embedded security features. Furthermore, this invention uses microcontroller reset or power-on as a trigger signal, ensuring that the peripheral addresses are updated every time the product using the device is reset and restarted, further increasing the difficulty of cracking the software or product and providing greater security for the microcontroller and its application products.
[0075] While the embodiments disclosed in this invention are as described above, the content is merely for the purpose of facilitating understanding of the invention and is not intended to limit the invention. Any person skilled in the art to which this invention pertains may make any modifications and changes in form and detail of the implementation without departing from the spirit and scope disclosed herein; however, the scope of protection of this invention shall still be determined by the scope defined in the appended claims.
Claims
1. A random peripheral mapping device for a microcontroller, characterized in that, This includes a data loading module, an advanced encryption module, and a mapping table generation module, which are connected in sequence. The data loading module is used to provide random data with a user identifier and transmit the random data to the advanced encryption module. The advanced encryption module is used to generate mapping table primitives based on the random data and transmit the mapping table primitives to the mapping table generation module. The mapping table generation module is used to generate a peripheral mapping table based on the mapping table primitives, so as to provide random peripheral addresses for the microcontroller to run software or access software. The mapping table generation module includes a mapping table generation unit and a peripheral address memory and a peripheral remapping logic control unit, which are respectively connected to the mapping table generation circuit. The mapping table generation unit is used to generate a peripheral fake address mapping table and a peripheral true fake address mapping table based on the mapping table primitives, and send the peripheral fake address mapping table to the peripheral address memory and the peripheral true fake address mapping table to the peripheral remapping logic control unit. The peripheral address memory is used to provide peripheral fake addresses to the peripheral remapping logic control unit and the microcontroller running software or access software based on the peripheral fake address mapping table; The peripheral remapping logic control unit is used to query the corresponding peripheral real address in the peripheral real address mapping table based on the peripheral fake address, and to find the corresponding peripheral based on the peripheral real address to perform data storage operation or read operation.
2. The apparatus according to claim 1, characterized in that, The data loading module includes an identification code generation unit and a true random number generator; The identification code generation unit is used to generate a unique user identification code based on user information, which serves as the user identifier; the true random number generator is used to generate true random numbers. The random data includes the true random number and the user's unique identifier.
3. The apparatus according to claim 2, characterized in that, The data loading module also includes a key generation module; The key generation module is used to generate a user key based on user-defined information; At this time, the random data includes the true random number, the user's unique identifier, and the user key.
4. The apparatus according to claim 1, characterized in that, The peripheral true / false address mapping table includes some or all of the microcontroller's peripheral true addresses.
5. The apparatus according to claim 1, characterized in that, The device is triggered when the microcontroller is reset or powered on.
6. A method for random peripheral mapping of a microcontroller based on a random peripheral mapping device of any one of claims 1-5, comprising: The microcontroller is reset or powered on; The data loading module in the random peripheral mapping device of the microcontroller generates random data with a user identifier and transmits the random data to the advanced encryption module in the random peripheral mapping device of the microcontroller. The advanced encryption module in the random peripheral mapping device of the microcontroller generates a mapping table primitive based on the random data and transmits the mapping table primitive to the mapping table generation module in the random peripheral mapping device of the microcontroller. The mapping table generation module in the random peripheral mapping device of the microcontroller generates a peripheral mapping table based on the mapping table primitives, so as to provide random peripheral addresses for the microcontroller to run software or access software. The step of generating a peripheral mapping table in the random peripheral mapping device of the microcontroller to provide random peripheral addresses for running or accessing software includes: The mapping table generation unit in the mapping table generation module generates a peripheral fake address mapping table and a peripheral true fake address mapping table based on the mapping table primitives, and sends the peripheral fake address mapping table to the peripheral address memory, and sends the peripheral true fake address mapping table to the peripheral remapping logic control unit in the mapping table generation module. The peripheral address memory in the mapping table generation module provides peripheral fake addresses to the peripheral remapping logic control unit and microcontroller running software or access software in the mapping table generation module based on the peripheral fake address mapping table; The peripheral remapping logic control unit in the mapping table generation module queries the corresponding peripheral real address in the peripheral real address mapping table based on the peripheral fake address, and performs data storage or reading operations based on the peripheral real address.
7. The method according to claim 6, characterized in that, The data loading module generates random data with user identifiers, including: The identification code generation unit in the data loading module generates a unique user identification code based on user information to serve as the user identifier; The true random number generator in the data loading module generates true random numbers; The data loading module generates the random data based on the user's unique identification code and the true random number.
8. The method according to claim 7, characterized in that, The data loading module also generates random data with user identifiers, including: The key generation module in the data loading module generates a user key based on user-defined information; At this time, the data loading module generates the random data based on the user key, the user's unique identification code, and the true random number.