Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present 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.
Fig. 1 is a flowchart of a first embodiment of a method for identifying authenticity of data of a WEB service according to the present invention, and as shown in fig. 1, an execution subject of the present invention is a service end of the WEB service, and may be specifically installed on a computer, a server, or other devices. The data authenticity identification method for the WEB service provided by the embodiment comprises the following steps:
step 101, receiving a request for calling the WEB service sent by a client of the WEB service, wherein the calling request carries identification information of the WEB service.
In this embodiment, if a client of a WEB service needs to obtain service content data from a server of the WEB service and needs to send a service invocation request to the server of the WEB service, the server of the WEB service receives the invocation request of the WEB service sent by the client of the WEB service, the invocation request carries identification information of the WEB service, and the identification information of the WEB service may be information that uniquely identifies the WEB service, such as a name of the WEB service or an access address of a WSDL file corresponding to the WEB service.
In this embodiment, communication between a server of a WEB service and a client of the WEB service complies with the SOAP protocol. During data transmission, the transmitted data is encapsulated into an XML format, and SOAP header information is added into the encapsulated data. Format information of data and the like may be included in the SOAP header information.
And 102, acquiring service content data to be sent of the corresponding WEB service according to the identification information of the WEB service.
In this embodiment, according to the identification information of the WEB service, the client service content data of the corresponding WEB service, which needs to be sent to the WEB service, is acquired at the corresponding storage location.
Step 103, generating a first encrypted ciphertext according to the random number and the service content data to be sent, and adding the random number and the first encrypted ciphertext into the SOAP header information.
In this embodiment, a random number is randomly generated, and a first encryption ciphertext is generated by using an encryption algorithm according to the random number and service content data to be transmitted.
In this embodiment, the random number and the service content data to be sent are used as input data, and after being encrypted by the encryption algorithm, the first encrypted ciphertext is matched with the random number and the service content data to be sent, that is, for the encryption algorithm, if a plaintext to be encrypted is determined, the encrypted ciphertext is unique.
In this embodiment, after the first encrypted ciphertext is obtained, the random number and the first encrypted ciphertext are associated and added to the SOAP header information.
And 104, sending the service content data to be sent added with the SOAP header information to the client of the WEB service, so that the client of the WEB service generates a second encrypted ciphertext according to the random number in the SOAP header information and the received service content data, and identifying the authenticity of the received service content data.
Specifically, in this embodiment, the to-be-transmitted service content data added with the SOAP header information is transmitted to the client of the WEB service, so that the client of the WEB service generates a second encrypted ciphertext according to the random number in the SOAP header information and the received service content data by using the same encryption algorithm as that used for generating the first encrypted ciphertext, compares the first encrypted ciphertext with the second encrypted ciphertext, identifies whether the received service content data is the to-be-transmitted service content data according to a comparison result, if the received service content data is identified to be the same as the to-be-transmitted service content data, it is determined that the received service content data is real data, and if the received service content data is identified to be different from the to-be-transmitted service content data, it is determined that the received service content data is data tampered by an attacker.
In the data authenticity identification method for the WEB service provided by this embodiment, a call request of the WEB service sent by a client of the WEB service is received, and the call request carries identification information of the WEB service; acquiring service content data to be sent of the corresponding WEB service according to the identification information of the WEB service; generating a first encrypted ciphertext according to the random number and service content data to be sent, and adding the random number and the first encrypted ciphertext into SOAP header information; and sending the service content data to be sent added with the SOAP header information to the client of the WEB service so that the client of the WEB service generates a second encrypted ciphertext according to the random number in the SOAP header information and the received service content data to identify the authenticity of the received service content data, thereby realizing the authenticity identification of the service content data transmitted between the WEB service end and the client and protecting the system safety of the client of the WEB service.
Further, in the method for identifying data authenticity of a WEB service provided in this embodiment, in step 103, a first encryption ciphertext is generated according to the random number and the service content data to be sent, which specifically includes:
firstly, the random number and service content data to be sent are spliced according to a preset rule to generate a first encrypted plaintext.
In this embodiment, the preset rule may be that the random number is spliced at the front end of the service content data to be sent, or the random number is spliced at the rear end of the service content data to be sent, or the length of the service content data is calculated, and the random number is spliced at the middle part of the service content data to be sent, or the random number is spliced at a specific position in the service content data to be sent, or other preset rules, and the preset rule is not limited in this embodiment.
The first encrypted plaintext is then encrypted using the MD5 encryption algorithm to generate a first encrypted ciphertext.
In this embodiment, since the MD5 encryption algorithm is specific to the same encrypted plaintext, and the encrypted ciphertext is unique, the MD5 encryption algorithm is used to encrypt the first encrypted plaintext. If an attacker intercepts the service content data being sent and tampers the service content data being sent, the random number and the tampered service content data are spliced according to a preset rule, and an encrypted plaintext generated after being encrypted by the MD5 encryption algorithm is different from the first encrypted ciphertext so as to identify the authenticity of the service content data.
In this embodiment, when generating a first encrypted ciphertext according to a random number and service content data to be transmitted, the random number and the service content data to be transmitted are first spliced according to a preset rule to generate a first encrypted plaintext; and then, the MD5 encryption algorithm is adopted to encrypt the first encrypted plaintext to generate a first encrypted ciphertext, and as the preset rule for splicing the random number and the service content data to be sent cannot be acquired by an attacker, the difficulty of the attacker in tampering the service content data is increased, and the client of the WEB service can more accurately identify whether the received service content data is real data.
Preferably, before step 103, the method for identifying data authenticity for a WEB service provided in this embodiment further includes:
first, it is determined whether service content data to be transmitted is confidential data.
In this embodiment, in order to protect important service content data to be sent from being stolen by an attacker, it is necessary to determine whether the service content data to be sent is confidential data.
In this embodiment, whether the service content data to be sent is confidential data can be determined according to a predefined tag.
And then, if the service content data to be transmitted is confidential data, encrypting the service content data to be transmitted by adopting a symmetric encryption algorithm.
In this embodiment, the adopted symmetric encryption algorithm may be a DES algorithm, an enhanced DES algorithm, or the like. After the service content data to be sent is encrypted by adopting a symmetric encryption algorithm, the symmetric encryption algorithm and the key can be acquired by a client of the WEB service.
In this embodiment, after the service content data to be sent is encrypted by using the symmetric encryption algorithm, the service content data to be sent in step 103 and step 104 is the encrypted service content data to be sent. In step 103, a first encrypted ciphertext is generated from the random number and the encrypted service content data to be sent, and the random number and the first encrypted ciphertext are added to the SOAP header information. In step 104, the encrypted service content data to be sent added with the SOAP header information is sent to the WEB service client, so that the WEB service client generates a second encrypted ciphertext according to the random number in the SOAP header information and the received encrypted service content data, so as to identify the authenticity of the received service content data, and when the received encrypted service content data is identified as the encrypted service content data to be sent, the received encrypted service content data is decrypted by using a decryption algorithm corresponding to the symmetric encryption algorithm, so as to obtain the real decrypted service content data.
In this embodiment, before generating a first encrypted ciphertext according to the random number and the service content data to be sent, it is determined whether the service content data to be sent is confidential data; and if the service content data to be transmitted is confidential data, encrypting the service content data to be transmitted by adopting a symmetric encryption algorithm. Because the service content data is transmitted in the form of encrypted ciphertext, the transmitted service content data can be effectively protected.
Fig. 2 is a flowchart of a second embodiment of the data authenticity identification method for WEB services according to the present invention, and as shown in fig. 2, an execution subject of the present invention is a client of a WEB service, which may be specifically installed on a computer, a server or other devices. The data authenticity identification method for the WEB service provided by the embodiment comprises the following steps:
step 201, sending a request for invoking the WEB service to a service end of the WEB service, where the request carries identification information of the WEB service.
In this embodiment, the identification information of the WEB service may be information that uniquely identifies the WEB service, such as a name of the WEB service or an access address of a WSDL file corresponding to the WEB service.
In this embodiment, a request for invoking a WEB service is sent to a server of the WEB service, where the request carries identification information of the WEB service, so that the server of the WEB service obtains service content data to be sent of the corresponding WEB service according to the identification information of the WEB service, generates a first encryption ciphertext according to a random number and the service content data to be sent, and adds the random number and the first encryption ciphertext to SOAP header information.
Step 202, receiving service content data to be sent, which is sent by a service end of the WEB service and added with SOAP header information, where the SOAP header information carries a random number and a first encrypted ciphertext, and the first encrypted ciphertext is generated according to the random number and the service content data to be sent.
In this embodiment, since the attacker only attacks the transmitted service content data, but does not attack the random number and the first encryption ciphertext in the SOAP header information, the random number and the first encryption ciphertext carried in the SOAP header information received by the client of the WEB service are the same as the random number and the first encryption ciphertext carried in the SOAP header information sent by the WEB service and the random number and the first encryption ciphertext carried in the SOAP header information sent by the WEB service.
Specifically, the first encrypted ciphertext is generated by encrypting according to the random number and the service content data to be sent by using an encryption algorithm.
Step 203, generating a second encrypted ciphertext according to the random number in the SOAP header and the received service content data.
In this embodiment, a second encrypted ciphertext is generated by using an encryption algorithm according to the random number in the SOAP header and the received service content data. In this embodiment, the encryption algorithm used for generating the second encrypted ciphertext is the same as the encryption algorithm used for generating the first encrypted ciphertext. After the encryption plaintext is determined, the encryption ciphertext is unique after encryption.
And step 204, comparing the first encrypted ciphertext with the second encrypted ciphertext, and identifying the authenticity of the received service content data according to the comparison result.
In this embodiment, since the random numbers input to generate the first encrypted ciphertext and the second encrypted ciphertext are the same, the encryption algorithms used are the same, therefore, if the service content data to be transmitted is the same as the received service content data, after comparing the first encrypted ciphertext with the second encrypted ciphertext, the first encrypted ciphertext and the second encrypted ciphertext are the same, the received service content data is determined to be the service content data to be sent, which indicates that the service content data is not falsified and is real service content data, if the service content data to be sent is different from the received service content data, and after the first encrypted ciphertext is compared with the second encrypted ciphertext, the first encrypted ciphertext is different from the second encrypted ciphertext, and the received service content data is determined to be the data obtained by tampering the service content data to be sent and is false service content data.
In the data authenticity identification method for the WEB service provided by this embodiment, a call request of the WEB service is sent to a service end of the WEB service, and the call request carries identification information of the WEB service; receiving service content data to be sent, which is added with SOAP header information and sent by a service end of the WEB service, wherein the SOAP header information carries a random number and a first encrypted ciphertext, and the first encrypted ciphertext is generated according to the random number and the service content data to be sent; generating a second encrypted ciphertext according to the random number in the SOAP header information and the received service content data; and comparing the first encrypted ciphertext with the second encrypted ciphertext, and identifying the authenticity of the received service content data according to the comparison result. The method and the system realize the authenticity identification of the service content data transmitted between the WEB service terminal and the client terminal, and protect the system safety of the client terminal of the WEB service.
Further, the method for identifying data authenticity of a WEB service provided in this embodiment generates, in step 203, a second encrypted ciphertext according to the random number in the SOAP header and the received service content data, and specifically includes:
firstly, the random number and the received service content data are spliced according to a preset rule to generate a second encrypted plaintext.
In this embodiment, the preset rule according to which the random number and the received service content data are spliced is the same as the preset rule according to which the random number and the service content data to be transmitted are spliced. For example, the preset rule may be to splice a random number at the front end of the received service content data, or splice a random number at the back end of the received service content data, or calculate the length of the received service content data, splice a random number at the middle of the received service content data, or splice a random number at a specific position in the received service content data, or other preset rules, which is not limited in this embodiment.
The second encrypted plaintext is then encrypted using the MD5 encryption algorithm to generate a second encrypted ciphertext.
In this embodiment, since the MD5 encryption algorithm is used for the first encrypted ciphertext, the MD5 encryption algorithm is also used to generate the second encrypted ciphertext when encrypting the second encrypted plaintext. In this embodiment, under the condition that the second encrypted plaintext is determined, the MD5 encryption algorithm is adopted to encrypt the second encrypted plaintext, and the obtained second encrypted ciphertext is unique.
In this embodiment, when a second encrypted ciphertext is generated according to the random number in the SOAP header information and the received service content data, the random number and the received service content data are first spliced according to a preset rule to generate a second encrypted plaintext; and then, the MD5 encryption algorithm is adopted to encrypt the second encrypted plaintext to generate a second encrypted ciphertext, and the preset rule for splicing the random number and the received service content data cannot be acquired by an attacker, so that the difficulty of the attacker in tampering the service content data is increased, and the client of the WEB service can more accurately identify whether the received service content data is real data.
Preferably, after step 204, the method for identifying data authenticity of a WEB service provided in this embodiment further includes:
first, if it is determined that the received service content data is service content data to be transmitted, it is determined whether the received service content data is confidential data.
In this embodiment, if it is determined that the received service content data is service content data to be sent, it indicates that the received service content data is not tampered with and is usable as real data. It is determined whether the received service content data is confidential data according to the tag of the received service content data. In this embodiment, the tag of the service content data may be searched in the SOAP header information.
Then, if the received service content data is confidential data, the received service content data is decrypted by using a decryption algorithm corresponding to the symmetric encryption algorithm.
In this embodiment, if it is determined that the received service content data is confidential data, the received service content data is decrypted by using a decryption algorithm corresponding to the symmetric encryption algorithm, and a key required in the decryption process and the decryption algorithm corresponding to the symmetric encryption algorithm are acquired from a service end of the WEB service in advance.
In this embodiment, after comparing the first encrypted ciphertext with the second encrypted ciphertext and identifying the authenticity of the received service content data according to the comparison result, if it is determined that the received service content data is service content data to be transmitted, it is determined whether the received service content data is confidential data; and if the received service content data is confidential data, decrypting the received service content data by adopting a decryption algorithm corresponding to the symmetric encryption algorithm. Since the service content data is transmitted in the form of encrypted ciphertext, the transmitted service content data can be effectively protected.
Fig. 3 is a flowchart of a third embodiment of the method for identifying data authenticity of a WEB service according to the present invention, and as shown in fig. 3, the method for identifying data authenticity of a WEB service according to the present embodiment includes:
step 301, the client of the WEB service sends a request for calling the WEB service to the server of the WEB service, and the calling request carries identification information of the WEB service.
In this embodiment, the client of the WEB service may be a client installed on a computer, a server, or other devices. Such as a WEB service client installed on a mall POS. The service end of the WEB service can be a service end installed on a computer, a server or other equipment, such as a service end of a WEB service installed on a bank server.
In this embodiment, a client of a WEB service sends a call request of the WEB service to a server of the WEB service, where the call request carries identification information of the WEB service, and for example, the identification information of the WEB service carried by the call request is identification information of a transfer service.
Step 302, the service end of the WEB service acquires the service content data to be sent of the corresponding WEB service according to the identification information of the WEB service.
In this embodiment, according to the identification information of the WEB service, the client service content data of the corresponding WEB service, which needs to be sent to the WEB service, is acquired at the corresponding storage location.
In step 303, the service end of the WEB service determines whether the service content data to be sent is confidential data, if so, step 304 is executed, otherwise, step 305 is executed.
In this embodiment, the service end of the WEB service may determine whether the service content data is confidential data according to a preset tag of the service content data.
And step 304, the service end of the WEB service encrypts the service content data to be sent by adopting a symmetric encryption algorithm.
In this embodiment, the adopted symmetric encryption algorithm may be a DES algorithm, an enhanced DES algorithm, and the like, which is not limited in this embodiment.
In this embodiment, step 305 is performed after step 304 is performed.
Step 305, the server side of the WEB service generates a random number, and splices the random number and the encrypted or unencrypted service content data to be sent according to a preset rule to generate a first encrypted plaintext.
In this embodiment, if the service content data to be sent is confidential data, the random number and the encrypted service content data to be sent are spliced according to a preset rule to generate a first encrypted plaintext. And if the service content data to be sent is not confidential data, directly splicing the random number and the unencrypted service content data to be sent according to a preset rule to generate a first encrypted plaintext.
Step 306, the server side of the WEB service encrypts the first encrypted plaintext by using the MD5 encryption algorithm to generate a first encrypted ciphertext, and adds the random number and the first encrypted ciphertext to the SOAP header information.
In this embodiment, a tag indicating whether the service content data to be transmitted is confidential data may also be added to the SOAP header information.
Step 307, the server of the WEB service sends the encrypted or unencrypted service content data to be sent, added with the SOAP header information, to the client of the WEB service.
Step 308, the client of the WEB service splices the random number in the SOAP header information and the received encrypted or unencrypted service content data according to a preset rule to generate a second encrypted plaintext.
In this embodiment, the preset rule according to which the random number in the SOAP header information is spliced with the received encrypted or unencrypted service content data is the same as the preset rule according to which the first encrypted plaintext is generated.
In step 309, the client of the WEB service encrypts the second encrypted plaintext by using the MD5 encryption algorithm to generate a second encrypted ciphertext.
And step 310, the client of the WEB service compares the first encrypted ciphertext with the second encrypted ciphertext, and identifies the authenticity of the received service content data according to the comparison result.
In this embodiment, the first encrypted ciphertext and the second encrypted ciphertext are compared, and if the comparison result is that the first encrypted ciphertext is the same as the second encrypted ciphertext, the received service content data is determined to be service content data to be sent; and if the comparison result shows that the first encrypted ciphertext is different from the second encrypted ciphertext, determining the received service content data as data obtained by tampering the service content data to be sent.
In step 311, if the client of the WEB service determines that the received service content data is the service content data to be transmitted, it determines whether the received service content data is confidential data, and if so, executes step 312. If not, the process is ended.
In this embodiment, the client of the WEB service may determine whether the received service content data is confidential data according to a tag indicating whether the service content data is confidential data in the SOAP header information.
In step 312, the client of the WEB service decrypts the received service content data by using the decryption algorithm corresponding to the symmetric encryption algorithm.
In this embodiment, the client of the WEB service obtains the symmetric encryption algorithm and the encryption key in advance, and decrypts the received service content data by using the decryption algorithm corresponding to the symmetric encryption algorithm.
Fig. 4 is a schematic structural diagram of a first service end of the WEB service according to the present invention, and as shown in fig. 4, the service end of the WEB service provided in this embodiment includes: a first receiving module 401, an obtaining module 402, a first generating module 403, an adding module 404 and a first sending module 405.
The first receiving module 401 is configured to receive a call request of a WEB service sent by a client of the WEB service, where the call request carries identification information of the WEB service. An obtaining module 402, configured to obtain, according to the identification information of the WEB service, service content data to be sent of the corresponding WEB service. A first generating module 403, configured to generate a first encrypted ciphertext according to the random number and the service content data to be sent. An adding module 404, configured to add the random number and the first encrypted ciphertext to a SOAP header. A first sending module 405, configured to send the service content data to be sent, which is added with the SOAP header information, to the client of the WEB service, so that the client of the WEB service generates a second encrypted ciphertext according to the random number in the SOAP header information and the received service content data, so as to identify whether the received service content data is true or false.
The server of the WEB service provided in this embodiment may execute the technical solution of the method embodiment shown in fig. 1, and the implementation principle and the technical effect are similar, which are not described herein again.
Further, the first generating module 403 is specifically configured to: splicing the random number and the service content data to be sent according to a preset rule to generate a first encrypted plaintext; and encrypting the first encrypted plaintext by using an MD5 encryption algorithm to generate a first encrypted ciphertext.
Preferably, as shown in fig. 4, the service end of the WEB service provided in this embodiment further includes: a first judgment module 406 and an encryption module 407.
The first determining module 406 is configured to determine whether the service content data to be sent is confidential data before the first generating module 403 generates a first encrypted ciphertext according to the random number and the service content data to be sent; the encryption module 407 is configured to encrypt the service content data to be sent by using a symmetric encryption algorithm if the service content data to be sent is confidential data.
Further, the service end of the WEB service provided in this embodiment may execute the technical solution of the method embodiment shown in fig. 3, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 5 is a schematic structural diagram of a first embodiment of a WEB service client according to the present invention, and as shown in fig. 5, the WEB service client provided in this embodiment includes: a second sending module 501, a second receiving module 502, a second generating module 503 and an identifying module 504.
The second sending module 501 is configured to send a request for invoking a WEB service to a service end of the WEB service, where the request carries identification information of the WEB service. A second receiving module 502, configured to receive service content data to be sent, which is sent by a service end of the WEB service and is added with SOAP header information, where the SOAP header information carries a random number and a first encrypted ciphertext, and the first encrypted ciphertext is generated according to the random number and the service content data to be sent. A second generating module 503, configured to generate a second encrypted ciphertext according to the random number in the SOAP header and the received service content data. An identifying module 504, configured to compare the first encrypted ciphertext with the second encrypted ciphertext, and identify whether the received service content data is true or false according to a comparison result.
The client of the WEB service provided in this embodiment may execute the technical solution of the method embodiment shown in fig. 2, and the implementation principle and the technical effect are similar, which are not described herein again.
Further, the second generating module 503 is specifically configured to: splicing the random number and the received service content data according to a preset rule to generate a second encrypted plaintext; and encrypting the second encrypted plaintext by using an MD5 encryption algorithm to generate a second encrypted ciphertext.
Further, the identifying module 504 is specifically configured to: comparing the first encrypted ciphertext with the second encrypted ciphertext, and if the comparison result shows that the first encrypted ciphertext is the same as the second encrypted ciphertext, determining that the received service content data is service content data to be sent; and if the comparison result shows that the first encrypted ciphertext is different from the second encrypted ciphertext, determining the received service content data as data obtained by tampering the service content data to be sent.
Preferably, as shown in fig. 5, the client of the WEB service provided in this embodiment further includes: a second determination module 505 and a decryption module 506.
The second determining module 505 is configured to compare the first encrypted ciphertext with the second encrypted ciphertext, identify whether the received service content data is to-be-sent service content data according to a comparison result, and determine whether the received service content data is confidential data if it is determined that the received service content data is to-be-sent service content data. A decryption module 506, configured to decrypt the received service content data by using a decryption algorithm corresponding to a symmetric encryption algorithm if the received service content data is confidential data.
Further, the client of the WEB service provided in this embodiment may execute the technical solution of the method embodiment shown in fig. 3, and the implementation principle and the technical effect are similar, which are not described herein again.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.