Intelligent city-based internet of things device encrypted transmission method and system
By combining RSA asymmetric encryption and symmetric encryption, and using the serial number of IoT devices and the server IP address to generate unique prime numbers, the problem of easy cracking of single encryption algorithms and data leakage caused by shared keys in IoT platforms is solved, realizing independent encryption between devices and high-security data transmission.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU JIUQI TECH CO LTD
- Filing Date
- 2023-03-27
- Publication Date
- 2026-04-17
AI Technical Summary
In existing IoT platforms, single encryption algorithms are easily cracked, the security of the RSA asymmetric encryption algorithm relies on randomly generated prime numbers, and the sharing of a public key pair by multiple devices leads to a high risk of data leakage.
It employs a two-stage encryption technique that combines RSA asymmetric encryption with symmetric encryption. It generates unique prime numbers using the serial number of IoT devices, server IP address, and database UUID, and generates unique RSA public and private key pairs. Then, it performs symmetric encryption based on the device ID and serial number to form two-stage encrypted ciphertext.
It enhances the data security of IoT devices, ensures that each device has an independent key pair, reduces the scale of data breaches, and improves overall security and encryption difficulty.
Smart Images

Figure CN116506158B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Internet of Things (IoT) communication technology, and in particular to an encrypted transmission method and system for IoT devices based on smart cities. Background Technology
[0002] Smart cities refer to a new digital model formed by applying next-generation information technologies such as the Internet of Things (IoT), cloud computing, and big data to urban planning, design, construction, management, and operation. With the increasingly widespread use of IoT, IoT data security is becoming increasingly important, especially for large IoT devices such as edge gateways. These devices are typically used in large factories or base stations, connecting hundreds or thousands of smaller IoT devices and aggregating their data before uploading it to servers or platforms. To ensure secure data transmission, large IoT devices usually encrypt plaintext data before transmission.
[0003] However, current IoT platforms typically employ a single encryption algorithm (such as symmetric encryption or RSA asymmetric encryption) for data encryption. With the continuous improvement of computing power, single-algorithm encryption is easily cracked, posing security risks. Furthermore, for symmetric encryption, the completely symmetrical encryption and decryption process weakens security to some extent. As for RSA asymmetric encryption, existing IoT platforms usually only have one public-key pair, shared by all devices; once cracked, all data from IoT devices within the platform becomes plaintext, posing a very high risk of data leakage. In addition, the principle of RSA asymmetric encryption dictates that its security relies primarily on the random generation of two prime numbers. If the two randomly generated prime numbers are too small, the key length will be insufficient, allowing for cracking, thus introducing inherent security vulnerabilities into the algorithm itself. Summary of the Invention
[0004] In order to overcome the shortcomings of the prior art, the present invention provides an encrypted transmission method and system for IoT devices based on smart cities.
[0005] To achieve the above objectives, the present invention provides an encrypted transmission method for IoT devices based on smart cities, comprising:
[0006] Obtain the unique serial number of an IoT device;
[0007] The function related to the obtained IoT device serial number, server IP address, current timestamp, and universally unique identifier in the current database is executed multiple times to obtain two integer arrays. Multiple bits of each integer array are concatenated to obtain two prime numbers. The product of the two prime numbers is greater than 1024 bits and one of the prime numbers is greater than or equal to twice the other prime number.
[0008] Based on the two prime numbers obtained, the RSA asymmetric encryption algorithm is used to obtain the RSA public key pair and RSA private key pair corresponding to the IoT device, and a unique device ID is assigned to the IoT device.
[0009] After binding and storing the serial number, device ID, public key pair, and private key pair of the IoT device into the database, the device ID and public key pair are returned to the IoT device.
[0010] The device receives data sent by an IoT device, and the data includes encrypted ciphertext and device ID. The ciphertext is a two-segment encrypted ciphertext formed by the IoT device encrypting the first-level ciphertext based on the RSA public key and then performing symmetric encryption based on the device ID and sequence code.
[0011] Verify the device ID and retrieve the serial number and RSA private key pair of the IoT device from the database using the verified device ID; perform symmetric decryption on the received ciphertext based on the device ID and serial number to obtain the first-level ciphertext, and use the RSA private key pair to decrypt the first-level ciphertext to obtain the plaintext.
[0012] According to an embodiment of the present invention, the two prime numbers are both greater than or equal to 513 bits in length and are generated through the following steps:
[0013] Step S21: Perform a hash operation on the obtained unique serial number of the IoT device to obtain a positive integer X associated with the serial number; merge all or part of the data bits in the server's IP address into the timestamp to form a positive integer Y; obtain the current universal unique identifier in the database and perform a hash operation to obtain a positive integer Z;
[0014] Step S22: Execute the function f(X,Y,Z) to obtain one of the single digits in the integer array;
[0015] Step S23: Repeat the above steps at least 513 times to form an integer array with a bit length greater than or equal to 513 bits;
[0016] Step S24: Perform operations on the integer array obtained in step S23. If the first bit is 0, add 1. Concatenate all bits in the integer array after the operation to obtain an integer with a length greater than or equal to 513 bits, and then perform prime number detection to obtain the first prime number Q.
[0017] Step S25: Repeat steps S21 to S23 to generate another integer array with a bit length greater than or equal to 513 bits;
[0018] Step S26: Perform operations on the other integer array obtained in step S25. If its first bit is 0, add 1. Concatenate all bits of the other integer array after the operation to obtain another integer with a length greater than or equal to 513 bits and the first prime number Q is greater than or equal to twice the length of the first prime number. Perform prime number detection on the other integer to obtain the second prime number P.
[0019] According to one embodiment of the present invention, when forming a positive integer Y, the number obtained by taking the remainder of the last bit of the server IP address modulo 10 is appended to the end of the thirteen-bit millisecond-level timestamp to form a fourteen-bit positive integer Y.
[0020] According to one embodiment of the present invention, the function f(X,Y,Z) is a function modulo 10, which is...
[0021] f(x)=[(X / Y)×Z 10 ]mod10.
[0022] According to one embodiment of the present invention, after all bits in the other integer array after the concatenation operation in step S26 are obtained to obtain another integer, it is determined whether the other integer is greater than or equal to twice the first prime number Q that has been generated. If not, the other integer is increased by a factor of more than twice so that the increased other integer is greater than or equal to twice the first prime number Q.
[0023] According to one embodiment of the present invention, the unique serial number of the IoT device is obtained during registration on the IoT platform to generate the corresponding RSA public key pair, RSA private key pair and device ID.
[0024] According to one embodiment of the present invention, when a key update request is received from a registered Internet of Things (IoT) device, the serial number of the IoT device is obtained from the database based on the device ID in the key update request; two prime numbers with a product greater than 1024 bits are regenerated by executing functions related to the IoT device serial number, the server's IP address, the current timestamp, and the universally unique identifier in the current database, wherein one of the prime numbers is greater than or equal to twice the other prime number;
[0025] The RSA public key pair and RSA private key pair corresponding to the IoT device are updated based on the two newly generated prime numbers, and the newly generated RSA public key is sent to the IoT device.
[0026] According to one embodiment of the present invention, when an IoT device performs two-segment encryption on plaintext, the symmetric encryption algorithm used based on the device ID and sequence code is any one of AES, DES, 3DES, and Blowfish.
[0027] On the other hand, this invention also provides an encrypted transmission system for IoT devices based on smart cities, comprising an acquisition module, a prime number generation module, a key generation module, a data transmission module, a data reception module, and a decryption module. The acquisition module acquires the unique serial number of the IoT device. The prime number generation module executes multiple functions related to the acquired IoT device serial number, the server's IP address, the current timestamp, and a universally unique identifier in the current database to obtain two integer arrays. Multiple bits from each integer array are concatenated to obtain two prime numbers, the product of which is greater than 1024 bits, and one prime number is greater than or equal to twice the other. The key generation module uses the RSA asymmetric encryption algorithm based on the two prime numbers to obtain an RSA public key pair and an RSA private key pair corresponding to the IoT device and assigns a unique device ID to the IoT device. The data transmission module binds and stores the IoT device's serial number, device ID, public key pair, and private key pair in the database, and then returns the device ID and public key pair to the IoT device. The data receiving module receives data sent by IoT devices. This data includes encrypted ciphertext and the device ID. The ciphertext is a two-part encrypted ciphertext formed by the IoT device encrypting the data using an RSA public key pair to obtain a first-level ciphertext, and then further encrypting it using the device ID and sequence number. The decryption module verifies the device ID and retrieves the IoT device's sequence number and RSA private key pair from the database using the verified device ID. It then performs symmetric decryption on the received ciphertext using the device ID and sequence number to obtain the first-level ciphertext, and finally decrypts the first-level ciphertext using the RSA private key pair to obtain the plaintext.
[0028] According to an embodiment of the present invention, the prime number generation module generates two prime numbers, both with a length greater than or equal to 513 bits, through the following steps:
[0029] Step S21: Perform a hash operation on the obtained unique serial number of the IoT device to obtain a positive integer X associated with the serial number; merge all or part of the data bits in the server's IP address into the timestamp to form a positive integer Y; obtain the current universal unique identifier in the database and perform a hash operation to obtain a positive integer Z;
[0030] Step S22: Execute the function f(X,Y,Z) to obtain one of the single digits in the integer array;
[0031] Step S23: Repeat the above steps at least 513 times to form an integer array with a bit length greater than or equal to 513 bits;
[0032] Step S24: Perform operations on the integer array obtained in step S23. If the first bit is 0, add 1. Concatenate all bits in the integer array after the operation to obtain an integer with a length greater than or equal to 513 bits, and then perform prime number detection to obtain the first prime number Q.
[0033] Step S25: Repeat steps S21 to S23 to generate another integer array with a bit length greater than or equal to 513 bits;
[0034] Step S26: Perform operations on the other integer array obtained in step S25. If its first bit is 0, add 1. Concatenate all bits of the other integer array after the operation to obtain another integer with a length greater than or equal to 513 bits and the first prime number Q is greater than or equal to twice the length of the first prime number. Perform prime number detection on the other integer to obtain the second prime number P.
[0035] In summary, the IoT device encryption transmission method for smart cities provided by this invention employs a two-stage encryption technique that combines RSA asymmetric encryption and symmetric encryption to enhance data security. Simultaneously, the RSA asymmetric encryption algorithm is optimized by combining the IoT device serial number and server IP address (physical parameters of the communication device) with a unique current timestamp and a universally unique identifier within the current database to generate each bit of an integer array. This ensures the randomness and uniqueness of the two prime numbers generated from the integer array in terms of both timing and the physical nature of the communication device. Furthermore, the precise control of the number of bits and size of the two randomly generated prime numbers ensures that the encrypted RSA private key pair has sufficient length, thereby enhancing the security of RSA encryption. In addition, the prime number generation method based on the IoT device serial number ensures that each device within the IoT platform has an independent public and private key pair. The secondary symmetric encryption based on the device ID and serial number further enhances the independence of key locations among the IoT devices, effectively avoiding the serious security risks associated with multiple devices sharing keys in existing IoT platforms.
[0036] To make the above and other objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0037] Figure 1 The diagram shown is a flowchart illustrating an encrypted transmission method for IoT devices based on a smart city, according to an embodiment of the present invention.
[0038] Figure 2 As shown Figure 1 A schematic diagram illustrating the process of generating RSA private and public key pairs.
[0039] Figure 3 As shown Figure 2 A flowchart of step S21.
[0040] Figure 4 The diagram shown is a schematic diagram of an IoT device encrypted transmission system based on a smart city according to an embodiment of the present invention. Detailed Implementation
[0041] The RSA algorithm is the most widely used asymmetric encryption algorithm today, and its principle is as follows:
[0042] Prepare two prime numbers P and Q;
[0043] [1] Calculate N: N = P * Q;
[0044] [2] Calculate L: Calculate the least common multiple L of (P - 1) and (Q - 1);
[0045] [3] Calculate E: E must satisfy two conditions simultaneously, 1 < E < L and E and L are relatively prime;
[0046] [4] Calculate D: D is calculated from E, 1 < D < L and E * D mod L = 1;
[0047] From this, we can obtain:
[0048] Public key pair: (E, N)
[0049] Private key pair: (D, N)
[0050] Assume the plaintext is A and the ciphertext is B; then applying the RSA asymmetric encryption algorithm, the encryption process is to take the remainder of the E - th power of the plaintext A with respect to N, and its formula is expressed as: B ≡ A E (mod N); the decryption process is to take the remainder of the D - th power of the ciphertext B with respect to N, and its formula is expressed as: A ≡ B D (mod N).
[0051] From the above principle of the RSA asymmetric encryption algorithm, the security advantage of this algorithm lies in that it is extremely difficult and time - consuming to find the two factors of a large number N. Therefore, when randomly generating two prime numbers P and Q, in addition to ensuring the randomness of the data, the sizes of P and Q also need to be considered. If the two randomly generated prime numbers P and Q are too small and too close, it will result in a short key length and be cracked. With the continuous improvement of computer computing power, there is a possibility that the traditional RSA asymmetric encryption algorithm will be attacked, and since all devices in the existing Internet of Things platforms share a set of public - private key pairs, once cracked, it may lead to the leakage of all data on all devices in the platform.
[0052] In view of this, this embodiment provides an encrypted transmission method for IoT devices based on smart cities, which includes: obtaining the unique serial number of the IoT device (step S10). Multiple executions of functions related to the obtained IoT device serial number, the server's IP address, the current timestamp, and a universally unique identifier in the current database are performed to obtain two integer arrays. Multiple bits of each integer array are concatenated to obtain two prime numbers, the product of which is greater than 1024 bits and one prime number is greater than or equal to twice the other prime number (step S20). Based on the two prime numbers, an RSA asymmetric encryption algorithm is used to obtain an RSA public key pair and an RSA private key pair corresponding to the IoT device, and a unique device ID is assigned to the IoT device (step S30). After binding and storing the IoT device's serial number, device ID, public key pair, and private key pair in the database, the device ID and public key pair are returned to the IoT device (step S40). The system receives data sent by an IoT device, including encrypted ciphertext and a device ID. The ciphertext is a two-part encrypted ciphertext formed by the IoT device encrypting the data using an RSA public key pair to obtain a first-level ciphertext, and then further encrypting it using the device ID and sequence code (step S50). The system verifies the device ID and retrieves the IoT device's sequence code and RSA private key pair from the database using the verified device ID. The system then performs symmetric decryption on the received ciphertext using the device ID and sequence code to obtain a first-level ciphertext, and finally decrypts the first-level ciphertext using the RSA private key pair to obtain the plaintext (step S60).
[0053] The following will combine Figure 1 and Figure 2 This embodiment will provide a detailed explanation of the specific principles behind the encrypted transmission method for IoT devices based on smart cities.
[0054] When an IoT device registers on the platform, it carries its unique serial number (SN). The server retrieves the SN from the device's registration information (step S10). This embodiment uses the initial access of a device to the IoT platform as an example to illustrate the method of obtaining the unique serial number (SN). However, this invention does not limit this in any way. In other embodiments, when updating the key based on an update request from a registered IoT device, the unique serial number (SN) of the IoT device can be found in the database using the device ID carried in the update request. Alternatively, during periodic key updates, the unique serial number (SN) of the corresponding IoT device can be found in the database based on the association between the update timer and the device ID.
[0055] After obtaining the unique serial number (SN) of the IoT device, step S20 is executed to generate prime numbers. As mentioned earlier, the RSA asymmetric encryption algorithm heavily relies on the difference between two prime numbers and the large number N formed by multiplying them. To ensure encryption security, step S20 generates an intermediate integer array to obtain two prime numbers with a product greater than 1024 bits, ensuring that one prime number is greater than or equal to twice the other. In this embodiment, each bit in the integer array used to generate the two prime numbers is obtained by executing functions related to the IoT device serial number (SN), the server's IP address, the current timestamp, and the universally unique identifier (UUID) in the current database.
[0056] The IoT device serial number (SN) is a physical parameter on the device side, and the server's IP address is a physical parameter on the platform side. Both serve as parameters for generating an integer array. While establishing the association between the IoT device and the RSA key, the uniqueness of the serial number (SN) also ensures the randomness and uniqueness of the two prime numbers generated from the integer array from the device's physical properties. The timestamp and the database-wide universally unique identifier (UUID) guarantee the uniqueness and randomness of the two prime numbers in terms of timing. Therefore, in the IoT device encrypted transmission method for smart cities provided in this embodiment, step S20, which uses prime number generation based on device physical parameters and timing parameters, not only achieves independent association between the device and the key but also significantly improves encryption security, ensuring secure data transmission.
[0057] In this embodiment, both prime numbers are 513 bits each, and their product has 1026 or 1025 bits, satisfying the requirement of being greater than or equal to 1024 bits. This setting allows the two prime numbers to be generated using the same steps, simplifying computational resources and code size. However, this invention does not impose any limitations on this. In other embodiments, two prime numbers generated that satisfy the condition that the product of the two prime numbers has more than 1024 bits and one prime number is more than twice the size of the other prime number are all within the scope of protection of this invention.
[0058] Figure 2 The diagram shows the process of generating two prime numbers.
[0059] Step S21: Perform data conversion processing on the IoT device's unique serial number, the server's IP address, timestamp, and the database's current universally unique identifier (UUID). Specifically:
[0060] Step S221: Perform a hash operation on the obtained unique serial number SN of the IoT device to obtain a positive integer X associated with the serial number;
[0061] Step S222: Merge all or part of the data bits in the server's IP address into the timestamp to form a positive integer Y. Specifically, take the last bit of the server's IP address modulo 10 and append it to the end of the thirteen-bit millisecond-level timestamp to form a fourteen-bit positive integer Y. However, this invention does not limit this. In other embodiments, a portion of the IP address may be randomly or fixedly truncated and concatenated to the time-unique current timestamp to form an integer.
[0062] Step S223: Obtain the current universally unique identifier (UUID) of the database and perform a hash operation to obtain a positive integer Z. Although this embodiment uses the fusion of the server's IP address and timestamp to form a positive integer Y as an example, the present invention does not limit this. In other embodiments, the unique serial number of the IoT device or the current universally unique identifier (UUID) of the database can also be fused with a timestamp to form one of the positive integers; while the other two are hashed to form two other positive integers.
[0063] After step S21, the data is converted into three positive integers X, Y, and Z. Then, step S22 is executed, where the three converted positive integers are input into the function f(X,Y,Z)=[(X / Y)×Z]. 10 Modulo 10 yields a single-digit number from 0 to 9. However, this invention does not limit the function form formed by X, Y, and Z. In other embodiments, the function f(X,Y,Z) can also be obtained by performing a modulo operation on other numbers after using an expression (such as a polynomial) based on the three parameters X, Y, and Z to obtain a single-digit number in the integer array.
[0064] In this embodiment, both prime numbers are 513 bits. The operation in step S21 is iterated 513 times, and an integer array with a length greater than or equal to 513 bits is formed according to the data generation order (step S23). To ensure that the number of bits in the prime number obtained after the operation based on the integer array meets the requirements, step S24 is executed: the integer array obtained in step S23 is operated on; if its first bit is 0, it is padded with 1; all bits in the concatenated integer array are joined to obtain an integer Q1 with a length greater than or equal to 513 bits, and then processed by a prime number detection method to obtain the first prime number Q. Specifically, a prime number detection method is used to determine whether the integer Q1 obtained by concatenating all bits in the integer array is a prime number. The prime number detection method can be any one of the following: prime number sieve, enumeration factor, or Miller-Rabin algorithm. If the detection result indicates that the concatenated integer Q1 is a prime number, then the integer Q1 formed by concatenating the integer array is directly assigned to the first prime number Q = Q1 in the RSA asymmetric encryption algorithm. If the judgment result indicates that the concatenated integer Q1 is not a prime number, then the integer Q1 is incremented by Q1 = Q1 + 1 and the prime number detection method is continued to judge the incremented integer Q1 until the incremented integer Q1 becomes a prime number, and then it is assigned to one of the prime numbers Q in the RSA asymmetric encryption algorithm.
[0065] After step S24, the first 513-bit prime number Q in the RSA asymmetric encryption algorithm is obtained. In this embodiment, since the other prime number is also 513 bits, based on the temporal uniqueness of the timestamp and the current universally unique identifier UUID in the database, steps S21 to S23 are repeated to generate another integer array (step S25). Similarly, to ensure the number of bits in the integer array formed by concatenating the integer arrays, step S26 will operate on the other integer array obtained in step S25; specifically, if its first bit is 0, it will be padded with 1. Then, all bits of the other integer array after the concatenation operation are concatenated to obtain another integer P1 with a length greater than or equal to 513 bits, ensuring that this other integer P1 is greater than or equal to twice the first prime number Q. The other integer P1 obtained by directly concatenating the other integer arrays generated by the loop steps S21 to S23 does not necessarily satisfy P1≥2Q. If it does not satisfy, a multiplication operation (such as P1=2*P1) can be used to increase the other integer P1 to make it satisfy P1≥2Q. However, the present invention does not impose any limitations on this. After satisfying another integer P1≥2Q, the other integer P1 is processed by the prime number detection method to obtain the second prime number P. The steps of the prime number detection method are the same as those of the first prime number Q, and will not be repeated here.
[0066] After calculating two unique, random prime numbers P and Q, each with 513 bits, based on the IoT device serial number (SN), the server's IP address, the current timestamp, and the universally unique identifier (UUID) in the current database, step S30 is executed. The two parameters are then input into the RSA asymmetric encryption algorithm to obtain the RSA public key pair and RSA private key pair corresponding to the IoT device, and a unique device ID is assigned to the IoT device.
[0067] By using a prime number generation method for IoT device serial numbers (SNs), the uniqueness of prime numbers is guaranteed, and a unique association between the device and the key is also achieved. This ensures that each device within the IoT communicates with the platform through its own unique RSA key. During communication, even if the key of one IoT device is attacked and cracked, data from other IoT devices can still be transmitted securely, greatly reducing the scale of data leakage and improving the overall security of the IoT.
[0068] After generating the RSA key, the server binds and stores the IoT device's serial number, device ID, public key pair, and private key pair in the database, and returns the device ID and public key pair to the IoT device (step S40). Based on the returned public key, the IoT device encrypts the message using the RSA public key when sending it, forming a first ciphertext M. To improve data security, a symmetric encryption algorithm is used to encrypt the first ciphertext M again on top of the RSA asymmetric encryption to form a two-part encrypted ciphertext N. During communication, even if the data is intercepted, the interceptor will only receive the ciphertext N formed by the combination of RSA asymmetric encryption and symmetric encryption, significantly increasing the difficulty of cracking it. Furthermore, in this embodiment, the symmetric encryption is based on the IoT device's device ID and serial number; the uniqueness and randomness of the device ID and serial number further increase the difficulty of cracking the symmetric encryption algorithm. At the same time, this setting also realizes the corresponding association between the symmetric encryption key and the IoT device, with each IoT device using an independent symmetric encryption key to encrypt the first ciphertext M formed after RSA asymmetric encryption.
[0069] In this embodiment, the symmetric encryption algorithm is AES. However, this invention does not limit it in any way. In other embodiments, any of DES, 3DES, and Blowfish may be used based on the device ID and serial number.
[0070] The IoT device sends two encrypted ciphertexts N and its device ID to the platform, which receives the corresponding data (step S50). Then, step S60 is executed, extracting the device ID from the received data and verifying it against the device IDs of IoT devices stored in the database. If the verification passes, the platform retrieves the IoT device's serial number SN and RSA private key pair from the database based on the device ID. The received ciphertext N is then decrypted using AES symmetric encryption based on the device ID and serial number SN to obtain the first-level ciphertext M. Finally, the first-level ciphertext M is decrypted using the RSA private key pair to obtain the plaintext.
[0071] In the encrypted transmission method for IoT devices based on smart cities, three positive integers X, Y, and Z are used to generate two prime numbers P and Q. X is a unique parameter related to the unique serial number (SN) of the IoT device; Y is the product of a unique timestamp and the server's IP address to ensure uniqueness; and Z is related to the universally unique identifier (UUID) in the current database. The combination of these three ensures the randomness and uniqueness of the two prime numbers P and Q, guaranteeing data transmission security. Furthermore, the product N of the two prime numbers is greater than 1024 bits, and P >= 2Q, ensuring a sufficiently long key and increasing the difficulty of cracking. In addition, the prime number generation method based on the device serial number (SN) also equips each IoT device with its own unique public and private key pairs to enhance security. The two-stage encryption formed by the fusion of RSA asymmetric encryption and AES symmetric encryption further optimizes data security.
[0072] In this embodiment, the RSA private key pair and RSA public key pair are generated when the IoT device registers on the platform, and the generated RSA private key pair is stored in the platform's database. To improve the security of key management, a key update timer is started when the RSA public key pair and RSA private key pair corresponding to the IoT device are generated. Based on the triggering of the key timer, the RSA public key pair and RSA private key pair associated with the serial number (SN) of each IoT device in the database are updated periodically, and the updated RSA public key pair is sent to the IoT device. Periodic key updates can effectively avoid security risks caused by key leakage on the platform side. However, this invention does not limit this in any way. In other embodiments, the server can also update the RSA private key pair and public key pair based on the key update request sent by the IoT device. Specifically, when a key update request is received from a registered IoT device, the serial number (SN) of the IoT device is retrieved from the database based on the device ID in the key update request. Two new RSA public key pairs are generated by executing functions related to the IoT device serial number, the server's IP address, the current timestamp, and a universally unique identifier in the current database. One of these new prime numbers must be greater than or equal to twice the value of the other. Based on the two newly generated prime numbers, the RSA public key pair and RSA private key pair corresponding to the IoT device are updated, and the RSA public key pair is sent to the IoT device.
[0073] In this embodiment, when generating two prime numbers in step S20, the distributed computing engine distributes the computation task across multiple worker nodes for distributed computation, thereby improving the prime number generation rate. Furthermore, when the platform collects a large amount of data from IoT devices, it employs an asynchronous data decryption mechanism. After receiving the ciphertext, the server sends a message queue, allowing downstream computing services (worker nodes) to asynchronously decrypt it before storing it in the database. Asynchronous decryption by the computing services significantly improves data processing on the platform side, effectively reducing the computational demands of the algorithm on the platform's servers.
[0074] Correspondingly, this embodiment provides an encrypted transmission system for IoT devices based on a smart city, comprising an acquisition module 10, a prime number generation module 20, a key generation module 30, a data transmission module 40, a data reception module 50, and a decryption module 60. The acquisition module 10 acquires the unique serial number of the IoT device. The prime number generation module 20 executes multiple functions related to the acquired IoT device serial number, the server's IP address, the current timestamp, and a universally unique identifier in the current database to obtain two integer arrays. Multiple bits from each integer array are concatenated to obtain two prime numbers, the product of which is greater than 1024 bits, and one prime number is greater than or equal to twice the other. The key generation module 30 uses the RSA asymmetric encryption algorithm based on the two prime numbers to obtain an RSA public key pair and an RSA private key pair corresponding to the IoT device and assigns a unique device ID to the IoT device. The data transmission module 40 binds and stores the IoT device's serial number, device ID, public key pair, and private key pair in the database, and then returns the device ID and public key pair to the IoT device. The data receiving module 50 receives data sent by the IoT device, which includes encrypted ciphertext and the device ID. The ciphertext is a two-part encrypted ciphertext formed by the IoT device encrypting the data using an RSA public key pair to obtain a first-level ciphertext, and then further encrypting it using the device ID and sequence code. The decryption module 60 verifies the device ID and retrieves the IoT device's sequence code and RSA private key pair from the database using the verified device ID; it then performs symmetric decryption on the received ciphertext using the device ID and sequence code to obtain a first-level ciphertext, and finally decrypts the first-level ciphertext using the RSA private key pair to obtain the plaintext.
[0075] Specifically, the prime number generation module 20 generates two prime numbers, both with a length greater than or equal to 513 bits, through the following steps:
[0076] Step S21: Perform a hash operation on the obtained unique serial number of the IoT device to obtain a positive integer X associated with the serial number; merge all or part of the data bits in the server's IP address into the timestamp to form a positive integer Y; obtain the current universal unique identifier in the database and perform a hash operation to obtain a positive integer Z;
[0077] Step S22: Execute the function f(X,Y,Z) to obtain one of the single digits in the integer array;
[0078] Step S23: Repeat the above steps at least 513 times to form an integer array with a bit length greater than or equal to 513 bits;
[0079] Step S24: Perform operations on the integer array obtained in step S23. If the first bit is 0, add 1. Concatenate all bits in the integer array after the operation to obtain an integer with a length greater than or equal to 513 bits, and then perform prime number detection to obtain the first prime number Q.
[0080] Step S25: Repeat steps S21 to S23 to generate another integer array with a bit length greater than or equal to 513 bits;
[0081] Step S26: Perform operations on the other integer array obtained in step S25. If its first bit is 0, pad it with 1. Concatenate all bits of the other integer array after the operation to obtain another integer with a length greater than or equal to 513 bits, and this other integer is greater than or equal to twice the first prime number Q. Perform prime number detection processing on the other integer to obtain the second prime number P. Since the functions of the IoT device encrypted transmission system based on smart cities have been described in detail in their corresponding method steps S10 to S60, they will not be repeated here. The various modules in the IoT device encrypted transmission system based on smart cities can be implemented in whole or in part through software, hardware, or a combination thereof. The above modules can be embedded in the processor of the computer device in hardware form or independent of the processor, or they can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0082] In summary, the IoT device encryption transmission method for smart cities provided by this invention employs a two-stage encryption technique that combines RSA asymmetric encryption and symmetric encryption to enhance data security. Simultaneously, the RSA asymmetric encryption algorithm is optimized by combining the IoT device serial number and server IP address (physical parameters of the communication device) with a unique current timestamp and a universally unique identifier within the current database to generate each bit of an integer array. This ensures the randomness and uniqueness of the two prime numbers generated from the integer array in terms of both timing and the physical nature of the communication device. Furthermore, the precise control of the number of bits and size of the two randomly generated prime numbers ensures that the encrypted RSA private key pair has sufficient length, thereby enhancing the security of RSA encryption. In addition, the prime number generation method based on the IoT device serial number ensures that each device within the IoT platform has an independent public and private key pair. The secondary symmetric encryption based on the device ID and serial number further enhances the independence of key locations among the IoT devices, effectively avoiding the serious security risks associated with multiple devices sharing keys in existing IoT platforms.
[0083] Although the present invention has been disclosed above by way of preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art may make some modifications and refinements without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be determined by the scope of protection claimed in the claims.
Claims
1. A method for encrypted transmission of IoT devices based on smart cities, characterized in that, include: Obtain the unique serial number of an IoT device; The function related to the obtained IoT device serial number, server IP address, current timestamp, and universally unique identifier in the current database is executed multiple times to obtain two integer arrays. Multiple bits of each integer array are concatenated to obtain two prime numbers. The product of the two prime numbers is greater than 1024 bits and one of the prime numbers is greater than or equal to twice the other prime number. Based on the two prime numbers obtained, the RSA asymmetric encryption algorithm is used to obtain the RSA public key pair and RSA private key pair corresponding to the IoT device, and a unique device ID is assigned to the IoT device. After binding and storing the serial number, device ID, public key pair, and private key pair of the IoT device into the database, the device ID and public key pair are returned to the IoT device. The device receives data sent by an IoT device, and the data includes encrypted ciphertext and device ID. The ciphertext is a two-segment encrypted ciphertext formed by the IoT device encrypting the first-level ciphertext based on the RSA public key and then performing symmetric encryption based on the device ID and sequence code. Verify the device ID and retrieve the serial number and RSA private key pair of the IoT device from the database using the verified device ID; perform symmetric decryption on the received ciphertext based on the device ID and serial number to obtain the first-level ciphertext, and use the RSA private key pair to decrypt the first-level ciphertext to obtain the plaintext.
2. The encrypted transmission method for IoT devices based on smart cities according to claim 1, characterized in that, Both prime numbers are greater than or equal to 513 bits in length and are generated through the following steps: Step S21: Perform a hash operation on the obtained unique serial number of the IoT device to obtain a positive integer X associated with the serial number; merge all or part of the data bits in the server's IP address into the timestamp to form a positive integer Y; obtain the current universal unique identifier in the database and perform a hash operation to obtain a positive integer Z; Step S22: Execute the function f(X,Y,Z) to obtain one of the single digits in the integer array; Step S23: Repeat the above steps at least 513 times to form an integer array with a bit length greater than or equal to 513 bits; Step S24: Perform operations on the integer array obtained in step S23. If the first bit is 0, add 1. Concatenate all bits in the integer array after the operation to obtain an integer with a length greater than or equal to 513 bits, and then perform prime number detection to obtain the first prime number Q. Step S25: Repeat steps S21 to S23 to generate another integer array with a bit length greater than or equal to 513 bits; Step S26: Perform operations on the other integer array obtained in step S25. If its first bit is 0, add 1. Concatenate all bits of the other integer array after the operation to obtain another integer with a length greater than or equal to 513 bits and the first prime number Q is greater than or equal to twice the length of the first prime number. Perform prime number detection on the other integer to obtain the second prime number P. 3.The smart city based Internet of Things device encrypted transmission method of claim 2, wherein, When forming a positive integer Y, the last bit of the server IP address is modulo 10, and the resulting number is appended to the end of the thirteen-digit millisecond-level timestamp to form a fourteen-digit positive integer Y. 4.The smart city based Internet of Things device encrypted transmission method of claim 2, wherein, The function f(X, Y, Z) is a function that takes modulo 10, which is f(X, Y, Z) = [(X / Y) x Z 10 ] mod 10. 5.The smart city based Internet of Things device encrypted transmission method of claim 2, wherein, After concatenating all bits in the other integer array in step S26 to obtain another integer, determine whether the other integer is greater than or equal to twice the first prime number Q that has been generated; if not, increase the other integer by a factor of more than twice so that the increased other integer is greater than or equal to twice the first prime number Q. 6.The smart city based Internet of Things device encrypted transmission method of claim 1, wherein, When registering on the IoT platform, obtain the unique serial number of the IoT device to generate the corresponding RSA public key pair, RSA private key pair, and device ID.
7. The encrypted transmission method for IoT devices based on smart cities according to claim 1, characterized in that: When a key update request is received from a registered IoT device, the serial number of the IoT device is retrieved from the database based on the device ID in the key update request. Two prime numbers with a product greater than 1024 bits are regenerated by executing functions related to the IoT device serial number, the server's IP address, the current timestamp, and the universally unique identifier in the current database, with one prime number being greater than or equal to twice the other prime number. The RSA public key pair and RSA private key pair corresponding to the IoT device are updated based on the two newly generated prime numbers, and the newly generated RSA public key is sent to the IoT device. 8.The smart city based Internet of Things device encrypted transmission method of claim 1, wherein, When IoT devices perform two-part encryption on plaintext, the symmetric encryption algorithm used based on the device ID and sequence code is any one of AES, DES, 3DES, and Blowfish.
9. A smart city-based Internet of Things device encrypted transmission system, characterized in that, include: The module retrieves the unique serial number of the IoT device. The prime number generation module executes functions multiple times related to the acquired IoT device serial number, server IP address, current timestamp, and universally unique identifier in the current database to obtain two integer arrays. Multiple bits of each integer array are concatenated to obtain two prime numbers. The product of the two prime numbers is greater than 1024 bits, and one of the prime numbers is greater than or equal to twice the other prime number. The key generation module uses the RSA asymmetric encryption algorithm based on the two prime numbers to obtain the RSA public key pair and RSA private key pair corresponding to the IoT device and assigns a unique device ID to the IoT device. The data transmission module binds and stores the serial number, device ID, public key pair, and private key pair of the IoT device into the database, and then returns the device ID and public key pair to the IoT device. The data receiving module receives data sent by IoT devices, and the data includes encrypted ciphertext and device ID. The ciphertext is a two-segment encrypted ciphertext formed by the IoT device encrypting the first-level ciphertext based on the RSA public key and then symmetrically encrypting it based on the device ID and sequence code. The decryption module verifies the device ID and retrieves the serial number and RSA private key pair of the IoT device from the database using the verified device ID. Based on the device ID and serial number, it performs symmetric decryption on the received ciphertext to obtain the first-level ciphertext, and then uses the RSA private key pair to decrypt the first-level ciphertext to obtain the plaintext.
10. The IoT device encrypted transmission system based on smart cities according to claim 9, characterized in that, The prime number generation module generates two prime numbers, each with a length greater than or equal to 513 bits, through the following steps: Step S21: Perform a hash operation on the obtained unique serial number of the IoT device to obtain a positive integer X associated with the serial number; merge all or part of the data bits in the server's IP address into the timestamp to form a positive integer Y; obtain the current universal unique identifier in the database and perform a hash operation to obtain a positive integer Z; Step S22: Execute the function f(X,Y,Z) to obtain one of the single digits in the integer array; Step S23: Repeat the above steps at least 513 times to form an integer array with a bit length greater than or equal to 513 bits; Step S24: Perform operations on the integer array obtained in step S23. If the first bit is 0, add 1. Concatenate all bits in the integer array after the operation to obtain an integer with a length greater than or equal to 513 bits, and then perform prime number detection to obtain the first prime number Q. Step S25: Repeat steps S21 to S23 to generate another integer array with a bit length greater than or equal to 513 bits; Step S26: Perform operations on the other integer array obtained in step S25. If its first bit is 0, add 1. Concatenate all bits of the other integer array after the operation to obtain another integer with a length greater than or equal to 513 bits and the first prime number Q is greater than or equal to twice the length of the first prime number. Perform prime number detection on the other integer to obtain the second prime number P.
Citation Information
Patent Citations
Internet-of-things data encryption transmission method and system, server and client
CN114844720A
Data security transmission method based on RSA encryption
CN115174085A