External encryption system
The external encryption system addresses high processor demands of SM2 encryption by integrating key components on a PCB board, enabling efficient, low-cost, and portable SM2 encryption via a USB interface.
Patent Information
- Application Number
- CN202411037424.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-12-20
AI Technical Summary
Existing SM2 encryption algorithms require high processor performance, leading to high costs and limitations in existing encryption systems.
An external encryption system utilizing a microcontroller unit, storage unit, random number generating unit, and USB to serial port unit, integrated on a PCB board, which includes a microcontroller unit configured with STM32F103, internal memory, and a voltage conversion unit, enabling efficient SM2 encryption without the need for a host computer.
The system provides fast response speed, low cost, ease of use, and portability, with a compact size, allowing direct plug-and-play operation via a USB port and reducing processor load through DMA data transfer.
Smart Images

Figure CN119167440A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data security, and in particular to an external encryption system. Background Art
[0002] At present, data assets have become an important strategic resource. When data assets are in circulation, it is necessary to establish an efficient, secure, and reliable transmission network. Ideally, data should be securely encrypted and transmitted point-to-point between the sender and the receiver without being leaked to a third party. No third party can intercept the data transmission or steal the plaintext data.
[0003] With the advent of the information age, data security and cyberspace security have become important components of national security. Cryptography, as a key technology to ensure information security, is becoming increasingly important. The SM2 algorithm is an elliptic curve public key cryptography algorithm specified in the Chinese national standard (GB / T 32918-2016). Based on the principle of elliptic curve cryptography (ECC), it provides an efficient and secure solution for key exchange, digital signature and public key encryption.
[0004] The working principle of the SM2 algorithm is based on point addition operations on elliptic curves. The specific steps include:
[0005] Key generation: First, generate a pair of public and private keys. The private key is a randomly generated integer, and the public key is the result of the dot addition operation of the private key and the base point.
[0006] Digital signature: Use the private key to sign the hash value of the message to generate a signature.
[0007] Signature verification: Use the public key to verify the received signature and message to ensure the validity of the signature.
[0008] Public key encryption: Use the recipient's public key to encrypt the message and generate ciphertext.
[0009] Private key decryption: Use the private key to decrypt the ciphertext and restore the original message.
[0010] At present, since the SM2 encryption algorithm has high requirements on processor performance when running, the SM2 encryption algorithm generally needs to run in a host computer, resulting in high costs for existing encryption systems. Summary of the invention
[0011] In view of the defects in the prior art, the present invention provides an external encryption system to solve the technical problems raised in the background technology.
[0012] In order to achieve the above object, the present invention provides an external encryption system, comprising: a microcontroller unit, a storage unit, a random number generating unit and a USB to serial port unit, wherein the storage unit, the random number generating unit and the USB to serial port unit are all connected to the microcontroller unit by signal; wherein the microcontroller unit is connected to the USB interface through the USB to serial port unit;
[0013] The random number generating unit is used to generate random numbers;
[0014] The storage unit is used to store the SM2 encryption algorithm and the random number;
[0015] The micro control unit is used to receive a command sent by the PC end through a serial port interrupt, and if the command is valid, encrypt the data to be encrypted according to the SM2 encryption algorithm and the random number to obtain a ciphertext, and output the ciphertext to the PC end.
[0016] Furthermore, the micro control unit is a single chip microcomputer.
[0017] Furthermore, the model of the single chip microcomputer is STM32F103.
[0018] Furthermore, the storage unit is an internal memory, including a static random access memory and an internal Flash.
[0019] Furthermore, the random number generating unit is an ADC pin of a single chip microcomputer.
[0020] Further, the micro control unit is used to configure timer, DMA and ADC peripherals;
[0021] The timer is used to trigger ADC sampling through overflow interrupt, and the sampling result is transferred to the static random access memory for storage through DMA;
[0022] After the specified number of sampling results are transmitted, the DMA generates an interrupt, triggering the timer interrupt to close to end the collection of this round of random numbers.
[0023] Furthermore, the sampling result is obtained by reading the voltage value on the ADC pin.
[0024] Furthermore, the external encryption system also includes a voltage conversion unit;
[0025] The voltage conversion unit is used to convert the 5V voltage output by the PC end into a 3.3V voltage to supply power to the micro control unit, the storage unit, the random number generating unit and the USB to serial port unit.
[0026] Furthermore, the voltage conversion unit, the micro control unit, the storage unit, the random number generation unit and the USB to serial port unit are integrated on a PCB board.
[0027] The beneficial effects of the present invention are embodied in:
[0028] The external encryption system provided in this application is easy to use and can be directly plugged into the USB port on the PC without any further operation. It has a fast response speed and a good user experience. It is small in size, low in cost, and easy to carry. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following is a brief introduction to the drawings required for the specific embodiments or the description of the prior art. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn according to the actual scale.
[0030] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application. For ordinary technicians in this field, other accompanying drawings can also be obtained based on these accompanying drawings without paying creative labor.
[0031] Figure 1 A structural block diagram of an external encryption system provided by an embodiment of the present invention;
[0032] Figure 2 A software program architecture block diagram of an external encryption system provided by an embodiment of the present invention;
[0033] The realization of the purpose, functional features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. The above-mentioned drawings have shown clear embodiments of this application, which will be described in more detail later. These drawings and textual descriptions are not intended to limit the scope of the concept of this application in any way, but to illustrate the concept of this application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0034] The following embodiments of the technical solution of the present invention are described in detail in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and are therefore only used as examples, and cannot be used to limit the protection scope of the present invention.
[0035] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should have the common meanings understood by those skilled in the art to which the present invention belongs.
[0036] In the description of the present application, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.
[0037] In addition, the terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. In the description of the present invention, the meaning of "plurality" is more than two, unless otherwise clearly and specifically defined.
[0038] In this application, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0039] In the present application, unless otherwise clearly specified and limited, a first feature being “above” or “below” a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being “above”, “above”, and “above” a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being “below”, “below”, and “below” a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.
[0040] like Figure 1As shown, an external encryption system provided by this embodiment includes a microcontroller unit, a storage unit, a random number generating unit, a USB to serial port unit and a voltage conversion unit, wherein the storage unit, the random number generating unit and the USB to serial port unit are all connected to the microcontroller signal. The voltage conversion unit is used to convert the 5V voltage output by the PC end into a 3.3V voltage, and then supply power to the microcontroller unit, the storage unit, the random number generating unit and the USB to serial port unit. The PC data protocol does not match the single-chip microcomputer interface, and needs to communicate with the single-chip microcomputer through the USB to serial port unit.
[0041] In this embodiment, the voltage conversion unit, micro control unit, storage unit, random number generation unit and USB to serial port unit are integrated on a PCB board. The PCB board can be installed in a USB housing of 53mm×24mm×14mm.
[0042] The microcontroller unit is connected to the USB interface through a USB-to-serial port unit; the random number generating unit is used to generate random numbers; the storage unit is used to store the SM2 encryption algorithm and the random numbers; the microcontroller unit is used to receive commands sent by the PC through a serial port interrupt, and if the command is valid, the encrypted data is encrypted according to the SM2 encryption algorithm and the random number to obtain a ciphertext, and the ciphertext is output to the PC.
[0043] In this embodiment, the main consumables are all surface mount components. The microcontroller unit uses a small 48-pin STM32 microcontroller without affecting the performance and user experience. The serial port conversion chip uses an 8-pin chip and does not require a crystal oscillator.
[0044] This application adopts STM32F1 series chips, with a maximum main frequency of 72MHz, 128K Flash, 20K SRAM, and low cost. Therefore, in order to reduce costs, in the technical solution of this application, the storage unit can directly use the internal memory (MEM) of the single-chip microcomputer, and its internal memory (MEM) includes static random access memory (SRAM) and internal Flash. The USB conversion chip can also use domestic chips.
[0045] like Figure 2 The data flow of the program running in this system is shown, where the thick arrows represent the flow of large data and the thin arrows represent the flow of small data, which are separated from each other in terms of the time they occupy the microcontroller unit (MCU). The commands sent by the PC are sent to the microcontroller unit (MCU) through the serial port interrupt, and the microcontroller unit (MCU) executes the SM2 encryption algorithm calculation, data storage and data return to the PC according to the commands.
[0046] The random number generating unit is the ADC pin of the single-chip microcomputer. During the calculation of the SM2 encryption algorithm, the microcontroller mainly interacts with a large amount of data with the internal memory, but the random number is read multiple times during the calculation of the SM2 encryption algorithm. This random number is obtained by reading the voltage value on the ADC pin multiple times. In order to reduce the load of the microcontroller, the random number can be collected and obtained in the following ways:
[0047] The microcontroller unit is used to configure the timer, DMA and ADC peripherals; the timer is used to trigger ADC sampling through overflow interrupt, and the sampling results are transferred to the static random access memory (SRAM) for storage through DMA; when the specified number of sampling results are transmitted, the DMA generates an interrupt, triggering the timer interrupt to close to end the collection of this round of random numbers.
[0048] During the random number generation process, the microcontroller configures the timer, DMA, and ADC peripherals and does not care about the data flow, but only about data acquisition and timer opening. Data is transmitted through direct memory access (DMA), which does not require the microcontroller's CPU to be occupied. That is, when transmitting data, the microcontroller's CPU can handle other processes, so that the random number collection process will not affect the MCU work, and the MCU can focus on the software algorithm work, thereby achieving the purpose of reducing the microcontroller (MCU) load.
[0049] In summary, the external encryption system provided by this application is easy to use and can be directly plugged into the USB port on the PC without any further operation; it has a fast response speed, with a response time of less than 2 seconds, and a good user experience; it is small in size, low in cost, and easy to carry.
[0050] Finally, it should be noted that the various technical features of the technical solution of the present application can be combined arbitrarily. In order to make the description concise, not all possible combinations of the various technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of the present application.
[0051] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions described in the above embodiments may still be modified, or some or all of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention, and should all be included in the scope of the claims and specification of the present invention.
Claims
1. An external encryption system, characterized in that: include: A microcontroller unit, a storage unit, a random number generating unit and a USB to serial port unit, wherein the storage unit, the random number generating unit and the USB to serial port unit are all signal-connected to the microcontroller unit; wherein the microcontroller unit is communicatively connected to the USB interface via the USB to serial port unit; The random number generating unit is used to generate random numbers; The storage unit is used to store the SM2 encryption algorithm and the random number; The micro control unit is used to receive a command sent by the PC end through a serial port interrupt, and if the command is valid, encrypt the data to be encrypted according to the SM2 encryption algorithm and the random number to obtain a ciphertext, and output the ciphertext to the PC end.
2. An external encryption system as claimed in claim 1, characterized in that: The micro control unit is a single chip microcomputer.
3. An external encryption system as claimed in claim 2, characterized in that: The model of the single chip microcomputer is STM32F103.
4. An external encryption system as claimed in claim 3, characterized in that: The storage unit is an internal memory, including a static random access memory and an internal Flash.
5. An external encryption system as claimed in claim 4, characterized in that: The random number generating unit is an ADC pin of the single chip microcomputer.
6. An external encryption system as claimed in claim 5, characterized in that: The micro control unit is used to configure the timer, DMA and ADC peripherals; The timer is used to trigger ADC sampling through overflow interrupt, and the sampling result is transferred to the static random access memory for storage through DMA; After the specified number of sampling results are transmitted, the DMA generates an interrupt, triggering the timer interrupt to close to end the collection of this round of random numbers.
7. An external encryption system as claimed in claim 6, characterized in that: The sampling result is obtained by reading the voltage value on the ADC pin.
8. An external encryption system as claimed in claim 1, characterized in that: The external encryption system also includes a voltage conversion unit; The voltage conversion unit is used to convert the 5V voltage output by the PC end into a 3.3V voltage to supply power to the micro control unit, the storage unit, the random number generating unit and the USB to serial port unit.
9. An external encryption system as claimed in claim 8, characterized in that: The voltage conversion unit, the micro control unit, the storage unit, the random number generation unit and the USB to serial port unit are integrated on a PCB board.
