USB Type-C port control program security design method and device
By adopting the design of the second and third partitions on the control chip, combined with the verification method of program upgrade software, the cost problems caused by the hardware signature algorithm are solved, and the security and response speed are improved.
Patent Information
- Application Number
- CN202412000497.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-09
AI Technical Summary
In the prior art, the control chip hardware needs to store hardware signature algorithms, resulting in high costs.
By adopting a second partition storing application firmware and a third partition as a buffer on the control chip, the replacement of two partitions in the prior art is realized, and verification of the target upgrade software is achieved by executing the program upgrade software stored in the first partition, the hardware signature algorithm is avoided in the second partition.
It saves hardware costs, solves the problem of high costs caused by the control chip hardware storage hardware, and improves the security and response speed of program upgrades.
Smart Images

Figure CN119961913A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a USB Type-C port control program security design method, a USB Type-C port control program security design device, a computer-readable storage medium, and an electronic device. Background Art
[0002] With the popularity of USB Type-C interfaces, the functions of USB Type C interfaces are becoming more and more complex, and higher requirements are placed on the security of USB Type C port control firmware programs. However, in the prior art, the control chip hardware needs to store the hardware signature algorithm, which leads to high costs.
[0003] Therefore, a method is urgently needed to solve the above problems. Summary of the invention
[0004] The main purpose of the present application is to provide a USB Type-C port control program security design method, a USB Type-C port control program security design device, a computer-readable storage medium and an electronic device, so as to at least solve the problem in the prior art that the control chip hardware needs to store a hardware signature algorithm, resulting in high costs.
[0005] According to one aspect of the present application, a USB Type-C port control program security design method is provided, which is applied to a control chip, wherein the control chip includes a first partition, a second partition and a third partition, wherein the first partition is used to store program upgrade software, the second partition is used to store application firmware, and the third partition is used as a buffer for the application firmware. The method includes: when the control chip is powered on, performing integrity verification on the program upgrade software and the application firmware; if the verification is successful, executing the program upgrade software stored in the first partition, and receiving a software upgrade request and a target upgrade software, wherein the software upgrade request is used to request the use of the target upgrade software to perform a software upgrade on the control chip; storing the target upgrade software in the third partition, and verifying the target upgrade software using an elliptic curve digital signature algorithm; if the verification is successful, writing the target upgrade software stored in the third partition into the second partition, and executing the target upgrade software to implement the USB Type-C port control program security design of the control chip.
[0006] Optionally, when the control chip is powered on, an integrity check is performed on the application firmware, including: an acquisition step, acquiring a program flag bit of the control chip, wherein the program flag bit is used to represent a loading address of the target upgrade software at the current moment; a first verification step, when the program flag bit points to the second partition, performing a hash check on the application firmware stored in the second partition; a first execution step, when the hash check is successful, executing the application firmware; and a first repetition step, when the hash check is unsuccessful, repeating the first verification step at least once until a predetermined number of times is reached.
[0007] Optionally, when the control chip is powered on, an integrity check is performed on the program upgrade software, including: a second check step, when the program flag does not point to the second partition or the repetition step reaches the predetermined number of times, a hash check is performed on the program upgrade software stored in the first partition; a second execution step, when the hash check is successful, the program upgrade software is executed; a second repetition step, when the hash check is unsuccessful, the second check step is repeated at least once until the predetermined number of times is reached.
[0008] Optionally, receiving a software upgrade request and a target upgrade software includes: receiving the software upgrade request; switching a program flag of the control chip to a first predetermined position, wherein the first predetermined position is a position pointing to the first partition; and receiving the target upgrade software.
[0009] Optionally, after writing the target upgrade software stored in the third partition into the second partition, the method further includes: switching the program flag of the control chip to a second predetermined position, wherein the second predetermined position is a position pointing to the second partition.
[0010] Optionally, executing the program upgrade software stored in the first partition and receiving a software upgrade request include: obtaining a program flag of the control chip, wherein the program flag is used to represent the loading address of the target upgrade software at the current moment; when the program flag points to the second partition, determining whether the application firmware is stored in the third partition; when the application firmware is stored in the third partition, obtaining the application firmware and the signature of the application firmware, and verifying the signature; when the signature verification is successful, writing the application firmware to the second partition; and receiving the software upgrade request when preset conditions are met, wherein the preset conditions include at least one of the following: the program flag does not point to the second partition, the second partition does not store the application firmware, and the signature verification is unsuccessful.
[0011] Optionally, after verifying the target upgrade software using an elliptic curve digital signature algorithm, the method further includes: if the verification is unsuccessful, erasing the target upgrade software stored in the third partition.
[0012] According to another aspect of the present application, a USB Type-C port control program security design device is provided, which is applied to a control chip, wherein the control chip includes a first partition, a second partition and a third partition, wherein the first partition is used to store program upgrade software, the second partition is used to store application firmware, and the third partition is used as a buffer for the application firmware. The device includes: a verification unit, which is used to perform integrity verification on the program upgrade software and the application firmware when the control chip is powered on; a receiving unit, which is used to execute the program upgrade software stored in the first partition when the verification is successful, and receive a software upgrade request and a target upgrade software, wherein the software upgrade request is used to request to use the target upgrade software to perform a software upgrade on the control chip; a verification unit, which is used to store the target upgrade software in the third partition and verify the target upgrade software using an elliptic curve digital signature algorithm; an execution unit, which is used to write the target upgrade software stored in the third partition into the second partition when the verification is successful, and execute the target upgrade software to implement the USB Type-C port control program security design of the control chip.
[0013] According to another aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the methods described.
[0014] According to another aspect of the present application, an electronic device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute any one of the methods described through the computer program.
[0015] By applying the technical solution of the present application, firstly, the control chip in the prior art generally includes two partitions for storing application firmware, while the present solution replaces the two partitions in the prior art by adopting a second partition for storing application firmware and a third partition as a buffer zone, and there is no need to store the hardware signature algorithm for verifying the upgrade software in the second partition. Instead, the verification of the target upgrade software is achieved by executing the program upgrade software stored in the first partition, thereby saving hardware costs and solving the problem of high cost caused by the need to store the hardware signature algorithm in the control chip hardware in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings constituting part of the present application are used to provide a further understanding of the present application. The exemplary embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1 A schematic diagram of the partitioning of a control chip in the prior art is shown;
[0018] Figure 2 A hardware structure block diagram of a mobile terminal for executing a USB Type-C port control program security design method provided in an embodiment of the present application is shown;
[0019] Figure 3 A schematic flow chart of a USB Type-C port control program security design method provided according to an embodiment of the present application is shown;
[0020] Figure 4 A schematic diagram of a process flow of generating an encrypted signature of a main application program of a control chip provided in an embodiment of the present application is shown;
[0021] Figure 5 A schematic flow chart of a USB Type-C port control program security design method provided according to an embodiment of the present application is shown;
[0022] Figure 6 A schematic diagram of partitioning of a control chip provided according to an embodiment of the present application is shown;
[0023] Figure 7 A structural block diagram of a USB Type-C port control program security design device provided according to an embodiment of the present application is shown.
[0024] The above drawings include the following reference numerals:
[0025] 102, processor; 104, memory; 106, transmission device; 108, input and output devices. DETAILED DESCRIPTION
[0026] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0027] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0029] In the prior art, the control chip is divided into Figure 1 As shown, it includes three partitions, namely, the Bootloader partition, the application firmware 1 partition and the application firmware 2 partition. Its working process is as follows: after the hardware is powered on, the program automatically starts to execute from the Bootloader program. When the Bootloader starts, the signature of the application firmware 1 partition program is checked. After the application firmware 1 is successfully checked, the microprocessor loads the application firmware 1 and executes it. If the firmware 1 check fails, the Bootloader continues to check the application firmware program 2. After the application firmware 2 is successfully checked, the microprocessor loads the application firmware 2 and executes it. If both the application firmware 1 and 2 checks are unsuccessful, the program stops in the Bootloader working mode. In the control chip in the prior art, the signature verification algorithm is implemented by hardware; in the Bootloader mode, it supports startup signature verification and program upgrade; in addition, the Bootloader program cannot be rewritten. The control chip in the prior art includes the implementation of the main functions and the program update function. The contents of the two partitions are the same. When the content of one partition is damaged, it will switch to another partition. The application includes the program itself and the signature. However, the control chip in the prior art has the following problems:
[0030] 1. The implementation cost of hardware signature algorithm is high;
[0031] 2. In addition to the functions of USB Type C port control, the two partitions of the application firmware also need to include the program implementation of security upgrades, which requires higher storage space for the program and memory space for the microcontroller, and also increases the cost of chip hardware design;
[0032] 3. With the development of technologies such as quantum computing, existing signature algorithms (such as RSA 1024 / ECDSAP256) will become less secure. Subsequent algorithm upgrades require hardware design upgrades, which is a considerable challenge to chip design costs;
[0033] 4. The signature algorithm is generally an asymmetric encryption signature (RSA / ECDSA), which has a large amount of calculation. The application is signed and verified when it starts, and the program startup time is long.
[0034] As introduced in the background technology, the control chip hardware in the prior art needs to store a hardware signature algorithm, which leads to high costs. To solve the above problems, the embodiments of the present application provide a USB Type-C port control program security design method, a USB Type-C port control program security design device and an electronic device.
[0035] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0036] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 2 1 is a hardware structure block diagram of a mobile terminal of a USB Type-C port control program security design method according to an embodiment of the present invention. Figure 2 As shown, the mobile terminal may include one or more ( Figure 2 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 2 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 2 More or fewer components as shown, or with Figure 2 Different configurations are shown.
[0037] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the USB Type-C port control program security design method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, the above method is implemented. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. The transmission device 106 is used to receive or send data via a network. The above-mentioned specific examples of the network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0038] In this embodiment, a USB Type-C port control program security design method running on a mobile terminal, a computer terminal or a similar computing device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in an order different from that shown here.
[0039] Figure 3 1 is a flowchart of a USB Type-C port control program security design method according to an embodiment of the present application. Figure 3 As shown, it is applied to a control chip, the control chip includes a first partition, a second partition and a third partition, wherein the first partition is used to store program upgrade software, the second partition is used to store application firmware, and the third partition is used as a buffer for the application firmware. The method includes the following steps:
[0040] Step S201, when the control chip is powered on, performing integrity check on the program upgrade software and the application firmware;
[0041] Step S202, if the verification is successful, executing the program upgrade software stored in the first partition, and receiving a software upgrade request and a target upgrade software, wherein the software upgrade request is used to request to use the target upgrade software to perform a software upgrade on the control chip;
[0042] Step S203, storing the target upgrade software in the third partition, and verifying the target upgrade software using an elliptic curve digital signature algorithm;
[0043] Step S204, when the verification is successful, the target upgrade software stored in the third partition is written into the second partition, and the target upgrade software is executed to implement the USB Type-C port control program security design of the control chip.
[0044] Specifically, the program upgrade software stored in the first partition includes program verification and application upgrade functions. The software implements the ECDSAP256 signature verification algorithm, and the public key used for ECDSA signature verification is implicit in the program. The chip is read-only after leaving the factory and cannot be rewritten. Abnormal interrupt processing during the chip upgrade process, and recovery processing after damage caused by abnormal interruption during the main program upgrade process. The application firmware stored in the second partition includes the implementation of the USB Type C function, and also includes an application interface for I2C communication with an external controller. When the main application is working, if a program update request is received from an external controller, it will switch to the Bootloader, that is, the program upgrade software mode for update. The third partition serves as a buffer for the above-mentioned application firmware. When upgrading the main application, the Bootloader will first put the received data into the application upgrade buffer, and then move it to the main application area after verification. If an abnormal interruption process such as power failure occurs during the process of moving from the application upgrade buffer to the main application area, the Bootloader will continue the transfer process the next time it is powered on.
[0045] Through this embodiment, firstly, the control chip in the prior art generally includes two partitions for storing application firmware, while this solution replaces the two partitions in the prior art by adopting a second partition for storing application firmware and a third partition as a buffer zone, and there is no need to store the hardware signature algorithm for verifying the upgrade software in the second partition. Instead, the verification of the target upgrade software is achieved by executing the above-mentioned program upgrade software stored in the first partition, thereby saving hardware costs and solving the problem of high cost caused by the need to store the hardware signature algorithm in the control chip hardware in the prior art.
[0046] In the specific implementation process, the above step S201 can be implemented by the following steps: step S20211, an acquisition step, obtaining the program flag of the above control chip, wherein the above flag is used to represent the loading address of the above target upgrade software at the current moment; step S20212, a first verification step, in the case where the above program flag points to the above second partition, a hash verification is performed on the above application firmware stored in the above second partition; step S20213, a first execution step, in the case where the above hash verification is successful, the above application firmware is executed; step S20214, a first repetition step, in the case where the above hash verification is unsuccessful, the above first verification step is repeated at least once until a predetermined number of times is reached. This method applies hash verification when the control chip is powered on, and asymmetric encryption is only applied to the application upgrade stage, which can ensure the security emphasis of program upgrades, save program startup time, and further increase the response speed of the application.
[0047] Specifically, the program flag bit can indicate the program loading address after the chip is powered on. For example, when the current pointer is AA, the chip loads the main application program into the chip controller program memory and executes it, otherwise the chip loads the bootloader into the chip controller program memory and executes it. The program flag bit can also be an upgrade processing flag. When entering the program upgrade process, this flag is set to 1, and the program upgrade is successful, and this flag is 0.
[0048] The above step S201 can also be implemented in other ways, for example: step S20215, the second verification step, when the above program flag does not point to the above second partition or the above repetition step reaches the above predetermined number of times, the above program upgrade software stored in the above first partition is hash-verified; step S20216, the second execution step, when the above hash verification is successful, the above program upgrade software is executed; step S20217, the second repetition step, when the above hash verification is unsuccessful, the above second verification step is repeated at least once until the above predetermined number of times is reached. This method applies hash verification when the control chip is powered on, and applies asymmetric encryption only to the application upgrade stage, which can ensure the security emphasis of program upgrade, save program startup time, and further increase the response speed of the application.
[0049] Specifically, Figure 4 As shown in the figure, the steps to generate the encrypted signature of the main application of the control chip are as follows: Generate an ECDSAP256 signature key pair (including a public key (Pub_key1) and a private key (Priv_key1)). After the main application is signed with HMAC-SHA256 (using a hardware key), it is signed with the standard algorithm ECDSA private key. Figure 5As shown, the power-on loading process of the control chip is as follows: the chip is powered on; determine whether the pointer (i.e., the program flag bit) points to the main program. If it points to the main program, load the main application program into the memory and clear the loading count; determine whether the loader hash check is successful. If successful, execute the main application program; if unsuccessful, add 1 to the loading count; determine whether the current loading count is greater than 2, otherwise load the main application program into the memory, and repeatedly determine whether the loader hash check is successful; if yes or the pointer does not point to the main program, load the Bootloader program and clear the loading count; determine whether the loader hash check is successful. If successful, execute the Bootloader program. If unsuccessful, add 1 to the loading count; determine whether the current loading count is greater than 2. If greater than 2, stop the program. Otherwise, load the Bootloader into the memory and repeatedly determine whether the loader hash check is successful.
[0050] In order to further improve the accuracy of the program flag, the above-mentioned step S202 of the present application can be implemented through the following steps: step S2021, receiving the above-mentioned software upgrade request; step S2022, switching the program flag of the above-mentioned control chip to a first predetermined position, wherein the above-mentioned first predetermined position is a position pointing to the above-mentioned first partition; step S2023, receiving the above-mentioned target upgrade software.
[0051] Specifically, the internal structure of the control chip is as follows: Figure 6 As shown, the first partition stores program upgrade software, namely Bootloader, for signature verification and application upgrade. The second partition stores application firmware for implementing functions. The third partition serves as a buffer for the application firmware for upgrade buffering. The workspace pointer is the program flag.
[0052] In some embodiments, the above step S204 can be specifically implemented by the following steps: Step S205, switching the program flag of the above control chip to a second predetermined position, wherein the above second predetermined position is a position pointing to the above second partition. This method can further improve the accuracy of the program flag.
[0053] The above step S202 of the present application can also be implemented by the following steps: step S2024, obtaining the program flag of the above control chip, wherein the above flag is used to represent the loading address of the above target upgrade software at the current moment; step S2025, in the case where the above flag points to the above second partition, determining whether the above application firmware is stored in the above third partition; step S2026, in the case where the above application firmware is stored in the above third partition, obtaining the above application firmware and the signature of the above application firmware, and verifying the above signature; step S2027, in the case where the above signature verification is successful, writing the above application firmware to the above second partition; step S2028, in the case where the preset conditions are met, receiving the above software upgrade request, wherein the above preset conditions include at least one of the above flag not pointing to the above second partition, the above second partition not storing the above application firmware, and the above signature verification is unsuccessful. This method can further improve the accuracy of the program flag.
[0054] In some embodiments, the above step S203 can be specifically implemented by the following steps: Step S206, if the verification is unsuccessful, erasing the target upgrade software stored in the third partition. This method can further improve the security of software upgrade.
[0055] The embodiment of the present application also provides a USB Type-C port control program security design device. It should be noted that the USB Type-C port control program security design device of the embodiment of the present application can be used to execute the USB Type-C port control program security design method provided by the embodiment of the present application. The device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0056] The following is an introduction to the USB Type-C port control program security design device provided in an embodiment of the present application.
[0057] Figure 7 Schematic diagram of a USB Type-C port control program security design device according to an embodiment of the present application. Figure 7 As shown, the control chip includes a first partition, a second partition and a third partition, wherein the first partition is used to store program upgrade software, the second partition is used to store application firmware, and the third partition is used as a buffer for the application firmware. The device includes:
[0058] The verification unit 10 is used to perform integrity verification on the program upgrade software and the application firmware when the control chip is powered on;
[0059] The receiving unit 20 is used to execute the program upgrade software stored in the first partition and receive a software upgrade request and a target upgrade software when the verification is successful, wherein the software upgrade request is used to request to use the target upgrade software to perform a software upgrade on the control chip;
[0060] A verification unit 30, configured to store the target upgrade software in the third partition and verify the target upgrade software using an elliptic curve digital signature algorithm;
[0061] The execution unit 40 is used to write the target upgrade software stored in the third partition into the second partition and execute the target upgrade software when the verification is successful, so as to implement the USB Type-C port control program security design of the control chip.
[0062] Specifically, the program upgrade software stored in the first partition includes program verification and application upgrade functions. The software implements the ECDSA P256 signature verification algorithm, and the public key used for ECDSA signature verification is implicit in the program. The chip is read-only after leaving the factory and cannot be rewritten. Abnormal interrupt processing during the chip upgrade process, and recovery processing after damage caused by abnormal interruption during the main program upgrade process. The application firmware stored in the second partition includes the implementation of the USB Type C function, and also includes an application interface for I2C communication with an external controller. When the main application is working, if a program update request is received from an external controller, it will switch to the Bootloader, that is, the program upgrade software mode for update. The third partition serves as a buffer for the above-mentioned application firmware. When upgrading the main application, the Bootloader will first put the received data into the application upgrade buffer, and then move it to the main application area after verification. If an abnormal interruption process such as power failure occurs during the process of moving from the application upgrade buffer to the main application area, the Bootloader will continue the transfer process the next time it is powered on.
[0063] Through this embodiment, firstly, the control chip in the prior art generally includes two partitions for storing application firmware, while this solution replaces the two partitions in the prior art by adopting a second partition for storing application firmware and a third partition as a buffer zone, and there is no need to store the hardware signature algorithm for verifying the upgrade software in the second partition. Instead, the verification of the target upgrade software is achieved by executing the above-mentioned program upgrade software stored in the first partition, thereby saving hardware costs and solving the problem of high cost caused by the need to store the hardware signature algorithm in the control chip hardware in the prior art.
[0064] In the specific implementation process, the verification unit includes a first acquisition module, a first verification module, a first execution module and a first repetition module, wherein the first acquisition module is used for the acquisition step to obtain the program flag of the control chip, wherein the flag is used to represent the loading address of the target upgrade software at the current moment; the first verification module is used for the first verification step, when the program flag points to the second partition, to perform a hash check on the application firmware stored in the second partition; the first execution module is used for the first execution step, when the hash check succeeds, to execute the application firmware; the first repetition module is used for the first repetition step, when the hash check fails, to repeat the first verification step at least once until the predetermined number of times is reached. The device applies hash check when the control chip is powered on, and asymmetric encryption is only applied to the application upgrade stage, which can ensure the security emphasis of program upgrade, save program startup time, and further increase the response speed of the application.
[0065] Specifically, the program flag bit can indicate the program loading address after the chip is powered on. For example, when the current pointer is AA, the chip loads the main application program into the chip controller program memory and executes it, otherwise the chip loads the bootloader into the chip controller program memory and executes it. The program flag bit can also be an upgrade processing flag. When entering the program upgrade process, this flag is set to 1, and the program upgrade is successful, and this flag is 0.
[0066] The verification unit also includes a second verification module, a second execution module and a second repetition module, wherein the second verification module is used for the second verification step, and when the program flag does not point to the second partition or the repetition step reaches the predetermined number of times, the program upgrade software stored in the first partition is hash-checked; the second execution module is used for the second execution step, and when the hash check succeeds, the program upgrade software is executed; the second repetition module is used for the second repetition step, and when the hash check fails, the second verification step is repeated at least once until the predetermined number of times is reached. The device applies hash check when the control chip is powered on, and asymmetric encryption is only applied to the application upgrade stage, which can ensure the security emphasis of program upgrade, save program startup time, and further increase the response speed of the application.
[0067] Specifically, Figure 4 As shown in the figure, the steps to generate the encrypted signature of the main application of the control chip are as follows: Generate an ECDSAP256 signature key pair (including a public key (Pub_key1) and a private key (Priv_key1)). After the main application is signed with HMAC-SHA256 (using a hardware key), it is signed with the standard algorithm ECDSA private key. Figure 5 As shown, the power-on loading process of the control chip is as follows: the chip is powered on; determine whether the pointer (i.e., the program flag bit) points to the main program. If it points to the main program, load the main application program into the memory and clear the loading count; determine whether the loader hash check is successful. If successful, execute the main application program; if unsuccessful, add 1 to the loading count; determine whether the current loading count is greater than 2, otherwise load the main application program into the memory, and repeatedly determine whether the loader hash check is successful; if yes or the pointer does not point to the main program, load the Bootloader program and clear the loading count; determine whether the loader hash check is successful. If successful, execute the Bootloader program. If unsuccessful, add 1 to the loading count; determine whether the current loading count is greater than 2. If greater than 2, stop the program. Otherwise, load the Bootloader into the memory and repeatedly determine whether the loader hash check is successful.
[0068] In order to further improve the accuracy of the program flag, the above-mentioned verification unit of the present application includes a first receiving module, a switching module and a second receiving module, wherein the first receiving module is used to receive the above-mentioned software upgrade request; the switching module is used to switch the program flag of the above-mentioned control chip to a first predetermined position, wherein the above-mentioned first predetermined position is a position pointing to the above-mentioned first partition; the second receiving module is used to receive the above-mentioned target upgrade software.
[0069] Specifically, the internal structure of the control chip is as follows: Figure 6 As shown, the first partition stores program upgrade software, namely Bootloader, for signature verification and application upgrade. The second partition stores application firmware for implementing functions. The third partition serves as a buffer for the application firmware for upgrade buffering. The workspace pointer is the program flag.
[0070] In some embodiments, the device further includes a first switching unit, configured to switch the program flag of the control chip to a second predetermined position, wherein the second predetermined position is a position pointing to the second partition. The device can further improve the accuracy of the program flag.
[0071] The receiving unit of the present application includes a second acquisition module, a determination module, a third acquisition module, a writing module and a third receiving module, wherein the second acquisition module is used to acquire the program flag of the control chip, wherein the flag is used to represent the loading address of the target upgrade software at the current moment; the determination module is used to determine whether the application firmware is stored in the third partition when the flag points to the second partition; the third acquisition module is used to acquire the application firmware and the signature of the application firmware when the application firmware is stored in the third partition, and verify the signature; the writing module is used to write the application firmware to the second partition when the signature verification is successful; the third receiving module is used to receive the software upgrade request when the preset conditions are met, wherein the preset conditions include at least one of the flag not pointing to the second partition, the second partition not storing the application firmware and the signature verification not being successful. The device can further improve the accuracy of the program flag.
[0072] In some embodiments, the device further includes an erasing unit, which is used to erase the target upgrade software stored in the third partition if the verification fails. The device can further improve the security of software upgrade.
[0073] The USB Type-C port control program safety design device includes a processor and a memory. The above units are stored in the memory as program units, and the processor executes the above program units stored in the memory to implement corresponding functions. The above modules are all located in the same processor; or, the above modules are located in different processors in any combination.
[0074] The processor contains a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and the software can be upgraded by adjusting the kernel parameters.
[0075] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0076] An embodiment of the present invention provides a computer-readable storage medium, which includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the USB Type-C port control program security design method.
[0077] Specifically, the USB Type-C port control program security design method includes:
[0078] Step S201, when the control chip is powered on, performing integrity check on the program upgrade software and the application firmware;
[0079] Step S202, if the verification is successful, executing the program upgrade software stored in the first partition, and receiving a software upgrade request and a target upgrade software, wherein the software upgrade request is used to request to use the target upgrade software to perform a software upgrade on the control chip;
[0080] Step S203, storing the target upgrade software in the third partition, and verifying the target upgrade software using an elliptic curve digital signature algorithm;
[0081] Step S204, when the verification is successful, the target upgrade software stored in the third partition is written into the second partition, and the target upgrade software is executed to implement the USB Type-C port control program security design of the control chip.
[0082] An embodiment of the present invention provides a processor, which is used to run a program, wherein the USB Type-C port control program security design method is executed when the program is running.
[0083] Specifically, the USB Type-C port control program security design method includes:
[0084] Step S201, when the control chip is powered on, performing integrity check on the program upgrade software and the application firmware;
[0085] Step S202, if the verification is successful, executing the program upgrade software stored in the first partition, and receiving a software upgrade request and a target upgrade software, wherein the software upgrade request is used to request to use the target upgrade software to perform a software upgrade on the control chip;
[0086] Step S203, storing the target upgrade software in the third partition, and verifying the target upgrade software using an elliptic curve digital signature algorithm;
[0087] Step S204, when the verification is successful, the target upgrade software stored in the third partition is written into the second partition, and the target upgrade software is executed to implement the USB Type-C port control program security design of the control chip.
[0088] An embodiment of the present invention provides a device, the device including a processor, a memory, and a program stored in the memory and executable on the processor, and when the processor executes the program, at least the following steps are implemented:
[0089] Step S201, when the control chip is powered on, performing integrity check on the program upgrade software and the application firmware;
[0090] Step S202, if the verification is successful, executing the program upgrade software stored in the first partition, and receiving a software upgrade request and a target upgrade software, wherein the software upgrade request is used to request to use the target upgrade software to perform a software upgrade on the control chip;
[0091] Step S203, storing the target upgrade software in the third partition, and verifying the target upgrade software using an elliptic curve digital signature algorithm;
[0092] Step S204, when the verification is successful, the target upgrade software stored in the third partition is written into the second partition, and the target upgrade software is executed to implement the USB Type-C port control program security design of the control chip.
[0093] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0094] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program for initializing at least the following method steps:
[0095] Step S201, when the control chip is powered on, performing integrity check on the program upgrade software and the application firmware;
[0096] Step S202, if the verification is successful, executing the program upgrade software stored in the first partition, and receiving a software upgrade request and a target upgrade software, wherein the software upgrade request is used to request to use the target upgrade software to perform a software upgrade on the control chip;
[0097] Step S203, storing the target upgrade software in the third partition, and verifying the target upgrade software using an elliptic curve digital signature algorithm;
[0098] Step S204, when the verification is successful, the target upgrade software stored in the third partition is written into the second partition, and the target upgrade software is executed to implement the USB Type-C port control program security design of the control chip.
[0099] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0100] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0101] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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 generate 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.
[0102] 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.
[0103] 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.
[0104] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0105] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0106] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0107] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0108] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:
[0109] 1) The USB Type-C port control program security design method of the present application, first, the control chip in the prior art generally includes two partitions for storing application firmware, and the present solution replaces the two partitions in the prior art by adopting a second partition for storing application firmware and a third partition as a buffer, and the second partition does not need to store the hardware signature algorithm for verifying the upgrade software, but the target upgrade software is verified by executing the above-mentioned program upgrade software stored in the first partition, saving hardware costs and solving the problem of high cost caused by the need to store the hardware signature algorithm in the control chip hardware in the prior art.
[0110] 2) The USB Type-C port control program security design device of the present application, first of all, the control chip in the prior art generally includes two partitions for storing application firmware, and the present solution replaces the two partitions in the prior art by adopting a second partition for storing application firmware and a third partition as a buffer zone, and there is no need to store the hardware signature algorithm for verifying the upgrade software in the second partition, but the verification of the target upgrade software is achieved by executing the above-mentioned program upgrade software stored in the first partition, saving hardware costs and solving the problem of high cost caused by the need to store the hardware signature algorithm in the control chip hardware in the prior art.
[0111] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A USB Type-C port control program security design method, characterized in that: Applied to a control chip, the control chip includes a first partition, a second partition and a third partition, wherein the first partition is used to store program upgrade software, the second partition is used to store application firmware, and the third partition is used as a buffer for the application firmware, the method includes: When the control chip is powered on, performing integrity check on the program upgrade software and the application firmware; If the verification is successful, executing the program upgrade software stored in the first partition, and receiving a software upgrade request and a target upgrade software, wherein the software upgrade request is used to request to use the target upgrade software to perform a software upgrade on the control chip; The target upgrade software is stored in the third partition, and the target upgrade software is verified by using an elliptic curve digital signature algorithm; If the verification is successful, the target upgrade software stored in the third partition is written into the second partition, and the target upgrade software is executed to implement the USB Type-C port control program security design of the control chip.
2. The method according to claim 1, characterized in that When the control chip is powered on, the application firmware is checked for integrity, including: An acquisition step, acquiring a program flag of the control chip, wherein the program flag is used to represent a loading address of the target upgrade software at a current moment; A first verification step, in which, when the program flag bit points to the second partition, a hash verification is performed on the application firmware stored in the second partition; A first execution step, in which the application firmware is executed if the hash verification succeeds; The first repetition step is to repeat the first verification step at least once when the hash verification is unsuccessful, until a predetermined number of times is reached.
3. The method according to claim 2, characterized in that When the control chip is powered on, the program upgrade software is checked for integrity, including: A second verification step, when the program flag does not point to the second partition or the first repetition step reaches the predetermined number of times, performing a hash verification on the program upgrade software stored in the first partition; The second execution step is to execute the program upgrade software if the hash verification succeeds; The second repetition step is to repeat the second verification step at least once when the hash verification is unsuccessful, until the predetermined number of times is reached.
4. The method according to claim 2, characterized in that: Receive software upgrade requests and target upgrade software, including: Receiving the software upgrade request; Switching the program flag to a first predetermined position, wherein the first predetermined position is a position pointing to the first partition; The target upgrade software is received.
5. The method according to claim 2, characterized in that: After writing the target upgrade software stored in the third partition into the second partition, the method further includes: The program flag is switched to a second predetermined position, wherein the second predetermined position is a position pointing to the second partition.
6. The method according to claim 1, characterized in that Executing the program upgrade software stored in the first partition and receiving a software upgrade request, comprising: Obtaining a program flag of the control chip, wherein the program flag is used to represent a loading address of the target upgrade software at a current moment; In a case where the program flag bit points to the second partition, determining whether the application firmware is stored in the third partition; In the case where the third partition stores the application firmware, obtaining the application firmware and a signature of the application firmware, and verifying the signature; If the signature verification is successful, writing the application firmware into the second partition; When a preset condition is met, the software upgrade request is received, wherein the preset condition includes at least one of: the program flag does not point to the second partition, the second partition does not store the application firmware, and the signature verification is unsuccessful.
7. The method according to claim 1, characterized in that After verifying the target upgrade software using the elliptic curve digital signature algorithm, the method further includes: If the verification is unsuccessful, the target upgrade software stored in the third partition is erased.
8. A USB Type-C port control program security design device, characterized in that: Applied to a control chip, the control chip includes a first partition, a second partition and a third partition, wherein the first partition is used to store program upgrade software, the second partition is used to store application firmware, and the third partition is used as a buffer for the application firmware, the device includes: A verification unit, configured to perform integrity verification on the program upgrade software and the application firmware when the control chip is powered on; a receiving unit, configured to execute the program upgrade software stored in the first partition and receive a software upgrade request and a target upgrade software if the verification is successful, wherein the software upgrade request is used to request to use the target upgrade software to perform a software upgrade on the control chip; A verification unit, configured to store the target upgrade software in the third partition and verify the target upgrade software using an elliptic curve digital signature algorithm; An execution unit is used to write the target upgrade software stored in the third partition into the second partition and execute the target upgrade software when the verification is successful, so as to implement the USB Type-C port control program security design of the control chip.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 7.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.