Key rotation method, device and computer mediumTechnical Field
The invention relates to the field of computers, and particularly provides a method, a device and a computer medium for key rotation.
Background
With the development of the internet industry, the problem of information security becomes more and more important, and how to protect the security of data and prevent information leakage also becomes the direction in which many internet manufacturers are researching. As a means for encrypting data, a key is the core of an encryption operation, and the security of the key can ensure the security of encrypted data.
Taking object storage needing encryption service in a cloud platform as an example, according to a traditional mode, an encryption key used by the object storage is provided for the object storage, the key generation efficiency is low, on the premise of considering safety, if key rotation is carried out on an encrypted file once, the plaintext of the encrypted file needs to be manually obtained, a new key is generated and then encryption is carried out, and under the condition that the data volume of the file needing encryption is large, the efficiency of the traditional mode is extremely low.
Disclosure of Invention
The invention provides a secret key rotation method with strong practicability aiming at the defects of the prior art,
the invention further aims to provide a key rotation device which is reasonable in design, safe and applicable.
A technical task of the third aspect is to provide a computer medium.
The technical scheme adopted by the invention for solving the technical problems is as follows:
a key rotation method is characterized in that a Barbican component of openstack is used for key management to generate a reliable random key, and an execution strategy is specified through a timing task of an xxl platform to finish automatic rotation of keys of encrypted contents.
Further, the method comprises the following steps:
s1, deploying a Barbican component in the openstack, wherein the core function of the Barbican component deployed for the first time is only opened for an admin user in the openstack, and only an administrator can use the creation function of the order and the secret;
s2, setting a key management executor, wherein the key management executor comprises a Barbican access module, a xxl timing task handler and a key replacement module.
S3, after several key round iterations, only the latest version of the key can complete the decryption operation.
Further, in step S1, if the tenant normally uses the order and secret functions, the policy file of Barbican is changed, and the attributes of order: post and secret: post are changed from rule: admin _ or _ creator to @, which is open for all users.
Further, in step S2, the Barbican access module is used for communication with Barbican to create a key, and the key is stored in an order of the Barbican component, and the clear text of the key can be obtained by calling a specific interface.
Further, the xxl timed task handler communicates with the xxl timed task platform to create a timed task;
when the back end receives the instruction key to open the key wheel, the handler calls xxl the timing task platform interface, the timing task execution period is set according to the cron expression, after the preset execution time is reached, xxl the timing task platform calls back the handler, and the back end starts to execute the encryption and decryption and key replacement actions.
Further, in the key replacement module, after the handler receives xxl timing task platform callback messages, the key replacement module obtains a current version ciphertext and a key to decrypt the ciphertext to obtain an encrypted plaintext, and obtains a key id identifier set in the plaintext at the same time.
Further, in step S3, after performing several rounds of iterations, the key and the ciphertext of the earlier version in Barbican and the database are deleted.
A key round apparatus comprising: at least one memory and at least one processor;
the at least one memory to store a machine readable program;
the at least one processor is configured to invoke the machine readable program to perform a key round method.
A computer readable medium having stored thereon computer instructions which, when executed by a processor, cause the processor to perform a method of key rotation.
Compared with the prior art, the key rotation method, the key rotation device and the computer medium have the following outstanding advantages that:
the key management of the invention uses the Barbican component of openstack, realizes the isolation of the key from the back end, and ensures the security of the key; the xxl timing task platform and the Barbican component communicate with the back end, so that the automatic processing of key rotation is realized, and the expense of manually performing key rotation by the back end of key management is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a flow chart of a key round-robin method.
Detailed Description
The present invention will be described in further detail with reference to specific embodiments in order to better understand the technical solutions of the present invention. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
A preferred embodiment is given below:
as shown in fig. 1, in the key round-robin method in this embodiment, a Barbican component of openstack is used for key management, a reliable random key is generated, and an execution policy is specified by timing tasks on an xxl platform, so that automatic key round-robin of encrypted content is completed.
The method specifically comprises the following steps:
s1, the Barbican component needs to be deployed in the openstack firstly, the core function of the Barbican component which is deployed for the first time is only open to admin users in the openstack, and only an administrator can use the creation function of the order and the secret.
To enable the tenant to use the order and secret functions normally, the policy file of Barbican is changed, and the attributes of ' orders: post ' and ' secret: post ' are changed from ' rule: admin _ or _ creator ' to ' @ open to all users.
And S2, setting a key management executor. The executor is divided into three parts, wherein the first part is a Barbican access module, the second part is an xxl timing task handler, and the third part is a key replacement module.
The communication between the Barbican access module and Barbican has the main task of creating a key. Taking AES _256 key as an example, the access module can set "algorithmic" attribute as "AES" and "bit _ length" as "256" in the body by calling the Barbican's openAPI POST/v 1/orders.
By this method, a key of type "AES _ 256" can be created, which is stored in an order of the Barbican component, and the key plaintext can be obtained by calling a specific interface.
The timed task handler is responsible for the communication between the back end and the xxl timed task platform and is mainly responsible for creating timed tasks. When the back end receives an instruction to open the key rotation for a secret key, the handler calls xxl a timed task platform interface, and sets a timed task execution period according to the cron expression, such as: "0012? 1 "represents 12 pm execution every monday. When the preset execution time is reached, xxl times the task platform callback handler, and the backend starts to execute the encryption/decryption and key replacement actions.
The key replacement module ensures that the ciphertext encrypted by the keys of different versions can be decrypted smoothly.
In order to decrypt different versions of the ciphertext with a specific master key, the ciphertext is added with a specific identifier indicating the actual key id in Barbican. After the handler receives xxl timing task platform callback information, the key replacement module acquires a current version of ciphertext and a key to decrypt the ciphertext to acquire an encrypted plaintext, and simultaneously acquires a key id identifier set in the plaintext, after the action is completed, the key replacement module deletes the identifier, adds a new key id generated by the Barbican access module as a new identifier into the key plaintext, encrypts the newly generated plaintext by using the new key, and stores the encrypted plaintext, so that the key is replaced, and the ciphertexts of different versions are decrypted by using keys of different versions.
S3, after performing round-robin iterations for several times, the key and the ciphertext of the earlier version need to be deleted, and if the maximum round-robin frequency is set to 5 times, when a certain master key is used as the key to generate the 6 th key in round-robin, the 1 st key should be deleted in Barbican, and the ciphertext generated by the first encryption should be deleted in the database. Through the method, the security problem caused by leakage of a certain secret key generated in the front can be prevented, and the timeliness of data security is ensured.
When data decryption is carried out, the identifier area of the ciphertext is read to identify which key in the Barbican is used for encryption, and then decryption operation is carried out, so that the old version key can be used continuously until the key rotation is finished.
A key round apparatus comprising: at least one memory and at least one processor;
the at least one memory to store a machine readable program;
the at least one processor is configured to invoke the machine readable program to perform a key round method.
A computer readable medium having stored thereon computer instructions which, when executed by a processor, cause the processor to perform a method of key rotation.
The above embodiments are only specific ones of the present invention, and the scope of the present invention includes but is not limited to the above embodiments, and any suitable changes or substitutions that are consistent with the present invention and claimed by a key rotation method, apparatus and computer medium, and by a person of ordinary skill in the art, should be within the scope of the present invention.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.