Security authentication method and apparatus applied to Wi-Fi
This application provides a security authentication method and apparatus applied to Wi-Fi. An access point AP negotiates, based on a password, a pairwise master key PMK with a first device based on a twin base password encrypted key exchange TBPEKE protocol, where the password is a shared key between the AP and the first device; and the AP performs a 4-way handshake with the first device based on the PMK. Therefore, in embodiments of this application, a PMK with a high entropy value can be generated by performing a TBPEKE procedure, so that the security authentication method provided in embodiments of this application can help resist an offline dictionary attack.
1 . A security authentication method applied to wireless fidelity (Wi-Fi), comprising:
negotiating, by an access point (AP) based on a password, a pairwise master key (PMK) with a first device based on a twin base password encrypted key exchange (TBPEKE) protocol, wherein the password is a shared key between the AP and the first device; and
performing, by the AP, a 4-way handshake with the first device based on the PMK;
wherein the PMK comprises a first PMK1 and a second PMK2, and negotiating, by the AP based on the password, the PMK with the first device based on the TBPEKE protocol comprises:
obtaining, by the AP, a first parameter X from the first device, wherein the first parameter X is determined based on a hash-to-curve function (g) for converting the password into a point on an elliptic curve through a point multiplication operation, X=g x , where x is a random number;
sending, by the AP, a second parameter Y to the first device, to indicate the first device to calculate the first PMK1 based on the first parameter X and the second parameter Y, wherein the second parameter Y is determined based on g, Y=g y , where y is a random number; and
calculating, by the AP, the second PMK2 based on the first parameter X and the second parameter Y.
2 . The method according to claim 1 , wherein before negotiating, by the access point AP based on the password, the PMK with the first device based on the TBPEKE protocol, the method further comprises:
performing, by the AP, an association with the first device to agree on a to-be-used security suite, wherein the security suite indicates g.
3 . The method according to claim 1 , wherein performing, by the AP, the 4-way handshake with the first device based on the PMK comprises:
sending, by the AP, a first message to the first device, wherein the first message indicates the first device to generate a first pairwise transient key (PTK1), the first message comprises a nonce of the AP, the first PTK1 is generated based on the first PMK1, the nonce of the AP, and a nonce of the first device, and the first PTK1 comprises a first key confirmation key (KCK1), a first key encryption key (KEK1), and a first transient key (TK1);
obtaining a second message from the first device, wherein a message integrity of the second message is protected by using the first KCK1, and the second message comprises the nonce of the first device;
generating, by the AP, a second PTK2 based on the second PMK2, the nonce of the AP, and the nonce of the first device, wherein the second PTK2 comprises a second KCK2, a second KEK2, and a second TK2;
sending, by the AP, a third message to the first device, wherein the third message comprises a group transient key (GTK), a privacy of the GTK of the third message is protected by using the second KEK2, and a message integrity of the third message is protected by using the second KCK2; and
obtaining from the first device a fourth message for responding to the third message, wherein a message integrity of the fourth message is protected by using the second KCK2.
4 . The method according to claim 1 , wherein g is represented as:
g=U·V pw , wherein
U and V are two independent randomly generated elements obtained from a cyclic group G whose order is a prime p, and pw represents the password.
5 . The method according to claim 1 , wherein g is pre-stored locally in the AP.
6 . The method according to claim 1 , wherein the second parameter Y is generated by the AP based on g; or
the second parameter Y is determined by the AP by reusing another second parameter Y sent to a second device.
7 . The method according to claim 1 , wherein before sending, by the AP, the second parameter Y to the first device, the method further comprises:
obtaining an identifier (ID) of the first device from the first device;
sending a token for an anti-DoS service to the first device, wherein the token is determined based on the ID of the first device and a key (k);
obtaining the token and the ID of the first device from the first device; and
performing verification on the token based on the ID of the first device and k.
8 . The method according to claim 1 , wherein before sending, by the AP, the second parameter Y to the first device, the method further comprises:
determining that a list does not comprise the ID of the first device, wherein the list comprises an ID of at least one device connected to a network provided by the AP.
9 . The method according to claim 7 , further comprising:
adding the ID of the first device to the list.
10 . The method according to claim 7 , wherein the ID of the first device comprises a MAC address of the first device.
11 . A security authentication method applied to wireless fidelity (Wi-Fi), the method comprising:
negotiating, by a first device based on a password, a pairwise master key (PMK) with an access point (AP) based on a twin base password encrypted key exchange (TBPEKE) protocol, wherein the password is a shared key between the AP and the first device; and
performing, by the first device, a 4-way handshake with the AP based on the PMK;
wherein the PMK comprises a first PMK1 and a second PMK2, and negotiating, by the first device based on the password, the pairwise master key PMK with the AP based on the TBPEKE protocol comprises:
sending, by the first device, a first parameter (X) to the AP, wherein X is determined based on a hash-to-curve function (g) for converting the password into a point on an elliptic curve through a point multiplication operation, X=g x , where x is a random number;
obtaining, by the first device, a second parameter (Y) from the AP, wherein Y is determined based on g, Y=g y , where y is a random number, and X and Y are used by the AP to calculate the second PMK2; and
calculating, by the first device, the first PMK1 based on X and Y.
12 . The method according to claim 11 , wherein before negotiating, by the first device based on the password, the PMK with the AP based on the TBPEKE protocol, the method further comprises:
performing, by the first device, an association with the AP to agree on a to-be-used security suite, wherein the security suite indicates g.
13 . The method according to claim 11 , wherein performing, by the first device, the 4-way handshake with the AP based on the PMK comprises:
receiving, by the first device, a first message from the AP, wherein the first message comprises a nonce of the AP;
generating, by the first device, a first pairwise transient key (PTK1) based on the first PMK1, the nonce of the AP, and a nonce of the first device, wherein the first PTK1 comprises a first key confirmation key (KCK1), a first key encryption key (KEK1), and a first transient key (TK1);
sending a second message to the AP, wherein a message integrity of the second message is protected by using the first KCK1, the second message comprises the nonce of the first device, the second message indicates the AP to generate a second PTK2, the second PTK2 is generated based on the second PMK2, the nonce of the AP, and the nonce of the first device, and the second PTK2 comprises a second KCK2, a second KEK2, and a second TK2;
obtaining a third message from the AP, wherein the third message comprises a group transient key (GTK), a privacy of the GTK of the third message is protected by using the second KEK2, and a message integrity of the third message is protected by using the second KCK2; and
sending a fourth message to the AP, wherein the fourth message is for responding to the third message, and a message integrity of the fourth message is protected by using the second KCK2.
14 . A security authentication apparatus applied to wireless fidelity (Wi-Fi), the apparatus comprising:
a processor and a transceiver, wherein
the processor is coupled to the transceiver and is configured to negotiate, based on a password, a pairwise master key (PMK) with a first device based on a twin base password encrypted key exchange (TBPEKE) protocol, wherein the password is a shared key between an access point (AP) and the first device; and
perform a 4-way handshake with the first device based on the PMK;
wherein the PMK comprises a first PMK1 and a second PMK2, and the processor is further configured to:
indicate the transceiver to obtain a first parameter (X) from the first device, wherein X is determined based on a hash-to-curve function (g) for converting the password into a point on an elliptic curve through a point multiplication operation, X=g x , where x is a random number;
indicate the transceiver to send a second parameter (Y) to the first device, to indicate the first device to calculate the first PMK1 based on X and Y, wherein Y is determined based on g, Y=g y , where y is a random number; and
calculate the second PMK2 based on X and Y.
15 . The apparatus according to claim 14 , wherein the processor is further configured to perform an association with the first device to agree on a to-be-used security suite, wherein the security suite indicates g.
16 . The apparatus according to claim 14 , wherein the processor is further configured to:
indicate the transceiver to send a first message to the first device, wherein the first message indicates the first device to generate a first pairwise transient key (PTKT), the first message comprises a nonce of the AP, the first PTK1 is generated based on the first PMK1, the nonce of the AP, and a nonce of the first device, and the first PTK1 comprises a first key confirmation key (KCK1), a first key encryption key (KEK1), and a first transient key (TK1);
indicate the transceiver to obtain a second message from the first device, wherein a message integrity of the second message is protected by using the first KCK1, and the second message comprises the nonce of the first device;
generate a second PTK2 based on the second PMK2, the nonce of the AP, and the nonce of the first device, wherein the second PTK2 comprises a second KCK2, a second KEK2, and a second TK2;
indicate the transceiver to send a third message to the first device, wherein the third message comprises a group transient key (GTK), a privacy of the GTK of the third message is protected by using the second KEK2, and a message integrity of the third message is protected by using the second KCK2; and
indicate the transceiver to obtain a fourth message from the first device, wherein the fourth message is for responding to the third message, and a message integrity of the fourth message is protected by using the second KCK2.
17 . The apparatus according to claim 14 , wherein g is represented as:
g=U·V pw , wherein
U and V are two independent randomly generated elements obtained from a cyclic group G whose order is a prime p, and pw represents the password.