CN110166226A - A kind of method and apparatus generating code key - Google Patents
A kind of method and apparatus generating code key Download PDFInfo
- Publication number
- CN110166226A CN110166226A CN201810145432.XA CN201810145432A CN110166226A CN 110166226 A CN110166226 A CN 110166226A CN 201810145432 A CN201810145432 A CN 201810145432A CN 110166226 A CN110166226 A CN 110166226A
- Authority
- CN
- China
- Prior art keywords
- server
- key
- certificate
- public key
- code key
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/06—Network architectures or network communication protocols for network security for supporting key management in a packet data network
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/12—Applying verification of the received information
- H04L63/126—Applying verification of the received information the source of the received data
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0816—Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
- H04L9/0819—Key transport or distribution, i.e. key establishment techniques where one party creates or otherwise obtains a secret value, and securely transfers it to the other(s)
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0816—Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
- H04L9/0819—Key transport or distribution, i.e. key establishment techniques where one party creates or otherwise obtains a secret value, and securely transfers it to the other(s)
- H04L9/0822—Key transport or distribution, i.e. key establishment techniques where one party creates or otherwise obtains a secret value, and securely transfers it to the other(s) using key encryption key
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0861—Generation of secret information including derivation or calculation of cryptographic keys or passwords
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/32—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
- H04L9/3263—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving certificates, e.g. public key certificate [PKC] or attribute certificate [AC]; Public key infrastructure [PKI] arrangements
- H04L9/3268—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving certificates, e.g. public key certificate [PKC] or attribute certificate [AC]; Public key infrastructure [PKI] arrangements using certificate validation, registration, distribution or revocation, e.g. certificate revocation list [CRL]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Hardware Design (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Storage Device Security (AREA)
Abstract
本发明公开了一种生成秘钥的方法和装置,涉及计算机技术领域。该方法的一具体实施方式包括:第一服务器将包含自身第一公钥的第一安全信息发送给第二服务器之后,接收到由第二服务器返回的第二秘钥,其中,第二秘钥是由第二服务器对第一安全信息进行验证,并在验证通过之后,由第二服务器利用第一公钥生成的;第一服务器在接收到由第二服务器发送的包含第二公钥的第二安全信息之后,对第二安全信息进行验证,并在验证通过之后,利用第二公钥生成第一服务器的第一秘钥。该实施方式提高了生成秘钥时的安全可靠性,有效的防止了第三方设备的攻击和窃听。
The invention discloses a method and a device for generating a secret key, and relates to the technical field of computers. A specific implementation of the method includes: after the first server sends the first security information including its own first public key to the second server, and then receives the second secret key returned by the second server, wherein the second secret key The first security information is verified by the second server, and is generated by the second server using the first public key after the verification is passed; the first server receives the second public key containing the second public key sent by the second server. After receiving the security information, verify the second security information, and use the second public key to generate the first secret key of the first server after the verification is passed. This embodiment improves the security reliability when generating the secret key, and effectively prevents attacks and eavesdropping by third-party devices.
Description
技术领域technical field
本发明涉及计算机技术领域,尤其涉及一种生成秘钥的方法和装置。The present invention relates to the field of computer technology, in particular to a method and device for generating a secret key.
背景技术Background technique
密钥交换,是一种用以获得认证密钥的协议。Key exchange is a protocol for obtaining authentication keys.
现有技术中所使用的密钥交换方式以ECDH密钥交换算法为主,具体的,如图1所示,用Master和Slave标识通信双方,流程如下:The key exchange method used in the prior art is based on the ECDH key exchange algorithm. Specifically, as shown in Figure 1, Master and Slave are used to identify the communication parties, and the process is as follows:
1、(A1)Master与slave建立通信连接,双方各自生成自己的publickey与priviatekey。1. (A1) The master establishes a communication connection with the slave, and both parties generate their own publickey and privatekey.
2、(A2)Master将自己的publickey_m写入到Slave中。2. (A2) Master writes its own publickey_m into Slave.
3、(A3)Slave收到publickey_m后,用publickey_m与priviatekey_s生成sharekey,并返回确认结果给Master。3. (A3) After receiving publickey_m, Slave uses publickey_m and privatekey_s to generate a sharekey, and returns the confirmation result to Master.
4、(A4)Macter发送读取指令,获取slave端公钥publickey_s。4. (A4) Macter sends a read command to obtain the slave public key publickey_s.
5、(A5)Slave将自己的公钥publickey_s返回给Master,Master收到Slave的公钥后生成sharekey。5. (A5) Slave returns its own public key publickey_s to Master, and Master generates sharekey after receiving Slave's public key.
6、(A6)双方用各自生成的sharekey进行加密数据通信。6. (A6) Both parties use their generated sharekeys for encrypted data communication.
在实现本发明过程中,发明人发现现有技术中至少存在如下问题:In the course of realizing the present invention, the inventor finds that there are at least the following problems in the prior art:
现有技术中的密钥交换的方式不能够抵御中间人的攻击,具体的,如图2所示,Attaker对Master扮演Slave,Attaker对Slave扮演Master。因此,攻击后的流程如下:The way of key exchange in the prior art cannot resist man-in-the-middle attacks. Specifically, as shown in FIG. 2 , the Attaker acts as the Slave to the Master, and the Attaker acts as the Master to the Slave. Therefore, the flow after the attack is as follows:
1、Master与Attacker建立通信连接,Attacker与Slave建立通信连接,Master、Attacker、Slave各自生成自己的publickey与priviatekey。1. The Master establishes a communication connection with the Attacker, and the Attacker establishes a communication connection with the Slave. The Master, Attacker, and Slave each generate their own publickey and privatekey.
2、Master将自己的publickey_m写入到Attacker中(此时,Master判定是写入到了Slave中)。2. The Master writes its own publickey_m into the Attacker (at this time, the Master judges that it is written into the Slave).
3、Attacker收到publickey_m后,用publickey_m与priviatekey_a生成sharekey_am,并返回确认结果给Master。3. After receiving publickey_m, Attacker uses publickey_m and privatekey_a to generate sharekey_am, and returns the confirmation result to Master.
4、Attacker将自己的publickey_a写入到Slave中(此时,Slave判定接收到了Master的公钥)。4. The Attacker writes its own publickey_a into the Slave (at this time, the Slave determines that it has received the Master's public key).
5、Slave收到publickey_a后,用publickey_a与priviatekey_s生成sharekey_sa,并返回确认结果给Attacker。5. After receiving publickey_a, Slave uses publickey_a and privatekey_s to generate sharekey_sa, and returns the confirmation result to Attacker.
6、Macter发送读取指令,获取Attacker端的公钥publickey_a。6. Macter sends a read command to obtain the public key publickey_a of the Attacker.
7、Attacker将自己的公钥publickey_a返回给Master,Master收到Attacker的公钥后生成sharekey_ma。7. Attacker returns its public key publickey_a to Master, and Master generates sharekey_ma after receiving Attacker's public key.
8、Attacker发送读取指令,获取Slave端公钥publickey_s。8. The Attacker sends a read command to obtain the public key publickey_s of the Slave.
9、Attacker使用Slave端的公钥publickey_s和自己的私钥生成共享密钥sharekey_as。9. The Attacker uses the public key publickey_s on the Slave side and its own private key to generate a shared key sharekey_as.
10、Master和Attacker使用sharekey_ma(等于sharekey_am)进行通信;Attacker和Slave使用sharekey_as(等于sharekey_sa)进行通信。10. Master and Attacker use sharekey_ma (equal to sharekey_am) to communicate; Attacker and Slave use sharekey_as (equal to sharekey_sa) to communicate.
这时,Master和Slave之间的通信内容就全部被Attacker获知了。At this time, the content of the communication between the Master and the Slave is all known by the Attacker.
因此,如何提高生成密钥时的安全可靠性显得尤为重要。Therefore, how to improve the security and reliability of key generation is particularly important.
发明内容Contents of the invention
有鉴于此,本发明实施例提供一种生成秘钥的方法和装置,能够提高生成密钥时的安全可靠性。In view of this, embodiments of the present invention provide a method and device for generating a secret key, which can improve the security and reliability of key generation.
为实现上述目的,根据本发明实施例的一个方面,提供了一种生成秘钥的方法。To achieve the above purpose, according to an aspect of the embodiments of the present invention, a method for generating a secret key is provided.
本发明实施的一种生成秘钥的方法包括:第一服务器将包含自身第一公钥的第一安全信息发送给第二服务器之后,接收到由第二服务器返回的第二秘钥,其中,第二秘钥是由第二服务器对第一安全信息进行验证,并在验证通过之后,由第二服务器利用第一公钥生成的;第一服务器在接收到由第二服务器发送的包含第二公钥的第二安全信息之后,对第二安全信息进行验证,并在验证通过之后,利用第二公钥生成第一服务器的第一秘钥。A method for generating a secret key implemented in the present invention includes: after the first server sends the first security information including its own first public key to the second server, and then receives the second secret key returned by the second server, wherein, The second secret key is verified by the second server on the first security information, and after the verification is passed, it is generated by the second server using the first public key; After receiving the second security information of the public key, the second security information is verified, and after the verification is passed, the second public key is used to generate the first secret key of the first server.
在本发明的另一实施方式中,第一服务器将第一公钥和第一服务器的第一身份信息发送给证书中心,由证书中心使用证书中心的证书私钥生成第一证书,并将第一证书返回给第一服务器,然后第一服务器将第一公钥和第一证书组成第一安全信息;第二服务器将第二公钥和第二服务器的第二身份信息发送给证书中心,由证书中心使用证书私钥生成第二证书,并将第二证书返回给第二服务器,然后第二服务器将第二公钥和第二证书组成第二安全信息。In another embodiment of the present invention, the first server sends the first public key and the first identity information of the first server to the certificate center, and the certificate center uses the certificate private key of the certificate center to generate the first certificate, and sends the second A certificate is returned to the first server, and then the first server forms the first security information with the first public key and the first certificate; the second server sends the second public key and the second identity information of the second server to the certificate center, and the The certificate center uses the private key of the certificate to generate the second certificate, and returns the second certificate to the second server, and then the second server forms the second security information with the second public key and the second certificate.
在本发明的另一实施方式中,由第二服务器对第一安全信息进行验证,并在验证通过之后,由第二服务器利用第一公钥生成第二秘钥的步骤包括:由第二服务器利用证书中心的证书公钥对第一安全信息中的第一证书进行验证,在验证通过的情况下,判定第一安全信息中的第一公钥来自第一服务器,然后利用第一公钥生成第二秘钥;对第二安全信息进行验证,并在验证通过之后,利用第二公钥生成第一服务器的第一秘钥的步骤包括:第一服务器利用证书公钥对第二安全信息中的第二证书进行验证,在验证通过的情况下,判定第二安全信息中的第二公钥来自第二服务器,然后利用第二公钥生成第一秘钥。In another embodiment of the present invention, the first security information is verified by the second server, and after the verification is passed, the step of generating the second secret key by the second server using the first public key includes: by the second server Use the certificate public key of the certificate center to verify the first certificate in the first security information. If the verification is passed, it is determined that the first public key in the first security information comes from the first server, and then use the first public key to generate Second secret key; verify the second security information, and after the verification is passed, the step of using the second public key to generate the first secret key of the first server includes: the first server uses the certificate public key to verify the second security information The second certificate is verified, and if the verification is passed, it is determined that the second public key in the second security information is from the second server, and then the second public key is used to generate the first secret key.
在本发明的另一实施方式中,第一服务器在生成第一秘钥之后,根据预设算法对第一秘钥进行加密处理,以得到第一服务器的第一加密秘钥;第二服务器在生成第二秘钥之后,根据预设算法对第二秘钥进行加密处理,以得到第二服务器的第二加密秘钥。In another embodiment of the present invention, after the first server generates the first key, it encrypts the first key according to a preset algorithm to obtain the first encryption key of the first server; After the second key is generated, the second key is encrypted according to a preset algorithm to obtain a second encryption key of the second server.
在本发明的另一实施方式中,根据预设算法对第一秘钥进行加密处理的步骤包括:将第一秘钥循环左移三个比特,然后将左移之后的第一秘钥与预设字符串进行逻辑与的处理,以得到第一加密秘钥;根据预设算法对第二秘钥进行加密处理的步骤包括:将第二秘钥循环左移三个比特,然后将左移之后的第二秘钥与预设的字符串进行逻辑与的处理,以得到第二加密秘钥。In another embodiment of the present invention, the step of encrypting the first secret key according to a preset algorithm includes: cyclically shifting the first secret key to the left by three bits, and then combining the left-shifted first secret key with the preset Let the character string be logically ANDed to obtain the first encryption key; the step of encrypting the second key according to the preset algorithm includes: shifting the second secret key to the left by three bits, and then shifting the left key The second secret key and the preset character string are logically ANDed to obtain the second encryption key.
为实现上述目的,根据本发明实施例的另一方面,提供了一种生成秘钥的装置。To achieve the above purpose, according to another aspect of the embodiments of the present invention, a device for generating a secret key is provided.
本发明实施例的一种生成秘钥的装置包括:第一生成模块,用于将包含自身第一公钥的第一安全信息发送给第二服务器之后,接收到由第二服务器返回的第二秘钥,其中,第二秘钥是由第二服务器对第一安全信息进行验证,并在验证通过之后,由第二服务器利用第一公钥生成的;第二生成模块,用于在接收到由第二服务器发送的包含第二公钥的第二安全信息之后,对第二安全信息进行验证,并在验证通过之后,利用第二公钥生成第一服务器的第一秘钥。An apparatus for generating a secret key according to an embodiment of the present invention includes: a first generating module, configured to receive the second security information returned by the second server after sending the first security information including its own first public key to the second server. A secret key, wherein the second secret key is verified by the second server on the first security information, and is generated by the second server using the first public key after the verification is passed; the second generating module is configured to receive After the second security information including the second public key is sent by the second server, the second security information is verified, and after the verification is passed, the second public key is used to generate the first secret key of the first server.
在本发明的另一实施方式中,第一服务器将第一公钥和第一服务器的第一身份信息发送给证书中心,由证书中心使用证书中心的证书私钥生成第一证书,并将第一证书返回给第一服务器,然后第一服务器将第一公钥和第一证书组成第一安全信息;第二服务器将第二公钥和第二服务器的第二身份信息发送给证书中心,由证书中心使用证书私钥生成第二证书,并将第二证书返回给第二服务器,然后第二服务器将第二公钥和第二证书组成第二安全信息。In another embodiment of the present invention, the first server sends the first public key and the first identity information of the first server to the certificate center, and the certificate center uses the certificate private key of the certificate center to generate the first certificate, and sends the second A certificate is returned to the first server, and then the first server forms the first security information with the first public key and the first certificate; the second server sends the second public key and the second identity information of the second server to the certificate center, and the The certificate center uses the private key of the certificate to generate the second certificate, and returns the second certificate to the second server, and then the second server forms the second security information with the second public key and the second certificate.
在本发明的另一实施方式中,第一生成模块还用于:由第二服务器利用证书中心的证书公钥对第一安全信息中的第一证书进行验证,在验证通过的情况下,判定第一安全信息中的第一公钥来自第一服务器,然后利用第一公钥生成第二秘钥;第二生成模块还用于:第一服务器利用证书公钥对第二安全信息中的第二证书进行验证,在验证通过的情况下,判定第二安全信息中的第二公钥来自第二服务器,然后利用第二公钥生成第一秘钥。In another embodiment of the present invention, the first generation module is also used for: the second server uses the certificate public key of the certificate center to verify the first certificate in the first security information, and if the verification is passed, determine The first public key in the first security information comes from the first server, and then uses the first public key to generate the second secret key; the second generating module is also used for: the first server uses the certificate public key to verify the first public key in the second security information The second certificate is verified, and if the verification is passed, it is determined that the second public key in the second security information is from the second server, and then the second public key is used to generate the first secret key.
在本发明的另一实施方式中,第一服务器在生成第一秘钥之后,根据预设算法对第一秘钥进行加密处理,以得到第一服务器的第一加密秘钥;第二服务器在生成第二秘钥之后,根据预设算法对第二秘钥进行加密处理,以得到第二服务器的第二加密秘钥。In another embodiment of the present invention, after the first server generates the first key, it encrypts the first key according to a preset algorithm to obtain the first encryption key of the first server; After the second key is generated, the second key is encrypted according to a preset algorithm to obtain a second encryption key of the second server.
在本发明的另一实施方式中,还包括第一处理模块,用于:将第一秘钥循环左移三个比特,然后将左移之后的第一秘钥与预设字符串进行逻辑与的处理,以得到第一加密秘钥;还包括第二处理模块,用于:将第二秘钥循环左移三个比特,然后将左移之后的第二秘钥与预设的字符串进行逻辑与的处理,以得到第二加密秘钥。In another embodiment of the present invention, it also includes a first processing module, configured to: cyclically shift the first secret key to the left by three bits, and then perform a logical AND on the left-shifted first secret key and the preset character string processing to obtain the first encryption key; a second processing module is also included, configured to: cyclically shift the second key to the left by three bits, and then perform the left-shifted second key with a preset character string Logical AND processing to obtain the second encryption key.
为实现上述目的,根据本发明的再一方面,提供了一种电子设备。To achieve the above object, according to another aspect of the present invention, an electronic device is provided.
本发明实施例的一种电子设备包括:一个或多个处理器;存储装置,用于存储一个或多个程序,当一个或多个程序被一个或多个处理器执行,使得一个或多个处理器实现本发明生成秘钥的方法。An electronic device according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, and when one or more programs are executed by one or more processors, one or more The processor implements the method for generating a secret key in the present invention.
为实现上述目的,根据本发明的再一方面,提供了一种计算机可读存储介质。To achieve the above purpose, according to still another aspect of the present invention, a computer-readable storage medium is provided.
本发明实施例的一种计算机可读存储介质,其上存储有计算机程序,其特征在于,程序被处理器执行时实现本发明生成秘钥的方法。A computer-readable storage medium according to an embodiment of the present invention, on which a computer program is stored, is characterized in that, when the program is executed by a processor, the method for generating a secret key of the present invention is implemented.
上述发明中的一个实施例具有如下优点或有益效果:因为采用将安全信息发送到对方服务器进行验证,并且只有在验证通过的情况下,才会进一步生成秘钥的技术手段,所以克服了在生成秘钥的过程中存在的安全可靠性差的技术问题,进而达到提高生成秘钥时的安全可靠性的技术效果。通过本发明的技术方案,提高了生成秘钥时的安全可靠性,有效的防止了第三方设备的攻击和窃听。An embodiment of the above invention has the following advantages or beneficial effects: because the security information is sent to the other server for verification, and only when the verification is passed, will the technical means of further generating the secret key overcome the problem of generating The technical problem of poor security and reliability in the process of generating the secret key, and then achieve the technical effect of improving the security and reliability of generating the secret key. Through the technical scheme of the invention, the security reliability when generating the secret key is improved, and the attack and eavesdropping of the third-party equipment are effectively prevented.
上述的非惯用的可选方式所具有的进一步效果将在下文中结合具体实施方式加以说明。The further effects of the above-mentioned non-conventional alternatives will be described below in conjunction with specific embodiments.
附图说明Description of drawings
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。在附图中:In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings that need to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those skilled in the art, other drawings can also be obtained based on these drawings without creative effort. In the attached picture:
图1是现有的使用ECDH密钥交换算法进行密钥交换的时序图;Fig. 1 is an existing sequence diagram of key exchange using the ECDH key exchange algorithm;
图2是根据现有的密钥交换算法进行交换时被攻击的示意图;Figure 2 is a schematic diagram of being attacked when exchanging according to an existing key exchange algorithm;
图3是根据本发明实施例的生成秘钥的方法的主要流程的示意图;3 is a schematic diagram of the main flow of a method for generating a secret key according to an embodiment of the present invention;
图4是根据本发明实施例的生成秘钥的装置的主要模块的示意图;4 is a schematic diagram of main modules of a device for generating a secret key according to an embodiment of the present invention;
图5是本发明实施例可以应用于其中的示例性系统架构图;FIG. 5 is an exemplary system architecture diagram to which the embodiment of the present invention can be applied;
图6是适于用来实现本发明实施例的终端设备或服务器的计算机系统的结构示意图。Fig. 6 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
具体实施方式Detailed ways
以下结合附图对本发明的示范性实施例做出说明,其中包括本发明实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本发明的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。Exemplary embodiments of the present invention are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present invention to facilitate understanding, and they should be regarded as exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
图3是根据本发明实施例的生成秘钥的方法的主要流程的示意图,如图3所示,本发明实施例的一种生成秘钥的方法主要包括如下步骤:FIG. 3 is a schematic diagram of the main flow of a method for generating a secret key according to an embodiment of the present invention. As shown in FIG. 3 , a method for generating a secret key in an embodiment of the present invention mainly includes the following steps:
步骤S301:第一服务器将包含自身第一公钥的第一安全信息发送给第二服务器之后,接收到由第二服务器返回的第二秘钥。其中,第二秘钥是由第二服务器对第一安全信息进行验证,并在验证通过之后,由第二服务器利用第一公钥生成的。通过将第一安全信息发送给第二服务器,然后由第二服务器做后续的验证和生成秘钥的处理。需要注意的是,第一安全信息中还可以包括用以进行验证的安全证书,在本发明的实施方式中,第一服务器将第一公钥和第一服务器的第一身份信息发送给证书中心,由证书中心使用证书中心的证书私钥生成第一证书,并将第一证书返回给第一服务器,然后第一服务器将第一公钥和第一证书组成第一安全信息。这样,就得到了由第一公钥和第一证书组成第一安全信息,然后第二服务器就可以先根据第一证书进行验证,然后在利用第一公钥来生成第二秘钥了。需要说明的是,第一身份没信息可以是任意的唯一身份标识即可。Step S301: After the first server sends the first security information including its first public key to the second server, it receives the second secret key returned by the second server. Wherein, the second secret key is verified by the second server on the first security information, and is generated by the second server using the first public key after the verification is passed. By sending the first security information to the second server, the second server performs subsequent verification and key generation. It should be noted that the first security information may also include a security certificate for verification. In the embodiment of the present invention, the first server sends the first public key and the first identity information of the first server to the certificate center , the certificate center uses the certificate private key of the certificate center to generate the first certificate, and returns the first certificate to the first server, and then the first server forms the first security information with the first public key and the first certificate. In this way, the first security information composed of the first public key and the first certificate is obtained, and then the second server can first perform verification according to the first certificate, and then use the first public key to generate the second secret key. It should be noted that the first identity information can be any unique identity.
具体的,在本发明的另一使用场景中,由第二服务器对第一安全信息进行验证,并在验证通过之后,由第二服务器利用第一公钥生成第二秘钥的步骤包括:由第二服务器利用证书中心的证书公钥对第一安全信息中的第一证书进行验证,在验证通过的情况下,判定第一安全信息中的第一公钥来自第一服务器,然后利用第一公钥生成第二秘钥。Specifically, in another application scenario of the present invention, the first security information is verified by the second server, and after the verification is passed, the step of generating the second secret key by the second server using the first public key includes: The second server uses the certificate public key of the certificate center to verify the first certificate in the first security information. The public key generates the second secret key.
步骤S302:第一服务器在接收到由第二服务器发送的包含第二公钥的第二安全信息之后,对第二安全信息进行验证,并在验证通过之后,利用第二公钥生成第一服务器的第一秘钥。在步骤S101中,第二服务器根据第一服务器发送的第一公钥生成了自身的第二秘钥。因此,第二服务器还需要将自身的第二公钥发送给第一服务器,用以使第一服务器根据第二公钥生成第一服务器的第一公钥。Step S302: After the first server receives the second security information containing the second public key sent by the second server, it verifies the second security information, and after the verification is passed, uses the second public key to generate the first server security information. the first secret key. In step S101, the second server generates its own second secret key according to the first public key sent by the first server. Therefore, the second server also needs to send its second public key to the first server, so that the first server can generate the first public key of the first server according to the second public key.
在本发明的实施例中,第二服务器将第二公钥和第二服务器的第二身份信息发送给证书中心,由证书中心使用证书私钥生成第二证书,并将第二证书返回给第二服务器,然后第二服务器将第二公钥和第二证书组成第二安全信息。同样的,为了增加安全可靠性,第二服务器同样会生成第二证书和第二公钥一起发送给第一服务器,然后由第一服务器进行验证,并生成第一公钥。需要说明的是,第二身份信息可以是任意的唯一身份标识即可。In the embodiment of the present invention, the second server sends the second public key and the second identity information of the second server to the certificate center, and the certificate center uses the certificate private key to generate the second certificate, and returns the second certificate to the first The second server, and then the second server forms the second security information with the second public key and the second certificate. Similarly, in order to increase security and reliability, the second server will also generate a second certificate and send it to the first server together with the second public key, and then the first server will verify and generate the first public key. It should be noted that the second identity information may be any unique identity.
具体的,在本发明的另一使用场景中,对第二安全信息进行验证,并在验证通过之后,利用第二公钥生成第一服务器的第一秘钥的步骤包括:第一服务器利用证书公钥对第二安全信息中的第二证书进行验证,在验证通过的情况下,判定第二安全信息中的第二公钥来自第二服务器,然后利用第二公钥生成第一秘钥。Specifically, in another usage scenario of the present invention, the step of verifying the second security information and using the second public key to generate the first secret key of the first server after the verification is passed includes: the first server uses the certificate The public key verifies the second certificate in the second security information, and if the verification is passed, it is determined that the second public key in the second security information comes from the second server, and then the second public key is used to generate the first secret key.
此外,为了使得第一服务器生成的第一秘钥和第二服务器生成的第二秘钥具有更高的保密性,可以对第一秘钥和第二秘钥进行加密处理。具体的,在本发明的实施例中,第一服务器在生成第一秘钥之后,根据预设算法对第一秘钥进行加密处理,以得到第一服务器的第一加密秘钥;第二服务器在生成第二秘钥之后,根据预设算法对第二秘钥进行加密处理,以得到第二服务器的第二加密秘钥。In addition, in order to make the first secret key generated by the first server and the second secret key generated by the second server more confidential, the first secret key and the second secret key may be encrypted. Specifically, in an embodiment of the present invention, after the first server generates the first secret key, it encrypts the first secret key according to a preset algorithm to obtain the first encryption key of the first server; the second server After the second key is generated, the second key is encrypted according to a preset algorithm to obtain a second encryption key of the second server.
需要说明的是,预设算法是预设设置在第一服务器和第二服务器中的,可以是任意的算法,只要能够对秘钥进行加密并且保证第一服务器和第二服务器能够正常通信即可,在本发明的实施例中,根据预设算法对第一秘钥进行加密处理的步骤包括:将第一秘钥循环左移三个比特,然后将左移之后的第一秘钥与预设字符串进行逻辑与的处理,以得到第一加密秘钥;根据预设算法对第二秘钥进行加密处理的步骤包括:将第二秘钥循环左移三个比特,然后将左移之后的第二秘钥与预设的字符串进行逻辑与的处理,以得到第二加密秘钥。需要说明的是,预设字符串是预先设置的,并且只要是能够与左移后的秘钥进行逻辑与的处理的字符串即可。It should be noted that the preset algorithm is preset in the first server and the second server, and can be any algorithm, as long as the secret key can be encrypted and the first server and the second server can communicate normally. , in an embodiment of the present invention, the step of encrypting the first secret key according to a preset algorithm includes: shifting the first secret key to the left by three bits, and then combining the left-shifted first secret key with the preset The character string is logically AND processed to obtain the first encryption key; the step of encrypting the second key according to the preset algorithm includes: shifting the second secret key to the left by three bits, and then shifting the left Logical AND processing is performed on the second key and the preset character string to obtain the second encryption key. It should be noted that the preset character string is preset, and only needs to be a character string that can be logically ANDed with the left-shifted key.
下面对本发明的具体流程做详尽阐述,首先,需要在Master(上述第一服务器)预存CA(上述证书中心)的公钥publickey_CA(上述证书公钥);在Slave(上述第二服务器)预存CA的公钥publickey_CA。The concrete flow process of the present invention is described in detail below, at first, need to prestore the public key publickey_CA (above-mentioned certificate public key) of CA (above-mentioned certificate center) at Master (above-mentioned first server); Public key publickey_CA.
然后以图1为例,是现有的使用ECDH密钥交换算法进行密钥交换的时序图,本发明所涉及的具体流程如下:Then taking Fig. 1 as an example, it is an existing sequence diagram of using the ECDH key exchange algorithm to carry out key exchange, and the specific process involved in the present invention is as follows:
1、Master与Slave建立通信连接,双方各自生成自己的publickey与priviatekey。1. The Master establishes a communication connection with the Slave, and both parties generate their own publickey and privatekey.
2、Master将公钥publickey_m和自己的身份信息(上述第一身份信息,可以是任意的唯一身份标识)发送到CA,由CA使用私钥priviatekey_CA生成证书certificate_m(上述第一证书),并将certificate_m返回给Master。2. The Master sends the public key publickey_m and its own identity information (the above-mentioned first identity information, which can be any unique identity) to the CA, and the CA uses the private key privatekey_CA to generate the certificate certificate_m (the above-mentioned first certificate), and sends the certificate_m Return to Master.
3、Slave将公钥publickey_s和自己的身份信息(上述第二身份信息,可以是任意的唯一身份标识)发送到CA,由CA使用私钥priviatekey_CA生成证书certificate_s(上述第二证书),并将certificate_s返回给Slave。3. Slave sends the public key publickey_s and its own identity information (the above-mentioned second identity information, which can be any unique identity) to the CA, and the CA uses the private key privatekey_CA to generate the certificate certificate_s (the above-mentioned second certificate), and sends the certificate_s Return to Slave.
4、Master将自己的publickey_m和证书certificate_m写入到Slave中。4. Master writes its own publickey_m and certificate certificate_m into Slave.
5、Slave收到publickey_m和证书certificate_m后,首先使用publickey_CA处理certificate_m,来验证publickey_m是否真的来自Master,如果的确来自Master则往下进行,否则退出。5. After Slave receives publickey_m and certificate_m, it first uses publickey_CA to process certificate_m to verify whether publickey_m really comes from the Master. If it does come from the Master, proceed further, otherwise exit.
6、Slave用publickey_m与priviatekey_s生成sharekey(上述第二秘钥),并返回确认结果给Master。6. Slave uses publickey_m and privatekey_s to generate sharekey (the second secret key above), and returns the confirmation result to Master.
7、Master发送读取指令,获取Slave端公钥publickey_s和证书certificate_s。7. The Master sends a read command to obtain the Slave public key publickey_s and certificate certificate_s.
8、Slave将自己的公钥publickey_s和证书certificate_s返回给Master。8. Slave returns its public key publickey_s and certificate certificate_s to Master.
9、Master收到publickey_s和证书certificate_s后,首先使用publickey_CA处理certificate_s,来验证publickey_s是否真的来自Slave,如果的确来自Slave则往下进行,否则退出。9. After the Master receives the publickey_s and the certificate_s, it first uses the publickey_CA to process the certificate_s to verify whether the publickey_s really comes from the Slave. If it does come from the Slave, proceed further, otherwise exit.
10、Master用publickey_s与priviatekey_m生成sharekey(上述第一秘钥),并返回确认结果给Slave。10. Master uses publickey_s and privatekey_m to generate sharekey (the first secret key above), and returns the confirmation result to Slave.
11、双方用各自生成的sharekey进行加密数据通信。11. Both parties use their generated sharekeys for encrypted data communication.
进一步的,为了增加生成秘钥的安全可靠性,可以对生成的秘钥进行加密处理。具体的流程如下:Further, in order to increase the security and reliability of the generated secret key, the generated secret key may be encrypted. The specific process is as follows:
1、Master对sharekey采用预设的预设算法进行加密处理,得到sharekey_changed。1. The Master encrypts the sharekey with a preset preset algorithm to obtain sharekey_changed.
2、Slave对sharekey采用预设的预设算法进行加密处理,得到sharekey_changed。2. The Slave encrypts the sharekey with a preset preset algorithm to obtain sharekey_changed.
在这里,预设算法可以是任意的算法,只要能够对秘钥进行加密并且保证第一服务器和第二服务器能够正常通信即可。例如,sharekey的长度为128bit,采用预设算法处理的流程为:Here, the preset algorithm may be any algorithm, as long as the key can be encrypted and normal communication between the first server and the second server can be guaranteed. For example, the length of the sharekey is 128bit, and the processing flow using the preset algorithm is:
1、将sharekey循环左移3bit。1. Rotate the sharekey to the left by 3 bits.
2、将第(1)步的结果和0x00112233445566778899aabbccddeeff进行逻辑与的处理,得到的结果作为sharekey_changed。2. Perform logical AND processing on the result of step (1) and 0x00112233445566778899aabbccddeeff, and the obtained result is taken as sharekey_changed.
根据本发明实施例的生成秘钥的方法可以看出,因为采用将安全信息发送到对方服务器进行验证,并且只有在验证通过的情况下,才会进一步生成秘钥的技术手段,所以克服了在生成秘钥的过程中存在的安全可靠性差的技术问题,进而达到提高生成秘钥时的安全可靠性的技术效果。通过本发明的技术方案,提高了生成秘钥时的安全可靠性,有效的防止了第三方设备的攻击和窃听。According to the method for generating a secret key according to the embodiment of the present invention, it can be seen that because the security information is sent to the other party’s server for verification, and only when the verification is passed, the secret key will be further generated, so it overcomes the problem of The technical problem of poor security and reliability existing in the process of generating the secret key, thereby achieving the technical effect of improving the security and reliability of generating the secret key. Through the technical scheme of the invention, the security reliability when generating the secret key is improved, and the attack and eavesdropping of the third-party equipment are effectively prevented.
图4是根据本发明实施例的生成秘钥的装置的主要模块的示意图,如图4所示,本发明实施例的一种生成秘钥的装置400主要包括:第一生成模块401和第二生成模块402,其中:Fig. 4 is a schematic diagram of main modules of a device for generating a secret key according to an embodiment of the present invention. As shown in Fig. 4 , a device 400 for generating a secret key according to an embodiment of the present invention mainly includes: a first generating module 401 and a second A module 402 is generated, wherein:
第一生成模块401,用于将包含自身第一公钥的第一安全信息发送给第二服务器之后,接收到由第二服务器返回的第二秘钥,其中,第二秘钥是由第二服务器对第一安全信息进行验证,并在验证通过之后,由第二服务器利用第一公钥生成的;第二生成模块402,用于在接收到由第二服务器发送的包含第二公钥的第二安全信息之后,对第二安全信息进行验证,并在验证通过之后,利用第二公钥生成第一服务器的第一秘钥。The first generating module 401 is configured to receive the second secret key returned by the second server after sending the first security information including its own first public key to the second server, wherein the second secret key is provided by the second The server verifies the first security information, and after the verification is passed, it is generated by the second server using the first public key; the second generating module 402 is configured to, after receiving the second public key sent by the second server, After the second security information, verify the second security information, and use the second public key to generate the first secret key of the first server after the verification is passed.
在本发明的另一实施方式中,第一服务器将第一公钥和第一服务器的第一身份信息发送给证书中心,由证书中心使用证书中心的证书私钥生成第一证书,并将第一证书返回给第一服务器,然后第一服务器将第一公钥和第一证书组成第一安全信息;第二服务器将第二公钥和第二服务器的第二身份信息发送给证书中心,由证书中心使用证书私钥生成第二证书,并将第二证书返回给第二服务器,然后第二服务器将第二公钥和第二证书组成第二安全信息。In another embodiment of the present invention, the first server sends the first public key and the first identity information of the first server to the certificate center, and the certificate center uses the certificate private key of the certificate center to generate the first certificate, and sends the second A certificate is returned to the first server, and then the first server forms the first security information with the first public key and the first certificate; the second server sends the second public key and the second identity information of the second server to the certificate center, and the The certificate center uses the private key of the certificate to generate the second certificate, and returns the second certificate to the second server, and then the second server forms the second security information with the second public key and the second certificate.
在本发明的另一实施方式中,第一生成模块401还用于:由第二服务器利用证书中心的证书公钥对第一安全信息中的第一证书进行验证,在验证通过的情况下,判定第一安全信息中的第一公钥来自第一服务器,然后利用第一公钥生成第二秘钥;第二生成模块402还用于:第一服务器利用证书公钥对第二安全信息中的第二证书进行验证,在验证通过的情况下,判定第二安全信息中的第二公钥来自第二服务器,然后利用第二公钥生成第一秘钥。In another embodiment of the present invention, the first generation module 401 is further configured to: use the certificate public key of the certificate center to verify the first certificate in the first security information by the second server, and if the verification is passed, Determine that the first public key in the first security information comes from the first server, and then use the first public key to generate a second secret key; the second generation module 402 is also used for: the first server uses the certificate public key to generate the second secret key in the second security information The second certificate is verified, and if the verification is passed, it is determined that the second public key in the second security information is from the second server, and then the second public key is used to generate the first secret key.
在本发明的另一实施方式中,第一服务器在生成第一秘钥之后,根据预设算法对第一秘钥进行加密处理,以得到第一服务器的第一加密秘钥;第二服务器在生成第二秘钥之后,根据预设算法对第二秘钥进行加密处理,以得到第二服务器的第二加密秘钥。In another embodiment of the present invention, after the first server generates the first key, it encrypts the first key according to a preset algorithm to obtain the first encryption key of the first server; After the second key is generated, the second key is encrypted according to a preset algorithm to obtain a second encryption key of the second server.
在本发明的另一实施方式中,还包括第一处理模块(图中未示出),用于:将第一秘钥循环左移三个比特,然后将左移之后的第一秘钥与预设字符串进行逻辑与的处理,以得到第一加密秘钥;还包括第二处理模块(图中未示出),用于:将第二秘钥循环左移三个比特,然后将左移之后的第二秘钥与预设的字符串进行逻辑与的处理,以得到第二加密秘钥。In another embodiment of the present invention, a first processing module (not shown in the figure) is also included, configured to: cyclically shift the first secret key to the left by three bits, and then combine the left-shifted first secret key with Preset character strings are subjected to logical AND processing to obtain the first encryption key; a second processing module (not shown in the figure) is also included for: cyclically shifting the second key to the left by three bits, and then shifting the left Logical AND processing is performed on the shifted second key and the preset character string to obtain a second encryption key.
从以上描述可以看出,因为采用将安全信息发送到对方服务器进行验证,并且只有在验证通过的情况下,才会进一步生成秘钥的技术手段,所以克服了在生成秘钥的过程中存在的安全可靠性差的技术问题,进而达到提高生成秘钥时的安全可靠性的技术效果。通过本发明的技术方案,提高了生成秘钥时的安全可靠性,有效的防止了第三方设备的攻击和窃听。As can be seen from the above description, because the security information is sent to the server of the other party for verification, and only when the verification is passed, the technical means of further generating the secret key is adopted, so the existing problems in the process of generating the secret key are overcome. The technical problem of poor safety and reliability, and then achieve the technical effect of improving the safety and reliability when generating the secret key. Through the technical scheme of the invention, the security reliability when generating the secret key is improved, and the attack and eavesdropping of the third-party equipment are effectively prevented.
图5示出了可以应用本发明实施例的生成秘钥方法或生成秘钥装置的示例性系统架构500。Fig. 5 shows an exemplary system architecture 500 to which the method for generating a secret key or the device for generating a secret key according to an embodiment of the present invention can be applied.
如图5所示,系统架构500可以包括终端设备501、502、503,网络504和服务器505。网络504用以在终端设备501、502、503和服务器505之间提供通信链路的介质。网络504可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。As shown in FIG. 5 , a system architecture 500 may include terminal devices 501 , 502 , and 503 , a network 504 and a server 505 . The network 504 is used as a medium for providing communication links between the terminal devices 501 , 502 , 503 and the server 505 . Network 504 may include various connection types, such as wires, wireless communication links, or fiber optic cables, among others.
用户可以使用终端设备501、502、503通过网络504与服务器505交互,以接收或发送消息等。终端设备501、502、503上可以安装有各种通讯客户端应用,例如购物类应用、网页浏览器应用、搜索类应用、即时通信工具、邮箱客户端、社交平台软件等(仅为示例)。Users can use terminal devices 501 , 502 , 503 to interact with server 505 through network 504 to receive or send messages and the like. Various communication client applications can be installed on the terminal devices 501, 502, and 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (just for example).
终端设备501、502、503可以是具有显示屏并且支持网页浏览的各种电子设备,包括但不限于智能手机、平板电脑、膝上型便携计算机和台式计算机等等。The terminal devices 501, 502, 503 may be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers and the like.
服务器505可以是提供各种服务的服务器,例如对用户利用终端设备501、502、503所浏览的购物类网站提供支持的后台管理服务器(仅为示例)。后台管理服务器可以对接收到的产品信息查询请求等数据进行分析等处理,并将处理结果(例如目标推送信息、产品信息--仅为示例)反馈给终端设备。The server 505 may be a server that provides various services, such as a background management server that provides support for shopping websites browsed by users using the terminal devices 501 , 502 , 503 (just an example). The background management server can analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information—just an example) to the terminal device.
需要说明的是,本发明实施例所提供的生成秘钥方法一般由服务器505执行,相应地,生成秘钥装置一般设置于服务器505中。It should be noted that the method for generating a secret key provided in the embodiment of the present invention is generally executed by the server 505 , and correspondingly, the device for generating a secret key is generally set in the server 505 .
应该理解,图5中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the numbers of terminal devices, networks and servers in Fig. 5 are only illustrative. According to the implementation needs, there can be any number of terminal devices, networks and servers.
下面参考图6,其示出了适于用来实现本发明实施例的终端设备的计算机系统600的结构示意图。图6示出的终端设备仅仅是一个示例,不应对本发明实施例的功能和使用范围带来任何限制。Referring now to FIG. 6 , it shows a schematic structural diagram of a computer system 600 suitable for implementing a terminal device according to an embodiment of the present invention. The terminal device shown in FIG. 6 is only an example, and should not limit the functions and scope of use of this embodiment of the present invention.
如图6所示,计算机系统600包括中央处理单元(CPU)601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储部分608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有系统600操作所需的各种程序和数据。CPU 601、ROM 602以及RAM 603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。As shown in FIG. 6 , a computer system 600 includes a central processing unit (CPU) 601 that can be programmed according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage section 608 into a random-access memory (RAM) 603 Instead, various appropriate actions and processes are performed. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601 , ROM 602 , and RAM 603 are connected to each other via a bus 604 . An input/output (I/O) interface 605 is also connected to the bus 604 .
以下部件连接至I/O接口605:包括键盘、鼠标等的输入部分606;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分607;包括硬盘等的存储部分608;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分609。通信部分609经由诸如因特网的网络执行通信处理。驱动器610也根据需要连接至I/O接口605。可拆卸介质611,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器610上,以便于从其上读出的计算机程序根据需要被安装入存储部分608。The following components are connected to the I/O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 608 including a hard disk, etc. and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, optical disk, magneto-optical disk, semiconductor memory, etc. is mounted on the drive 610 as necessary so that a computer program read therefrom is installed into the storage section 608 as necessary.
特别地,根据本发明公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本发明公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分609从网络上被下载和安装,和/或从可拆卸介质611被安装。在该计算机程序被中央处理单元(CPU)601执行时,执行本发明的系统中限定的上述功能。In particular, according to the disclosed embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the disclosed embodiments of the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, where the computer program includes program codes for executing the methods shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication portion 609 and/or installed from removable media 611 . When this computer program is executed by a central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are performed.
需要说明的是,本发明所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本发明中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本发明中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. A computer readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, in which computer-readable program codes are carried. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. . Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
附图中的流程图和框图,图示了按照本发明各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, program segment, or portion of code that includes one or more logical functions for implementing specified executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or they may sometimes be executed in the reverse order, depending upon the functionality involved. It is also to be noted that each block in the block diagrams or flowchart illustrations, and combinations of blocks in the block diagrams or flowchart illustrations, can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a A combination of dedicated hardware and computer instructions.
描述于本发明实施例中所涉及到的模块可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的模块也可以设置在处理器中,例如,可以描述为:一种处理器包括第一生成模块和第二生成模块。其中,这些模块的名称在某种情况下并不构成对该模块本身的限定。The modules involved in the embodiments described in the present invention may be implemented by software or by hardware. The described modules may also be set in a processor, for example, it may be described as: a processor includes a first generating module and a second generating module. Wherein, the names of these modules do not constitute a limitation on the module itself under certain circumstances.
作为另一方面,本发明还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的设备中所包含的;也可以是单独存在,而未装配入该设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被一个该设备执行时,使得该设备包括:第一服务器将包含自身第一公钥的第一安全信息发送给第二服务器之后,接收到由第二服务器返回的第二秘钥,其中,第二秘钥是由第二服务器对第一安全信息进行验证,并在验证通过之后,由第二服务器利用第一公钥生成的;第一服务器在接收到由第二服务器发送的包含第二公钥的第二安全信息之后,对第二安全信息进行验证,并在验证通过之后,利用第二公钥生成第一服务器的第一秘钥。As another aspect, the present invention also provides a computer-readable medium. The computer-readable medium may be contained in the device described in the above embodiments, or it may exist independently without being assembled into the device. The above-mentioned computer-readable medium carries one or more programs, and when the one or more programs are executed by one device, the device includes: the first server sends the first security information containing its own first public key to the second server. After the second server receives the second secret key returned by the second server, the second secret key is verified by the second server on the first security information, and after the verification is passed, the second secret key is used by the second server to Key generation; after receiving the second security information containing the second public key sent by the second server, the first server verifies the second security information, and uses the second public key to generate the first The server's first secret key.
根据本发明实施例的技术方案,因为采用将安全信息发送到对方服务器进行验证,并且只有在验证通过的情况下,才会进一步生成秘钥的技术手段,所以克服了在生成秘钥的过程中存在的安全可靠性差的技术问题,进而达到提高生成秘钥时的安全可靠性的技术效果。通过本发明的技术方案,提高了生成秘钥时的安全可靠性,有效的防止了第三方设备的攻击和窃听。According to the technical solution of the embodiment of the present invention, because the security information is sent to the other party's server for verification, and only when the verification is passed, the technical means of further generating the secret key will be overcome, so it overcomes the problem in the process of generating the secret key. The technical problem of poor safety and reliability exists, and then achieves the technical effect of improving the safety and reliability when generating the secret key. Through the technical scheme of the invention, the security reliability when generating the secret key is improved, and the attack and eavesdropping of the third-party equipment are effectively prevented.
上述具体实施方式,并不构成对本发明保护范围的限制。本领域技术人员应该明白的是,取决于设计要求和其他因素,可以发生各种各样的修改、组合、子组合和替代。任何在本发明的精神和原则之内所作的修改、等同替换和改进等,均应包含在本发明保护范围之内。The above specific implementation methods do not constitute a limitation to the protection scope of the present invention. It should be apparent to those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims (12)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810145432.XA CN110166226B (en) | 2018-02-12 | 2018-02-12 | A method and device for generating a secret key |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810145432.XA CN110166226B (en) | 2018-02-12 | 2018-02-12 | A method and device for generating a secret key |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN110166226A true CN110166226A (en) | 2019-08-23 |
| CN110166226B CN110166226B (en) | 2023-06-27 |
Family
ID=67635116
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201810145432.XA Active CN110166226B (en) | 2018-02-12 | 2018-02-12 | A method and device for generating a secret key |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN110166226B (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113497778A (en) * | 2020-03-18 | 2021-10-12 | 北京同邦卓益科技有限公司 | Data transmission method and device |
| CN116305062A (en) * | 2021-12-07 | 2023-06-23 | 中国移动通信有限公司研究院 | A data verification method, server and communication device |
Citations (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101299667A (en) * | 2008-06-05 | 2008-11-05 | 华为技术有限公司 | An authentication method, system, client device and server |
| US20110022835A1 (en) * | 2009-07-27 | 2011-01-27 | Suridx, Inc. | Secure Communication Using Asymmetric Cryptography and Light-Weight Certificates |
| CN102624528A (en) * | 2012-03-02 | 2012-08-01 | 中国人民解放军总参谋部第六十一研究所 | IBAKA (Identity Based Authentication and Key Agreement) method |
| CN104579694A (en) * | 2015-02-09 | 2015-04-29 | 浙江大学 | Identity authentication method and system |
| CN104753682A (en) * | 2015-04-03 | 2015-07-01 | 北京云安世纪科技有限公司 | Generating system and method of session keys |
| CN105049434A (en) * | 2015-07-21 | 2015-11-11 | 中国科学院软件研究所 | Identity authentication method and encryption communication method under peer-to-peer network environment |
| WO2016033610A1 (en) * | 2014-08-29 | 2016-03-03 | Visa International Service Association | Methods for secure cryptogram generation |
| CN105471845A (en) * | 2015-11-16 | 2016-04-06 | 数据通信科学技术研究所 | Communication method and communication system for preventing man-in-the-middle attack |
-
2018
- 2018-02-12 CN CN201810145432.XA patent/CN110166226B/en active Active
Patent Citations (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101299667A (en) * | 2008-06-05 | 2008-11-05 | 华为技术有限公司 | An authentication method, system, client device and server |
| US20110022835A1 (en) * | 2009-07-27 | 2011-01-27 | Suridx, Inc. | Secure Communication Using Asymmetric Cryptography and Light-Weight Certificates |
| CN102624528A (en) * | 2012-03-02 | 2012-08-01 | 中国人民解放军总参谋部第六十一研究所 | IBAKA (Identity Based Authentication and Key Agreement) method |
| WO2016033610A1 (en) * | 2014-08-29 | 2016-03-03 | Visa International Service Association | Methods for secure cryptogram generation |
| CN104579694A (en) * | 2015-02-09 | 2015-04-29 | 浙江大学 | Identity authentication method and system |
| CN104753682A (en) * | 2015-04-03 | 2015-07-01 | 北京云安世纪科技有限公司 | Generating system and method of session keys |
| CN105049434A (en) * | 2015-07-21 | 2015-11-11 | 中国科学院软件研究所 | Identity authentication method and encryption communication method under peer-to-peer network environment |
| CN105471845A (en) * | 2015-11-16 | 2016-04-06 | 数据通信科学技术研究所 | Communication method and communication system for preventing man-in-the-middle attack |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113497778A (en) * | 2020-03-18 | 2021-10-12 | 北京同邦卓益科技有限公司 | Data transmission method and device |
| CN113497778B (en) * | 2020-03-18 | 2023-05-12 | 北京同邦卓益科技有限公司 | Data transmission method and device |
| CN116305062A (en) * | 2021-12-07 | 2023-06-23 | 中国移动通信有限公司研究院 | A data verification method, server and communication device |
Also Published As
| Publication number | Publication date |
|---|---|
| CN110166226B (en) | 2023-06-27 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN106533665B (en) | Mthods, systems and devices for storing website private key plaintext | |
| CN111431713B (en) | Private key storage method and device and related equipment | |
| CN110492990B (en) | Private key management method, device and system in blockchain scenario | |
| CN111371549A (en) | Message data transmission method, device and system | |
| CN113630412B (en) | Resource downloading method, resource downloading device, electronic equipment and storage medium | |
| CN112765642B (en) | Data processing method, data processing device, electronic device and medium | |
| CN116112172B (en) | Android client gRPC interface security verification method and device | |
| CN111784887A (en) | A method, device and system for authorization and release of user access | |
| CN114240347A (en) | Business service secure docking method and device, computer equipment and storage medium | |
| CN108923925B (en) | Data storage method and device applied to block chain | |
| CN108880812A (en) | The method and system of data encryption | |
| CN110519203A (en) | A kind of data encryption and transmission method and device | |
| CN111416788B (en) | Method and device for preventing transmission data from being tampered with | |
| CN110166226B (en) | A method and device for generating a secret key | |
| CN112565156B (en) | Information registration method, device and system | |
| CN114417369A (en) | File transmission method and device, electronic equipment and computer readable medium | |
| CN115022057A (en) | Security authentication method, device and device, and storage medium | |
| CN111526128B (en) | Encryption management method and device | |
| EP4485858A1 (en) | Security authentication method, apparatus and system for digital currency transaction | |
| CN114428967B (en) | Data transmission method, device, equipment and storage medium | |
| US11811921B2 (en) | Photon-level light shifting for enhanced file system security and authenticity | |
| CN113381982B (en) | Registration method, device, electronic device and storage medium | |
| CN115459964A (en) | A data security processing method and device | |
| US12619980B2 (en) | Security authentication method, apparatus and system for digital currency transaction | |
| CN115828309B (en) | Service calling method and system |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |