Disclosure of Invention
In order to solve the problems in the related art, embodiments of the present disclosure provide a secure communication method, apparatus, chip, electronic device and readable storage medium method, apparatus, electronic device and readable storage medium.
In a first aspect, an embodiment of the present disclosure provides a secure communication method applied to a power distribution terminal, including:
the method comprises the steps that authentication is carried out on the basis of an improved SM2 algorithm with a power distribution main station, and after the authentication is successful, key agreement is carried out on the basis of the improved SM2 algorithm with the power distribution main station to obtain a session key K of a power distribution terminal and the power distribution main station, wherein in the improved SM2 algorithm, a random public key factor directly participates in an identifier mapping algorithm to realize binding between a random public key and an identifier;
and when the key negotiation result is true, carrying out encrypted communication with the power distribution main station by utilizing the session key K based on an SM1 algorithm.
According to the embodiment of the disclosure, the authentication of the power distribution terminal and the power distribution main station based on the improved SM2 algorithm comprises the following steps:
the power distribution terminal generates a first random public key factor r1, a unique identifier S1 of the session and a unique identifier ID1 of the power distribution terminal;
receiving a second random public key factor r2 sent by a power distribution master station and an identity displacement identifier ID2 of the power distribution master station;
calculating a first Request value Request according to the r1, the S1 and the ID1, and sending the first Request value Request to the power distribution main station, wherein the first Request value Request comprises a first encryption result obtained by carrying out encryption calculation on r1, S1 and ID1 based on an SM2 algorithm public key of the power distribution main station, and a second encryption result obtained by carrying out encryption calculation on an SM3 algorithm hash operation result of the r1, the S1 and the ID1 based on an MS2 algorithm private key of the power distribution terminal;
when a first judgment result obtained by the power distribution master station through calculation according to the first Request value Request is true, receiving a first Reply value Reply sent by the power distribution master station, wherein the first Reply value includes a third encryption result obtained by carrying out encryption calculation on r2, S1 and ID2 based on an SM2 algorithm public key of the power distribution terminal, and a fourth encryption result obtained by carrying out encryption calculation on an SM3 algorithm hash operation result of r2, S1 and ID2 based on an SM2 algorithm private key of the power distribution master station;
decrypting the first Reply value Reply to obtain the r2, the S1 and the ID 2;
and decrypting the fourth encryption result based on the SM2 algorithm public key of the power distribution main station to obtain a first decryption result, and successfully authenticating the power distribution terminal and the power distribution main station when the first decryption result is determined to be the same as the SM3 algorithm hash operation results of the r2, the S1 and the ID 2.
According to an embodiment of the present disclosure, the first Request value Request is calculated by the following formula: request = E pc (r1ǁS1ǁID1)ǁE dt (H (r 1 ǁ S1 ǁ ID 1)), the first recovery value Reply being calculated by the following formula: reply = E pt (r2ǁS1ǁID2)ǁE dc (H (r 2 ǁ S1 ǁ ID 2)), where ǁ is data stitching operation, H () is SM3 algorithm hash operation on data in parentheses, E pc () The SM2 algorithm public key of the distribution main station is used for carrying out encryption operation on data in brackets, E dt () Carrying out encryption operation on data in brackets by using SM2 algorithm private key of a power distribution terminal, E pt () Carrying out encryption operation on data in brackets by using SM2 algorithm public key of a power distribution terminal, E dc () The SM2 algorithm private key of the power distribution main station is used for carrying out encryption operation on data in brackets, E pt (r2ǁS1ǁID2)For the third encryption result, E dc (H (r 2 ǁ S1 ǁ ID 2)) is the fourth encryption result.
According to an embodiment of the present disclosure, decrypting the first Reply value Reply to obtain the r2, S1, and ID2 includes:
and carrying out decryption operation on the third encryption result based on an SM2 algorithm private key of the power distribution terminal to obtain the r2, the S1 and the ID 2.
According to the embodiment of the disclosure, the first judgment result is obtained by comparing a hash operation result of the SM3 algorithm of the distribution master station according to r1, S1 and ID1 with a second decryption result obtained by decrypting the second encryption result by using an SM2 algorithm public key of a distribution terminal;
wherein, when the SM3 algorithm hash operation result of the r1, the S1 and the ID1 is the same as the second decryption result, the first judgment result is true;
when the SM3 algorithm hash operation result of the r1, the S1 and the ID1 is different from the second decryption result, the first judgment result is false.
According to an embodiment of the disclosure, the key agreement with the power distribution master station based on the modified SM2 algorithm after the authentication is successful includes:
selecting point a = (x) on elliptic curve A ,y A ) Wherein, the point A satisfies an elliptic curve equation and is a point which is not at infinity;
receiving point B (x) transmitted by power distribution main station B ,y B ) Wherein point B satisfies the elliptic curve equation and is a non-infinite point;
obtaining the domain element in the point A, and carrying out dual transformation on the domain element in the point A to obtain a first conjugate value
,
Wherein,
n is a natural number,&is a bitwise AND operation;
calculating a first intermediate value based on the first conjugate value
Wherein mod is a modulo operation;
obtaining the domain element in the point B, and carrying out dual transformation on the domain element in the point B to obtain a second conjugate value
;
According to the first intermediate value t
A And a second conjugate value
Calculating a point on an elliptic curve
Wherein h is a cofactor;
when the point U is judged to be a non-infinite point, a third random number R is calculated A = R1^ R2, and transmits the R A To the distribution main station so that the distribution main station can be operated according to the third random number R A And a fourth random number R B Judging the result of key agreement, wherein the fourth random number R B The power distribution master station calculates a third random number R by adopting a mode of calculating a power distribution terminal A Calculated in the same way, and is a logic operation bit by bit.
According to an embodiment of the present disclosure, when the third random number R A And a fourth random number R B And if so, the key negotiation result is true, otherwise, the key negotiation result is false.
According to an embodiment of the present disclosure, the session key K is obtained by:
according to the formula K = KDF (x) U ǁy U ǁZ t ǁZ c ǁr1ǁr2,L K ) Calculating a session key K of the power distribution terminal and the power distribution main station, wherein KDF () is a key derivation function, x U And y U A field element of point U, Z t As a distinguishable mark, partial ellipse, with respect to the distribution terminalHash value, Z, of the circular curve system parameter and its public key c Is a hash value of a discernable identification about the distribution main station, a partial elliptic curve system parameter and its public key, L K Is the encoding length of the session key K.
According to an embodiment of the disclosure, the performing encrypted communication with the power distribution master station based on the SM1 algorithm by using the session key K includes:
acquiring monitoring data;
carrying out SM1 encryption operation on the monitoring data based on the session key K to obtain encrypted monitoring data, and sending the encrypted monitoring data to the power distribution master station;
acquiring encrypted control data sent by a power distribution master station, wherein the encrypted control data is obtained by carrying out SM1 encryption operation on the control data by the power distribution master station based on the session key K, and the control data is generated by the power distribution master station according to the received encrypted monitoring data;
and carrying out SM1 decryption operation on the encrypted control data according to the session key K to obtain the control data.
According to the embodiment of the disclosure, the safety communication method is applied to power distribution service communication, the connection between a power distribution terminal and a power distribution main station is disconnected after each power distribution service is finished, and a currently used session key is deleted and is not reused.
According to the embodiment of the disclosure, the power distribution terminal and the power distribution master station perform authentication and key agreement again when power distribution service communication is required or connection is overtime.
In a second aspect, an embodiment of the present disclosure provides a secure communication method, applied to a power distribution master station, including:
the method comprises the steps that authentication is carried out on the basis of an improved SM2 algorithm with a power distribution terminal, and after the authentication is successful, key agreement is carried out on the basis of the improved SM2 algorithm with the power distribution terminal to obtain a session key K of the power distribution terminal and a power distribution main station, wherein in the improved SM2 algorithm, a random public key factor directly participates in an identifier mapping algorithm to realize binding between a random public key and an identifier;
and when the key negotiation result is true, carrying out encrypted communication with the power distribution terminal by using the session key K based on an SM1 algorithm.
According to the embodiment of the disclosure, the authentication of the power distribution main station and the power distribution terminal based on the improved SM2 algorithm comprises the following steps:
the power distribution master station generates a second random public key factor r2 and an identity displacement identifier ID2 of the power distribution master station;
receiving a first random public key factor r1, a unique identifier S1 of the session and an identity unique identifier ID1 of the power distribution terminal, which are sent by the power distribution terminal;
receiving a first Request value Request sent by the power distribution terminal, wherein the first Request value Request is obtained by the power distribution terminal through calculation according to the r1, the S1 and the ID1, and the first Request value Request comprises a first encryption result obtained through encryption calculation of r1, S1 and ID1 based on an SM2 algorithm public key of a power distribution main station and a second encryption result obtained through encryption calculation of r1, S1 and the ID1 based on an SM2 algorithm private key of the power distribution terminal;
decrypting the first encryption result based on an SM2 algorithm private key of the power distribution master station to obtain r1, S1 and ID 1;
and decrypting the second encryption result based on the SM2 algorithm public key of the power distribution terminal to obtain a second decryption result, and when the second decryption result is determined to be the same as the SM3 algorithm hash operation result of the r1, the S1 and the ID1, the power distribution master station successfully authenticates the power distribution terminal.
According to an embodiment of the present disclosure, further comprising:
and after the power distribution main station successfully authenticates the power distribution terminal, sending a first recovery value Reply to the power distribution terminal so that the power distribution terminal authenticates the power distribution main station according to the first recovery value Reply.
According to an embodiment of the present disclosure, the first Request value Request is calculated by: wherein, | | is data splicing operation, H () is SM3 algorithm hash operation on the data in the parentheses, E | pc () The SM2 algorithm public key of the distribution main station is used for carrying out encryption operation on data in brackets, E dt () Is made by usingAnd the SM2 algorithm private key of the electric terminal carries out encryption operation on the data in the brackets to obtain the first encryption result and the second encryption result.
According to an embodiment of the disclosure, the key agreement with the power distribution terminal based on the modified SM2 algorithm after the authentication is successful includes:
selecting point B (x) on the elliptic curve B ,y B ) Wherein point B satisfies the elliptic curve equation and is a non-infinite point;
receiving point A = (x) transmitted by power distribution terminal A ,y A ) Wherein point a satisfies an elliptic curve equation and is a non-infinite point;
obtaining the domain element in the point B, and carrying out dual transformation on the domain element in the point B to obtain a second conjugate value
,
Wherein,
n is a natural number,&is a bitwise AND operation;
calculating a second intermediate value based on the second conjugate value
Wherein mod is a modulo operation;
obtaining the domain elements in the point A, and carrying out dual transformation on the domain elements in the point A to obtain a first conjugate value
;
According to the second intermediate value t
B And a first conjugate value
Calculating a point on an elliptic curve
Wherein h is more thanA factor;
when the point V is judged to be a point which is not at infinity, a fourth random number R is calculated B = R2^ R1, and transmits the R B To the distribution main station so that the distribution main station can be operated according to the fourth random number R B And a third random number R A Judging the result of key agreement, wherein the third random number R A The power distribution terminal calculates a fourth random number R by adopting a mode of calculating a power distribution main station B Calculated in the same way, is a bitwise logic operation.
According to the embodiment of the present disclosure, when the fourth random number R B And a third random number R A And if so, the key negotiation result is true, otherwise, the key negotiation result is false.
According to an embodiment of the present disclosure, the session key K is obtained by:
according to the formula K = KDF (x) U ǁy U ǁZ t ǁZ c ǁr1ǁr2,L K ) Calculating a session key K of the power distribution terminal and the power distribution main station, wherein KDF () is a key derivation function, x V And y V A field element of point V, Z t Is a hash value of the discernible identifier relating to the distribution terminal, the partial elliptic curve system parameter and its public key, Z c Is a hash value of the discernible identity, partial elliptic curve system parameters and its public key with respect to the distribution main station, L K Is the encoding length of the session key K.
According to an embodiment of the disclosure, the encrypted communication with the power distribution terminal by using the session key K based on the SM1 algorithm includes:
acquiring encrypted monitoring data sent by a power distribution terminal, wherein the encrypted monitoring data is obtained by carrying out SM1 encryption operation on the monitoring data by the power distribution terminal based on the session key K;
carrying out decryption operation on the encrypted monitoring data based on the session key K to obtain the monitoring data;
generating corresponding control data according to the monitoring data;
carrying out SM1 encryption operation on the control data based on the session key K to obtain encrypted control data;
and sending the encrypted control data to the power distribution terminal.
According to the embodiment of the disclosure, the safety communication method is applied to power distribution service communication, the connection between a power distribution terminal and a power distribution main station is disconnected after each power distribution service is finished, and a currently used session key is deleted and is not reused.
According to the embodiment of the disclosure, the power distribution master station and the power distribution terminal perform authentication and key agreement again when power distribution service communication is required or connection is overtime.
In a third aspect, an embodiment of the present disclosure provides a secure communication device, located at a power distribution terminal, including:
the first authentication and key agreement module is configured to enable the power distribution terminal and the power distribution master station to perform authentication based on an improved SM2 algorithm, and perform key agreement with the power distribution master station based on the improved SM2 algorithm after the authentication is successful, so as to obtain a session key K of the power distribution terminal and the power distribution master station, wherein in the improved SM2 algorithm, a random public key factor directly participates in an identifier mapping algorithm, so that binding between a random public key and an identifier is realized;
and the first encryption communication module is configured to enable the power distribution terminal to perform encryption communication with the power distribution main station by using the session key K based on an SM1 algorithm when the key negotiation result is true.
According to the embodiment of the disclosure, the authentication of the power distribution terminal and the power distribution main station based on the improved SM2 algorithm comprises the following steps:
the power distribution terminal generates a first random public key factor r1, a unique identifier S1 of the session and a unique identifier ID1 of the power distribution terminal;
receiving a second random public key factor r2 sent by a power distribution master station and an identity displacement identifier ID2 of the power distribution master station;
calculating a first Request value Request according to the r1, the S1 and the ID1, and sending the first Request value Request to the power distribution main station, wherein the first Request value Request comprises a first encryption result obtained by carrying out encryption calculation on r1, S1 and ID1 based on an SM2 algorithm public key of the power distribution main station, and a second encryption result obtained by carrying out encryption calculation on an SM3 algorithm hash operation result of the r1, the S1 and the ID1 based on an MS2 algorithm private key of the power distribution terminal;
when a first judgment result obtained by the power distribution master station through calculation according to the first Request value Request is true, receiving a first Reply value Reply sent by the power distribution master station, wherein the first Reply value includes a third encryption result obtained by carrying out encryption calculation on r2, S1 and ID2 based on an SM2 algorithm public key of the power distribution terminal, and a fourth encryption result obtained by carrying out encryption calculation on an SM3 algorithm hash operation result of r2, S1 and ID2 based on an SM2 algorithm private key of the power distribution master station;
decrypting the first Reply value Reply to obtain the r2, the S1 and the ID 2;
and decrypting the fourth encryption result based on the SM2 algorithm public key of the power distribution main station to obtain a first decryption result, and successfully authenticating the power distribution terminal and the power distribution main station when the first decryption result is determined to be the same as the SM3 algorithm hash operation results of the r2, the S1 and the ID 2.
According to an embodiment of the present disclosure, the first Request value Request is calculated by: request = E pc (r1ǁS1ǁID1)ǁE dt (H (r 1 ǁ S1 ǁ ID 1)), the first recovery value Reply being calculated by: reply = E pt (r2ǁS1ǁID2)ǁE dc (H (r 2 ǁ S1 ǁ ID 2)), where ǁ is data stitching operation, H () is SM3 algorithm hash operation on data in parentheses, E pc () The public key of SM2 algorithm of distribution main station is used to make encryption operation on the data in parentheses, E dt () The SM2 algorithm private key of the power distribution terminal is used for carrying out encryption operation on data in brackets, E pt () Carrying out encryption operation on data in brackets by using SM2 algorithm public key of a power distribution terminal, E dc () Carrying out encryption operation on data in brackets by using SM2 algorithm private key of a power distribution main station, E pt (r 2 ǁ S1 ǁ ID 2) is the third encryption result, E dc (H (r 2 ǁ S1 ǁ ID 2)) is the fourth encryption result.
According to an embodiment of the present disclosure, decrypting the first Reply value Reply to obtain the r2, S1, and ID2 includes:
and carrying out decryption operation on the third encryption result based on an SM2 algorithm private key of the power distribution terminal to obtain the r2, the S1 and the ID 2.
According to the embodiment of the disclosure, the first judgment result is obtained by comparing a hash operation result of the SM3 algorithm of the distribution master station according to r1, S1 and ID1 with a second decryption result obtained by decrypting the second encryption result by using an SM2 algorithm public key of a distribution terminal;
wherein, when the SM3 algorithm hash operation result of the r1, the S1 and the ID1 is the same as the second decryption result, the first judgment result is true;
when the SM3 algorithm hash operation result of the r1, the S1 and the ID1 is different from the second decryption result, the first judgment result is false.
According to an embodiment of the disclosure, the key agreement with the power distribution master station based on the modified SM2 algorithm after the authentication is successful includes:
selecting point a = (x) on elliptic curve A ,y A ) Wherein, the point A satisfies an elliptic curve equation and is a point which is not at infinity;
receiving point B (x) transmitted by distribution master station B ,y B ) Wherein point B satisfies the elliptic curve equation and is a non-infinite point;
obtaining the domain element in the point A, and carrying out dual transformation on the domain element in the point A to obtain a first conjugate value
,
Wherein,
n is a natural number,&is a bitwise AND operation;
calculating a first intermediate value based on the first conjugate value
Wherein mod is a modulo operation;
obtaining the domain element in the point B, and carrying out dual transformation on the domain element in the point B to obtain a second conjugate value
;
According to the first intermediate value t
A And a second conjugate value
Calculating a point on an elliptic curve
Wherein h is a cofactor;
when the point U is judged to be a non-infinite point, a third random number R is calculated A = R1^ R2, and transmits the R A To the distribution main station so that the distribution main station can be operated according to the third random number R A And a fourth random number R B Judging the result of key agreement, wherein the fourth random number R B The power distribution main station calculates a third random number R by adopting a mode of calculating a third random number R with the power distribution terminal A Calculated in the same way, is a bitwise logic operation.
According to an embodiment of the present disclosure, when the third random number R A And a fourth random number R B And if so, the key negotiation result is true, otherwise, the key negotiation result is false.
According to an embodiment of the present disclosure, the session key K is obtained by:
according to the formula K = KDF (x) U ǁy U ǁZ t ǁZ c ǁr1ǁr2,L K ) Calculating a session key K of the power distribution terminal and the power distribution main station, wherein KDF () is a key derivation function, x U And y U A field element of point U, Z t Is a hash value of the discernible identifier relating to the distribution terminal, the partial elliptic curve system parameter and its public key, Z c Is a distinguishable identification about the distribution main station, partial elliptic curve system parameters and the public thereofHash value of the key, L K Is the encoding length of the session key K.
According to an embodiment of the disclosure, the performing encrypted communication with the power distribution master station based on the SM1 algorithm by using the session key K includes:
acquiring monitoring data;
carrying out SM1 encryption operation on the monitoring data based on the session key K to obtain encrypted monitoring data, and sending the encrypted monitoring data to the power distribution master station;
acquiring encrypted control data sent by a power distribution master station, wherein the encrypted control data is obtained by carrying out SM1 encryption operation on the control data by the power distribution master station based on the session key K, and the control data is generated by the power distribution master station according to the received encrypted monitoring data;
and carrying out SM1 decryption operation on the encrypted control data according to the session key K to obtain the control data.
According to the embodiment of the disclosure, the safety communication device is applied to power distribution service communication, the connection between the power distribution terminal and the power distribution main station is disconnected after each power distribution service is finished, and the currently used session key is deleted and is not reused.
According to the embodiment of the disclosure, the power distribution terminal and the power distribution master station perform authentication and key agreement again when power distribution service communication is required or connection is overtime.
In a fourth aspect, an embodiment of the present disclosure provides a secure communication apparatus located at a power distribution master station, including:
the second authentication and key agreement module is configured to enable the power distribution master station and the power distribution terminal to perform authentication based on an improved SM2 algorithm, and perform key agreement with the power distribution terminal after the authentication is successful based on the improved SM2 algorithm, so as to obtain a session key K of the power distribution terminal and the power distribution master station, wherein in the improved SM2 algorithm, a random public key factor directly participates in an identifier mapping algorithm, so that binding between a random public key and an identifier is realized;
and the second encryption communication module is configured to enable the power distribution main station and the power distribution terminal to carry out encryption communication based on an SM1 algorithm by using the session key K when the key negotiation result is true.
According to the embodiment of the disclosure, the authentication of the power distribution main station and the power distribution terminal based on the improved SM2 algorithm comprises the following steps:
the power distribution master station generates a second random public key factor r2 and an identity displacement identifier ID2 of the power distribution master station;
receiving a first random public key factor r1, a unique identifier S1 of the session and an identity unique identifier ID1 of the power distribution terminal, which are sent by the power distribution terminal;
receiving a first Request value Request sent by the power distribution terminal, wherein the first Request value Request is obtained by the power distribution terminal through calculation according to the r1, the S1 and the ID1, and comprises a first encryption result obtained through encryption calculation of an SM2 algorithm public key of the power distribution main station on the r1, the S1 and the ID1, and a second encryption result obtained through encryption calculation of an SM2 algorithm private key of the power distribution terminal on the r1, the S1 and the ID 1;
decrypting the first encryption result based on an SM2 algorithm private key of the power distribution master station to obtain r1, S1 and ID 1;
and decrypting the second encryption result based on the SM2 algorithm public key of the power distribution terminal to obtain a second decryption result, and when the second decryption result is determined to be the same as the SM3 algorithm hash operation result of the r1, the S1 and the ID1, the power distribution master station successfully authenticates the power distribution terminal.
According to an embodiment of the present disclosure, further comprising:
and after the power distribution main station successfully authenticates the power distribution terminal, sending a first recovery value Reply to the power distribution terminal so that the power distribution terminal authenticates the power distribution main station according to the first recovery value Reply.
According to an embodiment of the present disclosure, the first Request value Request is calculated by the following formula: wherein | | is data splicing operation, H () is SM3 algorithm hash operation on the data in parentheses, E | | pc () The SM2 algorithm public key of the distribution main station is used for carrying out encryption operation on data in brackets, E dt () Is calculated by SM2 of the distribution terminalAnd the private key carries out encryption operation on the data in the brackets to obtain the first encryption result and the second encryption result.
According to an embodiment of the disclosure, the key agreement with the power distribution terminal based on the modified SM2 algorithm after the authentication is successful includes:
selecting point B (x) on the elliptic curve B ,y B ) Wherein point B satisfies the elliptic curve equation and is a non-infinite point;
receiving point A = (x) transmitted by power distribution terminal A ,y A ) Wherein point a satisfies an elliptic curve equation and is a non-infinite point;
obtaining the domain element in the point B, and carrying out dual transformation on the domain element in the point B to obtain a second conjugate value
,
Wherein,
n is a natural number,&is a bitwise AND operation;
calculating a second intermediate value based on the second conjugate value
Wherein mod is a modulo operation;
obtaining the domain element in the point A, and carrying out dual transformation on the domain element in the point A to obtain a first conjugate value
;
According to the second intermediate value t
B And a first conjugate value
Calculating a point on an elliptic curve
Wherein h is more thanA factor;
when the point V is judged to be a non-infinite point, a fourth random number R is calculated B = R2^ R1, and transmits the R B To the distribution main station to make the distribution main station according to the fourth random number R B And a third random number R A Judging the result of key agreement, wherein the third random number R A The power distribution terminal calculates a fourth random number R by adopting a mode of calculating a power distribution main station B Calculated in the same way, is a bitwise logic operation.
According to the embodiment of the present disclosure, when the fourth random number R B And a third random number R A And if so, the key negotiation result is true, otherwise, the key negotiation result is false.
According to an embodiment of the present disclosure, the session key K is obtained by:
according to the formula K = KDF (x) U ǁy U ǁZ t ǁZ c ǁr1ǁr2,L K ) Calculating a session key K of the power distribution terminal and the power distribution main station, wherein KDF () is a key derivation function, x V And y V A field element of point V, Z t Is a hash value of the discernible identifier relating to the distribution terminal, the partial elliptic curve system parameter and its public key, Z c Is a hash value of the discernible identity, partial elliptic curve system parameters and its public key with respect to the distribution main station, L K Is the encoding length of the session key K.
According to an embodiment of the disclosure, the encrypted communication with the power distribution terminal by using the session key K based on the SM1 algorithm includes:
acquiring encrypted monitoring data sent by a power distribution terminal, wherein the encrypted monitoring data is obtained by carrying out SM1 encryption operation on the monitoring data by the power distribution terminal based on the session key K;
carrying out decryption operation on the encrypted monitoring data based on the session key K to obtain the monitoring data;
generating corresponding control data according to the monitoring data;
carrying out SM1 encryption operation on the control data based on the session key K to obtain encrypted control data;
and sending the encrypted control data to the power distribution terminal.
According to the embodiment of the disclosure, the safety communication device is applied to power distribution service communication, the connection between the power distribution terminal and the power distribution main station is disconnected after each power distribution service is finished, and the currently used session key is deleted and is not reused.
According to the embodiment of the disclosure, the power distribution master station and the power distribution terminal perform authentication and key agreement again every time power distribution service communication needs to be performed or connection is overtime.
In a fifth aspect, embodiments of the present disclosure provide a chip including the secure communication apparatus according to any one of the third aspect or the fourth aspect.
In a sixth aspect, the present disclosure provides an electronic device, comprising a memory and a processor, wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method according to any one of the first aspect or the second aspect.
In a seventh aspect, the present disclosure provides a computer-readable storage medium, on which computer instructions are stored, and when executed by a processor, the computer instructions implement the method according to the first or second aspect.
According to the technical scheme provided by the embodiment of the disclosure, a power distribution terminal and a power distribution master station perform authentication based on an improved SM2 algorithm, and perform key agreement with the power distribution master station based on the improved SM2 algorithm after the authentication is successful to obtain a session key K of the power distribution terminal and the power distribution master station, wherein in the improved SM2 algorithm, a random public key factor directly participates in an identifier mapping algorithm to realize the binding between a random public key and an identifier; and when the key negotiation result is true, carrying out encrypted communication with the power distribution main station by utilizing the session key K based on an SM1 algorithm. By adopting the technical scheme of the embodiment of the disclosure, authentication and key agreement between the power distribution terminal and the power distribution main station are realized through the improved SM2 algorithm, and encrypted communication between the power distribution terminal and the power distribution main station is realized through the SM1 algorithm, so that both communication parties can use less communication resources and calculation resources on the premise of ensuring the security of the key agreement, the utilization rate of system resources in the power distribution terminal is optimized, the bottleneck of high concurrency of the power distribution main station when massive power distribution terminals are accessed is avoided, and the applicability of the scheme is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Detailed Description
Hereinafter, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily implement them. Also, for the sake of clarity, parts not relevant to the description of the exemplary embodiments are omitted in the drawings.
In the present disclosure, it is to be understood that terms such as "including" or "having," etc., are intended to indicate the presence of the disclosed features, numbers, steps, behaviors, components, parts, or combinations thereof, and are not intended to preclude the possibility that one or more other features, numbers, steps, behaviors, components, parts, or combinations thereof may be present or added.
It should also be noted that the embodiments and features of the embodiments in the present disclosure may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
In the present disclosure, if an operation of acquiring user information or user data or an operation of presenting user information or user data to others is involved, the operations are all operations authorized, confirmed by a user, or actively selected by the user.
The shared key can be obtained by the intelligent power distribution master station and the terminal on an insecure communication channel by using the existing secret SM2 algorithm. However, due to the high concurrency of the master station and the limited computing and storage capabilities of the terminal, the bidirectional identity authentication of the master station and the terminal of the intelligent distribution network cannot be ensured by using the standard SM2 algorithm.
In view of this, an embodiment of the present disclosure provides a secure communication method, including: the power distribution terminal and the power distribution master station perform authentication and key agreement based on an improved SM2 algorithm, wherein in the improved SM2 algorithm, a random public key factor directly participates in an identifier mapping algorithm to realize the binding between a random public key and an identifier; the power distribution terminal and the power distribution main station carry out encrypted communication based on an SM1 algorithm. By adopting the technical scheme of the embodiment of the disclosure, authentication and key agreement between the power distribution terminal and the power distribution main station are realized through the improved SM2 algorithm, and encrypted communication between the power distribution terminal and the power distribution main station is realized through the SM1 algorithm, so that both communication parties can use less communication resources and calculation resources on the premise of ensuring the security of key agreement, the utilization rate of system resources in the power distribution terminal is optimized, the bottleneck of high concurrency of the power distribution main station when massive power distribution terminals are accessed is avoided, and the applicability of the scheme is improved.
Fig. 1 shows a flow diagram of a secure communication method according to an embodiment of the present disclosure. As shown in fig. 1, the secure communication method is applied to a power distribution terminal, and includes the following steps S101 to S102:
in step S101, performing authentication with a power distribution master station based on an improved SM2 algorithm, and performing key agreement with the power distribution master station after the authentication is successful based on the improved SM2 algorithm to obtain a session key K of the power distribution terminal and the power distribution master station, where in the improved SM2 algorithm, a random public key factor directly participates in an identifier mapping algorithm, so as to realize binding between a random public key and an identifier;
in step S102, when the key agreement result is true, encrypted communication is performed with the power distribution master station based on the SM1 algorithm by using the session key K.
In the embodiment of the disclosure, the secure communication method is applied to a power distribution terminal, so that the power distribution terminal can perform secure communication with a power distribution main station. The distribution terminal can be various remote monitoring and control units installed on the medium-voltage distribution network site, and comprises a feeder terminal FTU, a distribution transformer monitoring terminal TTU, a remote terminal unit RTU, a distribution terminal unit DTU and the like. The power distribution terminal can be internally provided with a safety protection device for realizing the safety communication between the power distribution terminal and the power distribution main station.
Fig. 2 shows an example of a safety protection device of a power distribution terminal, and in the safety protection device shown in fig. 2, a processor, a wireless communication module, a serial communication module, a network cable socket, a safety chip, an SDRAM memory, an SD card slot, a power supply module, and a real-time clock may be included. Wherein, the processor can be a processor adopting S3C2416XH-40ARM926EJ dominant frequency 400 MHz; the wireless communication module is used for information interaction with external modules such as a power distribution main station and the like; the serial port communication module is used for accessing a serial port terminal; the network cable socket mainly plays a role in redundancy design and is used for increasing the reliability of the power distribution terminal equipment; the SDRAM memory is used for providing an operation space for programs needing to be operated in the power distribution terminal; the SD card slot is used for expanding a system in the power distribution terminal and expanding storage capacity; the power supply module is used for supplying power to modules such as a processor, a safety chip, an SDRAM (synchronous dynamic random access memory) and the like; the real-time clock is used for providing a time signal, and a time counter can be arranged in the real-time clock; the security chip is used for completing security authentication, security storage of important data and encryption and decryption of key data so as to realize security and integrity of data interaction between the security access device and the security access platform, standard domestic commercial key algorithms such as SM1 and SM2 are built in the security chip, and multiple functions of data communication line protection, data encryption and decryption, identity authentication, signature verification and the like can be realized so as to improve the service data transmission security of the power distribution terminal equipment.
In the embodiment of the disclosure, the power distribution terminal and the power distribution master station perform authentication and key agreement based on an improved SM2 algorithm, wherein in the improved SM2 algorithm, a random public key factor directly participates in an identifier mapping algorithm, and the binding between a random public key and an identifier is realized. Specifically, the power distribution terminal performs mutual authentication with the power distribution master station based on the improved SM2 algorithm, and after the mutual authentication is successful, the power distribution terminal and the power distribution master station perform key negotiation based on the improved SM2 algorithm.
In the embodiment of the present disclosure, the authentication between the power distribution terminal and the power distribution master station based on the improved SM2 algorithm includes: the power distribution terminal generates a first random public key factor r1, a unique identifier S1 of the session and a unique identifier ID1 of the power distribution terminal; receiving a second random public key factor r2 sent by a power distribution master station and an identity displacement identifier ID2 of the power distribution master station; calculating a first Request value Request according to the r1, the S1 and the ID1, and sending the first Request value Request to the power distribution main station, wherein the first Request value Request comprises a first encryption result obtained by carrying out encryption calculation on r1, S1 and ID1 based on an SM2 algorithm public key of the power distribution main station, and a second encryption result obtained by carrying out encryption calculation on an SM3 algorithm hash operation result of the r1, the S1 and the ID1 based on an MS2 algorithm private key of the power distribution terminal; when a first judgment result obtained by the power distribution master station through calculation according to the first Request value Request is true, receiving a first Reply value Reply sent by the power distribution master station, wherein the first Reply value includes a third encryption result obtained by carrying out encryption calculation on r2, S1 and ID2 based on an SM2 algorithm public key of the power distribution terminal, and a fourth encryption result obtained by carrying out encryption calculation on an SM3 algorithm hash operation result of r2, S1 and ID2 based on an SM2 algorithm private key of the power distribution master station; decrypting the first Reply value Reply to obtain the r2, the S1 and the ID 2; and decrypting the fourth encryption result based on the SM2 algorithm public key of the power distribution main station to obtain a first decryption result, and successfully authenticating the power distribution terminal and the power distribution main station when the first decryption result is determined to be the same as the SM3 algorithm hash operation results of the r2, the S1 and the ID 2.
Specifically, the power distribution terminal firstly generates a first random public key factor r1, a session unique identifier S1 and an identity unique identifier ID1 by using the distinguishable identifier of the power distribution terminal, the partial elliptic curve system parameter and the hash value Zt of the public key of the power distribution terminal, the distinguishable identifier of the power distribution master station, the partial elliptic curve system parameter and the hash value Zc of the public key of the power distribution master station, and the SM2 algorithm public key Pt of the power distribution terminal and the SM2 algorithm private key dt of the power distribution terminal. Meanwhile, the power distribution main station also generates a second random public key factor r2 and an identity displacement identifier ID2 based on the distinguishable identifier of the power distribution main station, the parameter of the partial elliptic curve system and the hash value ZA of the public key of the power distribution main station, the distinguishable identifier of the power distribution terminal, the parameter of the partial elliptic curve system and the hash value ZB of the public key of the power distribution terminal, and the SM2 algorithm public key Pt of the power distribution terminal and the SM2 algorithm private key dt of the power distribution terminal. And the power distribution terminal receives the second random public key factor r2 and the identity displacement identification ID2 of the power distribution main station, and temporarily stores the r2 and the ID2 for subsequent use.
Then, the power distribution terminal calculates a first Request value Request according to the first random public key factor r1, the session unique identifier S1 and the identity unique identifier ID1 of the power distribution terminal, where the first Request value Request may be calculated by the following formula: request = E pc (r1ǁS1ǁID1)ǁE dt (H (r 1 ǁ S1 ǁ ID 1)), where ǁ is data stitching operation, H () is SM3 algorithm hash operation on data in parentheses, E pc () The SM2 algorithm public key of the distribution main station is used for carrying out encryption operation on data in brackets, E dt () Carrying out encryption operation on data in brackets by using SM2 algorithm private key of a power distribution terminal, E pc (r1 ǁ S1 ǁ ID 1) as the first encryption result, E dt (H (r 1 ǁ S1 ǁ ID 1)) is recorded as a second encryption result. And the power distribution terminal sends the first Request value Request to the power distribution main station so that the power distribution main station obtains a first judgment result based on the first Request value Request.
In an embodiment of the present disclosure, the power distribution master station obtaining the first determination result based on the first Request value Request may be that the power distribution master station decrypts the first encryption result based on an SM2 algorithm private key of the power distribution master station, that is, calculates D dc (E pc (r 1 ǁ S1 ǁ ID 1)) to yield the r1, S1 and ID 1; decrypting the second encrypted result based on the SM2 algorithm public key of the power distribution terminal, namely calculating D pt (E dt (H (r 1 ǁ S1 ǁ ID 1))) to obtain a second decryption result; judging whether the second decryption result is the same as the SM3 algorithm hash operation result of the r1, the S1 and the ID1, if so, determining that the first judgment result is true, and sending a first Reply value Reply to the distribution terminal by the distribution master station, wherein the first Reply value Reply is calculated by the following formula: reply = E pt (r2ǁS1ǁID2)ǁE dc (r 2 ǁ S1 ǁ ID 2)), wherein E pt () The SM2 algorithm public key of the power distribution terminal is used for carrying out encryption operation on data in brackets, E dc () The method is to use the SM2 algorithm private key of the distribution main station to carry out encryption operation on the data in brackets, and can be recorded as E pt (r 2 ǁ S1 ǁ ID 2) is the third encryption result, E dc (H (r 2 ǁ S1 ǁ ID 2)) is a fourth encryption result; and if the first judgment result is false, judging that the first judgment result is false, and immediately interrupting the connection with the power distribution terminal by the power distribution main station.
The power distribution terminal receives the first Reply value Reply sent by the power distribution master station, and firstly, the third encryption result is decrypted based on an SM2 algorithm private key of the power distribution terminal to obtain r2, S1 and ID 2; then, decrypting the fourth encryption result based on an SM2 algorithm public key of the power distribution master station to obtain a first decryption result, judging whether the first decryption result is the same as the hash operation result of the SM3 algorithm of the r2, the S1 and the ID2, if so, successfully authenticating the power distribution master station by the power distribution terminal, and finishing bidirectional authentication by the power distribution terminal and the power distribution master station; and if the power distribution terminals are different from the power distribution main station, the power distribution terminals are disconnected from the power distribution main station.
In this disclosure, the performing, after successful authentication, key agreement with the distribution master station based on the modified SM2 algorithm includes: selecting point a = (x) on elliptic curve
A ,y
A ) Wherein point a satisfies an elliptic curve equation and is a non-infinite point; receiving point B (x) transmitted by distribution master station
B ,y
B ) Wherein point B satisfies the elliptic curve equation and is a point that is not at infinity; obtaining the domain element in the point A, and carrying out dual transformation on the domain element in the point A to obtain a first conjugate value
Wherein
n is a natural number,&is a bitwise AND operation; calculating a first intermediate value based on the first conjugate value
Wherein mod is a modulo operation; obtaining the domain element in the point B, and carrying out dual transformation on the domain element in the point B to obtain a second conjugate value
(ii) a According to the first intermediate value t
A And a second conjugate value
Calculating a point on an elliptic curve
Wherein h is a cofactor; when the point U is judged to be a non-infinite point, a third random number R is calculated
A = R1^ R2, and transmits the R
A To the distribution main station so that the distribution main station can be operated according to the third random number R
A And a fourth random number R
B Judging the result of key agreement, wherein the second stepFour random numbers R
B The power distribution main station calculates a third random number R by adopting a mode of calculating a third random number R with the power distribution terminal
A Calculated in the same way, is a bitwise logic operation. Specifically, when calculating the second conjugate value, after obtaining the field element in the point B, the data type of the field element may be first converted into an integer type, and then the second conjugate value is calculated; likewise, when calculating the first conjugate value, after acquiring the field element in the point a, the data type of the field element may be first converted into an integer type, and then the first conjugate value may be calculated. When calculating the third random number, the data type in the point U may be first converted into a character string type, and then the third random number is calculated. And if the point U is judged to be an infinite point, the key negotiation between the power distribution terminal and the power distribution main station fails, and the power distribution terminal is disconnected with the power distribution main station.
In the embodiment of the present disclosure, when the third random number R A And a fourth random number R B And if so, the key negotiation result is true, otherwise, the key negotiation result is false.
In this disclosure, after the key agreement between the power distribution terminal and the power distribution master station is successful, the session key K = KDF (x) of the power distribution terminal and the power distribution master station may be calculated U ǁy U ǁZ t ǁZ c ǁr1ǁr2,L K ) Where KDF () is a key derivation function, x U And y U A field element of point U, Z t Is a hash value of a discernible identifier relating to the distribution terminal, a partial elliptic curve system parameter and its public key, Z c Is a hash value of the discernible identity, partial elliptic curve system parameters and its public key with respect to the distribution main station, L K Is the encoding length of the session key K. And when the key negotiation result is true, the power distribution terminal performs data transmission with the power distribution master station based on the session key K.
In this disclosure, the performing encrypted communication with the distribution master station by using the session key K based on the SM1 algorithm includes: acquiring monitoring DATA 1; performing SM1 encryption operation on the monitoring DATA DATA1 based on the session key K to obtain encrypted monitoring DATAE 1 =E K (DATA 1), and encrypting the encrypted monitor DATA E 1 Sending the power distribution main station to the power distribution main station; obtaining encrypted control data E sent by power distribution master station 2 =E K (DATA 2), the encryption control DATA E 2 Performing SM1 encryption operation on control DATA DATA2 for the power distribution master station based on the session key K, wherein the control DATA DATA2 is obtained by the power distribution master station according to the received encrypted monitoring DATA E 1 The result is obtained; carrying out SM1 decryption operation D on the encrypted control data according to the session key K K (E K (DATA 2)), the control DATA2 is obtained.
According to the technical scheme of the embodiment of the disclosure, authentication and key agreement between the power distribution terminal and the power distribution main station are realized through an improved SM2 algorithm, encrypted communication between the power distribution terminal and the power distribution main station is realized through an SM1 algorithm, so that both communication parties can use less communication resources and calculation resources on the premise of ensuring the security of the key agreement, the utilization rate of system resources in the power distribution terminal is optimized, the bottleneck of high concurrency of the power distribution main station when massive power distribution terminals are accessed is avoided, and the applicability of the scheme is improved.
According to the embodiment of the disclosure, the safety communication method is applied to power distribution service communication, the connection between a power distribution terminal and a power distribution main station is disconnected after each power distribution service is finished, and a currently used session key is deleted and is not reused. The method comprises the steps that authentication and key agreement are required to be carried out again when power distribution service communication is required to be carried out between the power distribution main station and the power distribution terminal every time, and the authentication and key agreement are required to be carried out again when the connection between the power distribution main station and the power distribution terminal is overtime.
According to the technical scheme of the embodiment of the disclosure, the authentication and the key negotiation between the power distribution terminal and the power distribution master station are required to be carried out again when the service communication is carried out each time and the connection is overtime, so that the safety is further improved.
Fig. 3 shows a flow diagram of a secure communication method according to an embodiment of the present disclosure. As shown in fig. 3, the secure communication method is applied to a power distribution master station, and includes the following steps S301 to S302:
in step S301, performing authentication with a power distribution terminal based on an improved SM2 algorithm, and performing key agreement with the power distribution terminal based on the improved SM2 algorithm after the authentication is successful, to obtain a session key K of the power distribution terminal and the power distribution master station, where in the improved SM2 algorithm, a random public key factor directly participates in an identifier mapping algorithm, so as to realize binding between a random public key and an identifier;
in step S302, when the key agreement result is true, encrypted communication is performed with the distribution terminal based on the SM1 algorithm using the session key K.
According to the embodiment of the disclosure, the authentication of the power distribution main station and the power distribution terminal based on the improved SM2 algorithm comprises the following steps: the power distribution master station generates a second random public key factor r2 and an identity displacement identifier ID2 of the power distribution master station; receiving a first random public key factor r1, a unique identifier S1 of the session and an identity unique identifier ID1 of the power distribution terminal, which are sent by the power distribution terminal; receiving a first Request value Request sent by the power distribution terminal, wherein the first Request value Request is obtained by the power distribution terminal through calculation according to the r1, the S1 and the ID1, and the first Request value Request comprises a first encryption result obtained through encryption calculation of r1, S1 and ID1 based on an SM2 algorithm public key of a power distribution main station and a second encryption result obtained through encryption calculation of r1, S1 and the ID1 based on an SM2 algorithm private key of the power distribution terminal; decrypting the first encryption result based on an SM2 algorithm private key of the power distribution master station to obtain r1, S1 and ID 1; and decrypting the second encryption result based on the SM2 algorithm public key of the power distribution terminal to obtain a second decryption result, and when the second decryption result is determined to be the same as the SM3 algorithm hash operation result of the r1, the S1 and the ID1, the power distribution master station successfully authenticates the power distribution terminal.
According to the embodiment of the disclosure, after the power distribution master station successfully authenticates the power distribution terminal, a first Reply value Reply is sent to the power distribution terminal, so that the power distribution terminal authenticates the power distribution master station according to the first Reply value Reply.
According to the embodiment of the present disclosure, the first Request value Request is calculated by the following formulaTo: request = E pc (r1ǁS1ǁID1)ǁE dt (H (r 1 ǁ S1 ǁ ID 1)), where | | is the data concatenation operation, H () is the SM3 algorithm hash operation on the data in parentheses, E |) pc () The public key of SM2 algorithm of distribution main station is used to make encryption operation on the data in parentheses, E dt () The SM2 algorithm private key of the power distribution terminal is used for carrying out encryption operation E on the data in brackets pc (r 1 ǁ S1 ǁ ID 1) is the first encryption result, E dt (H (r 1 ǁ S1 ǁ ID 1)) is the second encryption result.
According to the embodiment of the disclosure, the key agreement with the power distribution terminal based on the improved SM2 algorithm after the authentication is successful includes: selecting point B (x) on the elliptic curve
B ,y
B ) Wherein point B satisfies the elliptic curve equation and is a non-infinite point; receiving point A = (x) transmitted by power distribution terminal
A ,y
A ) Wherein point a satisfies an elliptic curve equation and is a non-infinite point; obtaining the domain element in the point B, and carrying out dual transformation on the domain element in the point B to obtain a second conjugate value
Wherein
n is a natural number,&is a bitwise AND operation; calculating a second intermediate value based on the second conjugate value
Wherein mod is a modulo operation; obtaining the domain element in the point A, and carrying out dual transformation on the domain element in the point A to obtain a first conjugate value
(ii) a According to the second intermediate value t
B And a first conjugate value
Calculating a point on an elliptic curve
Wherein h is a cofactor; when the point V is judged to be a non-infinite point, a fourth random number R is calculated
B = R2^ R1, and transmits the R
B To the distribution main station so that the distribution main station can be operated according to the fourth random number R
B And a third random number R
A Judging the result of key agreement, wherein the third random number R
A The power distribution terminal calculates a fourth random number R by adopting a mode of calculating a power distribution main station
B Calculated in the same way, is a bitwise logic operation.
According to the embodiment of the present disclosure, when the fourth random number R B And a third random number R A And if so, the key negotiation result is true, otherwise, the key negotiation result is false.
According to the embodiment of the present disclosure, the session key K is obtained by: according to the formula K = KDF (x) U ǁy U ǁZ t ǁZ c ǁr1ǁr2,L K ) Calculating a session key K of the power distribution terminal and the power distribution master station, wherein KDF () is a key derivation function, x V And y V A field element of point V, Z t Is a hash value of the discernible identifier relating to the distribution terminal, the partial elliptic curve system parameter and its public key, Z c Is a hash value of the discernible identity, partial elliptic curve system parameters and its public key with respect to the distribution main station, L K Is the encoding length of the session key K.
According to the embodiment of the disclosure, the performing encrypted communication with the power distribution terminal by using the session key K based on the SM1 algorithm includes: obtaining encrypted monitoring data E sent by power distribution terminal 1 Said encrypted monitoring data E 1 The distribution terminal performs SM1 encryption operation E on monitoring DATA DATA1 based on the session key K K (DATA 1); carrying out decryption operation D on the encrypted monitoring data E1 based on the session key K K (E K (DATA 1)), obtaining the monitoring DATA 1; generating corresponding control DATA2 according to the monitoring DATA 1; based on the session key K pairThe control DATA DATA2 performs an SM1 encryption operation E K (DATA 2) obtaining encrypted control DATA E 2 (ii) a Transmitting the encryption control data E 2 To the power distribution terminal.
According to the technical scheme of the embodiment of the disclosure, authentication and key agreement between the power distribution terminal and the power distribution main station are realized through an improved SM2 algorithm, encrypted communication between the power distribution terminal and the power distribution main station is realized through an SM1 algorithm, so that both communication parties can use less communication resources and calculation resources on the premise of ensuring the security of the key agreement, the utilization rate of system resources in the power distribution terminal is optimized, the bottleneck of high concurrency of the power distribution main station when massive power distribution terminals are accessed is avoided, and the applicability of the scheme is improved.
According to the embodiment of the disclosure, the safety communication method is applied to power distribution service communication, the connection between a power distribution terminal and a power distribution main station is disconnected after each power distribution service is finished, and a currently used session key is deleted and is not reused. The method comprises the steps that authentication and key agreement are required to be carried out again when power distribution service communication is required to be carried out between the power distribution main station and the power distribution terminal every time, and the authentication and key agreement are required to be carried out again when the connection between the power distribution main station and the power distribution terminal is overtime.
According to the technical scheme of the embodiment of the disclosure, the authentication and key agreement between the power distribution terminal and the power distribution master station are required to be carried out again by setting when the service communication is carried out each time and the connection is overtime, so that the safety is further improved.
Fig. 4 shows a block diagram of a secure communication device according to an embodiment of the present disclosure. The apparatus may be implemented as part or all of an electronic device through software, hardware, or a combination of both.
The secure communication device 400 may be located at a power distribution terminal, as shown in fig. 4, the secure communication device 400 including:
the first authentication and key agreement module 401 is configured to enable the power distribution terminal and the power distribution master station to perform authentication based on an improved SM2 algorithm, and perform key agreement with the power distribution master station based on the improved SM2 algorithm after the authentication is successful, so as to obtain a session key K of the power distribution terminal and the power distribution master station, where in the improved SM2 algorithm, a random public key factor directly participates in an identifier mapping algorithm, so as to implement binding between a random public key and an identifier;
a first encryption communication module 402 configured to enable the power distribution terminal to perform encryption communication with the power distribution master station based on an SM1 algorithm by using the session key K when the key negotiation result is true.
According to the embodiment of the disclosure, the authentication of the power distribution terminal and the power distribution master station based on the improved SM2 algorithm includes: the power distribution terminal generates a first random public key factor r1, a unique identifier S1 of the session and a unique identifier ID1 of the power distribution terminal; receiving a second random public key factor r2 sent by a power distribution master station and an identity displacement identifier ID2 of the power distribution master station; calculating a first Request value Request according to the r1, the S1 and the ID1, and sending the first Request value Request to the power distribution main station, wherein the first Request value Request comprises a first encryption result obtained by carrying out encryption calculation on r1, S1 and ID1 based on an SM2 algorithm public key of the power distribution main station, and a second encryption result obtained by carrying out encryption calculation on an SM3 algorithm hash operation result of the r1, S1 and ID1 based on an MS2 algorithm private key of the power distribution terminal; when a first judgment result obtained by the power distribution master station through calculation according to the first Request value Request is true, receiving a first Reply value Reply sent by the power distribution master station, wherein the first Reply value includes a third encryption result obtained by carrying out encryption calculation on r2, S1 and ID2 based on an SM2 algorithm public key of the power distribution terminal, and a fourth encryption result obtained by carrying out encryption calculation on an SM3 algorithm hash operation result of r2, S1 and ID2 based on an SM2 algorithm private key of the power distribution master station; decrypting the first Reply value Reply to obtain the r2, the S1 and the ID 2; and decrypting the fourth encryption result based on the SM2 algorithm public key of the power distribution main station to obtain a first decryption result, and successfully authenticating the power distribution terminal and the power distribution main station when the first decryption result is determined to be the same as the SM3 algorithm hash operation results of the r2, the S1 and the ID 2.
Wherein the first Request value Request is calculated by the following formula: request = E pc (r1ǁS1ǁID1)ǁE dt (H (r 1 ǁ S1 ǁ ID 1)), the first recovery value Reply being calculated by the following formula: reply = E pt (r2ǁS1ǁID2)ǁE dc (H (r 2 ǁ S1 ǁ ID 2)), where ǁ is data stitching operation, H () is SM3 algorithm hash operation on data in parentheses, E pc () The SM2 algorithm public key of the distribution main station is used for carrying out encryption operation on data in brackets, E dt () The SM2 algorithm private key of the power distribution terminal is used for carrying out encryption operation on data in brackets, E pt () The SM2 algorithm public key of the power distribution terminal is used for carrying out encryption operation on data in brackets, E dc () The SM2 algorithm private key of the power distribution main station is used for carrying out encryption operation on data in brackets, E pt (r 2 ǁ S1 ǁ ID 2) is the third encryption result, E dc (H (r 2 ǁ S1 ǁ ID 2)) is the fourth encryption result. The decrypting the first Reply value Reply to obtain the r2, the S1 and the ID2 includes: and carrying out decryption operation on the third encryption result based on an SM2 algorithm private key of the power distribution terminal to obtain r2, S1 and ID 2.
According to the embodiment of the disclosure, the first judgment result is obtained by comparing a hash operation result of the SM3 algorithm of the distribution master station according to r1, S1 and ID1 with a second decryption result obtained by decrypting the second encryption result by using an SM2 algorithm public key of the distribution terminal; wherein, when the SM3 algorithm hash operation result of the r1, the S1 and the ID1 is the same as the second decryption result, the first judgment result is true; when the SM3 algorithm hash operation result of the r1, the S1 and the ID1 is different from the second decryption result, the first judgment result is false.
According to the embodiment of the disclosure, after the authentication is successful, performing key agreement with the power distribution master station based on the improved SM2 algorithm includes: selecting point a = (x) on elliptic curve
A ,y
A ) Wherein point a satisfies an elliptic curve equation and is a non-infinite point; receiving point B (x) transmitted by power distribution main station
B ,y
B ) Wherein point B satisfies the elliptic curve equation and is a non-infinite point; obtaining the domain elements in the point A, and carrying out dual transformation on the domain elements in the point A to obtainFirst conjugate value
Wherein
n is a natural number,&is a bitwise AND operation; calculating a first intermediate value based on the first conjugate value
Wherein mod is a modulo operation; obtaining the domain element in the point B, and carrying out dual transformation on the domain element in the point B to obtain a second conjugate value
(ii) a According to the first intermediate value t
A And a second conjugate value
Calculating a point on the elliptic curve
Wherein h is a cofactor; when the point U is judged to be a non-infinite point, a third random number R is calculated
A = R1^ R2, and transmits the R
A To the distribution main station so that the distribution main station can be operated according to the third random number R
A And a fourth random number R
B Judging a key negotiation result, wherein the fourth random number R
B The power distribution main station calculates a third random number R by adopting a mode of calculating a third random number R with the power distribution terminal
A Calculated in the same way, is a bitwise logic operation. When the third random number R
A And a fourth random number R
B And if so, the key negotiation result is true, otherwise, the key negotiation result is false. According to the formula K = KDF (x)
U ǁy
U ǁZ
t ǁZ
c ǁr1ǁr2,L
K ) And calculating a session key K of the power distribution terminal and the power distribution main station, wherein KDF () is a key derivation function, x
U And y
U A field element of point U, Z
t To be related toDiscernable identification of an electrical terminal, hash value, Z, of partial elliptic curve system parameters and of its public key
c Is a hash value of the discernible identity, partial elliptic curve system parameters and its public key with respect to the distribution main station, L
K The encoding length of the session key K is; and when the key negotiation result is true, the power distribution terminal performs data transmission with the power distribution master station based on the session key K.
According to the embodiment of the disclosure, the encrypted communication with the power distribution master station by using the session key K based on the SM1 algorithm includes: acquiring monitoring data; carrying out SM1 encryption operation on the monitoring data based on the session key K to obtain encrypted monitoring data, and sending the encrypted monitoring data to the power distribution master station; acquiring encrypted control data sent by a power distribution master station, wherein the encrypted control data is obtained by carrying out SM1 encryption operation on the control data by the power distribution master station based on the session key K, and the control data is generated by the power distribution master station according to the received encrypted monitoring data; and carrying out SM1 decryption operation on the encrypted control data according to the session key K to obtain the control data.
According to the technical scheme of the embodiment of the disclosure, authentication and key agreement between the power distribution terminal and the power distribution main station are realized through an improved SM2 algorithm, encrypted communication between the power distribution terminal and the power distribution main station is realized through an SM1 algorithm, so that both communication parties can use less communication resources and calculation resources on the premise of ensuring the security of the key agreement, the utilization rate of system resources in the power distribution terminal is optimized, the bottleneck of high concurrency of the power distribution main station when massive power distribution terminals are accessed is avoided, and the applicability of the scheme is improved.
Fig. 5 shows a block diagram of another secure communication device according to an embodiment of the present disclosure. The apparatus may be implemented as part or all of an electronic device through software, hardware, or a combination of both.
The secure communication device 500 may be located at a power distribution main station, as shown in fig. 5, and the secure communication device 500 includes:
the second authentication and key agreement module 501 is configured to enable the power distribution master station and the power distribution terminal to perform authentication based on an improved SM2 algorithm, and perform key agreement with the power distribution terminal after the authentication is successful based on the improved SM2 algorithm, so as to obtain a session key K of the power distribution terminal and the power distribution master station, where in the improved SM2 algorithm, a random public key factor directly participates in an identifier mapping algorithm, so as to realize binding between a random public key and an identifier;
and a second encrypted communication module 502 configured to enable the power distribution master station and the power distribution terminal to perform encrypted communication based on an SM1 algorithm by using the session key K when the key agreement result is true.
According to the embodiment of the disclosure, the authentication of the power distribution main station and the power distribution terminal based on the improved SM2 algorithm includes: the power distribution master station generates a second random public key factor r2 and an identity displacement identifier ID2 of the power distribution master station; receiving a first random public key factor r1, a unique identifier S1 of the session and an identity unique identifier ID1 of the power distribution terminal, which are sent by the power distribution terminal; receiving a first Request value Request sent by the power distribution terminal, wherein the first Request value Request is obtained by the power distribution terminal through calculation according to the r1, the S1 and the ID1, and comprises a first encryption result obtained through encryption calculation of an SM2 algorithm public key of the power distribution main station on the r1, the S1 and the ID1, and a second encryption result obtained through encryption calculation of an SM2 algorithm private key of the power distribution terminal on the r1, the S1 and the ID 1; decrypting the first encryption result based on an SM2 algorithm private key of the power distribution master station to obtain r1, S1 and ID 1; and decrypting the second encryption result based on the SM2 algorithm public key of the power distribution terminal to obtain a second decryption result, and when the second decryption result is determined to be the same as the SM3 algorithm hash operation result of the r1, the S1 and the ID1, the power distribution master station successfully authenticates the power distribution terminal. And after the power distribution main station successfully authenticates the power distribution terminal, sending a first recovery value Reply to the power distribution terminal so that the power distribution terminal authenticates the power distribution main station according to the first recovery value Reply.
Wherein the first Request value Request is calculated by the following formula: request = E pc (r1ǁS1ǁID1)ǁE dt (H(r1ǁS1ǁID1) Wherein, | | is data splicing operation, H () is SM3 algorithm hash operation on the data in parentheses, E | pc () The public key of SM2 algorithm of distribution main station is used to make encryption operation on the data in parentheses, E dt () The SM2 algorithm private key of the power distribution terminal is used for carrying out encryption operation E on the data in brackets pc (r 1 ǁ S1 ǁ ID 1) is the first encryption result, E dt (H (r 1 ǁ S1 ǁ ID 1)) is the second encryption result.
According to the embodiment of the disclosure, the key agreement with the power distribution terminal based on the improved SM2 algorithm after the authentication is successful includes: selecting point B (x) on the elliptic curve
B ,y
B ) Wherein point B satisfies the elliptic curve equation and is a non-infinite point; receiving point A = (x) transmitted by power distribution terminal
A ,y
A ) Wherein, the point A satisfies an elliptic curve equation and is a point which is not at infinity; obtaining the domain element in the point B, and carrying out dual transformation on the domain element in the point B to obtain a second conjugate value
Wherein
n is a natural number,&is a bitwise AND operation; calculating a second intermediate value based on the second conjugate value
Wherein mod is a modulo operation;
obtaining the domain element in the point A, and carrying out dual transformation on the domain element in the point A to obtain a first conjugate value
(ii) a According to the second intermediate value t
B And a first conjugate value
Calculating a point on an elliptic curve
Wherein h is a cofactor; when the point V is judged to be a non-infinite point, a fourth random number R is calculated
B = R2^ R1, and transmits the R
B To the distribution main station so that the distribution main station can be operated according to the fourth random number R
B And a third random number R
A Judging the result of key agreement, wherein the third random number R
A The power distribution terminal calculates a fourth random number R by adopting a mode of calculating a power distribution main station
B Calculated in the same way, is a bitwise logic operation. When the fourth random number R
B And a third random number R
A And if so, the key negotiation result is true, otherwise, the key negotiation result is false. According to the formula K = KDF (x)
U ǁy
U ǁZ
t ǁZ
c ǁr1ǁr2,L
K ) Calculating a session key K of the power distribution terminal and the power distribution main station, wherein KDF () is a key derivation function, x
V And y
V A field element of point V, Z
t Is a hash value of the discernible identifier relating to the distribution terminal, the partial elliptic curve system parameter and its public key, Z
c Is a hash value of the discernible identity, partial elliptic curve system parameters and its public key with respect to the distribution main station, L
K Is the encoding length of the session key K.
According to the embodiment of the disclosure, the encrypted communication with the power distribution terminal by using the session key K based on the SM1 algorithm includes: acquiring encrypted monitoring data sent by a power distribution terminal, wherein the encrypted monitoring data is obtained by carrying out SM1 encryption operation on the monitoring data by the power distribution terminal based on the session key K; carrying out decryption operation on the encrypted monitoring data based on the session key K to obtain the monitoring data; generating corresponding control data according to the monitoring data; performing SM1 encryption operation on the control data based on the session key K to obtain encrypted control data; and sending the encrypted control data to the power distribution terminal.
According to the technical scheme of the embodiment of the disclosure, authentication and key agreement between the power distribution terminal and the power distribution main station are realized through an improved SM2 algorithm, encrypted communication between the power distribution terminal and the power distribution main station is realized through an SM1 algorithm, so that both communication parties can use less communication resources and calculation resources on the premise of ensuring the security of the key agreement, the utilization rate of system resources in the power distribution terminal is optimized, the bottleneck of high concurrency of the power distribution main station when massive power distribution terminals are accessed is avoided, and the applicability of the scheme is improved.
The embodiment of the present disclosure also provides a chip, where the chip includes the above secure communication device, and the device may be implemented as part or all of the chip through software, hardware, or a combination of both.
The present disclosure also discloses an electronic device, and fig. 6 shows a block diagram of the electronic device according to an embodiment of the present disclosure.
As shown in fig. 6, the electronic device includes a memory and a processor, where the memory is to store one or more computer instructions, where the one or more computer instructions are executed by the processor to implement a method according to an embodiment of the disclosure.
According to an embodiment of the present disclosure, the method includes: the power distribution terminal and the power distribution master station perform authentication and key agreement based on an improved SM2 algorithm, wherein in the improved SM2 algorithm, a random public key factor directly participates in an identifier mapping algorithm to realize the binding between a random public key and an identifier; the power distribution terminal and the power distribution main station carry out encrypted communication based on an SM1 algorithm. Or, the power distribution master station and the power distribution terminal perform authentication and key agreement based on an improved SM2 algorithm, wherein in the improved SM2 algorithm, a random public key factor directly participates in an identifier mapping algorithm, and the binding between a random public key and an identifier is realized; the power distribution main station and the power distribution terminal carry out encrypted communication based on an SM1 algorithm.
FIG. 7 shows a schematic block diagram of a computer system suitable for use in implementing methods according to embodiments of the present disclosure.
As shown in fig. 7, the computer system includes a processing unit that can execute the various methods in the above-described embodiments according to a program stored in a Read Only Memory (ROM) or a program loaded from a storage section into a Random Access Memory (RAM). In the RAM, various programs and data necessary for the operation of the computer system are also stored. The processing unit, the ROM, and the RAM are connected to each other by a bus. An input/output (I/O) interface is also connected to the bus.
The following components are connected to the I/O interface: an input section including a keyboard, a mouse, and the like; an output section including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section including a hard disk and the like; and a communication section including a network interface card such as a LAN card, a modem, or the like. The communication section performs a communication process via a network such as the internet. The drive is also connected to the I/O interface as needed. A removable medium such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive as necessary, so that a computer program read out therefrom is mounted into the storage section as necessary. The processing unit can be realized as a CPU, a GPU, a TPU, an FPGA, an NPU and other processing units.
In particular, the methods described above may be implemented as computer software programs, according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program comprising program code for performing the above-described method. In such an embodiment, the computer program may be downloaded and installed from a network via the communication section, and/or installed from a removable medium.
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 disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). 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 the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present disclosure may be implemented by software or by programmable hardware. The units or modules described may also be provided in a processor, and the names of the units or modules do not in some cases constitute a limitation on the units or modules themselves.
As another aspect, the present disclosure also provides a computer-readable storage medium, which may be a computer-readable storage medium included in the electronic device or the computer system in the above embodiments; or it may be a separate computer readable storage medium not incorporated into the device. The computer readable storage medium stores one or more programs for use by one or more processors in performing the methods described in the present disclosure.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is possible without departing from the inventive concept. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.