Encrypted SPI interface based on AES algorithm
By introducing the AES encryption and decryption module into the SPI interface, the security threat problem caused by the lack of encryption mechanism in the SPI interface is solved, the security of data transmission is achieved, and the data security of embedded systems and peripheral devices is ensured.
Patent Information
- Application Number
- CN202410700625.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-09-17
AI Technical Summary
The SPI interface lacks an encryption mechanism, resulting in information leakage and security threats during data transmission. Especially in embedded systems and peripheral devices, attackers can intrude or steal data through the SPI interface.
Design an encrypted SPI interface based on the AES algorithm, including the AES encryption module and the AES decryption module. The SPI data is processed through the state machine control unit, byte substitution unit, row shift unit, column mixing unit, key expansion unit and other components. Encrypt and decrypt, and send and receive data through the SPI interface module to ensure the security of data transmission.
It realizes the encrypted transmission of SPI interface data, enhances the security between devices, prevents information leakage and attacks, and ensures that data security is compatible with the SPI protocol.
Smart Images

Figure CN118656880A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of integrated circuits, and in particular to an encrypted SPI interface based on an AES algorithm. Background Art
[0002] The SPI interface is a synchronous serial communication interface with the characteristics of full-duplex, high reliability and fast transmission speed. The SPI interface adopts a four-wire pin standard, which can occupy fewer pins to achieve data transmission, save chip pin data, and greatly reduce the chip area. Compared with other serial buses, the SPI interface does not need to transmit data at a fixed baud rate and does not require addressing for point-to-point communication. Its simple and easy-to-use advantages make it widely used in embedded systems and various peripheral device interfaces, such as memory, sensors, wireless modules, etc.
[0003] Since the SPI interface lacks an encryption mechanism, information leakage may occur during data transmission, posing a security threat to other SPI devices and causing major security issues. For example, the SPI interface is often used in embedded systems, and attackers can use it to invade the system, control the device, or steal security information; a large number of peripheral devices such as memory and sensors use the SPI interface, and attackers can use it to steal or tamper with device data.
[0004] As the SPI interface becomes more and more widely used, the security of the SPI interface has become a pressing issue. Summary of the invention
[0005] The purpose of the present invention is to provide an encrypted SPI interface based on the AES algorithm to solve the problems in the background technology.
[0006] In order to solve the above technical problems, the present invention provides an encrypted SPI interface based on the AES algorithm, comprising:
[0007] AES encryption module, encrypts the SPI data transmitted by the host computer;
[0008] AES decryption module, decrypts the data encrypted by the AES encryption module and transmits it to the host computer;
[0009] SPI interface module, for sending and receiving SPI encrypted data.
[0010] In one embodiment, the AES encryption module includes a first state machine control unit, a byte substitution unit, a row shift unit, a column mixing unit, a first round key addition unit and a first key expansion unit; the first state machine control unit is used to control the state jump of the AES encryption module, implement the encryption operation of SPI data, and generate SPI encrypted data; the byte substitution unit implements byte mapping by searching S-box; the row shift unit is used to exchange the positions between bytes in each row; the column mixing unit further confuses the elements in the matrix; the first round key addition unit is used to perform an XOR operation on the round key and the state matrix; the first key expansion unit is used to perform an expansion operation on the original key to generate a round key.
[0011] In one embodiment, the AES decryption module includes a second state machine control unit, a second key expansion unit, a second round key addition unit, an inverse column mixing unit, a reverse row shift unit and an inverse byte substitution unit; the second state machine control unit is used to control the state jump of the AES decryption module, implement the decryption operation of the encrypted SPI data, and generate the decrypted SPI data; the second key expansion unit is used to perform an expansion operation on the original key to generate a round key; the second round key addition unit is used to perform an XOR operation on the round key and the state matrix; the inverse column mixing unit is used for the inverse operation of the state matrix column mixing; the reverse row shift unit is used to restore the position between bytes in each row; the reverse byte substitution unit is used to implement byte mapping by searching for an inverse S-box.
[0012] In one embodiment, the SPI interface module includes a clock control module, a control module, a sending data register, a receiving data register, a shift register and a data transceiver module; the clock control module is used to generate an SCK clock signal; the control module is used to control the clock division, the master-slave mode of the SPI interface, the chip select signal CS and the state jump of the SPI interface module; the sending data register is used to cache the encrypted SPI data generated by the AES encryption module; the receiving data register is used to cache the encrypted SPI data output by the shift register; the shift register is used to serially shift the input and output data; and the data transceiver module is used to send and receive data.
[0013] In one embodiment, the control module selects the master-slave mode under the configuration of the host computer and transmits the SPI data to the AES encryption module for encryption processing, writes the SPI encrypted data into the sending data register, and sends the encrypted data through the shift register and the data transceiver module; at the same time, the data transceiver module receives the encrypted data, caches it in the receiving data register through the shift register, transmits it to the AES decryption module for decryption processing, and finally writes the SPI decrypted data into the host computer to realize encrypted data transmission between devices.
[0014] In one implementation, the encrypted SPI interface is compatible with the SPI protocol.
[0015] The invention provides an encrypted SPI interface based on the AES algorithm, comprising an AES encryption module, an AES decryption module, and an SPI interface module; the AES encryption module encrypts the SPI data transmitted by the host computer; the AES decryption module decrypts the data encrypted by the AES encryption module and transmits it to the host computer; and the SPI interface module sends and receives the SPI encrypted data. The invention adds an AES encryption module and an AES decryption module on the basis of being compatible with the SPI protocol, thereby ensuring the data security of the SPI interface. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 This is a schematic diagram of an encrypted SPI interface based on the AES algorithm provided by the present invention;
[0017] Figure 2 It is a schematic diagram of an AES encryption module in an encrypted SPI interface based on the AES algorithm provided by the present invention;
[0018] Figure 3 The present invention provides a schematic diagram of an AES decryption module in an encrypted SPI interface based on the AES algorithm. DETAILED DESCRIPTION
[0019] The following is a further detailed description of an encrypted SPI interface based on the AES algorithm proposed by the present invention in conjunction with the accompanying drawings and specific embodiments. The advantages and features of the present invention will become clearer according to the following description. It should be noted that the accompanying drawings are all in a very simplified form and are not in precise proportions, and are only used to conveniently and clearly assist in explaining the purpose of the embodiments of the present invention.
[0020] The present invention provides an encrypted SPI interface based on the AES algorithm, the structure of which is as follows: Figure 1 As shown, it includes an AES encryption module, an AES decryption module, and an SPI interface module.
[0021] The structure of the AES encryption module is as follows Figure 2 As shown, it includes a state machine control unit 1, which is used to control the state jump of the AES encryption module, realize the encryption operation of SPI data, and generate encrypted SPI data; a byte substitution unit, which is used to realize byte mapping by searching S-box; a row shift unit, which is used to exchange the positions between bytes in each row; a column mixing unit, which is used to further confuse the elements in the matrix; a round key adding unit 1, which is used to perform an XOR operation on the round key and the state matrix; and a key expansion unit 1, which is used to perform an expansion operation on the original key to generate a round key.
[0022] The structure of the AES decryption module is as follows Figure 3As shown, it includes a state machine control unit 2, which is used to control the state jump of the AES decryption module, realize the decryption operation of the encrypted SPI data, and generate the decrypted SPI data; a key expansion unit 2, which is used to expand the original key and generate the round key; a round key addition unit 2, which is used to perform an XOR operation on the round key and the state matrix; an inverse column mixing unit, which is used for the inverse operation of the state matrix column mixing; a reverse row shift unit, which is used to restore the position between the bytes in each row; and an inverse byte substitution unit, which is used to realize byte mapping by searching the inverse S-box.
[0023] Please continue reading Figure 1 The SPI interface module includes a clock control module for generating an SCK clock signal; a control module for controlling the frequency division of the clock, the master-slave mode of the SPI interface, the chip select signal CS and the state jump of the SPI interface module; a sending data register for caching the encrypted SPI data generated by the AES encryption module; a receiving data register for caching the encrypted SPI data output by the shift register; a shift register for serially shifting the input and output data; and a data transceiver module for sending and receiving data.
[0024] The invention discloses a working process of an encrypted SPI interface based on an AES algorithm: a host computer configuration control module selects a master-slave mode and transmits SPI data to an AES encryption module for encryption processing, then writes the SPI encrypted data into a sending data register, and finally sends the encrypted data through a shift register and a data transceiver module; at the same time, the data transceiver module receives the encrypted data, caches the data in a receiving data register through a shift register, and then transmits the data to an AES decryption module for decryption processing, and finally writes the SPI decrypted data into the host computer, thereby realizing encrypted data transmission between devices.
[0025] The above description is only a description of the preferred embodiments of the present invention, and is not intended to limit the scope of the present invention. Any changes or modifications made by a person skilled in the art in the field of the present invention based on the above disclosure shall fall within the scope of protection of the claims.
Claims
1. An encrypted SPI interface based on the AES algorithm, characterized in that: include: AES encryption module, encrypts the data transmitted by the host computer; AES decryption module, receives the encrypted data from the SPI interface module and decrypts it, and transmits the decrypted data to the host computer; The SPI interface module sends the encrypted data of the AES encryption module with the SPI bus timing, or receives the encrypted SPI data and waits to send it to the SPI decryption module for decryption.
2. The encrypted SPI interface based on the AES algorithm as claimed in claim 1, characterized in that: The AES encryption module includes a first state machine control unit, a byte substitution unit, a row shift unit, a column mixing unit, a first round key adding unit and a first key expansion unit; the first state machine control unit is used to control the state jump of the AES encryption module, realize the encryption operation of SPI data, and generate SPI encrypted data; the byte substitution unit realizes byte mapping by searching S-box; the row shift unit is used to exchange the positions between bytes in each row; the column mixing unit further confuses the elements in the matrix; the first round key adding unit is used to perform an XOR operation on the round key and the state matrix; the first key expansion unit is used to perform an expansion operation on the original key to generate a round key.
3. The encrypted SPI interface based on the AES algorithm as claimed in claim 2, characterized in that: The AES decryption module includes a second state machine control unit, a second key expansion unit, a second round key addition unit, an inverse column mixing unit, a reverse row shift unit and an inverse byte substitution unit; the second state machine control unit is used to control the state jump of the AES decryption module, realize the decryption operation of the encrypted SPI data, and generate the decrypted SPI data; the second key expansion unit is used to perform an expansion operation on the original key to generate a round key; the second round key addition unit is used to perform an XOR operation on the round key and the state matrix; the inverse column mixing unit is used for the inverse operation of the state matrix column mixing; the reverse row shift unit is used to restore the position between bytes in each row; the reverse byte substitution unit is used to realize byte mapping by searching for an inverse S-box.
4. The encrypted SPI interface based on the AES algorithm as claimed in claim 3, characterized in that: The SPI interface module includes a clock control module, a control module, a sending data register, a receiving data register, a shift register and a data transceiver module; the clock control module is used to generate an SCK clock signal; the control module is used to control the frequency division of the clock, the master-slave mode of the SPI interface, the chip select signal CS and the state jump of the SPI interface module; the sending data register is used to cache the encrypted SPI data generated by the AES encryption module; the receiving data register is used to cache the encrypted SPI data output by the shift register; the shift register is used to serially shift the input and output data; and the data transceiver module is used to send and receive data.
5. The encrypted SPI interface based on the AES algorithm as claimed in claim 4, characterized in that: The control module selects the master-slave mode under the configuration of the host computer and transmits the SPI data to the AES encryption module for encryption processing, writes the SPI encrypted data into the sending data register, and sends the encrypted data through the shift register and the data transceiver module; at the same time, the data transceiver module receives the encrypted data, caches it in the receiving data register through the shift register, transmits it to the AES decryption module for decryption processing, and finally writes the SPI decrypted data into the host computer to realize encrypted data transmission between devices.
6. The encrypted SPI interface based on the AES algorithm as claimed in claim 1, characterized in that: The encrypted SPI interface is compatible with the SPI protocol.
