Data transmission method and apparatus, storage medium, electronic device, and program product
By adjusting the key generation method of the RSA algorithm and setting the decryption modulus to a smaller p, and combining symmetric and asymmetric encryption, the problem of excessive computational resource consumption of the RSA algorithm is solved, achieving more efficient data transmission and expanding application scenarios.
Patent Information
- Application Number
- CN202411095279.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2044-08-09
AI Technical Summary
The RSA algorithm has limited application scenarios due to its excessive consumption of computational resources in secure data transmission.
By resetting the key generation method of the RSA algorithm and adjusting the decryption modulus to a smaller value p, a public key and a private key are generated, and data transmission is performed by combining symmetric encryption and asymmetric encryption methods.
It reduces the resource consumption of devices running the RSA algorithm, improves computing efficiency, expands the application scenarios of the RSA algorithm, and enhances the security of data transmission.
Smart Images

Figure CN119070990B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the field of communications, and in particular, to a data transmission method and device, a storage medium, an electronic device, and a program product. BACKGROUND
[0002] RSA (Rivest-Shamir-Adleman) algorithm has a wide range of applications in the field of data security transmission. The RSA algorithm in the related art requires a large amount of computing resources during operation, and therefore, there are problems of excessive resource consumption and limited application scenarios. SUMMARY
[0003] Embodiments of the present application provide a data transmission method and device, a storage medium, an electronic device, and a program product to at least solve the problem of excessive resource consumption and limited application scenarios of the RSA algorithm in the related art due to the need for a large amount of computing resources during operation.
[0004] According to an embodiment of the present application, a data transmission method is provided, comprising: generating a public key and a private key included in a transmission key of an asymmetric encryption RSA algorithm by the following way: randomly generating a public key exponent e, wherein e is an integer; randomly generating a large prime number p and a large prime number q, and taking p as a private key modulus, wherein p and q are different, a first difference value and e are co-prime, the first difference value is a difference value between p and a predetermined value; determining a public key modulus N based on p and q, and determining a private key exponent d based on p and e, wherein a first product of d and e is taken modulo the first difference value to obtain the predetermined value; determining the public key based on e and N, and determining the private key based on p and d; and sending an indication message carrying the public key to a target device, wherein the indication message is used to instruct the target device to encrypt target data to be transmitted based on the public key to obtain target encrypted data, and the private key is used to decrypt the target encrypted data received from the target device to obtain the target data.
[0005] In an exemplary embodiment, the predetermined value is 1.
[0006] In an exemplary embodiment, sending the indication message carrying the public key to the target device comprises: sending the indication message carrying the public key to the target device under the triggering of a request message sent by the target device.
[0007] In an example embodiment, the indication message further comprises a first bit number of p, a first encryption algorithm, a first initial vector of the first encryption algorithm, and a first rule for indicating a first key K generation method of the first encryption algorithm, wherein the first initial vector and k are binary numbers of a predetermined bit number determined by a mode of the first encryption algorithm; the indication message is used to instruct the target device to encrypt the target data by: the target device generating a random number R of the first bit number; the target device deriving R by a key derivation function KDF according to the first rule to obtain k; the target device encrypting the target data by the first encryption algorithm based on k and the first initial vector to obtain first intermediate data, in a case that a second bit number of the target data is an integer multiple of the predetermined bit number; the target device encrypting R according to a RSA algorithm based on the public key to obtain second intermediate data; and the target device determining the target encrypted data based on the first intermediate data and the second intermediate data.
[0008] In an example embodiment, the indication message further instructs the target device to pad the target data in a case that a second bit number of the target data is not an integer multiple of the predetermined bit number.
[0009] In an example embodiment, the method further comprises: receiving the target encrypted data sent by the target device, and determining whether the second intermediate data included in the target encrypted data is received for the first time; in a case that the second intermediate data is determined to be received for the first time, decrypting the second intermediate data according to the RSA algorithm based on the private key to obtain R; deriving R by kDF according to the first rule to obtain k, and storing k and the second intermediate data correspondingly; and decrypting the first intermediate data included in the target encrypted data by the first encryption algorithm based on k and the first initial vector to obtain the target data.
[0010] In an example embodiment, after receiving the target encrypted data sent by the target device and determining whether the second intermediate data included in the target encrypted data is received for the first time, the method further comprises: in a case that the second intermediate data is determined not to be received for the first time, obtaining k corresponding to the second intermediate data stored in advance; and decrypting the first intermediate data by the first encryption algorithm based on k and the first initial vector to obtain the target data.
[0011] According to another embodiment of the present application, a data transmission device is provided, comprising: a generating module configured to generate a public key and a private key included in a transmission key of an asymmetric encryption RSA algorithm by: randomly generating a public key exponent e, wherein e is an integer; randomly generating a large prime number p and a large prime number q, and taking p as a private key modulus, wherein p is different from q, a first difference value is coprime with e, the first difference value is a difference value between p and a predetermined value; determining a public key modulus N based on p and q, and determining a private key exponent d based on p and e, wherein a first product is the predetermined value when the first product is taken modulo the first difference value, the first product is a product of d and e; determining the public key based on e and N, and determining the private key based on p and d; and a sending module configured to send an indication message carrying the public key to a target device, wherein the indication message is used to instruct the target device to encrypt target data to be transmitted based on the public key to obtain target encrypted data, and the private key is used to decrypt the target encrypted data received from the target device to obtain the target data.
[0012] According to still another embodiment of the present application, a computer readable storage medium is also provided, and the computer readable storage medium stores a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
[0013] According to still another embodiment of the present application, an electronic device is also provided, comprising a memory and a processor, the memory stores a computer program, and the processor is configured to execute the computer program to execute the steps in any of the above method embodiments.
[0014] According to still another embodiment of the present application, a computer program product is also provided, and the computer program product comprises a computer program, and the computer program is executed by a processor to implement the steps in any of the above method embodiments.
[0015] According to the present application, by resetting the key generation method of the RSA algorithm, the decryption modulus is adjusted to a smaller p, so that the problem of excessive resource consumption and limited application scenarios of the RSA algorithm in the related art due to the need for large calculation resources during running can be solved, the operation efficiency of the RSA algorithm is improved, the resource consumption of the device running the RSA algorithm is reduced, and the application scenarios of the RSA algorithm are expanded. BRIEF DESCRIPTION OF DRAWINGS
[0016] Figure 1 is a hardware structure block diagram of a mobile terminal according to the data transmission method of the embodiment of the present application;
[0017] Figure 2 is a flow of the data transmission method according to the embodiment of the present applicationFigure 1 ;
[0018] Figure 3 is a flow of a data transmission method according to an embodiment of the present application Figure 2 ;
[0019] Figure 4 is a flow of a data transmission method according to an embodiment of the present application Figure 3 ;
[0020] Figure 5 is a schematic diagram of a data transmission method according to an embodiment of the present application
[0021] Figure 6 is a structural block diagram of a data transmission device according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] Hereinafter, the embodiments of the present application will be described in detail with reference to the accompanying drawings and in conjunction with embodiments.
[0023] It should be noted that the terms "first", "second", and the like in the description and claims of the present application and the above-mentioned accompanying drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence.
[0024] 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 the case of running on a mobile terminal, Figure 1 is a hardware structural block diagram of a mobile terminal for a data transmission method according to an embodiment of the present application. As shown in Figure 1 , the mobile terminal can include one or more (only one is shown in Figure 1 ) processors 102 (the processor 102 can 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 above-mentioned mobile terminal can further include a transmission device 106 for communication function and an input / output device 108. Those skilled in the art can understand that Figure 1 The structure shown is only schematic, which does not limit the structure of the above-mentioned mobile terminal. For example, the mobile terminal can further include more or less components than those shown in Figure 1 , or have a different configuration from that shown in Figure 1 .
[0025] 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 data transmission 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, implementing the above-mentioned method. 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 located relative to the processor 102, and these remote memories may 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 combinations thereof.
[0026] The transmission device 106 is used to receive or send data via a network. A specific example of the aforementioned network may include a wireless network provided by the mobile terminal's communications provider. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0027] In this embodiment, a data transmission method running on the above mobile terminal or network architecture is provided. Figure 2 This is the process of the data transmission method according to an embodiment of the present invention. Figure 1 ,like Figure 2 As shown, the process includes the following steps:
[0028] Step S202, generating a public key and a private key included in a transmission key of an asymmetric encryption RSA algorithm in the following manner: randomly generating a public key exponent e, where e is an integer; randomly generating a large prime number p and a large prime number q, and using p as a private key modulus, where p and q are different, a first difference is mutually prime to e, and the first difference is the difference between p and a predetermined value; determining a public key modulus N based on p and q, and determining a private key exponent d based on p and e, where a first product modulo the first difference is the predetermined value, and the first product is the product of d and e; determining the public key based on e and N, and determining the private key based on p and d;
[0029] In step S204, an indication message carrying the public key is sent to a target device, where the indication message is used to instruct the target device to encrypt target data to be transmitted based on the public key to obtain target encrypted data, and the private key is used to decrypt the target encrypted data received from the target device to obtain the target data.
[0030] In the above steps, the subject performing the above steps includes but is not limited to a server, a mobile terminal, an embedded system, a dedicated hardware security module (HSM), other devices capable of running RSA algorithm, etc., the target device includes but is not limited to a server, a mobile terminal, an embedded system, a dedicated hardware security module (HSM), other devices capable of running RSA algorithm, etc., but is not limited thereto, and the target data includes but is not limited to network communication data, digital certificates, software licenses, Internet of Things device data, mobile device data, etc. The way of sending the indication message to the target device includes but is not limited to sending through MQTT (Message Queuing Telemetry Transport) protocol, sending through CoAP (Constrained Application Protocol) protocol, sending through RESTful API (Application Programming Interface), sending through LWM2M (Lightweight Machine to Machine) protocol, sending through FTP (File Transfer Protocol) / SFTP (Secure File Transfer Protocol), etc.
[0031] In an optional embodiment, the subject performing the above steps includes but is not limited to an Internet of Things device, the target device includes but is not limited to a management tool device, and the target data includes but is not limited to configuration information issued by the management tool device to the Internet of Things device.
[0032] Through the above steps, since the key generation method of the RSA algorithm is reset to adjust the decryption modulus to a smaller p, the operation amount of the device running the RSA algorithm is reduced, the problem of excessive resource consumption and limited application scenarios of the RSA algorithm in the related art due to the need for large calculation resources during running is solved, the operation efficiency of the RSA algorithm is improved, the resource consumption of the device running the RSA algorithm is reduced, and thus the application scenarios of the RSA algorithm are expanded.
[0033] In an optional embodiment, the predetermined value is 1.
[0034] In an optional embodiment, the method for generating the transmission key of the RSA algorithm includes but is not limited to: randomly generating a public key exponent e; randomly generating two prime numbers p and q, wherein p and q are different, p satisfies gcd(e, (p-1))=1, and p is a private key modulus; determining a public key modulus N and a private key exponent d, wherein N=p×q, and d=e -1 mod(p-1); based on the public key exponent e and the public key modulus N, determining a public key included in the transmission key, and based on the private key exponent d and the private key modulus p, determining a private key included in the transmission key.
[0035] In an optional embodiment, sending the indication message carrying the public key to the target device includes: sending the indication message carrying the public key to the target device triggered by a request message sent by the target device.
[0036] In the above steps, the manner in which the target device sends the indication message includes but is not limited to: sending through the MQTT protocol, sending through the CoAP protocol, sending through the RESTful API, sending through LWM2M, sending through FTP / SFTP, etc., the length of N is the standard length of the public key modulus of the RSA algorithm, for example, the length of N is 1024 bits, the length of N is 2048 bits, etc.
[0037] In an optional embodiment, the indication message further includes a first number of bits of p, a first encryption algorithm, a first initial vector of the first encryption algorithm, and a first rule for indicating a first key K generation method of the first encryption algorithm, wherein the first initial vector and k are both binary numbers of a predetermined number of bits, and the predetermined number of bits is determined by the mode of the first encryption algorithm; the indication message is used to instruct the target device to encrypt the target data in the following manner: the target device generates a random number R with a number of bits equal to the first number of bits; the target device derives R through a key derivation function KDF according to the first rule to obtain k; the target device encrypts the target data through the first encryption algorithm based on k and the first initial vector to obtain first intermediate data, under the condition that the second number of bits of the target data is an integer multiple of the predetermined number of bits; the target device encrypts R according to the RSA algorithm based on the public key to obtain second intermediate data; and the target device determines the target encrypted data based on the first intermediate data and the second intermediate data.
[0038] In the above steps, the first encryption algorithm includes but is not limited to: AES128-OFB (Advanced Encryption Standard with a 128-bit block size in Output Feedback mode) algorithm, AES-CBC (Advanced Encryption Standard in Cipher Block Chaining mode) algorithm, AES-ECB (Advanced Encryption Standard in Electronic Codebook mode) algorithm, AES-CTR (Advanced Encryption Standard in Counter mode) algorithm, AES-GCM (Advanced Encryption Standard in Galois / Counter Mode) algorithm, etc., and the first initial vector is a pre-set vector. For example, the first initial vector can be a predetermined number of 0s. The way of encrypting R according to the RSA algorithm to obtain the second intermediate data includes but is not limited to: second intermediate data = R e mod N.
[0039] Through the above steps, the data to be transmitted is encrypted in a combination of symmetric encryption and asymmetric encryption, thereby improving the security of data transmission.
[0040] In an optional embodiment, the indication message is further used to instruct the target device to perform the following operation: in a case where the target device determines that the second number of bits of the target data is not an integer multiple of the predetermined number of bits, padding the target data so that the second number of bits of the padded target data is an integer multiple of the predetermined number of bits.
[0041] In the above steps, padding the target data includes but is not limited to: padding the target data with 0s.
[0042] In an optional embodiment, the method further comprises: receiving the target encrypted data sent by the target device, determining whether the second intermediate data included in the target encrypted data is received for the first time, in the case of determining that the second intermediate data is received for the first time, decrypting the second intermediate data according to the RSA algorithm to obtain R based on the private key, deriving k from R by the kDF based on the first rule, and storing k and the second intermediate data correspondingly, and decrypting the first intermediate data included in the target encrypted data by the first encryption algorithm based on k and the first initial vector to obtain the target data.
[0043] In an optional embodiment, the management tool end device regenerates R and updates the second intermediate data according to the RSA algorithm in a manner including but not limited to: R = second intermediate data d mod p, that is, R is the result of the e-th power of the second intermediate data modulo p.
[0044] Through the above steps, the target encrypted data generated by combining symmetric encryption and asymmetric encryption is decrypted, and the security of data transmission is improved.
[0045] In an optional embodiment, after receiving the target encrypted data sent by the target device and determining whether the second intermediate data included in the target encrypted data is received for the first time, the method further comprises: in the case of determining that the second intermediate data is not received for the first time, obtaining the k corresponding to the second intermediate data stored in advance, and decrypting the first intermediate data by the first encryption algorithm based on k and the first initial vector to obtain the target data.
[0046] Through the above steps, since the RSA decryption and KDF derivation processes do not need to be performed again in the case of pre-storing the second intermediate data and the corresponding k, the pre-stored key K is directly used, the calculation overhead is reduced, and the decryption efficiency is improved.
[0047] The present application will be described in detail below with reference to specific embodiments:
[0048] Figure 3 is the flow of the data transmission method according to an embodiment of the present application Figure 2 As shown in Figure 3 , the flow comprises the following steps:
[0049] Step S302, generating a public key exponent e;
[0050] Step S304, two prime numbers p and q are randomly generated, wherein p and q are different, p satisfies gcd(e, (p-1))=1, and p is a private key modulus;
[0051] Step S306, a public key modulus N and a private key exponent d are determined, wherein N=p×q, and d=e -1 mod(p-1);
[0052] Step S308, based on the public key exponent e and the public key modulus N, a public key included in the transmission key is determined, and based on the private key exponent d and the private key modulus p, a private key included in the transmission key is determined.
[0053] In the above steps, the public key is used to encrypt information m by the following formula to obtain ciphertext c, and the private key is used to decrypt ciphertext c by the following formula to obtain information m: c=m e mod N, m=c d mod p.
[0054] In the standard RSA algorithm in the related art, the private key modulus is N, and therefore, when decryption is performed, N needs to be calculated by modulo operation. In the present solution, the generation rule of the transmission key is adjusted, and the calculation of N by modulo operation in the related art is adjusted to the calculation of p by modulo operation, and the lightweight of the RSA algorithm can be realized by trying to reduce the length of p. In addition, the public key modulus in the present solution is still N, and the length of N is the standard length of the public key of the RSA algorithm (for example, RSA-1024bits, RSA-2048bits), and therefore, the present solution can improve the decryption calculation efficiency while ensuring the compatibility of the public key encryption.
[0055] Figure 4 is a flow of a data transmission method according to an embodiment of the present application Figure 3 , Figure 5 is a schematic diagram of a data transmission method according to an embodiment of the present application, as shown in the figure, the flow includes the following steps: Figure 4
[0056] Step S402, after the Internet of Things device A is initialized, the transmission key of the RSA algorithm is automatically generated.
[0057] Step S404, before the management tool end issues the sensitive configuration to the device A, the public key, the length PL of the private key modulus p, and the algorithm type used for encrypting the sensitive configuration are acquired.
[0058] Step S406, the device A returns the public key, pL, and the algorithm type Kdf-RSA-nopadding-AES128-OFB.
[0059] Step S408, the management tool end generates a random number R with length pL, derives a 16-byte symmetric key K from R through the kdf algorithm, uses K to do AES128-OFB symmetric encryption on the sensitive configuration to obtain ciphertext E, uses the public key of device A to do RSA encryption on R to obtain S, and issues S+E to device A.
[0060] Step S410, device A uses the private key p to decrypt S to obtain R, derives a 16-byte symmetric key K from R through the kdf algorithm, and uses K to do AES128-OFB decryption on E to obtain the plaintext sensitive information.
[0061] In the above steps, after device A does RSA decryption on S, it stores S and the corresponding k, in the case that the received S is pre-stored, directly uses k to decrypt to obtain the plaintext sensitive information, and the management tool end updates or regenerates S at a predetermined time.
[0062] In the data transmission method in the above embodiments of the present application, the key generation rule of the RSA algorithm is modified to be lightweight, so that the modified RSA algorithm can be efficiently executed on a single-chip microcomputer device and a low-performance Internet of Things device, without the need for customization and additional external device costs such as additional chips, while ensuring the secure transmission of sensitive information during configuration interaction of the low-performance Internet of Things device and meeting the need for confidentiality in business processes.
[0063] From the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software on a general-purpose hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation. Based on this understanding, the technical solutions of the present application or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes a plurality of instructions for causing a terminal device (which can be a mobile phone, computer, server, or network device) to execute the method described in each embodiment of the present application.
[0064] In this embodiment, a data transmission device is also provided, which is used to implement the above embodiments and preferred embodiments, and has been described above and will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, hardware or a combination of software and hardware is also possible and is contemplated.
[0065] Figure 6 is a structural block diagram of a data transmission device according to an embodiment of the present application, asFigure 6 As shown, the apparatus comprises: a generating module 62 configured to generate a public key and a private key included in a transmission key of an asymmetric encryption RSA algorithm by: randomly generating a public key exponent e, wherein e is an integer; randomly generating a large prime number p and a large prime number q, and taking p as a private key modulus, wherein p is different from q, a first difference value is coprime with e, the first difference value is a difference value between p and a predetermined value; determining a public key modulus N based on p and q, and determining a private key exponent d based on p and e, wherein a first product, which is a product of d and e, is taken modulo the first difference value to obtain the predetermined value; determining the public key based on e and N, and determining the private key based on p and d; and a sending module 64 configured to send an indication message carrying the public key to a target device, wherein the indication message is used to instruct the target device to encrypt target data to be transmitted based on the public key to obtain target encrypted data, and the private key is used to decrypt the target encrypted data received from the target device to obtain the target data.
[0066] In an optional embodiment, the predetermined value is 1.
[0067] In an optional embodiment, the sending module 64 comprises a sending unit configured to send the indication message carrying the public key to the target device triggered by a request message sent by the target device.
[0068] In an optional embodiment, the indication message further comprises a first bit number of p, a first encryption algorithm, a first initial vector of the first encryption algorithm, and a first rule used to indicate a first key K generation method of the first encryption algorithm, wherein the first initial vector and k are both binary numbers of a predetermined bit number, and the predetermined bit number is determined by a mode of the first encryption algorithm; the indication message is used to instruct the target device to encrypt the target data by: the target device generates a random number R with a bit number of the first bit number; the target device derives R by a key derivation function KDF to obtain k according to the first rule; the target device encrypts the target data by the first encryption algorithm based on k and the first initial vector to obtain first intermediate data in a case where a second bit number of the target data is an integer multiple of the predetermined bit number; the target device encrypts R according to the RSA algorithm based on the public key to obtain second intermediate data; and the target device determines the target encrypted data based on the first intermediate data and the second intermediate data.
[0069] In an optional embodiment, the indication message is further used to instruct the target device to perform the following operation: padding the target data so that the second number of bits of the padded target data is an integer multiple of the predetermined number of bits, in a case where the target device determines that the second number of bits of the target data is not an integer multiple of the predetermined number of bits.
[0070] In an optional embodiment, the data transmission apparatus further comprises: a receiving module, configured to receive the target encrypted data sent by the target device, and determine whether the second intermediate data included in the target encrypted data is received for the first time; a first decryption module, configured to, in a case where it is determined that the second intermediate data is received for the first time, decrypt the second intermediate data according to the RSA algorithm based on the private key to obtain R; a derivation module, configured to derive k from R by the kDF based on the first rule to obtain k, and store k and the second intermediate data correspondingly; and a second decryption module, configured to decrypt the first intermediate data included in the target encrypted data by the first encryption algorithm based on k and the first initial vector to obtain the target data.
[0071] In an optional embodiment, the data transmission apparatus further comprises: a receiving module, configured to receive the target encrypted data sent by the target device, and determine whether the second intermediate data included in the target encrypted data is received for the first time; a first decryption module, configured to, in a case where it is determined that the second intermediate data is received for the first time, decrypt the second intermediate data according to the RSA algorithm based on the private key to obtain R; a derivation module, configured to derive k from R by the kDF based on the first rule to obtain k, and store k and the second intermediate data correspondingly; and a second decryption module, configured to decrypt the first intermediate data included in the target encrypted data by the first encryption algorithm based on k and the first initial vector to obtain the target data.
[0072] It should be noted that the above various modules can be implemented by software or hardware, and for the latter, the following implementation manners can be used, but are not limited thereto: the above modules are located in the same processor; or the above various modules are located in different processors in any combination.
[0073] Embodiments of the present application also provide a computer readable storage medium, which stores a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
[0074] In an exemplary embodiment, the above computer readable storage medium can include, but is not limited to: a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.
[0075] Embodiments of the present application also provide an electronic device comprising a memory and a processor, the memory storing a computer program, and the processor being configured to execute the computer program to perform the steps of any of the above method embodiments.
[0076] In an example embodiment, the electronic device can further comprise a transmission device connected to the processor, and an input / output device connected to the processor.
[0077] Embodiments of the present application also provide a computer program product comprising a computer program which, when executed by a processor, implements the steps of any of the above method embodiments.
[0078] The specific examples in the present embodiments can refer to the examples described in the above embodiments and example implementations, which will not be repeated here.
[0079] Obviously, those skilled in the art should understand that the modules or steps of the present application described above can be realized by general computing devices, which can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, which can be realized by program codes executable by computing devices, so that they can be stored in storage devices and executed by computing devices, and in some cases, the steps shown or described can be executed in different order, or they can be manufactured into individual integrated circuit modules, or multiple modules or steps can be manufactured into a single integrated circuit module. Thus, the present application is not limited to any particular combination of hardware and software.
[0080] The above only describes the preferred embodiments of the present application and is not intended to limit the present application. Those skilled in the art can make various modifications and changes to the present application. Any modification, equivalent replacement, improvement, etc. within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A data transmission method, characterized by, The method comprises: generating a public key and a private key included in a transmission key of an asymmetric encryption RSA algorithm by the following manner: randomly generating a public key exponent e, wherein e is an integer; randomly generating a large prime number p and a large prime number q, and taking p as a private key modulus, wherein p is different from q, a first difference value is coprime with e, the first difference value is a difference value between p and a predetermined value; determining a public key modulus N based on p and q, and determining a private key exponent d based on p and e, wherein a first product of d and e is taken modulo the first difference value to obtain the predetermined value; determining the public key based on e and N, and determining the private key based on p and d; sending an indication message carrying the public key to a target device, wherein the indication message is used to instruct the target device to encrypt target data to be transmitted based on the public key to obtain target encrypted data, and the private key is used to decrypt the target encrypted data received from the target device to obtain the target data.
2. The method of claim 1, wherein, The predetermined value is 1.
3. The method of claim 1, wherein, The sending of the indication message carrying the public key to the target device comprises: sending the indication message carrying the public key to the target device under the triggering of a request message sent by the target device.
4. The method of claim 1, wherein, The indication message further comprises a first number of bits of p, a first encryption algorithm, a first initial vector of the first encryption algorithm, and a first rule used to instruct a first key K generation method of the first encryption algorithm, wherein the first initial vector and k are both binary numbers of a predetermined number of bits, and the predetermined number of bits is determined by a mode of the first encryption algorithm. The indication message is used to instruct the target device to encrypt the target data by the following manner: The target device generates a random number R with a number of bits being the first number of bits; The target device derives R by a key derivation function KDF according to the first rule to obtain k; The target device encrypts the target data by the first encryption algorithm based on k and the first initial vector to obtain first intermediate data in a case where a second number of bits of the target data is an integer multiple of the predetermined number of bits; The target device encrypts R according to the RSA algorithm based on the public key to obtain second intermediate data; The target device determines the target encrypted data based on the first intermediate data and the second intermediate data.
5. The method of claim 4, wherein, The indication message is further used to instruct the target device to perform the following operation: In a case where the target device determines that the second number of bits of the target data is not an integer multiple of the predetermined number of bits, the target device pads the target data so that the second number of bits of the padded target data is an integer multiple of the predetermined number of bits.
6. The method of claim 4, wherein, The method further comprises: receiving the target encrypted data sent by the target device, and determining whether the second intermediate data included in the target encrypted data is received for the first time; in a case where it is determined that the second intermediate data is received for the first time, decrypting the second intermediate data according to the RSA algorithm based on the private key to obtain R; deriving R by a kDF to obtain k based on the first rule, and storing k and the second intermediate data correspondingly; decrypting the first intermediate data included in the target encrypted data by the first encryption algorithm based on k and the first initial vector to obtain the target data.
7. The method of claim 6, wherein, After receiving the target encrypted data sent by the target device and determining whether the second intermediate data included in the target encrypted data is received for the first time, the method further comprises: In a case where it is determined that the second intermediate data is not received for the first time, obtaining k corresponding to the second intermediate data stored in advance; decrypting the first intermediate data by the first encryption algorithm based on k and the first initial vector to obtain the target data.
8. A data transmission apparatus, characterized by comprising: Comprise: The generating module is configured to generate a public key and a private key included in a transmission key of an asymmetric encryption RSA algorithm in the following manner: randomly generating a public key exponent e, wherein e is an integer; randomly generating a large prime number p and a large prime number q, and taking p as a private key modulus, wherein p and q are different, a first difference value is coprime with e, the first difference value is a difference between p and a predetermined value; determining a public key modulus N based on p and q, and determining a private key exponent d based on p and e, wherein a first product of d and e is taken modulo the first difference value to obtain the predetermined value; determining the public key based on e and N, and determining the private key based on p and d; The sending module is configured to send an indication message carrying the public key to a target device, wherein the indication message is used to instruct the target device to encrypt target data to be transmitted based on the public key to obtain target encrypted data, and the private key is used to decrypt the target encrypted data received from the target device to obtain the target data.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, wherein the computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 7.
10. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the steps of the method in any one of claims 1 to 7.
11. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 7.
Citation Information
Patent Citations
Implicit certificate key generation method based on SM2 digital signature
CN112367175A
Data processing method, decryption terminal, encryption terminal and storage medium
CN116226874A