Authentication method, medium, and electronic device
An authentication method and an electronic device. The method includes sending, by a first device, in response to a first device determining that a distance between the first device and a second device reaches a first distance, a first request to the second device, so that the second device determines whether wireless communication between the first and second device is relayed before the first device performs a service, determining, in response to the distance between the first and second device reaching a second distance, whether success ciphertext sent by the second device is received, wherein the success ciphertext is sent in response to the second device determining that wireless communication between the first and second device is not relayed and the second distance being less than the first distance, and performing the service in response to reception and successful verification of the success ciphertext.
1 . An authentication method, comprising:
sending, by a first device, in response to the first device determining that a distance between the first device and a second device reaches a first preset distance, a first authentication request to the second device, wherein the first authentication request requests that the second device determine whether wireless communication between the first device and the second device is subject to a relay attack according to a duration of an anti-relay determination exceeding a time threshold and before the first device performs a service agreed on with the second device, wherein the anti-relay determination comprises simultaneously performing satellite positioning and network positioning to determine a height and position of the second device and further comprises determining, in a trusted execution environment (TEE), whether the second device is rooted, wherein the second device being rooted comprises the second device being subject to malicious control;
determining, by the first device, in response to determining that the distance between the first device and the second device reaches a second preset distance, whether a first authentication success ciphertext sent by the second device is received, wherein the first authentication success ciphertext is sent by the second device in response to the second device determining that wireless communication between the first device and the second device is not subject to the relay attack, and further in response to the second preset distance being less than the first preset distance; and
performing, by the first device, the service agreed on with the second device in response to the first device determining that the first authentication success ciphertext sent by the second device is received, and further in response to verification performed by the first device on the first authentication success ciphertext succeeding.
2 . The method according to claim 1 , further comprising:
sending, by the first device, a second authentication request to the second device, in response to the first device determining that the distance between the first device and the second device reaches the second preset distance, and further in response to the first authentication success ciphertext sent by the second device being not received or verification on the received first authentication success ciphertext failing, wherein the second authentication request requests that the second device perform biometric verification on a user of the second device; and
performing, by the first device, the service agreed on with the second device in response to the first device receiving a second authentication success ciphertext sent by the second device and further in response to verification performed by the first device on the second authentication success ciphertext succeeding, wherein the second authentication success ciphertext is sent by the second device after the biometric verification performed by the second device on the user succeeds.
3 . The method according to claim 2 , further comprising performing, before the performing, by the first device, the service agreed on with the second device:
determining, by the first device, whether the distance between the first device and the second device is less than a third preset distance, wherein the third preset distance is less than the second preset distance; and
performing, by the first device, the service agreed on with the second device, in response to the first device determining that the distance between the first device and the second device is less than the third preset distance.
4 . The method according to claim 2 , further comprising:
performing, by the first device, verification on the second authentication success ciphertext in response to the distance between the first device and the second device being less than the third preset distance, further in response to the first device receiving the second authentication success ciphertext, and further in response to determining that the distance between the first device and the second device is less than the third preset distance.
5 . The method according to claim 1 , further comprising:
performing, by the first device, verification on the first authentication success ciphertext or the second authentication success ciphertext in response to receiving the first authentication success ciphertext or the second authentication success ciphertext.
6 . The method according to claim 1 , further comprising:
performing, by the first device, verification on the first authentication success ciphertext, in response to the distance between the first device and the second device being less than the second preset distance, further in response to the first device receiving the first authentication success ciphertext, and further in response to the distance between the first device and the second device reaching the second preset distance.
7 . The method according to claim 1 , wherein the agreed service is an unlock service or a payment service.
8 . The method according to claim 7 , wherein when the agreed service is the unlock service, the second device is a mobile terminal, and the first device is a vehicle or a lock.
9 . The method according to claim 7 , wherein when the agreed service is the payment service, the second device is a mobile terminal, and the first device is a tolling terminal.
10 . An authentication method, comprising:
receiving, by a second device, a first authentication request from a first device, wherein the first authentication request is sent by the first device in response to a distance between the second device and the first device reaching a first preset distance;
determining, by the second device in response to the received first authentication request, whether wireless communication between the second device and the first device is subject to a relay attack according to a duration of an anti-relay determination exceeding a time threshold, wherein the anti-relay determination comprises simultaneously performing satellite positioning and network positioning to determine a height and position of the second device and further comprises determining, in a trusted execution environment (TEE), whether the second device is rooted, wherein the second device being rooted comprises the second device being subject to malicious control; and
sending, by the second device, a first authentication success ciphertext to the first device in response to determining that wireless communication between the second device and the first device is not subject to the relay attack, wherein the first authentication success ciphertext is associated with performance, by the first device, of a service agreed on between the first device and the second device.
11 . The method according to claim 10 , further comprising performing, after the receiving the first authentication request:
receiving, by the second device, a second authentication request from the first device, wherein the second authentication request is sent by the first device in response to the first device determining that the distance between the first device and the second device reaches a second preset distance, and further in response to the first authentication success ciphertext sent by the second device not being received or verification performed by the first device on the received first authentication success ciphertext failing, and further in response to the second preset distance being less than the first preset distance;
performing, by the second device, biometric verification on a user of the second device in response to the received second authentication request; and
sending, by the second device, a second authentication success ciphertext to the first device in response to the biometric verification succeeding.
12 . The method according to claim 11 , further comprising performing, before the receiving the first authentication request from the first device:
receiving, by the second device, a wireless communication broadcast sent by the first device;
establishing, by the second device, wireless communication with the first device;
receiving, by the second device, a data obtaining request from the first device; and
sending, by the second device in response to the data obtaining request being received from the first device, data required for authentication to the first device, wherein the data required for authentication comprises the first preset distance and the second preset distance.
13 . The method according to claim 10 , wherein the agreed service is an unlock service or a payment service.
14 . The method according to claim 13 , wherein when the agreed service is the unlock service, the second device is a mobile terminal, and the first device is a vehicle or a lock.
15 . The method according to claim 13 , wherein when the agreed service is the payment service, the second device is a mobile terminal, and the first device is a tolling terminal.
16 . A non-transitory, non-volatile computer-readable medium, wherein the non-transitory, non-volatile computer-readable medium stores instructions, and when the instructions are executed on a computer associated with a first device, the first device is enabled to perform the authentication method according to claim 1 .
17 . A first device, comprising:
one or more processors; and
at least one non-transitory memory; and
at least one non-transitory computer readable memory connected to the one or more processors and including computer program code, wherein the at least one non-transitory computer readable memory and the computer program code are configured, with the one or more processors, to cause the first device to perform at least:
sending, in response to determining that a distance between the first device and a second device reaches a first preset distance, a first authentication request to the second device, wherein the first authentication request requests that the second device determine whether wireless communication between the first device and the second device is subject to a relay attack according to a duration of an anti-relay determination exceeding a time threshold and before the first device performs a service agreed on with the second device, wherein the anti-relay determination comprises simultaneously performing satellite positioning and network positioning to determine a height and position of the second device and further comprises determining, in a trusted execution environment (TEE), whether the second device is rooted, wherein the second device being rooted comprises the second device being subject to malicious control;
determining in response to determining that the distance between the first device and the second device reaches a second preset distance, whether a first authentication success ciphertext sent by the second device is received, wherein the first authentication success ciphertext is sent by the second device in response to the second device determining that wireless communication between the first device and the second device is not subject to the relay attack, and further in response to the second preset distance being less than the first preset distance; and
performing the service agreed on with the second device in response to the first device determining that the first authentication success ciphertext sent by the second device is received, and further in response to verification performed by the first device on the first authentication success ciphertext succeeding.