Secure data mirroring method with key agreement function
The technical field is as follows:
the invention relates to a secure data mirroring method with a key agreement function, belonging to the field of computer network communication and the field of information security.
Background art:
database mirroring is a data synchronization technology, which automatically copies the whole database or a part of key data in the database to another disk, and whenever the data in the primary database is updated, the database management system automatically copies the updated data to the past, thereby ensuring the consistency of the mirrored data and the primary data. The database mirror image is mainly used for data backup and coping with high concurrency scenes, when a storage medium fails, the mirror image disk can continuously provide the usability of the database, and meanwhile, the database management system automatically utilizes the mirror image disk to repair the database without closing the system and reinstalling a database copy; when the storage medium is not in fault, the database mirror image can be used for dealing with high concurrency scenes, when one user adds an exclusive lock to the database and modifies data, other users can read the mirror database without waiting for the user to release the lock, and the read-write separation of the database is realized. With the development of internet technology, more and more enterprises design database disaster recovery schemes based on database mirroring technology, provide real-time data backup capability, and help the enterprises to solve problems in high-concurrency scenes. However, most enterprises adopt database mirroring technologies which only provide a function of plaintext data transmission, which is difficult to ensure data security, resulting in many data leakage events, and these database mirroring technologies are generally difficult to meet the requirement of real-time data synchronization, resulting in loss of part of critical data. At present, network security and informatization work is comprehensively promoted in China, and in order to respond to national call and adapt to the current development situation of the Internet in China, a database mirroring technology is required to be combined with a data encryption technology based on a trusted third party key conversion center and a synchronization technology based on log files, a secure data mirroring method with a key negotiation function is developed, enterprises can synchronize key data in real time, and meanwhile, the security of the data is guaranteed.
In the data mirroring method and the storage system provided in the patent application 201710214893.3, after receiving the target data, the local controller determines whether the data size of the target data exceeds the free capacity of the mirror cache that is pre-saved when the data size of the target data does not exceed the free capacity of the local cache. And when the data volume of the target data does not exceed the spare capacity of the pre-stored mirror cache, the local controller sends the target data to the mirror controller. And the mirror image controller writes the target data into the mirror image cache. And after receiving the mirroring completion message sent by the mirroring controller, the local controller writes the target data into the local cache. According to the invention, the total amount of unused mirror image resources of the local controller is determined before the target data is sent to the mirror image controller through the spare capacity of the mirror image cache pre-stored by the local controller, so that all the target data received by the mirror image controller can be completely mirrored in time. However, the invention has the following disadvantages: firstly, plaintext transmission is adopted in the transmission process of mirror image data, so that sensitive information of a user is easily leaked; secondly, the mirror image transmission content of the data mirror image method is data itself, and if massive data is transmitted, the system overhead is too large.
Patent application 201510617830.3 discloses a user data mirror loading method, device and terminal in an android system, and provides a user data mirror loading method, device and terminal in an android system, relates to the field of communication, and is used for providing a user data mirror loading method capable of being adaptively adjusted according to the storage space capacity of a terminal, so that the complicatedness of user data mirror compiling is reduced, and the development and maintenance resources of user data mirrors are reduced. In the embodiment process, a pre-generated partition table, a user data mirror image and a non-user data mirror image are obtained; loading the non-user data mirror images to a specified directory according to the partition table; calculating the residual capacity of the terminal; according to the residual capacity, the preset user data partition capacity in the partition table is modified to be the same as the residual capacity; and expanding the size of the pre-generated user data mirror image to the size which is the same as the user data partition capacity in the modified partition table, and loading the expanded user data mirror image to a specified directory of the terminal according to the modified partition table. Firstly, the transmission process of the mirror image data adopts plaintext transmission, which is easy to cause the leakage of sensitive information of a user; secondly, the data mirroring method is only suitable for an android operating system and is poor in compatibility.
Patent application 201280060360.X hidden automatic data mirroring for native interfaces in distributed virtual machines, in which an initial request referencing a data container is sent from a distributed enhanced remote execution container native interface component of a distributed virtual machine to a distributed enhanced virtual machine native interface component of the distributed virtual machine in response to receiving the initial request from the remote execution container. A data mirroring data structure is received that includes immutable data and a reference to a data container. A received data mirroring data structure that includes immutable data and a reference to a data container is stored within a local memory store. In response to an initial request to reference a data container, a reference to a locally stored data mirroring data structure is returned to the remote execution container. However, the invention has the following disadvantages: firstly, the automatic data mirroring technology needs to utilize a native interface, is only suitable for a distributed virtual machine environment, and is poor in compatibility; secondly, plaintext transmission is adopted in the mirror image data transmission process, so that sensitive information of a user is easily leaked; thirdly, the mirror data depends on a mirror data structure defined in advance, and the universality is poor.
Patent application 200710159670.8 discloses a system and method for configuring data mirroring, and relates to a system, method and program for data mirroring. In response to identifying a new storage volume on a primary storage subsystem designated for use, a plurality of parameters for the new storage volume requiring data mirroring are automatically determined. At the same time, a corresponding storage volume in the second storage subsystem is automatically determined to mirror data from the new storage volume in the primary storage subsystem. The parameters of the new storage volume are automatically entered into the data mirroring table. The table identifies the new storage volume, the parameters of the new storage volume, and the corresponding storage volume. The table also maps the new storage volume to a corresponding storage volume such that data updates to the new storage volume are mirrored to the corresponding storage volume. By determining the parameters that the previous storage volume and the subsequent storage volume in the primary storage subsystem have the same value, the parameters of the new storage volume can be determined. In response, these values for the parameters of the new storage volume are entered into the data mirroring table. However, the invention has the following disadvantages: firstly, plaintext transmission is adopted in the transmission process of mirror image data, so that sensitive information of a user is easily leaked; second, the data mirroring method needs to determine a plurality of parameters of the corresponding storage volumes of the primary storage subsystem and the second storage subsystem, and needs to redefine the parameters when the storage medium is replaced, which is complicated and has poor operability.
The invention discloses a method for mirroring data of a 200610020460.6 network information system at different places, provides a method for mirroring data of a network information system at different places, and belongs to the field of information security. By the technologies of data state synchronization, local data monitoring, mass data caching, remote playback, error control and the like, the real-time reconstruction of local data center data at different places is realized under the condition of not influencing the efficiency of a local data center server, the outstanding contradiction between the local data bandwidth and the backup line bandwidth is solved, the requirement on the backup network bandwidth and the occupation of other network resources are greatly reduced, and the system efficiency is improved. Meanwhile, even if the midway network fails or the bandwidth is unstable, the system can tolerate that any slight change of the data of the local data center can be correctly and timely transmitted to the remote backup center, so that the data consistency of the local data center and the remote backup center is ensured. The invention supports the disaster backup strategy of a private line/a non-private line and supports the Internet, greatly reduces the cost of the disaster recovery and damage resistance system and has wide application prospect. However, the invention has the following disadvantages: firstly, plaintext transmission is adopted in the transmission process of mirror image data, so that sensitive information of a user is easily leaked; secondly, the mirror image transmission content of the data mirror image method is data, and if massive data is transmitted, the system overhead is overlarge; thirdly, the data mirroring method synchronizes data through data state synchronization, and the synchronization interval is set manually, which may cause loss of part of key data and poor real-time performance.
Patent application 201110447809.5 distributed data mirroring method and storage data node, the invention relates to a distributed data mirroring method and device. The method comprises the following steps: receiving a data operation request, performing operation corresponding to the data operation request on the data, performing backup operation corresponding to the data operation request on the data, and generating a logical file name; generating a mirror image record comprising a logic file name, a mirror image strategy and an operation type; acquiring a list of destination data storage node addresses to be mirrored from a master control node of a mirror destination distributed file system determined by file region information; and according to the mirror image strategy and the operation type in the mirror image record, performing corresponding operation of the data operation request on the data on the target data storage node. Therefore, the distributed data mirroring method and the storage data nodes of the invention utilize the distributed file system as a data center to carry out data mirroring, and select the available storage data nodes to carry out data mirroring, thereby realizing high reliability of the mirroring system. However, the invention has the following disadvantages: firstly, plaintext transmission is adopted in the transmission process of mirror image data, so that sensitive information of a user is easily leaked; secondly, the distributed file system is used as a data center for data mirroring, so that the cost is high, and the distributed file system is not suitable for small enterprises.
Patent application 201410509938.6 data mirroring control apparatus and method, the invention provides a data mirroring control apparatus and method. The data mirroring control apparatus includes: a command distribution unit configured to transmit a first write command to the plurality of mirrored storages, the first write command including an instruction for data requested to be written by the host; a memory lock setting unit configured to set a memory lock on data requested to be written by the host among data stored in the host memory, and configured to release the memory lock on the data after the data with the memory lock is written to the plurality of mirrored storage devices. However, the invention has the following disadvantages: firstly, plaintext transmission is adopted in the transmission process of mirror image data, so that sensitive information of a user is easily leaked; second, the memory is locked during the mirrored data transfer process, causing other data input operations to be forced to wait, and therefore using this data mirroring approach results in a slower system response rate.
Patent application 201510453871.3 provides a method, device and system for implementing data mirroring, which is applied to a server cluster system, and includes: establishing a trust relationship between the main server and the standby server by setting the type of the authentication secret key and setting the authentication secret key as authorized users; detecting the name of a server in a running state at intervals of set time; judging whether the server name is the same as the name of the main server or not; according to the trust relationship, if so, copying the key data on the main server to the standby server through script resources, otherwise, copying the key data on the standby server to the main server through script resources. The device includes: the device comprises a creating unit, a detecting unit, a judging unit and a mirroring unit. The system comprises: the invention provides a main server, a standby server and a device for realizing data mirroring. The scheme can improve the efficiency of configuring the server cluster system. However, this system has the following drawbacks: firstly, although the main server and the standby server are authenticated, the transmission process of the mirror image data adopts plaintext transmission, which easily causes the leakage of sensitive information of a user; secondly, the data mirroring technology is only suitable for a server cluster environment and is poor in compatibility.
The invention discloses a method and a device for data mirroring of patent application 201110415166.6, and provides a method and a device for data mirroring, wherein the method comprises the following steps: decapsulating a first message carried by a first interface to obtain payload data of the first message, wherein the first interface is a source interface; and generating a second message of the network type corresponding to the second interface from the payload data, and sending the second message to the second interface, wherein the second interface is a mirror image destination interface of the first interface, and the first interface and the second interface correspond to different types of networks. The invention can solve the problems that the business carried by the STM-N interface has no data mirror image, even if the mirror image can be carried out, the SDH network analysis instrument can not identify the payload content, and the engineering and the test maintenance work are very inconvenient. However, the invention has the following disadvantages: firstly, plaintext transmission is adopted in the transmission process of mirror image data, so that sensitive information of a user is easily leaked; secondly, the data mirroring method aims to solve the problem of mirroring transmission identification in the SDH network, is not suitable for other networks and has poor compatibility.
The invention provides a method and a device for ensuring service validity during data mirroring, and provides two methods for realizing data mirroring, wherein a monitored device receives or is about to send a data frame, and after detecting that the data frame is a mirrored data frame, source information of the mirrored data frame and the mirrored data frame are sent to a mirroring port together, and then the monitoring device where the mirroring port is located stores a corresponding relation between the mirrored data frame and the source information of the mirrored data frame. The source information of the mirror data frame at least comprises: receiving or sending a port number of the mirrored data frame or a device number of the monitored device, further comprising: the receiving or sending indication, the receiving or sending time, the service flow identification and the like of the mirror image data frame realize that one port of one device monitors the data frame transmitted on more than one port of the device or other devices, further realize that one port of one device monitors the data frames of different service flows in different directions and transmitted on a plurality of ports of the device or other devices at the same time, and expand the monitoring range of the monitoring device. However, the invention has the following disadvantages: firstly, plaintext transmission is adopted in the transmission process of mirror image data, so that sensitive information of a user is easily leaked; secondly, the mirror image transmission content of the data mirror image method is data itself, and if massive data is transmitted, the system overhead is too large.
Journal "middle and primary school electrified education" paper 2013.10 "SQL Server non-domain control database mirror image script configuration example analysis", which proposes a database mirror image script configuration method in the mirror image transmission process, and adopts the clustering technology, database mirror image, log transmission, database copy and other modes to ensure high availability and high security of data. The thesis introduces how to configure database mirroring in a script execution manner in a domain-free environment, which is simpler and faster to operate compared with a complex view. The method provides possibility for the terminal user to transplant the script into the program according to the actual situation to realize the program configuration mirror. However, the invention has the following disadvantages: firstly, plaintext transmission is adopted in the transmission process of mirror image data, so that sensitive information of a user is easily leaked; secondly, the data mirroring technology is only suitable for SQL Server, and script parameters and statements need to be redefined when other databases are replaced, so that compatibility is poor.
Journal "computer and modernization" paper "database mirror image XML Schema applied research" in 2009.11, which provides a method for applying XMLSchema Schema and related technology to mirror databases, and implements mirror image applied research by using C # language on microsoft. The method has general practical value and application prospect for developing database related software. However, the invention has the following disadvantages: firstly, plaintext transmission is adopted in the transmission process of mirror image data, so that sensitive information of a user is easily leaked; secondly, the database mirroring technology bottom layer is realized by a C # language on a Microsoft.
Journal "Instrument and Meter and analytical monitoring" paper 2014.5, "scheme research and implementation of enterprise high-availability data secure storage", the paper selects an optimal data mirroring scheme between storage devices by analyzing and comparing three data secure storage schemes and combining the current situation of the enterprise. Through the LVM (logical volume management) technology of the IBM Power server, a data mirroring relationship is established between two sets of IBM storage equipment which are in an active state at the same time, and when a production host writes data, the data can be written into two sets of disk equipment at the same time. The data storage, backup and safety requirements of the enterprise PLM business system are met, and the requirements of a production system on high reliability, continuous operation and smooth transition of the PLM system are met. However, the invention has the following disadvantages: firstly, plaintext transmission is adopted in the transmission process of mirror image data, so that sensitive information of a user is easily leaked; second, the database mirroring technology is based on IBM storage devices, cannot be applied to all storage devices, and is poor in compatibility.
Journal "modern book information technology" paper "design and implementation of a MARC data mirroring system" in term of 2008.6, a design scheme of the MARC data mirroring system is provided on the basis of analyzing the storage characteristics of MARC data in a relational database. According to the scheme, the file transmission server is introduced, so that remote operation is converted into local operation when the source database and the target database perform data copying, records are synchronously converted into network files for transmission, and data copying between the source database and the target database is reliable, rapid and effective. The system to which this paper relates has the following drawbacks: firstly, plaintext transmission is adopted in the transmission process of mirror image data, so that sensitive information of a user is easily leaked; secondly, the mirror image transmission content of the data mirror image method is data itself, and if massive data is transmitted, the system overhead is too large.
Disclosure of Invention
Aiming at the technical problems of poor safety, sensitive information leakage, large system overhead, poor platform compatibility, poor universality, high complexity, poor operability, slow system response rate, poor instantaneity and the like of the data mirroring method, the invention provides a secure data mirroring method with a key agreement function based on a data encryption technology of a trusted third party key conversion center and a synchronization technology based on log files; the method can effectively avoid data leakage, reduce system overhead, improve system response rate, has low complexity and good platform compatibility, is suitable for master-slave copy among all databases, and has strong operability. To this end.
The above purpose is realized by the following technical scheme:
the invention provides a safe data mirroring method with a key agreement function, which comprises a master database encryption module, a master database safe mirroring module, a slave database safe mirroring module and a slave database decryption module;
wherein: the main database encryption module is used for blocking the complete mirror image data of the main database to form blocked plaintext data; generating a corresponding message authentication code for the block plaintext data through a hash function, and attaching the message authentication code to the block plaintext data to form block plaintext mirror image data; then, block plaintext mirror image data are encrypted to form block ciphertext mirror image data, and the block ciphertext mirror image data are transmitted to a slave database decryption module to ensure data confidentiality;
the master database security mirror image module is responsible for actively sending authorization information to the slave database, and transmitting blocked ciphertext mirror image data between the master database and the slave database in an encryption mode based on a mirror image log file of the master database and a customized one-time pad scheme;
the slave database security mirror image module is responsible for receiving the authorization information of the master database and completing identity authentication; based on the mirror image log file of the slave database and the customized one-time pad scheme, the blocked ciphertext mirror image data between the master database and the slave database are transmitted in an encryption mode, so that safe data synchronization is realized;
the slave database decryption module is used for decrypting the block ciphertext mirror image data to form block plaintext mirror image data; and carrying out Hash processing on each block of plaintext mirror image data, identifying the authenticity of the message authentication code, and combining the block plaintext data into complete mirror image data.
The invention further improves that the main database encryption module comprises a main database encryption preprocessing module, a main database encryption control module, a main database ciphertext data interface module, an encryption and decryption parameter setting module and a session key generating module; the main database encryption module completes encryption preprocessing based on a ciphertext block chaining mode CBC: partitioning the complete mirror image data of the main database to form partitioned plaintext data; generating a corresponding message authentication code for the block plaintext data through a hash function, and attaching the message authentication code to the block plaintext data to form block plaintext mirror image data; then, based on a customized one-time pad scheme, acquiring a session key negotiated by a master database and a slave database, encrypting blocked plaintext mirror data by adopting an AES algorithm to form blocked ciphertext mirror data, and transmitting the blocked ciphertext mirror data to a slave database decryption module in a ciphertext mode to ensure data confidentiality; the master database and the slave database complete identity authentication through the key conversion center, and then generate and distribute session keys based on a customized one-time pad scheme, so that the security of key distribution can be ensured;
the main database encryption preprocessing module receives complete mirror image data of an SQL statement sent by a user, and blocks the complete mirror image data based on a ciphertext block chaining mode CBC to form blocked plaintext data; generating a corresponding message authentication code for the block plaintext data through a hash function, and attaching the message authentication code to the block plaintext data to form block plaintext mirror image data; then setting an initial vector IV, generating an initial key request, and sending the partitioned plaintext mirror data, the initial vector IV and the initial key request to a main database encryption control module;
the main database encryption control module receives the blocked plaintext mirror data, the initial vector IV and the initial key request of the main database encryption preprocessing module, forwards the initial vector IV and the initial key request to the encryption and decryption parameter setting module, receives the session key SK sent by the session key generation module as the initial key, performs AES (advanced encryption Standard) encryption on the blocked plaintext mirror data by using the initial key and the initial vector IV based on a ciphertext block chaining mode CBC (cipher text block chaining) and sends the generated blocked ciphertext mirror data to the main database ciphertext data interface module;
the master database ciphertext data interface module receives the block ciphertext mirror data of the master database encryption control module and forwards the block ciphertext mirror data to the master database security mirror authorization module; the encryption and decryption parameter setting module receives an initial vector IV and an initial key request sent by the main database encryption control module, extracts main database identity information A and auxiliary database identity information B from the initial key request, then sends the main database identity information A and the auxiliary database identity information B to the key conversion center KTC, and receives a main database shared key K returned by the key conversion center KTCATAnd sharing a secret key K from a databaseBTAfter the initialization of the identity information and the shared key is finished, the identity information A of the master database, the identity information B of the slave database and the shared key K of the master database are obtainedATSending the initial vector IV, the identity information A of the master database and the shared key K of the slave database to a session key generation moduleBTSending to a session key verification distribution module;
the session key generation module receives the identity information A of the master database, the identity information B of the slave database and the shared key K of the master database which are sent by the encryption and decryption parameter setting module
ATRandomly generating a session key SK by a linear congruence method, sending the session key SK to a master database encryption control module, and sending master database key negotiation information A,
Sending the key to a key conversion center KTC, key negotiation information A of a main database,
Where a represents the primary database identity information,
key K shared by representatives with a master database
ATEncrypted slave database identity B and session key SK, and then receives slave database key agreement information sent by key conversion center KTC
Will negotiate information from database key
To the session key authentication distribution module,
representing shared secret key K from database
BTEncrypted master database identity a and session key SK.
The invention further improves that the master database security mirror image module comprises a master database security mirror image authorization module, a master database data security synchronization module and a ciphertext data sending module; the master database security mirror image module is responsible for actively sending authorization information to the slave database, and based on a mirror image log file of the master database and a customized one-time pad scheme, block cipher text mirror image data between the master database and the slave database are transmitted in an encryption mode, so that safe data synchronization is realized, data leakage is avoided, and the master database security mirror image module is suitable for master-slave copy among all databases;
the master database security mirror image authorization module acquires the identity information of the slave database based on a locally configured mirror image log file, and sends authorization request information and an authorization account number to the slave database security mirror image authorization module according to the identity information of the slave database; meanwhile, receiving authorization response information sent by a database security mirror image authorization module to complete mirror image authorization; after the mirror image authorization is completed, the main database security mirror image authorization module receives the block cipher text mirror image data sent by the main database cipher text data interface module through a TCP/IP transmission protocol based on a Socket interface Socket and sends the block cipher text mirror image data to the main database data security synchronization module;
the master database data security synchronization module receives the blocked ciphertext mirror data sent by the master database security mirror authorization module, writes the blocked ciphertext mirror data into a master database mirror log file, and then sends the blocked ciphertext mirror data to the ciphertext data sending module; the ciphertext data sending module receives the partitioned ciphertext mirror data of the main database data safety synchronization module and forwards the partitioned ciphertext mirror data to the ciphertext data receiving module.
The invention further improves that the slave database security mirror image module comprises a ciphertext data receiving module, a slave database data security synchronization module and a slave database security mirror image authorization module; the slave database security mirror image module is responsible for receiving the authorization information of the master database and completing identity authentication; based on the mirror image log file of the slave database and the customized one-time pad scheme, transmitting the partitioned cipher text mirror image data between the master database and the slave database in an encryption mode; the method has the advantages that safe data synchronization is realized, data leakage is avoided, and the method is suitable for master-slave copy among all databases;
the ciphertext data receiving module receives the block ciphertext mirror image data sent by the ciphertext data sending module and forwards the block ciphertext mirror image data to the slave database data security synchronization module; the slave database data security synchronization module receives the block ciphertext mirror image data sent by the ciphertext data receiving module and writes the block ciphertext mirror image data into a slave database mirror image log file; meanwhile, receiving the cursor position of the slave database mirror image file sent by the slave database security mirror image authorization module, taking out the block cipher text mirror image data behind the cursor position in the slave database mirror image log file, and sending the block cipher text mirror image data to the slave database security mirror image authorization module;
the slave database security mirror image authorization module receives authorization request information and an authorization account number sent by the master database security mirror image authorization module, then sends authorization response information to the master database security mirror image authorization module to complete mirror image authorization, sets a slave database mirror image file cursor position according to the authorization request information, and sends the slave database mirror image file cursor position to the slave database data security synchronization module; and meanwhile, the slave database security mirror image authorization module receives the partitioned cipher text mirror image data sent by the slave database data security synchronization module and sends the partitioned cipher text mirror image data to the slave database cipher text data interface module.
The invention further improves that the slave database decryption module comprises a session key verification distribution module, a slave database ciphertext data interface module, a slave database decryption control module and a slave database decryption restoration module; the slave database decryption module decrypts the blocked ciphertext mirror image data by adopting an AES algorithm based on the ciphertext block chaining mode CBC and a customized one-time pad scheme and using a session key negotiated by the master database and the slave database to form blocked plaintext mirror image data; carrying out Hash processing on each block of plaintext mirror image data, identifying the authenticity of the message authentication code, combining the block plaintext data in the block plaintext data into complete mirror image data, and preventing replay attack in the working mode during data mirror image transmission; the master database and the slave database complete identity authentication through the key conversion center, and then generate and distribute session keys based on a customized one-time pad scheme, so that the security of key distribution can be ensured;
the session key verification and distribution module receives the initial vector IV, the identity information A of the master database and the shared key K of the slave database sent by the encryption and decryption parameter setting module
BTThen receives the key negotiation information of the slave database sent by the session key generation module
Using shared secret key K from database
BTDecrypting secondary database key agreement information
Verifying the identity information A of the master database, and taking out a session key SK; in addition, the session key verification distribution module receives a decryption initial parameter request sent from the database decryption control module, and then sends the initial vector IV and the session key SK to the slave database decryption control module; the slave database ciphertext data interface module receives the blocked ciphertext mirror image data sent by the slave database security mirror image authorization moduleAnd forwarding to a slave database decryption control module;
the slave database decryption control module receives the block ciphertext mirror image data sent by the slave database security mirror image authorization module; meanwhile, the slave database decryption control module generates and sends a decryption initial parameter request to the session key verification distribution module, then receives an initial vector IV and a session key SK sent by the session key verification distribution module, takes the session key SK as an initial key, performs AES decryption on the block ciphertext mirror image data by using the initial key and the initial vector IV based on a ciphertext block chaining mode CBC, and sends the generated block plaintext mirror image data to the slave database decryption restoration module; the slave database decryption reduction module receives the block plaintext mirror image data sent from the database decryption control module, takes out the additional message authentication code for each block of block plaintext mirror image data, performs hash processing to identify the authenticity of the message authentication code, combines the block plaintext data into complete mirror image data, and stores the complete mirror image data in the slave database to finish data synchronization.
Advantageous effects
Compared with the prior art, the invention provides a safe data mirroring method with a key agreement function based on the data encryption technology of a trusted third party key conversion center and the synchronization technology based on log files; the method completes the identity authentication of a master database and a slave database through a trusted third party key conversion center, provides a customized one-time pad scheme to enable the master database and the slave database to share a session key, ensures the security of key distribution, completes the mirror image authorization and data transmission of the master database and the slave database through an encryption mode, realizes safe data synchronization based on the customized one-time pad scheme, and avoids data leakage; the method is based on log file synchronization data, when a user completes DML operation on a master database, as long as the operation is not a SELECT operation, the operation is written into a master database log file, and the slave database is notified to complete the same DML operation through an event, but data transmission is not directly transmitted from the master database to the slave database, so that the method reduces the system overhead, improves the system response rate, has low complexity, realizes data synchronization based on event response, reduces the possibility of key data loss, and has strong real-time performance; in addition, the mirror image transmission content is a universal relational database Data Manipulation Language (DML), the universality is strong, and the mirror image transmission among different platforms is easy, so that the platform compatibility is good, the method is suitable for master-slave copy among all databases, and the operability is strong. The data mirroring method has the advantages of wide application range, practicability, convenience, good overall safety performance, and good real-time performance and stability.
Drawings
FIG. 1 is a diagram of an application scenario of the present invention;
FIG. 2 is an overall block diagram of the present invention;
FIG. 3 is an overall schematic block diagram of the present invention;
FIG. 4 is a mirror key agreement schematic of the present invention;
FIG. 5 is a diagram of a master database encryption module architecture of the present invention;
FIG. 6 is a block diagram of a primary database security mirror module of the present invention;
FIG. 7 is a diagram of a slave database security mirror module architecture of the present invention;
FIG. 8 is a block diagram of a slave database decryption module of the present invention;
FIG. 9 is a secure data mirroring transmission flow diagram of the present invention;
FIG. 10 is a secure data image reception flow diagram of the present invention;
Detailed Description
The invention is described in further detail below with reference to the following detailed description and accompanying drawings:
the invention provides a safe data mirroring method with a key agreement function based on a data encryption technology of a trusted third party key conversion center and a synchronization technology based on log files; the method completes the identity authentication of a master database and a slave database through a trusted third party key conversion center, provides a customized one-time pad scheme to enable the master database and the slave database to share a session key, ensures the security of key distribution, completes the mirror image authorization and data transmission of the master database and the slave database through an encryption mode, realizes safe data synchronization based on the customized one-time pad scheme, and avoids data leakage; the method is based on log file synchronization data, when a user completes DML operation on a master database, as long as the operation is not a SELECT operation, the operation is written into a master database log file, and the slave database is notified to complete the same DML operation through an event, but data transmission is not directly transmitted from the master database to the slave database, so that the method reduces the system overhead, improves the system response rate, has low complexity, realizes data synchronization based on event response, reduces the possibility of key data loss, and has strong real-time performance; in addition, the mirror image transmission content is a universal relational database Data Manipulation Language (DML), the universality is strong, and the mirror image transmission among different platforms is easy, so that the platform compatibility is good, the method is suitable for master-slave copy among all databases, and the operability is strong.
Fig. 1 shows an application scenario diagram of the present invention, which mainly includes three entities: a master database, a slave database and a Key Transformation Center (KTC). The data mirroring technology of the invention automatically copies all data of the master database or part of key data in the master database to the slave database, and whenever the data of the master database is updated, the database management system also automatically copies the updated data to the slave database, thereby ensuring the consistency of the mirrored data and the master data. The data is encrypted before being copied, an encrypted key is distributed by a key conversion center (KTC), and the confidentiality of the data is ensured based on a customized one-time pad scheme. The data mirroring technology of the invention completes mirroring authorization and data transmission of the master database and the slave database in an encryption mode, realizes safe data synchronization based on a customized one-time pad scheme, avoids data leakage, is suitable for master-slave copy among all databases, can be used for database disaster recovery schemes of enterprises, provides real-time data backup capability, and can help the enterprises to solve the problems in high-concurrency scenes.
As shown in fig. 2, which is an overall block diagram of the present invention, a secure data mirroring method with a key agreement function according to the present invention includes: the system comprises a main database encryption module (1), a main database security mirror module (2), a slave database security mirror module (3) and a slave database decryption module (4). The invention completes the mirror image authorization and data transmission of the master database and the slave database in an encryption mode, realizes safe data synchronization based on a customized one-time pad scheme, avoids data leakage, and is suitable for master-slave copy among all databases. The system comprises a master database user and master database encryption module (1), a master database encryption module (1) and master database security mirror module (2), a master database encryption module (1) and slave database decryption module (4), a master database security mirror module (2) and slave database security mirror module (3), a slave database security mirror module (3) and slave database decryption module (4), a slave database user and slave database decryption module (4), all based on a TCP/IP protocol, and data interaction is completed through a Socket interface Socket.
As shown in fig. 3, the overall principle structure of the present invention mainly includes five major parts: the system comprises a main database encryption module (1), a main database security mirror module (2), a slave database security mirror module (3) and a slave database decryption module (4). The main database encryption module (1) comprises a main database encryption preprocessing module (1-1), a main database encryption control module (1-2), a main database ciphertext data interface module (1-3), an encryption and decryption parameter setting module (1-4) and a session key generation module (1-5). The master database security mirror image module (2) comprises a master database security mirror image authorization module (2-1), a master database data security synchronization module (2-2) and a ciphertext data sending module (2-3). The slave database security mirror image module (3) comprises a ciphertext data receiving module (3-1), a slave database data security synchronization module (3-2) and a slave database security mirror image authorization module (3-3). The slave database decryption module (4) comprises a session key verification distribution module (4-1), a slave database ciphertext data interface module (4-2), a slave database decryption control module (4-3) and a slave database decryption restoration module (4-4).
The mirror key agreement principle of the present invention is shown in fig. 4:
firstly, an entity A acquires identity information A of a master database, identity information B of a slave database and the master database from an encryption and decryption parameter setting module (1-4)Shared secret key K
ATThen, an entity A generates a session key SK locally and randomly through a linear congruence method in a session key generation module (1-5), and sends the session key SK to a main database encryption control module (1-2); next, the session key generation module (1-5) shares the key K with the master database
ATEncrypting the slave database identity B and the session key SK, and then sending the master database key agreement information A,
(including master database identity information A, sharing key K with master database
ATEncrypted slave database identity B and session key SK) to a Key Transformation Centre (KTC);
secondly, the entity KTC receives the key negotiation information A of the main database sent by the session key generation module (1-5),
shared key K of main database stored by KTC
ATDecrypts the master database key agreement information a,
obtaining identity information A of a master database, identity information B of a slave database and a session key SK; then share secret key K from database saved by KTC
BTEncrypting the identity information A and the session key SK of the master database to obtain the key negotiation information of the slave database
And sending to a session key generation module (1-5) of the entity A;
thirdly, a session key generation module (1-5) of the entity A receives key negotiation information sent by the KTC from the database
And forwarded to the session key authentication distribution module (4-1) of entity B;
fourthly, the session key verification distribution module (4-1) of the entity B receives the key agreement sent by the session key generation module (1-5) from the databaseBusiness information
And obtaining the identity information A of the master database and the shared secret key K of the slave database from the encryption and decryption parameter setting modules (1-4)
BTUsing shared secret keys K from the database
BTDecrypting secondary database key agreement information
And verifying the identity information A of the master database and taking out the session key SK.
The main database encryption module of the invention is shown in fig. 5, and completes encryption preprocessing based on a ciphertext block chaining mode CBC: partitioning the complete mirror image data of the main database to form partitioned plaintext data; generating a corresponding message authentication code for the block plaintext data through a hash function, and attaching the message authentication code to the block plaintext data to form block plaintext mirror image data; then, based on a customized one-time pad scheme, a session key negotiated by a master database and a slave database is obtained, block plaintext mirror data are encrypted by adopting an AES algorithm to form block ciphertext mirror data, and the block ciphertext mirror data are transmitted to a slave database decryption module (4) in a ciphertext mode to ensure the confidentiality of the data; the master database and the slave database complete identity authentication through the key conversion center, and then generate and distribute the session key based on a customized one-time pad scheme, so that the security of key distribution can be ensured. The main database encryption module (1) comprises a main database encryption preprocessing module (1-1), a main database encryption control module (1-2), a main database ciphertext data interface module (1-3), an encryption and decryption parameter setting module (1-4) and a session key generation module (1-5).
The main database encryption preprocessing module (1-1) receives complete mirror image data of an SQL statement sent by a user, and blocks the complete mirror image data based on a ciphertext block chaining mode (CBC) to form blocked plaintext data; generating a corresponding message authentication code for the block plaintext data through a hash function, and attaching the message authentication code to the block plaintext data to form block plaintext mirror image data; then setting an initial vector IV, generating an initial key request, and sending the partitioned plaintext mirror data, the initial vector IV and the initial key request to a main database encryption control module (1-2);
the main database encryption control module (1-2) receives the blocked plaintext mirror data, an initial vector IV and an initial key request of the main database encryption preprocessing module (1-1), forwards the initial vector IV and the initial key request to the encryption and decryption parameter setting module (1-4), receives a session key SK sent by the session key generation module (1-5) and serves as an initial key, conducts AES encryption on the blocked plaintext mirror data by using the initial key and the initial vector IV on the basis of a ciphertext block chaining mode CBC, and sends the generated blocked ciphertext mirror data to the main database ciphertext data interface module (1-3);
the master database ciphertext data interface module (1-3) receives the partitioned ciphertext mirror data of the master database encryption control module (1-2) and forwards the partitioned ciphertext mirror data to the master database security mirror authorization module (2-1); the encryption and decryption parameter setting module (1-4) receives an initial vector IV and an initial key request sent by the main database encryption control module (1-2), extracts main database identity information A and slave database identity information B from the initial key request, then sends the main database identity information A and the slave database identity information B to the key conversion center KTC, and receives a main database shared key K returned by the key conversion center KTCATAnd sharing a secret key K from a databaseBTAfter the initialization of the identity information and the shared key is finished, the identity information A of the master database, the identity information B of the slave database and the shared key K of the master database are obtainedATSending to a session key generation module (1-5) to obtain an initial vector IV, master database identity information A and a slave database shared key KBTSending to a session key verification distribution module (4-1);
the session key generation module (1-5) receives the identity information A of the master database, the identity information B of the slave database and the shared key K of the master database which are sent by the encryption and decryption parameter setting module (1-4)
ATRandomly generating a session key SK by a linear congruence method, sending the session key SK to a master database encryption control module, and sending master database key negotiation information A,
Sending the key to a key conversion center KTC, key negotiation information A of a main database,
Where a represents the primary database identity information,
key K shared by representatives with a master database
ATEncrypted slave database identity B and session key SK, and then receives slave database key agreement information sent by key conversion center KTC
Will negotiate information from database key
Forwarded to a session key authentication distribution module (4-1),
representing shared secret key K from database
BTEncrypted master database identity a and session key SK. The master database security mirror module is responsible for actively sending authorization information to the slave database, and transmitting block ciphertext mirror data between the master database and the slave database in an encryption mode based on a mirror log file of the master database and a customized one-time pad scheme, so that the secure data synchronization is realized, the data leakage is avoided, and the master database security mirror module is suitable for master-slave copy among all databases. The master database security mirror image module (2) comprises a master database security mirror image authorization module (2-1), a master database data security synchronization module (2-2) and a ciphertext data sending module (2-3).
The master database security mirror image authorization module (2-1) acquires the identity information of the slave database based on a locally configured mirror image log file, and sends authorization request information and an authorization account number to the slave database security mirror image authorization module (3-3) according to the identity information of the slave database; meanwhile, receiving authorization response information sent by a database security mirror image authorization module (3-3) to complete mirror image authorization; after mirror image authorization is completed, the main database security mirror image authorization module (2-1) receives the block cipher text mirror image data sent by the main database cipher text data interface module (1-3) through a TCP/IP transmission protocol based on a Socket interface Socket, and sends the block cipher text mirror image data to the main database data security synchronization module (2-2);
the master database data security synchronization module (2-2) receives the blocked ciphertext mirror data sent by the master database security mirror authorization module (2-1), writes the blocked ciphertext mirror data into a master database mirror log file, and then sends the blocked ciphertext mirror data to the ciphertext data sending module (2-3); the ciphertext data sending module (2-3) receives the partitioned ciphertext mirror image data of the main database data security synchronization module (2-2) and forwards the partitioned ciphertext mirror image data to the ciphertext data receiving module (3-1).
The slave database security mirror module of the invention is as shown in fig. 7, and is responsible for receiving the authorization information of the master database and completing identity authentication; based on the mirror image log file of the slave database and the customized one-time pad scheme, transmitting the partitioned cipher text mirror image data between the master database and the slave database in an encryption mode; the method realizes safe data synchronization, avoids data leakage, and is suitable for master-slave copy among all databases. The slave database security mirror image module (3) comprises a ciphertext data receiving module (3-1), a slave database data security synchronization module (3-2) and a slave database security mirror image authorization module (3-3).
The ciphertext data receiving module (3-1) receives the partitioned ciphertext mirror image data sent by the ciphertext data sending module (2-3) and forwards the partitioned ciphertext mirror image data to the slave database data security synchronization module (3-2); the slave database data security synchronization module (3-2) receives the block ciphertext mirror image data sent by the ciphertext data receiving module (3-1), and writes the block ciphertext mirror image data into a slave database mirror image log file; meanwhile, the cursor position of the slave database mirror image file sent by the slave database security mirror image authorization module (3-3) is received, the block cipher text mirror image data after the cursor position in the slave database mirror image log file is taken out and sent to the slave database security mirror image authorization module (3-3);
the slave database security mirror image authorization module (3-3) receives authorization request information and an authorization account number sent by the master database security mirror image authorization module (2-1), then sends authorization response information to the master database security mirror image authorization module (2-1), completes mirror image authorization, sets a slave database mirror image file cursor position according to the authorization request information, and sends the slave database mirror image file cursor position to the slave database data security synchronization module (3-2); meanwhile, the partitioned ciphertext mirror image data sent from the database data security synchronization module (3-2) is received from the database security mirror image authorization module (3-3) and sent to the slave database ciphertext data interface module (4-2).
The slave database decryption module of the invention is as shown in fig. 8, based on a ciphertext block chaining mode CBC and a customized one-time pad scheme, uses a session key negotiated by a master database and a slave database, and decrypts blocked ciphertext mirror image data by using an AES algorithm to form blocked plaintext mirror image data; carrying out Hash processing on each block of plaintext mirror image data, identifying the authenticity of the message authentication code, combining the block plaintext data in the block plaintext data into complete mirror image data, and preventing replay attack in the working mode during data mirror image transmission; the master database and the slave database complete identity authentication through the key conversion center, and then generate and distribute the session key based on a customized one-time pad scheme, so that the security of key distribution can be ensured. The slave database decryption module (4) comprises a session key verification distribution module (4-1), a slave database ciphertext data interface module (4-2), a slave database decryption control module (4-3) and a slave database decryption restoration module (4-4).
The session key verification distribution module (4-1) receives the initial vector IV, the identity information A of the master database and the shared key K of the slave database sent by the encryption and decryption parameter setting module (1-4)
BTThen receives the key negotiation information of the slave database sent by the session key generation module (1-5)
Using shared secret key K from database
BTDecrypting secondary database key agreement information
Verifying the identity information A of the master database, and taking out a session key SK; in addition, the session key verification distribution module (4-1) receives a decryption initial parameter request sent from the database decryption control module (4-3), and then sends the initial vector IV and the session key SK to the slave database decryption control module (4-3); the slave database ciphertext data interface module (4-2) receives the block ciphertext mirror image data sent by the slave database security mirror image authorization module (3-3) and forwards the block ciphertext mirror image data to the slave database decryption control module (4-3);
the slave database decryption control module (4-3) receives the block ciphertext mirror image data sent by the slave database security mirror image authorization module (3-3); meanwhile, the slave database decryption control module (4-3) generates and sends a decryption initial parameter request to the session key verification distribution module (4-1), then receives an initial vector IV and a session key SK which are sent by the session key verification distribution module (4-1), takes the session key SK as an initial key, performs AES decryption on the blocked ciphertext mirror image data by using the initial key and the initial vector IV based on a ciphertext block chaining mode CBC, and sends the generated blocked plaintext mirror image data to the slave database decryption restoration module (4-4); the slave database decryption reduction module (4-4) receives the block plaintext mirror image data sent from the database decryption control module (4-3), takes out the additional message authentication code for hash processing to identify the authenticity of the message authentication code, combines the block plaintext data into complete mirror image data and stores the complete mirror image data in the slave database to finish data synchronization.
The secure data mirror transmission flow of the present invention is shown in fig. 9:
firstly, a master database and a slave database perform secure mirror authorization; firstly, starting a database service, acquiring identity information of a slave database by a master database security mirror image authorization module (2-1) from a locally configured mirror image log file, and sending authorization request information and an authorization account number to a slave database security mirror image authorization module (3-3) through a TCP/IP transmission protocol based on a Socket according to the identity information of the slave database; and then receiving authorization response information sent from the database security mirror image authorization module (3-3) to complete mirror image authorization.
Secondly, carrying out encryption preprocessing on the complete mirror image data in the main database; after mirror image authorization, a main database user performs a DML operation on each pair of main databases, and sends the complete mirror image data (which are composed of SQL statements corresponding to a plurality of DML operations) to a main database encryption preprocessing module (1-1) as long as the operation is not a SELECT operation; the main database encryption preprocessing module (1-1) blocks the complete mirror image data based on a ciphertext block chaining mode CBC to form blocked plaintext data; generating a corresponding message authentication code for the block plaintext data through a hash function, and attaching the message authentication code to the block plaintext data to form block plaintext mirror image data; and then setting an initial vector IV, generating an initial key request, and sending the blocked plaintext mirror data, the initial vector IV and the initial key request to a master database encryption control module (1-2).
Thirdly, encrypting the partitioned plaintext mirror image data in the main database; the main database encryption control module (1-2) receives the blocked plaintext mirror data, the initial vector IV and the initial key request of the main database encryption preprocessing module (1-1), forwards the initial vector IV and the initial key request to the encryption and decryption parameter setting module (1-4), then receives the session key SK sent by the session key generation module (1-5) as the initial key, conducts AES encryption on the blocked plaintext mirror data by using the initial key and the initial vector IV based on a ciphertext block chaining mode CBC, and sends the generated blocked ciphertext mirror data to the main database ciphertext data interface module (1-3).
Fourthly, sending the block cipher text mirror image data in the master database to the slave database; the master database data security synchronization module (2-2) receives the block ciphertext mirror data sent by the master database security mirror authorization module (2-1), writes the block ciphertext mirror data into a master database mirror log file, and then sends the block ciphertext mirror data to a ciphertext data receiving module (3-1) where the slave database is located through the ciphertext data sending module (2-3).
The secure data image receiving flow of the present invention is shown in fig. 10:
firstly, performing security mirror image authorization on a slave database and a master database; the method comprises the steps that firstly, a database service is started, a slave database security mirror image authorization module (3-3) receives authorization request information and an authorization account number sent by a master database security mirror image authorization module (2-1), then authorization response information is sent to the master database security mirror image authorization module (2-1), mirror image authorization is completed, the cursor position of a slave database mirror image file is set according to the authorization request information, and the cursor position of the slave database mirror image file is sent to a slave database data security synchronization module (3-2).
Secondly, receiving the partitioned ciphertext mirror image data of the main database from the database; the ciphertext data receiving module (3-1) receives the partitioned ciphertext mirror image data sent by the ciphertext data sending module (2-3) and forwards the partitioned ciphertext mirror image data to the slave database data security synchronization module (3-2); the slave database data security synchronization module (3-2) receives the block ciphertext mirror image data sent by the ciphertext data receiving module (3-1), and writes the block ciphertext mirror image data into a slave database mirror image log file; meanwhile, the cursor position of the slave database mirror image file sent by the slave database security mirror image authorization module (3-3) is received, then the block cipher text mirror image data behind the cursor position in the slave database mirror image log file is taken out and sent to the slave database security mirror image authorization module (3-3), and finally the block cipher text mirror image data is forwarded to the slave database decryption control module (4-3).
Thirdly, decrypting the partitioned ciphertext mirror image data in the slave database; and a decryption initial parameter request is generated and sent to the session key verification distribution module (4-1) from the database decryption control module (4-3), then an initial vector IV and a session key SK which are sent by the session key verification distribution module (4-1) are received, the session key SK is used as an initial key, based on a ciphertext block chaining mode CBC, AES decryption is carried out on the blocked ciphertext mirror data by using the initial key and the initial vector IV, and the generated blocked plaintext mirror data is sent to the slave database decryption restoration module (4-4).
Fourthly, verifying the integrity of the partitioned plaintext mirror image data in the database and restoring the complete mirror image data; the block plaintext mirror image data sent from the database decryption control module (4-3) is received from the database decryption restoration module (4-4), an additional message authentication code is taken out for each block of block plaintext mirror image data based on a ciphertext block chaining mode CBC, hash processing is carried out to identify the authenticity of the message authentication code, the block plaintext data are combined into complete mirror image data (SQL sentences), the corresponding SQL sentences are executed by the database, mirror image transmission is completed, and data synchronization is achieved.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention in any way, but any modifications or equivalent variations made according to the technical spirit of the present invention are within the scope of the present invention as claimed.