Key generation method and device, electronic equipment and storage medium
By generating and storing encrypted key data on the cloud server, combined with user identification and cloud application information, the security and migration issues of key storage in cloud applications are solved, and differences in hardware and software versions are shielded, achieving Security and suitability of keys.
Patent Information
- Application Number
- CN202411007791.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-25
- Publication Date
- 2024-08-30
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In cloud applications, there are security and migration issues when keys are stored on cloud application instances, and due to differences in hardware and software versions, it is difficult for existing technologies to provide suitable key generation and storage solutions.
When generating a key on the cloud server, the encryption algorithm and password are used to encrypt data such as the user ID, and the encrypted data is saved locally and on the storage server, and combined with the user ID and cloud application information to ensure that the key uniqueness and security, and uses encryption algorithms that support all hardware and Android versions to mask differences in hardware and software versions.
It realizes the secure storage and migration of keys with users, ensuring the uniqueness and security of keys. It also shields the differences between hardware and software versions and provides a key generation and storage solution suitable for cloud applications.
Smart Images

Figure CN118573371A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud applications, and in particular to a key generation method and device, an electronic device and a storage medium. Background Art
[0002] In the Android platform, the storage module for the application key library is called keystore. Keystore is to store the key used by a keyword key of a certain application securely. When the application uses the key of a keyword key for data encryption and decryption, it only needs to tell the keystore that it needs to use the keyword key for data encryption and decryption, and does not need to care about the storage location of the key of the keyword key. For general Android phones, the key is stored in the encryption chip. However, since the instances of cloud applications are shared, for the same cloud application, the cloud application platform is likely to allocate different instances to the same user each time. This leads to security issues and the key cannot be migrated with the user if the key of the cloud application is stored in the currently running instance of the cloud application. In addition, the keystore module is a security module. The Android platform will often optimize it, and there will be major changes every few major versions. At the same time, there are often multiple hardware platforms on the cloud application platform. The hardware and Android versions used by different hardware platforms are often different. In order to reduce the dependence on platform evolution, a corresponding solution is also needed to shield the differences in hardware and software versions.
[0003] In view of this, how to provide a key generation and storage solution suitable for cloud applications and shield the differences in hardware and software versions has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] In order to solve the technical problems existing in the prior art, the embodiments of the present application provide a key generation method and device, an electronic device and a storage medium.
[0005] In a first aspect, an embodiment of the present application provides a key generation method, which is applied to a cloud server, comprising: When the cloud application requires to generate a key for the keyword key, an encryption algorithm and a password are determined, and the specified data is encrypted using the encryption algorithm and the password to obtain encrypted data, wherein the specified data is the key for the keyword key, and the specified data includes a user identifier of a user using the cloud application; The user identification, the information of the cloud application, the information of the encryption algorithm, the information of the password and the encrypted data are combined, and the combined data is saved locally and in a storage server.
[0006] In a second aspect, an embodiment of the present application further provides a key generation device, which is applied to a cloud server, including: an encryption unit, used to determine an encryption algorithm and a password when the cloud application requires generation of a key for the keyword key, and to encrypt designated data using the encryption algorithm and the password to obtain encrypted data, wherein the designated data is the key for the keyword key, and the designated data includes a user identifier of a user using the cloud application; The storage unit is used to combine the user identification, the information of the cloud application, the information of the encryption algorithm, the information of the password and the encrypted data, and save the combined data locally and in a storage server.
[0007] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the key generation method described in the first aspect are executed.
[0008] In a fourth aspect, an embodiment of the present application further provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to perform the steps of the key generation method as described in the first aspect.
[0009] In summary, the key generation method and device, electronic device and storage medium provided in the embodiments of the present application add the concept of user identification. The user identification is different from the identification of the application in Android. It is a unique identification for each user. Since the combined data containing the encrypted key also contains the user identification and the information containing the cloud application, it is possible to distinguish the keys corresponding to the cloud applications used by different users. At the same time, since the keys are stored locally and in the storage server, and the cloud server will be released after the user finishes using the cloud application, this can ensure that the keys are destroyed after use and will not be used by other applications. They can also be reused by downloading them from the storage server, which can ensure the security of the keys and enable the keys to be migrated with the users. In addition, the differences in hardware and software versions can be shielded by using an encryption algorithm supported by the hardware and Android versions of all cloud application platforms. In summary, this solution can provide a key generation and storage solution suitable for cloud applications, and can shield the differences in hardware and software versions. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Figure 1 A schematic diagram of a process flow of an embodiment of a key generation method provided in an embodiment of the present application; Figure 2A schematic diagram of the structure of an embodiment of a key generation device provided in an embodiment of the present application; Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0011] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0012] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0013] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
[0014] Reference Figure 1 FIG. 1 is a flow chart of a key generation method provided in an embodiment of the present application. The key generation method is applied to a cloud server and includes: S10. When the cloud application requires to generate a key for the keyword key, determine an encryption algorithm and a password, and use the encryption algorithm and the password to encrypt the specified data to obtain encrypted data, wherein the specified data is the key for the keyword key, and the specified data includes a user identifier of a user who uses the cloud application; In this embodiment, it should be noted that when determining the encryption algorithm and the password, an encryption algorithm can be selected from multiple encryption algorithms, and a password can be selected from the password group corresponding to the selected encryption algorithm. The encryption algorithm can be a symmetric encryption algorithm or an asymmetric encryption algorithm, and the password group can contain at least one password. It should be noted that if the selected encryption algorithm is an asymmetric encryption algorithm, there are two password groups corresponding to the asymmetric encryption algorithm, one of which is a public key password group and the other is a private key password group. At this time, selecting a password from the password group corresponding to the selected encryption algorithm refers to selecting a password from the private key password group. In addition to the user ID of the user, the specified data can also include at least one of the current system time and at least one hardware serial number, wherein the hardware serial number can include the WIFI mac (Media Access Control, media access control) address, SN (Serial No., device serial number), IMEI (International Mobile Equipment Identity, International Mobile Equipment Identity Code), etc. The execution subject of steps S10 and S11 can be the system of the cloud server. Specifically, the system can call the corresponding interface to perform specific processing through the keystore.
[0015] S11. Combine the user identification, the cloud application information, the encryption algorithm information, the password information and the encrypted data, and save the combined data locally and in a storage server.
[0016] In this embodiment, it should be noted that the combined data may also include the length of the encrypted data, then, combining the user identification, the cloud application information, the encryption algorithm information, the password information and the encrypted data may include: combining the user identification, the cloud application information, the encryption algorithm information, the password information, the length of the encrypted data and the encrypted data. After the user finishes using the cloud application this time, the combined data saved locally will be destroyed. When the user uses the same cloud application next time, the combined data that the user previously saved using the same cloud application can be downloaded from the storage server and saved locally during the process of restoring the user archive.
[0017] The key generation method provided in the embodiment of the present application adds the concept of user identification. The user identification is different from the identification of the application in Android. It is a unique identification for each user. Since the combined data including the encrypted key also includes the user identification and the information including the cloud application, it is possible to distinguish the keys corresponding to the cloud applications used by different users. At the same time, since the keys are stored locally and in the storage server, and the cloud server will be released after the user finishes using the cloud application, this can ensure that the keys are destroyed after use and will not be used by other applications. They can also be reused by downloading them from the storage server, which can ensure the security of the keys and enable the keys to be migrated with the users. In addition, the differences in hardware and software versions can be shielded by using an encryption algorithm supported by the hardware and Android versions of all cloud application platforms. In summary, this solution can provide a key generation and storage solution suitable for cloud applications, and can shield the differences in hardware and software versions.
[0018] Based on the foregoing method embodiment, the method may further include: When the cloud application encrypts or decrypts data using the keyword key, the legitimacy of the user and the cloud application is verified; If the legality check passes, the combined data corresponding to the keyword key is obtained, and the encrypted data in the combined data is decrypted based on the encryption algorithm information and password information in the combined data to obtain the key of the keyword key, and the key of the keyword key is used to encrypt or decrypt the data.
[0019] In this embodiment, it should be noted that decrypting the encrypted data in the combined data based on the information of the encryption algorithm and the password in the combined data may include: determining the decryption algorithm based on the information of the encryption algorithm in the combined data, and determining the decryption password based on the information of the password in the combined data; decrypting the encrypted data in the combined data using the decryption algorithm and the decryption password. If the encryption algorithm is an asymmetric encryption algorithm, the decryption password is the public key corresponding to the private key selected in step S10. When the cloud application encrypts or decrypts data using the keyword key, the system will perform a legitimacy check on the user and the cloud application: if the legitimacy check passes, the key corresponding to the keyword key will be used to encrypt or decrypt the data; otherwise, the key corresponding to the keyword key will be refused to be used to encrypt or decrypt the data. Specifically, performing legitimacy verification on users and cloud applications may include: verifying whether a user identifier of a user using the cloud application is consistent with the user identifier in the combined data, and verifying whether information of the cloud application is consistent with the information of the cloud application in the combined data; if the user identifier of the user using the cloud application is consistent with the user identifier in the combined data, and the information of the cloud application is consistent with the information of the cloud application in the combined data, then it is determined that the legitimacy verification has passed; otherwise, it is determined that the legitimacy verification has failed.
[0020] Based on the aforementioned method embodiment, the cloud application information may be the package name of the cloud application, the encryption algorithm information may be the identifier of the encryption algorithm, the password information may be the identifier of the password, and the combined data may include the ASCII code (American Standard Code for Information Interchange) corresponding to the user identifier, the ASCII code corresponding to the package name of the cloud application, the ASCII code corresponding to the identifier of the encryption algorithm, the ASCII code corresponding to the identifier of the password, the ASCII code corresponding to the length of the encryption algorithm, and the encrypted data.
[0021] In this embodiment, it should be noted that the package name of the cloud application is the name of the application package of the cloud application, the identifier of the encryption algorithm can be the index of the encryption algorithm, and the identifier of the password can be the index of the password. Different parts of the combined data can be separated by ASCII code 0. For example, assuming that when cloud application A needs to generate a key for the account account key, the selected encryption algorithm is AES (Advanced Encryption Standard), the index of AES is 0, the password is 123abc, the index of 123abc in the AES password group is 6, the length of the encrypted data obtained by encrypting the specified data is 20, the package name of cloud application A is com.android.test, and the user identifier of the user using cloud application A is test, then the structure of the combined data corresponding to account can be ASCII code (test)\0ASCII code (com.android.test)\0ASCII code (0)\0ASCII code (6)\0ASCII code (20)\0encrypted data (encrypted data is represented in binary form). Among them, ASCII code (X) represents the ASCII code corresponding to X. When the cloud application uses account to encrypt and decrypt data, the system can obtain the combined data corresponding to account through the keystore, determine that the encryption algorithm is AES based on the encryption algorithm index in the combined data, and determine that the password is 123abc based on the password index in the combined data. Use the decryption algorithm corresponding to AES and 123abc to decrypt the encrypted data in the combined data with a length equal to the length of the encrypted data, and obtain the key generated by cloud application A for account. This key can then be used for data encryption and decryption.
[0022] Reference Figure 2 FIG. 1 is a schematic diagram of a key generation device provided in an embodiment of the present application, and the device is applied to a cloud server, including: The encryption unit 20 is used to determine an encryption algorithm and a password when the cloud application requires to generate a key for the keyword key, and to encrypt the specified data using the encryption algorithm and the password to obtain encrypted data, wherein the specified data is the key for the keyword key, and the specified data includes a user identifier of a user using the cloud application; The storage unit 21 is used to combine the user identification, the information of the cloud application, the information of the encryption algorithm, the information of the password and the encrypted data, and save the combined data locally and in a storage server.
[0023] The key generation device provided in the embodiment of the present application adds the concept of user identification. The user identification is different from the application identification in Android. It is a unique identification for each user. Since the combined data including the encrypted key also includes the user identification and the information including the cloud application, it is possible to distinguish the keys corresponding to the cloud applications used by different users. At the same time, since the keys are stored locally and in the storage server, and the cloud server will be released after the user finishes using the cloud application, this can ensure that the keys are destroyed after use and will not be used by other applications. They can also be reused by downloading them from the storage server, which can ensure the security of the keys and enable the keys to be migrated with the users. In addition, the differences in hardware and software versions can be shielded by using an encryption algorithm supported by the hardware and Android versions of all cloud application platforms. In summary, this solution can provide a key generation and storage solution suitable for cloud applications, and can shield the differences in hardware and software versions.
[0024] Based on the above device embodiment, the device may further include: A verification unit, used to verify the legitimacy of the user and the cloud application when the cloud application encrypts or decrypts data using the keyword key; The encryption and decryption unit is used to obtain the combined data corresponding to the keyword key if the legality check passes, decrypt the encrypted data in the combined data based on the information of the encryption algorithm and the password in the combined data, obtain the key of the keyword key, and use the key of the keyword key to encrypt or decrypt the data.
[0025] Based on the above device embodiment, the verification unit is specifically used for: Verifying whether a user identifier of a user using the cloud application is consistent with the user identifier in the combined data, and verifying whether information of the cloud application is consistent with the information of the cloud application in the combined data; If the user identifier of the user using the cloud application is consistent with the user identifier in the combined data, and the information of the cloud application is consistent with the information of the cloud application in the combined data, it is determined that the legitimacy check has passed; otherwise, it is determined that the legitimacy check has failed.
[0026] Based on the aforementioned device embodiment, the cloud application information may be the package name of the cloud application, the encryption algorithm information may be the identifier of the encryption algorithm, the password information may be the identifier of the password, and the combined data may include the ASCII code corresponding to the user identifier, the ASCII code corresponding to the package name of the cloud application, the ASCII code corresponding to the identifier of the encryption algorithm, the ASCII code corresponding to the identifier of the password, and the encrypted data.
[0027] The key generation device provided in the embodiment of the present application has an implementation process that is consistent with the key generation method provided in the embodiment of the present application, and the effect that can be achieved is also the same as the key generation method provided in the embodiment of the present application, which will not be repeated here.
[0028] like Figure 3 As shown, an electronic device provided by an embodiment of the present application includes: a processor 30, a memory 31 and a bus 32, wherein the memory 31 stores machine-readable instructions executable by the processor 30, and when the electronic device is running, the processor 30 communicates with the memory 31 through the bus 32, and the processor 30 executes the machine-readable instructions to perform the steps of the key generation method as described above.
[0029] Specifically, the memory 31 and the processor 30 can be general-purpose memories and processors, which are not specifically limited here. When the processor 30 runs the computer program stored in the memory 31, the key generation method can be executed.
[0030] Corresponding to the above-mentioned key generation method, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned key generation method are executed.
[0031] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A key generation method, applied to a cloud server, characterized in that: include: When the cloud application requires to generate a key for the keyword key, an encryption algorithm and a password are determined, and the specified data is encrypted using the encryption algorithm and the password to obtain encrypted data, wherein the specified data is the key for the keyword key, and the specified data includes a user identifier of a user using the cloud application; The user identification, the information of the cloud application, the information of the encryption algorithm, the information of the password and the encrypted data are combined, and the combined data is saved locally and in a storage server.
2. The method according to claim 1, characterized in that Also includes: When the cloud application encrypts or decrypts data using the keyword key, the legitimacy of the user and the cloud application is verified; If the legality check passes, the combined data corresponding to the keyword key is obtained, and the encrypted data in the combined data is decrypted based on the encryption algorithm information and password information in the combined data to obtain the key of the keyword key, and the key of the keyword key is used to encrypt or decrypt the data.
3. The method according to claim 2, characterized in that The legitimacy verification of users and cloud applications includes: Verifying whether a user identifier of a user using the cloud application is consistent with the user identifier in the combined data, and verifying whether information of the cloud application is consistent with the information of the cloud application in the combined data; If the user identifier of the user using the cloud application is consistent with the user identifier in the combined data, and the information of the cloud application is consistent with the information of the cloud application in the combined data, it is determined that the legitimacy check has passed; otherwise, it is determined that the legitimacy check has failed.
4. The method according to claim 1, characterized in that The information of the cloud application is the package name of the cloud application, the information of the encryption algorithm is the identifier of the encryption algorithm, the information of the password is the identifier of the password, and the combined data includes the ASCII code corresponding to the user identifier, the ASCII code corresponding to the package name of the cloud application, the ASCII code corresponding to the identifier of the encryption algorithm, the ASCII code corresponding to the identifier of the password, and the encrypted data.
5. A key generation device, applied to a cloud server, characterized in that: include: an encryption unit, used to determine an encryption algorithm and a password when the cloud application requires generation of a key for the keyword key, and to encrypt designated data using the encryption algorithm and the password to obtain encrypted data, wherein the designated data is the key for the keyword key, and the designated data includes a user identifier of a user using the cloud application; The storage unit is used to combine the user identification, the information of the cloud application, the information of the encryption algorithm, the information of the password and the encrypted data, and save the combined data locally and in a storage server.
6. The device according to claim 5, characterized in that Also includes: A verification unit, used to verify the legitimacy of the user and the cloud application when the cloud application encrypts or decrypts data using the keyword key; The encryption and decryption unit is used to obtain the combined data corresponding to the keyword key if the legality check passes, decrypt the encrypted data in the combined data based on the information of the encryption algorithm and the password in the combined data, obtain the key of the keyword key, and use the key of the keyword key to encrypt or decrypt the data.
7. The device according to claim 6, characterized in that The verification unit is used for: Verifying whether a user identifier of a user using the cloud application is consistent with the user identifier in the combined data, and verifying whether information of the cloud application is consistent with the information of the cloud application in the combined data; If the user identifier of the user using the cloud application is consistent with the user identifier in the combined data, and the information of the cloud application is consistent with the information of the cloud application in the combined data, it is determined that the legitimacy check has passed; otherwise, it is determined that the legitimacy check has failed.
8. The device according to claim 5, characterized in that The information of the cloud application is the package name of the cloud application, the information of the encryption algorithm is the identifier of the encryption algorithm, the information of the password is the identifier of the password, and the combined data includes the ASCII code corresponding to the user identifier, the ASCII code corresponding to the package name of the cloud application, the ASCII code corresponding to the identifier of the encryption algorithm, the ASCII code corresponding to the identifier of the password, and the encrypted data.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the key generation method according to any one of claims 1 to 4 are executed.
10. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the key generation method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Method and device for secret key generation and corresponding decryption
CN105681039A
Private key offline storage method and system based on zero knowledge proof, and storage medium
CN111865582A
Key storage method and device, storage medium and electronic equipment
CN112906034A
Token-based authentication method and device, equipment and storage medium
CN115529591A
Data protection method and electronic equipment
CN117195276A
