WO2024061326A1 - 一种数据保护方法及电子设备 - Google Patents

一种数据保护方法及电子设备 Download PDF

Info

Publication number
WO2024061326A1
WO2024061326A1 PCT/CN2023/120459 CN2023120459W WO2024061326A1 WO 2024061326 A1 WO2024061326 A1 WO 2024061326A1 CN 2023120459 W CN2023120459 W CN 2023120459W WO 2024061326 A1 WO2024061326 A1 WO 2024061326A1
Authority
WO
WIPO (PCT)
Prior art keywords
counter
user data
electronic device
value
security chip
Prior art date
Application number
PCT/CN2023/120459
Other languages
English (en)
French (fr)
Inventor
李昂
郑亮
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2024061326A1 publication Critical patent/WO2024061326A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/70Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer
    • G06F21/71Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information
    • G06F21/72Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information in cryptographic circuits

Definitions

  • the present application relates to the field of data security technology, and in particular to a data protection method and electronic equipment.
  • security chips As a hardware-level high-security and trusted environment, security chips have security strength against physical attacks and are widely used in mobile devices, Internet of Things (IOT) devices and other devices with high security requirements.
  • IOT Internet of Things
  • security chips in devices can be used to store verification values that verify user data.
  • an electronic device uses user data, it needs to verify the correctness of the check value. Only when the check value passes the verification can the electronic device use the user data. How to improve the security of the check value of user data stored in security chips in China requires further research.
  • This application provides a data protection method and electronic device, which implements a multi-level authentication mechanism in a security chip. Only when the authentication is passed, the electronic device can use the second user data, which ensures the security of user data stored on the electronic device and prevents attackers from forging user data.
  • the present application provides a data protection method, the method comprising:
  • the electronic device obtains the second user data, the certificate of the first counter and the first check value of the first user data from the non-security chip; wherein the certificate of the first counter in the non-security chip is used to obtain the first counter's certificate.
  • the first value, the first check value and the first value of the first counter are used to verify whether the second user data is the same as the first user data; the electronic device obtains the certificate of the first counter from the security chip; in non-security When the credentials of the first counter in the chip are the same as the credentials of the first counter in the security chip, the electronic device obtains the first value of the first counter through the security chip; the electronic device uses the security chip based on the second user data and the first counter The first value of obtains the second check value of the second user data; when the first check value and the second check value are the same, the electronic device uses the second user data.
  • the non-security chip may be a flash chip, a server, or a storage device such as a hard disk, which is not limited in the embodiments of the present application.
  • the first user data is user data previously stored by the electronic device.
  • the second user data is the first user data previously stored by the electronic device.
  • the storage location of the first user data is the first storage location. Then the second user data can be user data read from the first storage location.
  • the attacker may have modified the first user data, for example, modified the first user data to the second user data.
  • the first user data and the second user data are different.
  • User data is different.
  • the storage locations of the first user data and the second user data may be the same.
  • the electronic device uses the second user data, that is, the electronic device uses the first user data.
  • a multi-level authentication mechanism is implemented within the security chip. Only when the authentication is passed, the electronic device can use the second user data, which ensures the security of user data stored on the electronic device and prevents attackers from forging user data.
  • the method further includes: when the credentials of the first counter in the non-security chip are different from the credentials of the first counter in the security chip, the electronic device cannot obtain the security chip from the security chip. to the first value of the first counter. In this way, when the attacker does not know the credentials of the first counter, the credentials of the first counter cannot pass the authentication, and the attacker cannot obtain the first value of the first counter, which ensures the security of the first counter stored in the security chip. First value security.
  • a possible implementation further includes: when the first check value and the second check value are different, the electronic device cannot use the second user data.
  • the security chip can also calculate the verification value of the user data based on other factors.
  • Other factors include but are not limited to one or more of a hardware unique key and a device unique ID.
  • Other factors can also be other numerical values, which are not limited in the embodiments of this application.
  • the second check value calculated by the security chip based on the second user data and the first value of the first counter is the same as the first check value.
  • the check value is also different, that is, the check value of the user data cannot be verified.
  • the electronic device cannot use the forged second user data.
  • the method before the electronic device obtains the second user data, the certificate of the first counter and the first check value of the first user data from the non-security chip, the method further includes : The electronic device stores the first user data, the first check value of the first user data and the certificate of the first counter in the non-secure chip. The electronic device stores the first value of the first counter and the credentials of the first counter in the secure chip.
  • the electronic device stores the first value of the first counter in the security chip, ensuring the security of the first value of the first counter and preventing the first value of the first counter from being obtained by an attacker.
  • the electronic device stores the credentials of the first counter in the security chip, so that when the electronic device uses the stored user data, it performs authentication based on the credentials of the first counter. Only after the authentication is passed, the electronic device can use the stored user data. , ensuring the security of user data stored on electronic devices.
  • the electronic device stores the credentials of the first counter in the security chip, which specifically includes: the electronic device generates the credentials of the first counter through the security chip; the electronic device stores the credentials of the first counter. Credentials are stored within the secure chip.
  • the security chip needs to save the credentials of the first counter in the non-security chip or on the server, so that when the electronic device uses the user data, it can be based on the credentials of the first counter stored in the non-security chip or on the server. Authentication.
  • the electronic device obtains the credential of the first counter outside the security chip; the electronic device stores the credential of the first counter in the security chip.
  • the first value of the first counter is obtained based on the initial value of the first counter and the first preset value, wherein the initial value of the counter is randomly generated.
  • the initial value of the first counter is randomly generated, which can prevent an attacker from obtaining the first value of the first counter through brute force enumeration, resulting in the leakage of the first value of the first counter stored in the security chip. , improving the security of the first value of the first counter stored in the security chip.
  • the method before the electronic device stores the first value of the first counter in the security chip, the method further includes: the electronic device generates an initial value of the first counter through the security chip. In this way, the initial value of the first counter is generated in the security chip, which improves the security of the value of the counter stored in the security chip.
  • the method before the electronic device obtains the second user data, the certificate of the first counter and the first check value of the first user data from the non-security chip, the method further includes : The electronic device obtains the first user data, the identification of the first counter and the credentials of the first counter stored in the non-security chip from the non-security chip; the electronic device determines the information stored in the security chip based on the identification of the first counter through the security chip.
  • the credential of the first counter in the non-security chip when the credential of the first counter in the non-security chip is the same as the credential of the first counter in the security chip, the electronic device obtains the first value of the first counter; the electronic device uses the security chip based on the The first value of a counter and the first user data obtain the first verification value of the first user data; the electronic device stores the first verification value of the first user data in the non-security chip. In this way, when the electronic device stores the first user data, the first verification value will be generated in the security chip based on the first user data and the first value of the first counter. After generating the first check value, the electronic device stores the first check value in a non-secure chip, such as a flash chip or on a server.
  • a non-secure chip such as a flash chip or on a server.
  • the second verification value is generated in the security chip based on the second user data and the first value of the first counter. It is also different from the first verification value, causing the verification to fail and preventing attackers from forging user data.
  • the method further includes: the electronic device obtains third user data, and the third user data is the changed second user data; The electronic device sends the third user data, the credentials of the first counter in the non-security chip, and the identity of the first counter to the security chip; the electronic device obtains the credentials of the first counter based on the identity of the first counter through the security chip; in the non-security When the credentials of the first counter in the chip are the same as the credentials of the first counter in the security chip, the electronic device obtains the first value of the first counter through the security chip, and based on the first value of the first counter and the second preset value to obtain the second value of the first counter; the electronic device obtains the third check value of the third user data based on the third user data and the second value of the first counter through the security chip; the electronic device obtains the third check value of the third user data based on the security chip.
  • the check value is stored in the non-secure chip.
  • the electronic device uses the second user data, causing the second user data to change and obtain the third user data.
  • the electronic device needs to store the third user data.
  • the electronic device When storing third-party user data, the electronic device must be The check value of the third user data, that is, the third check value, is generated within the entire chip. So that when the subsequent electronic device uses the third user data, it can verify whether the third user data is forged data based on the check value.
  • this application provides an electronic device.
  • the electronic device includes: one or more processors, one or more memories, and a display screen; one or more memories and display screens are coupled to one or more processors, One or more memories are used to store computer program codes.
  • the computer program codes include computer instructions.
  • One or more processors call the computer instructions to cause the electronic device to execute: obtain the second user data and the first counter from the non-security chip.
  • the certificate and the first check value of the first user data wherein, the certificate of the first counter in the non-security chip is used to obtain the first value of the first counter, and the first check value and the first value of the first counter are used To verify whether the second user data is the same as the first user data; obtain the certificate of the first counter from the security chip; when the certificate of the first counter in the non-security chip is the same as the certificate of the first counter in the security chip , obtain the first value of the first counter through the security chip; obtain the second verification value of the second user data based on the second user data and the first value of the first counter through the security chip; between the first verification value and the first value of the first counter, If the two check values are the same, the second user data is used.
  • the non-secure chip may be a flash chip, a server, or a storage device such as a hard disk, and the embodiments of the present application do not limit this.
  • the first user data is user data previously stored by the electronic device.
  • the second user data is the first user data stored before being read by the electronic device.
  • the storage location of the first user data is the first storage location. Then the second user data can be the user data read from the first storage location.
  • the attacker may have modified the first user data, for example, modified the first user data to the second user data.
  • the first user data and the second user data are different.
  • User data is different.
  • the storage locations of the first user data and the second user data may be the same.
  • the electronic device uses the second user data, that is, the electronic device uses the first user data.
  • a multi-level authentication mechanism is implemented within the security chip. Only when the authentication is passed, the electronic device can use the second user data, which ensures the security of user data stored on the electronic device and prevents attackers from forging user data.
  • one or more processors invoke computer instructions to cause the electronic device to execute: the credentials of the first counter in the non-security chip are different from the credentials of the first counter in the security chip.
  • the first value of the first counter cannot be obtained from the security chip.
  • the attacker does not know the credentials of the first counter, the credentials of the first counter cannot pass the authentication, and the attacker cannot obtain the first value of the first counter, which ensures the security of the first counter stored in the security chip.
  • one or more processors call computer instructions to cause the electronic device to execute: when the first check value and the second check value are different, the second check value cannot be used. User data.
  • the security chip can also calculate the verification value of the user data based on other factors, including but not limited to one or more of the hardware unique key and the device unique ID. Other factors can also be other values, which are not limited in the embodiments of the present application.
  • the second check value calculated by the security chip based on the second user data and the first value of the first counter is the same as the first check value.
  • the verification value is also different, that is, the verification value of the user data fails, and the electronic device cannot use the forged second user data at this time.
  • one or more processors invoke computer instructions to cause the electronic device to execute: converting the first user data, the first check value of the first user data and the first counter Credentials are stored in a non-secure chip. The first value of the first counter and the credentials of the first counter are stored in the security chip.
  • the electronic device stores the first value of the first counter in the security chip, ensuring the security of the first value of the first counter and preventing the first value of the first counter from being obtained by an attacker.
  • the electronic device stores the credentials of the first counter in the security chip, so that when the electronic device uses the stored user data, it performs authentication based on the credentials of the first counter. Only after the authentication is passed, the electronic device can use the stored user data. , ensuring the security of user data stored on electronic devices.
  • one or more processors invoke computer instructions to cause the electronic device to execute: Generate the certificate of the first counter through the security chip; store the certificate of the first counter in the security chip.
  • the security chip needs to save the credentials of the first counter in the non-security chip or on the server, so that when the electronic device uses the user data, it can be based on the credentials of the first counter stored in the non-security chip or on the server. Authentication.
  • the credentials of the first counter are obtained outside the security chip; and the credentials of the first counter are stored in the security chip.
  • the first value of the first counter is obtained based on the initial value of the first counter and the first preset value, wherein the initial value of the counter is randomly generated.
  • the initial value of the first counter is randomly generated, which can prevent an attacker from obtaining the first value of the first counter through brute force enumeration, resulting in the leakage of the first value of the first counter stored in the security chip. , improving the security of the first value of the first counter stored in the security chip.
  • one or more processors invoke computer instructions to cause the electronic device to execute: generate an initial value of the first counter through the security chip.
  • the initial value of the first counter is generated in the security chip, which improves the security of the value of the counter stored in the security chip.
  • one or more processors invoke computer instructions to cause the electronic device to execute: obtain the first user data, the identification of the first counter and the non-security chip from the non-security chip The credentials of the first counter stored in the security chip; the credentials of the first counter stored in the security chip are determined based on the identity of the first counter; the credentials of the first counter in the non-security chip and the credentials of the first counter in the security chip Under the same situation, the first value of the first counter is obtained; the first check value of the first user data is obtained through the security chip based on the first value of the first counter and the first user data; and the first value of the first user data is obtained. A check value is stored in the non-secure chip.
  • the electronic device when the electronic device stores the first user data, the first verification value will be generated in the security chip based on the first user data and the first value of the first counter.
  • the electronic device After generating the first check value, the electronic device stores the first check value in a non-secure chip, such as a flash chip or on a server.
  • a non-secure chip such as a flash chip or on a server.
  • the attacker forges user data for example, uses the second user data to replace the first user data
  • the second verification value is generated in the security chip based on the second user data and the first value of the first counter. It is also different from the first verification value, causing the verification to fail and preventing attackers from forging user data.
  • one or more processors call computer instructions to enable the electronic device to execute: after the electronic device uses the second user data, obtain third user data, the third user data is the changed second user data; send the third user data, the credential of the first counter in the non-secure chip and the identifier of the first counter to the secure chip; obtain the credential of the first counter based on the identifier of the first counter through the secure chip; when the credential of the first counter in the non-secure chip and the credential of the first counter in the secure chip are the same, obtain the first value of the first counter through the secure chip, and obtain the second value of the first counter based on the first value and the second preset value of the first counter; obtain a third verification value of the third user data based on the third user data and the second value of the first counter through the secure chip; and save the third verification value of the third user data in the non-secure chip.
  • the electronic device uses the second user data, causing the second user data to change and obtain the third user data.
  • the electronic device needs to store the third user data.
  • the electronic device needs to generate a check value of the third user data in the security chip, that is, a third check value. So that when the subsequent electronic device uses the third user data, it can verify whether the third user data is forged data based on the check value.
  • this application provides a computer-readable storage medium for storing computer instructions.
  • the computer instructions When the computer instructions are run on an electronic device, the electronic device causes the electronic device to execute any of the possible implementation methods provided in the first aspect.
  • this application provides a computer program product.
  • the computer program product When the computer program product is run on an electronic device, it causes the electronic device to execute a data protection method provided in any possible implementation of the first aspect.
  • FIGS 1-3 are schematic diagrams of several security chips provided by embodiments of the present application.
  • Figure 4 is a schematic diagram of an electronic device storing a check value of user data provided by an embodiment of the present application
  • Figure 5 is a schematic diagram of an electronic device verifying a check value of user data provided by an embodiment of the present application
  • Figure 6 is a schematic diagram of another electronic device storing a check value of user data provided by an embodiment of the present application.
  • Figure 7 is a schematic diagram of another electronic device verifying the check value of user data provided by an embodiment of the present application.
  • Figure 8 is a schematic diagram of the hardware structure of an electronic device 100 provided by an embodiment of the present application.
  • Figure 9 is a schematic diagram of the software structure of an electronic device 100 provided by an embodiment of the present application.
  • Figure 10 is a schematic flowchart of a method for generating counter credentials provided by an embodiment of the present application.
  • Figure 11 is a schematic flowchart of another method for generating counter credentials provided by an embodiment of the present application.
  • Figure 12 is a schematic diagram of protecting user data and generating a check value of user data provided by an embodiment of the present application
  • Figure 13 is a schematic diagram of a method for verifying the correctness of the check value of the first user data in the security chip before the electronic device uses the first user data according to an embodiment of the present application;
  • Figure 14 is a schematic diagram of a method for saving changed second user data provided by an embodiment of the present application.
  • Figure 15 is a schematic flow chart of a data protection method provided by an embodiment of the present application.
  • Figure 16 is a schematic flowchart of a data protection device provided by an embodiment of the present application.
  • first and second are used for descriptive purposes only and shall not be understood as implying or implying relative importance or implicitly specifying the quantity of indicated technical features. Therefore, the features defined as “first” and “second” may explicitly or implicitly include one or more of the features. In the description of the embodiments of this application, unless otherwise specified, “plurality” The meaning is two or more.
  • GUI graphical user interface
  • the check value of user data is used to protect the security of user data on electronic devices. Before the electronic device stores user data, a check value of the user data is generated and stored in a non-secure chip. When the electronic device uses user data, the electronic device will verify the correctness of the verification value of the user data in the security chip. Only if the verification passes, the electronic device can obtain and use the user data. When the verification value of the user data fails to pass, the electronic device cannot obtain the user data.
  • the verification value of the user data may be generated based on the user data or based on other parameters, which is not limited in the embodiments of the present application.
  • the electronic device When the electronic device stores user data, it will additionally store a check value of the user data so that the electronic device can verify the correctness of the check value of the user data. Specifically, before the electronic device uses the user data, the electronic device obtains the check value of the user data stored separately, and obtains the check value of the user data from the security chip, and adds the check value of the user data stored elsewhere. When the check value of the user data calculated in the security chip is consistent, the check value of the user data passes. At this time, the electronic device can obtain and use the user data. Otherwise, the electronic device cannot obtain or use the user data.
  • the identity authentication information is generally stored in the security chip of the electronic device to prevent the user data from being stored in the electronic device. Identity authentication information leaked.
  • Form 1 As shown in Figure 1, the security chip is located in the built-in security core of the main chip (SOC chip) in the electronic device. It can be that a part of the main chip is divided as a security chip, or the security chip is integrated inside the main chip.
  • SOC chip main chip
  • Form 2 As shown in Figure 2, the security chip is located in the secure element (SE) of the external SOC chip.
  • SE is an electronic component that resists physical attacks. It contains a microprocessor, storage, and encryption and decryption hardware. Can be used independently.
  • Form 3 As shown in Figure 3, the security chip is composed of a SOC chip and an SE with an external SOC chip to complete some high-security services. Ensure high security of equipment.
  • the security chip can also be in other forms, which is not limited in the embodiments of this application.
  • FIG. 4 shows a schematic diagram of a verification value of user data stored in an electronic device.
  • the check value of the user data may be an adder value.
  • the counter value is +1, and then the updated counter value is stored in the security chip.
  • the value of the counter will be changed, for example +1, and then the updated counter value will be stored in the security chip.
  • the content of user data and the value of the counter are bound one-to-one.
  • the value of the counter will also change accordingly.
  • the electronic device obtains user data.
  • the data generated can be called user data.
  • the user data may include Internet data balance, recharge card balance, bus card balance and other data.
  • the electronic device obtains the counter value one.
  • the electronic device Before the electronic device stores the user data, the electronic device can obtain the counter value one.
  • the electronic device stores the user data and the counter value in the non-security chip, and stores the counter value in the security chip.
  • the electronic device may store user data and counter values in a non-secure chip, and the non-secure chip may be a flash chip.
  • the electronic device can encrypt the user data and counter value and store them in the non-secure chip.
  • the user data and the counter value 1 may be stored in the same area in the non-security chip, or may be stored in different areas in the non-security chip. This is not limited in the embodiment of the present application.
  • the electronic device also needs to store the counter value in the security chip.
  • Figure 5 shows a schematic diagram of an electronic device verifying a check value of user data.
  • Figure 5 shows a method flow for verifying the check value of user data.
  • the electronic device obtains the counter value two from the non-security chip.
  • the electronic device When an electronic device needs to use user data, the electronic device needs to first verify the check value of the user data.
  • the electronic device obtains the counter value two from the non-secure chip.
  • the electronic device can obtain the counter value two from the flash chip.
  • the counter value two obtained by the electronic device from the non-secure chip may be different from the previously stored counter value one.
  • the electronic device obtains the counter value three from the security chip.
  • the electronic device also needs to obtain the counter value three from the security chip.
  • the counter value three obtained by the electronic device from the security chip may be different from the previously stored counter value one.
  • the electronic device cannot use user data.
  • counter value 2 and counter value 3 are different, it means that the attacker may have modified counter value 1 stored in the security chip, or the attacker may have modified counter value 1 stored in the non-security chip. Then the verification value of the user data cannot be verified. In order to protect the security of user data, the electronic device cannot use the user data at this time.
  • the attacker may forge the user data before using it and use the forged user data.
  • Figure 6 shows another schematic diagram of storing a check value of user data.
  • the check value of the user data may be calculated based on the user data.
  • a check value is calculated based on the user data, and then the check value is stored in the security chip.
  • the electronic device uses user data and causes the user data to change, when storing the changed user data, a verification value will be obtained based on the changed user data, and then the updated verification value will be stored in the security chip.
  • the content of user data and the check value are bound one-to-one.
  • the check value of the user data will also change accordingly.
  • S601 The electronic device obtains user data.
  • S602 The electronic device obtains a verification value 1 of the user data based on the user data.
  • the electronic device can calculate the hash value of the user data and use the hash value as the check value one.
  • the electronic device can also obtain the check value one of the user data based on the user data in other ways, which is not limited in the embodiments of the present application.
  • the electronic device stores the verification value of the user data in the security chip.
  • the check value of the user data is stored in the security chip. So that when the user data is used later, the check value of the user data can be verified. If the verification passes, the electronic device is allowed to use the user data.
  • Figure 7 shows a schematic diagram of another electronic device verifying the check value of user data.
  • Figure 7 shows the flow of another method of checking the check value of user data.
  • the electronic device obtains the check value two of the user data from the security chip.
  • the electronic device needs to first verify the check value of the user data. First, the electronic device obtains the check value two of the user data from the security chip.
  • the second verification value of the user data obtained by the electronic device from the security chip may be different from the first verification value of the user data stored previously.
  • the electronic device obtains the check value three of the user data based on the user data.
  • the electronic device also obtains the check value three of the user data. For example, the electronic device can calculate the check value three of the user data based on the user data stored in the non-security chip.
  • the check value of the user data calculated by the electronic device based on the user data stored in the non-secure chip is different from the user data previously calculated based on the user data stored in the non-secure chip.
  • the checksum of the data may be different.
  • check value three and check value two are the same, execute S704. If check value three and check value two are different, execute S705.
  • the electronic device can Obtain and use user data.
  • the electronic device cannot use user data.
  • the check value three and the check value two are different, it means that the attacker may have modified the check value of the user data stored in the security chip, and the attacker may also have modified the user data stored in the non-security chip, then the The check value of the user data cannot pass the verification. In order to protect the security of the user data, the electronic device cannot use the user data at this time.
  • embodiments of the present application provide a data protection method, which includes applying for a counter, protecting user data, and using user data.
  • applying for counter includes the following steps:
  • Step 1 The electronic device obtains the first user data.
  • Step 2 The electronic device obtains the certificate of the first counter and sets the value of the first counter to the first value.
  • the electronic device can set the value of the first counter to the first value in the security chip, because the security chip has a high safety factor to avoid leakage of the value of the first counter.
  • Step 3 The electronic device stores the credentials of the first counter in the security chip, and stores the credentials of the first counter in the non-security chip or in the cloud.
  • Protecting user data includes the following steps:
  • Step 1 The electronic device sends the first user data and the certificate of the first counter to the security chip.
  • Step 2 When the credentials of the first counter sent by the electronic device are the same as the credentials of the first counter stored in the security chip, the electronic device calculates the first verification based on the first user data and the first value of the first counter. value.
  • Step 3 The electronic device saves the first verification value in the non-security chip or in the cloud.
  • Using user data includes the following steps:
  • Step 1 The electronic device sends the second user data, the certificate of the first counter and the first verification value to the security chip.
  • Step 2 When the credentials of the first counter sent by the electronic device are the same as the credentials of the first counter stored in the security chip, the electronic device calculates the second calibration based on the second user data and the first value of the first counter. test value.
  • Step 3 If the first check value and the second check value are the same, the verification is successful, indicating that the first user data and the second user data are the same, that is, the user data has not been changed, and the electronic device can use the first user data.
  • the verification fails, indicating that the first user data and the second user data are different. An attacker may have changed the first user data, and the electronic device cannot use the second user data. 1. User data.
  • the user data can only be used after passing the authentication in the security chip, preventing the user data from being changed by the attacker, and protecting the user Data security.
  • FIG. 8 shows a schematic structural diagram of the electronic device 100.
  • the electronic device 100 may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (personal digital assistant) digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, wearable device, vehicle-mounted device, smart home device and/or Smart city equipment, the embodiment of this application does not place special restrictions on the specific type of electronic equipment.
  • PDA personal digital assistant
  • AR augmented reality
  • VR virtual reality
  • AI artificial intelligence
  • wearable device wearable device
  • vehicle-mounted device smart home device and/or Smart city equipment
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone interface 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (SIM) card interface 195, etc.
  • a processor 110 an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone interface 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display
  • the sensor module 180 may include a pressure sensor 180A, a gyro sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light. Sensor 180L, bone conduction sensor 180M, etc.
  • the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100 .
  • the electronic device 100 may include more or fewer components than shown in the figures, or some components may be combined, some components may be separated, or some components may be arranged differently.
  • the components illustrated may be implemented in hardware, software, or a combination of software and hardware.
  • the processor 110 may include one or more processing units.
  • the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processing unit (GPU), and an image signal processor. (image signal processor, ISP), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU), etc.
  • application processor application processor, AP
  • modem processor graphics processing unit
  • GPU graphics processing unit
  • image signal processor image signal processor
  • ISP image signal processor
  • controller video codec
  • digital signal processor digital signal processor
  • DSP digital signal processor
  • baseband processor baseband processor
  • neural network processor neural-network processing unit
  • the controller can generate operation control signals based on the instruction operation code and timing signals to complete the control of fetching and executing instructions.
  • the processor 110 may also be provided with a memory for storing instructions and data.
  • the memory in processor 110 is cache memory. This memory may hold instructions or data that have been recently used or recycled by processor 110 . If the processor 110 needs to use the instructions or data again, it can be called directly from the memory. Repeated access is avoided and the waiting time of the processor 110 is reduced, thus improving the efficiency of the system.
  • the processor 110 may include one or more interfaces.
  • the interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver/transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input/output (GPIO) interface, a subscriber identity module (SIM) interface, and/or a universal serial bus (USB) interface, etc.
  • I2C inter-integrated circuit
  • I2S inter-integrated circuit sound
  • PCM pulse code modulation
  • UART universal asynchronous receiver/transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB universal serial bus
  • the I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (derail clock line, SCL).
  • processor 110 may include multiple sets of I2C buses.
  • the processor 110 can communicate via various I2C
  • the bus interface couples the touch sensor 180K, charger, flash, camera 193, etc. respectively.
  • the processor 110 can be coupled to the touch sensor 180K through an I2C interface, so that the processor 110 and the touch sensor 180K communicate through the I2C bus interface to implement the touch function of the electronic device 100 .
  • the I2S interface can be used for audio communication.
  • processor 110 may include multiple sets of I2S buses.
  • the processor 110 can be coupled with the audio module 170 through the I2S bus to implement communication between the processor 110 and the audio module 170 .
  • the audio module 170 can transmit audio signals to the wireless communication module 160 through the I2S interface to implement the function of answering calls through a Bluetooth headset.
  • the PCM interface can also be used for audio communications to sample, quantize and encode analog signals.
  • the audio module 170 and the wireless communication module 160 may be coupled through a PCM bus interface.
  • the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface to implement the function of answering calls through a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
  • the UART interface is a universal serial data bus used for asynchronous communication.
  • the bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication.
  • a UART interface is generally used to connect the processor 110 and the wireless communication module 160 .
  • the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function.
  • the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.
  • the MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193 .
  • MIPI interfaces include camera serial interface (CSI), display serial interface (DSI), etc.
  • the processor 110 and the camera 193 communicate through the CSI interface to implement the shooting function of the electronic device 100 .
  • the processor 110 and the display screen 194 communicate through the DSI interface to implement the display function of the electronic device 100 .
  • the GPIO interface can be configured through software.
  • the GPIO interface can be configured as a control signal or as a data signal.
  • the GPIO interface can be used to connect the processor 110 with the camera 193, display screen 194, wireless communication module 160, audio module 170, sensor module 180, etc.
  • the GPIO interface can also be configured as an I2C interface, I2S interface, UART interface, MIPI interface, etc.
  • the USB interface 130 is an interface that complies with the USB standard specification, and may be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc.
  • the USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio through them. This interface can also be used to connect other electronic devices, such as AR devices, etc.
  • the interface connection relationships between the modules illustrated in the embodiment of the present invention are only schematic illustrations and do not constitute a structural limitation of the electronic device 100 .
  • the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
  • the charging management module 140 is used to receive charging input from the charger.
  • the charger can be a wireless charger or a wired charger.
  • the charging management module 140 may receive charging input from the wired charger through the USB interface 130 .
  • the charging management module 140 may receive wireless charging input through the wireless charging coil of the electronic device 100 . While the charging management module 140 charges the battery 142, it can also provide power to the electronic device through the power management module 141.
  • the power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110.
  • the power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, the wireless communication module 160, and the like.
  • the power management module 141 can also be used to monitor battery capacity, battery cycle times, battery health status (leakage, impedance) and other parameters.
  • the power management module 141 may also be provided in the processor 110 .
  • the power management module 141 and the charging management module 140 may also be provided in the same device.
  • the wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
  • Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example: Antenna 1 can be reused as a diversity antenna for a wireless LAN. In other embodiments, antennas may be used in conjunction with tuning switches.
  • the mobile communication module 150 can provide solutions for wireless communication including 2G/3G/4G/5G applied on the electronic device 100 .
  • the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc.
  • the mobile communication module 150 can receive electromagnetic waves through the antenna 1, perform filtering, amplification and other processing on the received electromagnetic waves, and transmit them to the modem processor for demodulation.
  • the mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves through the antenna 1 for radiation.
  • at least part of the functional modules of the mobile communication module 150 may be disposed in the processor 110 . in some In embodiments, at least part of the functional modules of the mobile communication module 150 and at least part of the modules of the processor 110 may be provided in the same device.
  • a modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal.
  • the demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the application processor outputs sound signals through audio devices (not limited to speaker 170A, receiver 170B, etc.), or displays images or videos through display screen 194.
  • the modem processor may be a stand-alone device.
  • the modem processor may be independent of the processor 110 and may be provided in the same device as the mobile communication module 150 or other functional modules.
  • the wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (bluetooth, BT), and global navigation satellites. Wireless communication solutions such as global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (infrared, IR), etc.
  • the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 .
  • the wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 for radiation.
  • the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology.
  • the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time division code division multiple access (time-division code division multiple access, TD-SCDMA), long term evolution (long term evolution, LTE), BT, GNSS, WLAN, NFC , FM, and/or IR technology, etc.
  • the GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), Beidou navigation satellite system (BDS), quasi-zenith satellite system (quasi) -zenith satellite system (QZSS) and/or satellite based augmentation systems (SBAS).
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • BDS Beidou navigation satellite system
  • QZSS quasi-zenith satellite system
  • SBAS satellite based augmentation systems
  • the electronic device 100 implements display functions through a GPU, a display screen 194, an application processor, and the like.
  • the GPU is an image processing microprocessor and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering.
  • Processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
  • the display screen 194 is used to display images, videos, etc.
  • the display screen 194 includes a display panel.
  • the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diodes (QLED), etc.
  • the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
  • the electronic device 100 can implement the shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
  • ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise and brightness of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.
  • Camera 193 is used to capture still images or video.
  • the object passes through the lens to produce an optical image that is projected onto the photosensitive element.
  • the photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
  • CMOS complementary metal-oxide-semiconductor
  • the photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to convert it into a digital image signal.
  • ISP outputs digital image signals to DSP for processing.
  • DSP converts digital image signals into standard RGB, YUV and other format image signals.
  • the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
  • Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
  • Video codecs are used to compress or decompress digital video.
  • Electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as: moving picture experts group, MPEG)1, MPEG2, MPEG3, MPEG4, etc.
  • NPU is a neural network (NN) computing processor.
  • NN neural network
  • Intelligent cognitive applications of the electronic device 100 can be implemented through the NPU, such as image recognition, face recognition, speech recognition, text understanding, etc.
  • the internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM).
  • RAM random access memories
  • NVM non-volatile memories
  • Random access memory can include static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous memory Dynamic random access memory (double data rate synchronous dynamic random access memory, DDR SDRAM, such as the fifth generation DDR SDRAM is generally called DDR5SDRAM), etc.;
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • SDRAM synchronous dynamic random access memory
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • DDR SDRAM double data rate synchronous dynamic random access memory
  • DDR5SDRAM double data rate synchronous dynamic random access memory
  • Non-volatile memory can include disk storage devices and flash memory.
  • Flash memory can be divided according to the operating principle to include NOR FLASH, NAND FLASH, 3D NAND FLASH, etc.
  • the storage unit potential level it can include single-level storage cells (single-level cell, SLC), multi-level storage cells (multi-level cell, MLC), third-level storage unit (triple-level cell, TLC), fourth-level storage unit (quad-level cell, QLC), etc., which can include universal flash storage (English: universal flash storage, UFS) according to storage specifications. , embedded multi media card (embedded multi media Card, eMMC), etc.
  • the random access memory can be directly read and written by the processor 110, can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data, etc.
  • the non-volatile memory can also store executable programs and user and application program data, etc., and can be loaded into the random access memory in advance for direct reading and writing by the processor 110.
  • the external memory interface 120 can be used to connect an external non-volatile memory to expand the storage capacity of the electronic device 100 .
  • the external non-volatile memory communicates with the processor 110 through the external memory interface 120 to implement the data storage function. For example, save music, video and other files in external non-volatile memory.
  • the electronic device 100 can implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D, and the application processor. Such as music playback, recording, etc.
  • the audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be provided in the processor 110 , or some functional modules of the audio module 170 may be provided in the processor 110 .
  • Speaker 170A also called “speaker” is used to convert audio electrical signals into sound signals.
  • the electronic device 100 can listen to music through the speaker 170A, or listen to hands-free calls.
  • Receiver 170B also called “earpiece” is used to convert audio electrical signals into sound signals.
  • the electronic device 100 answers a call or a voice message, the voice can be heard by bringing the receiver 170B close to the human ear.
  • Microphone 170C also called “microphone” or “microphone” is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak close to the microphone 170C with the human mouth and input the sound signal to the microphone 170C.
  • the electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which in addition to collecting sound signals, may also implement a noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and implement directional recording functions, etc.
  • the earphone interface 170D is used to connect a wired earphone.
  • the earphone interface 170D may be the USB interface 130, or may be a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
  • OMTP open mobile terminal platform
  • CTIA cellular telecommunications industry association of the USA
  • the pressure sensor 180A is used to sense pressure signals and can convert the pressure signals into electrical signals.
  • pressure sensor 180A may be disposed on display screen 194 .
  • pressure sensors 180A there are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc.
  • a capacitive pressure sensor may include at least two parallel plates of conductive material.
  • the electronic device 100 determines the intensity of the pressure based on the change in capacitance.
  • the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A.
  • the electronic device 100 may also calculate the touched position based on the detection signal of the pressure sensor 180A.
  • touch operations acting on the same touch location but with different touch operation intensities may correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold is applied to the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold is applied to the short message application icon, an instruction to create a new short message is executed.
  • the gyro sensor 180B may be used to determine the motion posture of the electronic device 100 .
  • the angular velocity of electronic device 100 about three axes ie, x, y, and z axes
  • the gyro sensor 180B can be used for image stabilization. For example, when the shutter is pressed, the gyro sensor 180B detects the angle at which the electronic device 100 shakes, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shake of the electronic device 100 through reverse movement to achieve anti-shake.
  • the gyro sensor 180B can also be used for navigation and somatosensory game scenes.
  • Air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.
  • Magnetic sensor 180D includes a Hall sensor.
  • the electronic device 100 may utilize the magnetic sensor 180D to detect opening and closing of the flip holster.
  • the electronic device 100 may detect the opening and closing of the flip according to the magnetic sensor 180D. Then, based on the detected opening and closing status of the leather case or the opening and closing status of the flip cover, features such as automatic unlocking of the flip cover are set.
  • the acceleration sensor 180E can detect the acceleration of the electronic device 100 in various directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of electronic devices and be used in horizontal and vertical screen switching, pedometer and other applications.
  • Distance sensor 180F for measuring distance.
  • Electronic device 100 can measure distance via infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 may utilize the distance sensor 180F to measure distance to achieve fast focusing.
  • Proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode.
  • the light emitting diode may be an infrared light emitting diode.
  • the electronic device 100 emits infrared light outwardly through the light emitting diode.
  • Electronic device 100 uses photodiodes to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100 . When insufficient reflected light is detected, the electronic device 100 may determine that there is no object near the electronic device 100 .
  • the electronic device 100 can use the proximity light sensor 180G to detect when the user holds the electronic device 100 close to the ear for talking, so as to automatically turn off the screen to save power.
  • the proximity light sensor 180G can also be used in holster mode, and pocket mode automatically unlocks and locks the screen.
  • the ambient light sensor 180L is used to sense ambient light brightness.
  • the electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness.
  • the ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures.
  • the ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in the pocket to prevent accidental touching.
  • Fingerprint sensor 180H is used to collect fingerprints.
  • the electronic device 100 can use the collected fingerprint characteristics to achieve fingerprint unlocking, access to application locks, fingerprint photography, fingerprint answering of incoming calls, etc.
  • Temperature sensor 180J is used to detect temperature.
  • the electronic device 100 utilizes the temperature detected by the temperature sensor 180J to execute the temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of a processor located near the temperature sensor 180J in order to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to prevent the low temperature from causing the electronic device 100 to shut down abnormally. In some other embodiments, when the temperature is lower than another threshold, the electronic device 100 performs boosting on the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
  • Touch sensor 180K also known as "touch device”.
  • the touch sensor 180K can be disposed on the display screen 194.
  • the touch sensor 180K and the display screen 194 form a touch screen, which is also called a "touch screen”.
  • the touch sensor 180K is used to detect a touch operation on or near the touch sensor 180K.
  • the touch sensor can pass the detected touch operation to the application processor to determine the touch event type.
  • Visual output related to the touch operation may be provided through display screen 194 .
  • the touch sensor 180K may also be disposed on the surface of the electronic device 100 at a location different from that of the display screen 194 .
  • Bone conduction sensor 180M can acquire vibration signals.
  • the bone conduction sensor 180M can acquire the vibration signal of the vibrating bone mass of the human body's vocal part.
  • the bone conduction sensor 180M can also contact the human body's pulse and receive blood pressure beating signals.
  • the bone conduction sensor 180M can also be provided in an earphone and combined into a bone conduction earphone.
  • the audio module 170 can analyze the voice signal based on the vibration signal of the vocal vibrating bone obtained by the bone conduction sensor 180M to implement the voice function.
  • the application processor can analyze the heart rate information based on the blood pressure beating signal acquired by the bone conduction sensor 180M to implement the heart rate detection function.
  • the buttons 190 include a power button, a volume button, etc.
  • Key 190 may be a mechanical key. It can also be a touch button.
  • the electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100 .
  • the motor 191 can generate vibration prompts.
  • the motor 191 can be used for vibration prompts for incoming calls and can also be used for touch vibration feedback.
  • touch operations for different applications can correspond to different vibration feedback effects.
  • the motor 191 can also respond to different vibration feedback effects for touch operations in different areas of the display screen 194 .
  • Different application scenarios such as time reminders, receiving information, alarm clocks, games, etc.
  • the touch vibration feedback effect can also be customized.
  • the indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, or may be used to indicate messages, missed calls, notifications, etc.
  • the SIM card interface 195 is used to connect a SIM card.
  • the SIM card can be inserted into the SIM card interface 195 or pulled out from the SIM card interface 195. Realize contact and separation from the electronic device 100 .
  • the electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
  • SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card, etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the plurality of cards may be the same or different.
  • the SIM card interface 195 is also compatible with different types of SIM cards.
  • the SIM card interface 195 is also compatible with external memory cards.
  • the electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications.
  • the electronic device 100 uses an eSIM, that is, an embedded SIM card.
  • the eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100 .
  • the software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a microservice architecture, or a cloud architecture.
  • the embodiment of the present invention takes the Android system of the layered architecture as an example to illustrate the software structure of the electronic device 100.
  • the system of the electronic device 100 can also be an IOS system, a Hongmeng system, etc., which is not limited in the embodiment of the present application.
  • the type of electronic device 100 is different, and the system of the electronic device 100 can also be different.
  • the embodiment of the present application takes the system of the electronic device 100 as an Android system as an example for explanation.
  • the layered architecture divides the software into several layers, and each layer has clear roles and division of labor.
  • the layers communicate through software interfaces.
  • the Android system is divided into four layers, from top to bottom: application layer, application framework layer, Android runtime and system libraries, and kernel layer.
  • the embodiments of the present application do not limit the layering of the software structure of the electronic device.
  • the Android runtime and system library, and the kernel layer can be regarded as one layer, called the system layer. It should be understood that Figure 9 also adds a hardware layer in the electronic device based on the Android system.
  • the modules included in each layer shown in Figure 9 are modules involved in the embodiments of the present application.
  • the modules included in the following layers do not constitute the structure and module deployment level of the electronic device (example description). ) limit.
  • the identity authentication information registration module can be deployed at the application layer or at the application framework layer.
  • the modules shown in Figure 9 can be deployed individually, or several modules can be deployed together.
  • the division of modules in Figure 9 is an example.
  • the names of the modules shown in Figure 9 are examples.
  • the application layer can include a series of application packages.
  • the application package can include camera, gallery, calendar, calling, map, navigation, WLAN, Bluetooth, SMS and other applications.
  • the application framework layer provides application programming interface (API) and programming framework for the applications in the application layer.
  • API application programming interface
  • the application framework layer includes some predefined functions.
  • the application framework layer can include a window manager, a content provider, a phone manager, a resource manager, an anti-rollback service module, etc.
  • a window manager is used to manage window programs.
  • the window manager can obtain the display size, determine whether there is a status bar, lock the screen, capture the screen identity authentication information verification module, etc.
  • Content providers are used to store and retrieve data and make this data accessible to applications.
  • Said data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
  • the phone manager is used to provide communication functions of the electronic device 100 .
  • call status management including connected, hung up, etc.
  • the resource manager provides various resources to applications, such as localized strings, icons, pictures, layout files, video files, etc.
  • the anti-rollback service module mainly provides a medium for transmitting messages between applications and security chips. Specifically, before the application saves user data, when the application applies for a counter, the anti-rollback service module allocates an idle counter to the application, obtains the counter's identification, and sends the counter's identification to the security chip.
  • the anti-rollback service module sends the counter's identification to the security chip so that the security chip can modify and save the value of the counter.
  • the verification value of the user data can be obtained based on the value of the counter. Only when the verification passes, the electronic device can use the user data.
  • the value of the corresponding counter will also change, and then the check value of the changed user data will also change.
  • the anti-rollback service module sends the verification value of the user data to the security chip, and sends the user data to the security chip.
  • the security chip will be based on the user data and counter sent by the anti-rollback service module. The numerical calculation of another check value is obtained. If the check value is the same as the previously stored check value, the verification is passed.
  • the user data sent by the anti-rollback service module to the security chip is the same as the previously stored user data.
  • the electronic device can use the application data. If the check value is different from the previously stored check value, the verification fails.
  • the user data sent by the anti-rollback service module to the security chip is different from the previously stored user data. An attacker may have modified the user. Data, the application data cannot be used by electronic devices.
  • the system layer may include the Android runtime, system library, and functional modules in the kernel layer.
  • the system layer may include a security chip, and the number of security chips may be one or more.
  • the security chip is only used to store the counter value, the verification value of the user data, the counter certificate, etc., and performs multi-level authentication based on the counter value, the verification value of the user data, the counter certificate, etc. to ensure the security of the user data.
  • Figure 10 is a schematic flowchart of a method for generating counter credentials provided by an embodiment of the present application.
  • the security chip Before the security chip obtains the specific value of the counter, it verifies whether the certificate of the counter stored in the security chip is the same as the certificate of the received counter. Only under the same circumstances can the security chip obtain the specific value of the counter.
  • the security chip encrypts the value of the counter based on the counter's credentials to obtain the encrypted counter value. Before the security chip obtains the specific value of the counter, the security chip receives the counter's credentials. If the security chip can decrypt the encrypted counter value based on the received counter certificate, the security chip can obtain the specific value of the counter.
  • the first application obtains the counter's credentials.
  • the first application obtains the credentials of the counter.
  • the counter certificate can be one or multiple.
  • the counter credentials of different counters may be different, or multiple counters may share the credentials of one counter, which is not limited in the embodiment of the present application.
  • the first application may store the counter's credentials in a non-secure chip, such as a flash chip.
  • the first application may also store the counter's credentials in a server. This embodiment of the application does not limit this.
  • the first application can obtain the counter's credentials in any of the following ways.
  • Method 1 The first application obtains the counter's credentials from the server.
  • Method 2 The first application obtains the counter's credentials from the local area of the electronic device.
  • Method 3 Before the first application needs to obtain the counter's credentials, the electronic device can prompt the user to enter the credentials, and the credentials can be used as the counter's credentials.
  • the first application can also obtain the counter's credentials through other methods, which is not limited in the embodiments of this application.
  • the first application sends the counter's credentials to the anti-rollback service module.
  • the anti-rollback service module allocates a first counter to the first application and obtains the identifier of the first counter.
  • the anti-rollback service module can randomly allocate the counters from the multiple idle counters.
  • One counter serves as the first counter.
  • the anti-rollback service module can also allocate multiple counters to the first application at the same time. For example, the anti-rollback service module may determine the number of counters allocated to the first application based on the number of credentials of the counter. For example, if there is a certificate for one counter, then the anti-rollback service module can allocate a counter to the first application. If there are three counters, then the anti-rollback service module can allocate three different counters for the first application. .
  • the first application may send the number of counters to be allocated.
  • the anti-rollback service module may determine the number of counters to be allocated to the first application based on the number of counters sent by the first application that need to be allocated. For example, if the number of counters to be allocated sent by the first application to the anti-rollback service module is one, the anti-rollback service module may allocate one counter to the first application. If the first application uses the anti-rollback service
  • the number of counters to be allocated sent by the module is three, and the anti-rollback service module can allocate three counters to the first application.
  • the number of counter credentials sent by the first application to the anti-rollback service module is the same as the number of counters to be allocated. For example, if the number of counters to be allocated sent by the first application to the anti-rollback service module is one, then the number of counter credentials sent by the first application to the anti-rollback service module is also one. If the number of counters to be allocated sent by the first application to the anti-rollback service module is three, then the number of counter credentials sent by the first application to the anti-rollback service module is also three.
  • the number of counter credentials sent by the first application to the anti-rollback service module and the number of counters to be allocated may be different. For example, if the number of counters to be allocated sent by the first application to the anti-rollback service module is one, then the number of counter credentials sent by the first application to the anti-rollback service module may be one. If the number of counters that need to be allocated sent by the first application to the anti-rollback service module is three, and the number of counter credentials sent by the first application to the anti-rollback service module is also two, then one counter uses one counter's Voucher, two counters share the voucher of another counter.
  • the anti-rollback service module also needs to record the corresponding relationship between the first application and the first counter. Because the anti-rollback service module can be used for multiple different Applications are allocated counters, so the anti-rollback service module needs to record the corresponding relationship between each application and each counter.
  • Table 1 shows the betting-win relationship between multiple different applications and each counter recorded in the anti-rollback service module.
  • the counter corresponding to the first application is the first counter
  • the counter corresponding to the second application is the second counter and the third counter
  • the counter corresponding to the third application is the fourth counter.
  • the anti-rollback service module can also record the correspondence between more or fewer applications and counters, which is not limited in the embodiments of the present application.
  • the anti-rollback service module can clear the binding relationship between the application and the counter so that the counter can be used by other applications.
  • the anti-rollback service module can clear the binding relationship between the application and the counter so that the counter can be used by other applications.
  • the anti-rollback service module sends the identification of the first counter and the counter's certificate to the security chip.
  • the anti-rollback service module allocates the first counter to the first application, the identification and the certificate of the first counter are sent to the security chip.
  • the security chip sets the initial value of the first counter to the first threshold.
  • the initial value of the counter is used to generate count values of different user data when saving different user data.
  • the first threshold may be randomly generated, that is, the initial values for different counters are different.
  • the first threshold can also be preset, and the initial values of different counters are the same.
  • the security chip saves the initial value of the first counter and the counter's certificate, and uses the counter's certificate as the first
  • the security chip saves the initial value of the first counter and the certificate of the counter, so that when the user data is saved later, a count value of the user data is generated based on the initial value of the first counter, and a check value of the user data is generated based on the count value.
  • the counter's credentials are used by the security chip to verify whether it is consistent with the received counter's credentials before using the user data to obtain the verification value of the user data. If they are consistent, the security chip is allowed to obtain the verification value of the user data, otherwise , the security chip cannot obtain the verification value of user data.
  • Table 2 shows the initial values of counters corresponding to different applications stored in a security chip and the credentials of the counters.
  • the first application corresponds to a first counter
  • the initial value of the first counter is the first threshold
  • the certificate of the first counter is the first token.
  • the second application corresponds to a second counter and a third counter.
  • the initial value of the second counter is the second threshold
  • the initial value of the third counter is the third threshold
  • the certificate of the second counter is the second token
  • the certificate of the third counter is For the third token.
  • the third application corresponds to a fourth counter
  • the initial value of the fourth counter is the fourth threshold
  • the certificate of the fourth counter is the fourth token.
  • the first threshold, the second threshold, the third threshold and the fourth threshold are randomly generated, so the first threshold, the second threshold, the third threshold and the fourth threshold may be different from each other or partially the same, They may all be the same, which is not limited in the embodiments of this application.
  • the second token and the third token may be different or the same, which is not limited in the embodiments of this application.
  • the first token, the second token, the third token and the fourth token may be different from each other, may be partially the same, or may be all the same, which is not limited in the embodiment of the present application.
  • Table 3 shows the initial value of the counter and the counter's credentials stored in another security chip. Since the anti-rollback service module stores the identifiers of counters corresponding to different applications, the security chip does not need to store the identifiers of counters corresponding to different applications. The security chip can only store the initial values of counters corresponding to different counters and the number of counters. certificate.
  • the initial value of the first counter is the first threshold
  • the certificate of the first counter is the first token.
  • the initial value of the second counter is the second threshold
  • the certificate of the second counter is the second token.
  • the initial value of the third counter is the third threshold
  • the certificate of the third counter is the third token.
  • the initial value of the fourth counter is the fourth threshold, and the certificate of the fourth counter is the fourth token.
  • the first token, the second token, the third token and the fourth token may be different from each other, may be partially the same, or may be all the same, which is not limited in the embodiment of the present application.
  • the security chip sends a message that the counter has been set to the anti-rollback service module.
  • the anti-rollback service module sends a message that the counter has been set to the first application.
  • Figure 11 shows a schematic flowchart of another method for generating counter credentials.
  • FIG. 11 is a schematic flowchart of a method for a security chip to generate a counter's credentials.
  • the embodiment of FIG. 10 is a schematic flowchart of a method for the first application to generate a counter's credentials.
  • the security factor of the security chip is higher, so the credentials that generate the counter within the security chip are more secure.
  • the first application sends a request to apply for a counter to the anti-rollback service module.
  • the first application may start sending a request to apply for a counter to the anti-rollback service module after being downloaded and before saving the user data.
  • the anti-rollback service module allocates a first counter to the first application and obtains the identifier of the first counter.
  • the anti-rollback service module sends the identification of the first counter to the security chip.
  • the security chip obtains the certificate of the first counter.
  • the security chip can obtain the credentials of the first counter in any of the following ways.
  • Method 1 The security chip obtains the credentials of the first counter from the server.
  • Method 2 The security chip obtains the credentials of the first counter from the local area of the electronic device.
  • Method 3 Before the security chip needs to obtain the credential of the first counter, the electronic device can prompt the user to enter the credential, which can be used as the credential of the first counter.
  • the security chip can also obtain the credentials of the first counter through other methods, which is not limited in the embodiments of this application.
  • the security chip sets the initial value of the first counter to the first threshold.
  • the initial value of the counter is used to generate count values of different user data when saving different user data.
  • the first threshold may be randomly generated, that is, the initial values for different counters are different.
  • the first threshold can also be preset, and the initial values of different counters are the same.
  • S1105 may be executed before S1104, and S1105 and S1104 may be executed simultaneously, which is not limited in the embodiment of the present application.
  • the security chip saves the initial value of the first counter and the certificate of the first counter.
  • the security chip sends the certificate of the first counter to the anti-rollback service module.
  • the anti-rollback service module sends the credential of the first counter to the first application.
  • Table 4 shows one or more counter credentials corresponding to one or more applications stored in the non-secure chip of the electronic device or in the server. certificate.
  • the first application corresponds to the first counter
  • the certificate of the first counter is the first token.
  • the second application corresponds to a second counter and a third counter.
  • the certificate of the second counter is the second token
  • the certificate of the third counter is the third token.
  • the third application corresponds to a fourth counter
  • the certificate of the fourth counter is the fourth token.
  • the second token and the third token may be different or the same, which is not limited in the embodiment of the present application.
  • the first token, the second token, the third token and the fourth token may be different from each other, may be partially the same, or may be all the same, which is not limited in the embodiment of the present application.
  • the first application can obtain the credentials of the first counter, so that before the electronic device uses the user data in the first application, the credentials of the first counter can be sent to the security chip.
  • the credentials of the first counter stored in the security chip Only when the certificate is the same as the certificate of the first counter sent by the first application, the electronic device can use the user data in the first application.
  • the first application can save the credentials of the first counter in a non-secure chip, such as a flash chip.
  • the first application may also save the credentials of the first counter in the server.
  • the embodiments of the present application do not limit this.
  • Figure 12 is a schematic diagram of protecting user data and generating a check value of user data provided by an embodiment of the present application.
  • the value of the counter in the SE will also change accordingly. Then the check value of the changed user data will also change accordingly.
  • the first application obtains the first user data.
  • the first user data may be the remaining amount of Internet traffic, for example, the remaining amount of Internet traffic is 30G.
  • the first application sends the first user data and the certificate of the first counter to the anti-rollback service module.
  • the first application selects one or more counters from previously applied counters to generate a voucher for the first user data. For example, the first application may select the first counter from previously applied counters.
  • the credentials of one or more counters that the first application has previously applied for are stored in the non-security chip of the electronic device or in the server.
  • the first application can select the credentials of the first counter from the credentials of the one or more counters so that it can generate Check value of the first user data.
  • the first application After obtaining the credentials of the first counter, the first application sends the first user data and the credentials of the first counter to the anti-rollback service module.
  • the anti-rollback service module obtains the identifier of the first counter.
  • the anti-rollback service module After receiving the first user data and the credentials of the first counter sent by the first application, the anti-rollback service module obtains the identification of the first counter.
  • the anti-rollback service module sends the identification of the first counter, the first user data and the certificate of the first counter to the security chip.
  • the security chip determines the certificate of the first counter stored in the security chip based on the identification of the first counter.
  • the security chip stores the credentials of multiple counters corresponding to the counters.
  • the security chip After the security chip receives the identification of the first counter, the first user data and the credential of the first counter sent by the anti-rollback service module, the security chip can obtain the credential of the first counter from the security chip based on the identification of the first counter. .
  • the security chip obtains the initial value of the first counter.
  • the security chip can obtain the initial value of the first counter only when the credentials of the first counter of the security chip are the same as the credentials of the first counter sent by the anti-backoff service module. In this way, the attacker cannot obtain the initial value of the first counter without knowing the credentials of the first counter.
  • the first preset value may be a fixed value or a random number, which is not limited in the embodiment of the present application.
  • the security chip calculates the first verification value based on the first value of the first counter and the first user data.
  • the security chip may calculate the HMAC value of the first value of the first counter and the first user data, and use the HMAC value as the first verification value.
  • the security chip can also calculate the first verification value based on other factors, the first value of the first counter and the first user data.
  • Other factors include but are not limited to one or more of hardware unique keys and device unique IDs.
  • the first check value is calculated based on the value of the first counter and the first user data. Before the electronic device needs to use the first user data, it needs to be verified that the first check value passes. If any one of the value of the first counter and the first user data changes, the first verification value will fail the verification, and the electronic device will not be able to use the first user data. In this way, the attacker can be prevented from tampering with the first user data, and the security of the electronic device using the first user data is improved.
  • S1207 and S1208 can also be replaced with S1207B as follows.
  • the security chip calculates the first verification value based on the initial value of the first counter and the first user data.
  • the security chip can also calculate the first verification value based on other factors, the initial value of the first counter and the first user data.
  • Other factors include but are not limited to one or more of hardware unique keys and device unique IDs.
  • the security chip sends the first verification value to the anti-rollback service module.
  • the anti-rollback service module sends the first verification value to the first application.
  • the first application can save the first verification value in a non-security chip, such as a flash chip.
  • the first application can also save the first verification value in the server.
  • the embodiments of the present application do not limit this.
  • Table 5 exemplarily shows the check values corresponding to different user data.
  • the check value of the first user data is the first check value
  • the check value of the third user data is the third check value.
  • the first user data and the third user data are different.
  • the first check value, the second check value and the third check value may be completely different, partially the same, or entirely the same, which is not limited in the embodiments of the present application.
  • the check value corresponding to the first user data also changes.
  • the electronic device before the electronic device uses the first user data, the correctness of the check value of the first user data needs to be verified in the security chip. Only after the check value of the first user data passes the verification, the electronic device can use the first user data. Prevent attackers from forging user data.
  • Figure 13 shows a schematic diagram of a method for verifying the correctness of the check value of the first user data in the security chip before the electronic device uses the first user data.
  • the first application sends the second user data, the certificate of the first counter, and the first verification value to the anti-rollback service module.
  • the correctness of the check value of the first user data needs to be verified.
  • an attacker may modify previously saved first user data.
  • the first user data may be the remaining amount of Internet traffic, for example, the remaining amount of Internet traffic is 30G.
  • the attacker may modify the remaining amount of Internet traffic to 100G.
  • the remaining 100G of Internet traffic can be called second user data.
  • the certificate and the first verification value of the first counter may be obtained locally by the first application, or may be obtained from the server, which is not limited in this embodiment of the present application.
  • the anti-rollback service module obtains the identifier of the first counter.
  • the anti-rollback service module After receiving the second user data, the certificate of the first counter, and the first verification value sent by the first application, the anti-rollback service module obtains the identification of the first counter.
  • the anti-rollback service module sends the identification of the first counter, the second user data, the certificate of the first counter, and the first verification value to the security chip.
  • the security chip determines the certificate of the first counter stored in the security chip based on the identification of the first counter.
  • the security chip stores the credentials of multiple counters corresponding to the counters.
  • the security chip After the security chip receives the identification of the first counter, the first user data and the credential of the first counter sent by the anti-rollback service module, the security chip can obtain the credential of the first counter from the security chip based on the identification of the first counter. .
  • the security chip obtains the first value of the first counter.
  • the security chip can obtain the first value of the first counter only when the credentials of the first counter of the security chip are the same as the credentials of the first counter sent by the anti-backoff service module. In this way, if the attacker does not know the credentials of the first counter, the attacker cannot obtain the first value of the first counter, and the attacker cannot tamper with the value of the first counter, ensuring that the value of the counter stored in the security chip is accuracy
  • the security chip calculates a second check value based on the first value of the first counter and the second user data.
  • the security chip can calculate the first value of a counter and the HMAC value of the second user data, and use the HMAC value as the first check value.
  • the security chip can also calculate the second verification value based on other factors, the first value of the first counter, and the second user data.
  • Other factors include but are not limited to one or more of hardware unique keys and device unique IDs.
  • the security chip can confirm that the second user data is the same as the first user data.
  • the security chip calculates the second verification based on the second user data and the first value of the first counter. The value is different from the first check value previously stored in the security chip.
  • the first check value may be the first HMAC value obtained based on the first value of the first counter and the first user data.
  • the second check value may be a second HMAC value obtained based on the first value of the first counter and the second user data.
  • the security chip can confirm that the second user data is the same as the first user data.
  • the HMAC value calculated by the security chip based on the second user data and the first value of the first counter is the same as the security
  • the first HMAC value previously stored in the chip is different.
  • the secure chip can confirm that the second user data is the same as the first user data, it means that the attacker has not changed the first user data stored in the non-secure chip.
  • the first application then uses the second user data.
  • the security chip sends a verification pass message to the anti-rollback service module.
  • the anti-rollback service module sends a verification pass message to the first application.
  • the first application uses the second user data.
  • the security chip When it is confirmed that the second user data is the same as the first user data, the security chip sends a verification pass message to the first application. In response to the verification passing message, the first application may use the second user data.
  • the security chip When it is confirmed that the second user data is different from the first user data, the security chip will not send a verification pass message to the first application. Then, if the first application does not receive the verification passing message, the first application cannot use the second user data.
  • the electronic device after the electronic device uses the second user data, causing the second user data to change, the electronic device also needs to save the changed second user data. Then when the changed second user data is saved, the counter value corresponding to the changed second user data stored in the security chip will change.
  • the security chip will calculate the third verification value based on the changed second user data and the counter value corresponding to the changed second user data, and save the third verification value in the security chip. At the same time, the third verification value needs to be stored in the security chip.
  • the check value is stored in the non-secure chip or on the server.
  • the first application can use the second user data only when the second user data is the same as the first user data, and then the second user data is the first user data.
  • the first user data and the second user data may be the remaining amount of Internet traffic, for example, the remaining amount of Internet traffic is 30G.
  • the second user data changes.
  • the changed second user data is 10G.
  • the electronic device needs to save the changed second user data.
  • Figure 14 is a schematic diagram of a method for saving changed second user data provided by an embodiment of the present application.
  • the changed second user data may also be called third user data.
  • the first application sends the changed second user data and the certificate of the first counter to the anti-rollback service module.
  • the first application When the first application saves the first user data, it uses the certificate of the first counter. Then when saving the changed second user data, it can also use the certificate of the first counter. In other embodiments, when saving the changed second user data, credentials of other counters may also be used, which is not limited in the embodiments of the present application. This embodiment of the present application takes as an example an example of continuing to use the first counter's credentials when saving the changed second user data.
  • the anti-rollback service module obtains the identifier of the first counter.
  • the anti-rollback service module After receiving the changed second user data and the credential of the first counter, the anti-rollback service module obtains the identifier of the first counter.
  • the anti-rollback service module sends the identification of the first counter, the changed second user data and the certificate of the first counter to the security chip.
  • the security chip determines the certificate of the first counter stored in the security chip based on the identification of the first counter.
  • the security chip stores the credentials of multiple counters corresponding to the counters.
  • the security chip After the security chip receives the identification of the first counter, the changed second user data and the credential of the first counter sent by the anti-rollback service module, the security chip can obtain the first counter from the security chip based on the identification of the first counter. The counter's credentials.
  • the security chip determines that the certificate of the first counter is the same as the certificate of the first counter stored in the security chip, and obtains the first value of the first counter.
  • the security chip can obtain the first value of the first counter only when the credentials of the first counter of the security chip are the same as the credentials of the first counter sent by the anti-backoff service module. In this way, the attacker cannot obtain the first value of the first counter without knowing the credentials of the first counter, and the attacker cannot modify the value of the first counter. The accuracy of the counter value stored in the security chip is guaranteed.
  • the second preset value may be a fixed value or a random number, which is not limited in this embodiment of the present application.
  • the second preset value may be the same as the first preset value, and the second preset value may also be different from the first preset value, which is not limited in the embodiments of the present application.
  • the security chip calculates a third check value based on the second value of the first counter and the changed second user data.
  • the security chip can calculate the second value of a counter and the HMAC value of the changed second user data, and use the HMAC value as the third check value.
  • the security chip can also calculate the third verification value based on other factors, the second value of the first counter, and the changed second user data.
  • Other factors include but are not limited to one or more of hardware unique keys and device unique IDs.
  • the security chip sends the third verification value to the anti-rollback service module.
  • the anti-rollback service module sends the third verification value to the first application.
  • the first application can store the third check value in a non-security chip, such as a flash chip.
  • the first application can also save the third verification value in the server.
  • the embodiments of the present application do not limit this.
  • Figure 15 is a schematic flowchart of a data protection method provided by an embodiment of the present application.
  • the electronic device obtains the second user data, the certificate of the first counter, and the first verification value of the first user data from the non-security chip.
  • the first user data is user data previously stored by the electronic device.
  • the second user data is the first user data stored before being read by the electronic device.
  • the storage location of the first user data is the first storage location. Then the second user data can be the user data read from the first storage location.
  • the attacker may have modified the first user data, for example, modified the first user data to the second user data.
  • the first user data and the second user data are different.
  • User data is different.
  • the storage locations of the first user data and the second user data may be the same.
  • the electronic device uses the second user data, that is, the electronic device uses the first user data.
  • the electronic device obtains the certificate of the first counter from the security chip.
  • the electronic device stores the credentials of the first counter in the security chip, which specifically includes: the electronic device generates the credentials of the first counter through the security chip; the electronic device stores the credentials of the first counter in the security chip.
  • the security chip needs to save the credentials of the first counter in the non-security chip or on the server, so that when the electronic device uses the user data, it can be based on the credentials of the first counter stored in the non-security chip or on the server. Authentication.
  • the electronic device obtains the credential of the first counter outside the security chip; the electronic device stores the credential of the first counter in the security chip.
  • the non-security chip may be a flash chip, a server, or a storage device such as a hard disk. This is not the case in the embodiment of this application. limited.
  • the method further includes: when the credentials of the first counter in the non-security chip are different from the credentials of the first counter in the security chip, the electronic device cannot obtain the credentials of the first counter from the security chip. first value. In this way, when the attacker does not know the credentials of the first counter, the credentials of the first counter cannot pass the authentication, and the attacker cannot obtain the first value of the first counter, which ensures the security of the first counter stored in the security chip. First value security.
  • a possible implementation further includes: when the first check value and the second check value are different, the electronic device cannot use the second user data.
  • the security chip can also calculate the verification value of the user data based on other factors.
  • Other factors include but are not limited to one or more of a hardware unique key and a device unique ID.
  • Other factors can also be other numerical values, which are not limited in the embodiments of this application.
  • the second check value calculated by the security chip based on the second user data and the first value of the first counter is the same as the first check value.
  • the verification value is also different, that is, the verification value of the user data fails, and the electronic device cannot use the forged second user data at this time.
  • the first value of the first counter is obtained based on the initial value of the first counter and the first preset value, wherein the initial value of the counter is randomly generated.
  • the initial value of the first counter is randomly generated, which can prevent an attacker from obtaining the first value of the first counter through brute force enumeration, resulting in the leakage of the first value of the first counter stored in the security chip. , improving the security of the first value of the first counter stored in the security chip.
  • the method before the electronic device stores the first value of the first counter in the security chip, the method further includes: the electronic device generates an initial value of the first counter through the security chip. In this way, the initial value of the first counter is generated in the security chip, which improves the security of the value of the counter stored in the security chip.
  • the electronic device obtains a second verification value of the second user data based on the second user data and the first value of the first counter through the security chip; when the first verification value and the second verification value are the same, the electronic device uses the second user data.
  • the security chip and the non-security chip can realize data exchange through I2C or SPI bus communication.
  • a multi-level authentication mechanism is implemented within the security chip. Only when the authentication is passed, the electronic device can use the second user data, which ensures the security of user data stored on the electronic device and prevents attackers from forging user data.
  • the method before the electronic device obtains the second user data, the certificate of the first counter and the first verification value of the first user data from the non-security chip, the method further includes: the electronic device obtains the first verification value of the first user data from the non-security chip.
  • a user data, a first check value of the first user data and a certificate of the first counter are stored in the non-secure chip.
  • the electronic device stores the first value of the first counter and the credentials of the first counter in the secure chip.
  • the electronic device stores the first value of the first counter in the security chip, ensuring the security of the first value of the first counter and preventing the first value of the first counter from being obtained by an attacker.
  • the electronic device stores the credentials of the first counter in the security chip so that when the electronic device uses the stored user data, authentication is performed based on the credentials of the first counter. Only after the authentication is passed can the electronic device use the stored user data, thereby ensuring the security of the user data stored on the electronic device.
  • the method further includes: the electronic device obtains the second user data from the non-security chip.
  • the first user data, the identification of the first counter and the credentials of the first counter stored in the non-security chip are obtained in the security chip; the electronic device determines the identity of the first counter stored in the security chip based on the identification of the first counter through the security chip. Credential; When the credentials of the first counter in the non-security chip and the credentials of the first counter in the security chip are the same, the electronic device obtains the first value of the first counter; the electronic device uses the security chip based on the first value of the first counter.
  • the electronic device stores the first check value of the first user data in the non-security chip.
  • the first verification value will be generated in the security chip based on the first user data and the first value of the first counter.
  • the electronic device stores the first check value in a non-secure chip, such as a flash chip or on a server.
  • the attacker forges user data for example, uses the second user data to replace the first user data, during authentication, the second verification value is generated in the security chip based on the second user data and the first value of the first counter. It is also different from the first verification value, causing the verification to fail and preventing attackers from forging user data.
  • the method further includes: the electronic device obtains the third user data, and the third user data is the changed second user data; the electronic device obtains the third user data.
  • the user data, the credentials of the first counter in the non-security chip, and the identity of the first counter are sent to the security chip; the electronic device obtains the credentials of the first counter based on the identity of the first counter through the security chip; the first counter in the non-security chip
  • the electronic device obtains the first value of the first counter through the security chip, and obtains the first counter based on the first value of the first counter and the second preset value.
  • the second value the electronic device obtains the third check value of the third user data based on the third user data and the second value of the first counter through the security chip; the electronic device saves the third check value of the third user data in Inside the non-secure chip.
  • the electronic device uses the second user data, causing the second user data to change and obtain the third user data.
  • the electronic device needs to store the third user data.
  • the electronic device needs to generate a check value of the third user data in the security chip, that is, a third check value. So that when the subsequent electronic device uses the third user data, it can verify whether the third user data is forged data based on the check value.
  • the electronic device includes: one or more processors, one or more memories, and a display screen; one or more memories and display screens are coupled with one or more processors, and one or more
  • the memory is used to store computer program code.
  • the computer program code includes computer instructions.
  • One or more processors call the computer instructions to cause the electronic device to execute: obtain the second user data, the credentials of the first counter and the third counter from the non-secure chip.
  • a first check value of user data wherein the certificate of the first counter in the non-security chip is used to obtain the first value of the first counter, and the first check value and the first value of the first counter are used for verification Whether the second user data is the same as the first user data; obtain the credential of the first counter from the security chip; when the credential of the first counter in the non-security chip is the same as the credential of the first counter in the security chip, pass the security The chip obtains the first value of the first counter; the security chip obtains the second verification value of the second user data based on the second user data and the first value of the first counter; between the first verification value and the second verification value If the values are the same, the second user data is used.
  • the non-security chip may be a flash chip, a server, or a storage device such as a hard disk, which is not limited in the embodiments of the present application.
  • the first user data is user data previously stored by the electronic device.
  • the second user data is the first user data stored before being read by the electronic device.
  • the storage location of the first user data is the first storage location. Then the second user data can be the user data read from the first storage location.
  • the attacker may have modified the first user data, for example, modified the first user data to the second user data.
  • the first user data and the second user data are different.
  • User data is different.
  • the storage locations of the first user data and the second user data may be the same.
  • the electronic device uses the second user data, that is, the electronic device uses the first user data.
  • a multi-level authentication mechanism is implemented within the security chip. Only when the authentication is passed, the electronic device can use the second user data, which ensures the security of user data stored on the electronic device and prevents attackers from forging user data.
  • one or more processors invoke computer instructions to cause the electronic device to execute: when the credentials of the first counter in the non-secure chip are different from the credentials of the first counter in the secure chip, it is impossible to obtain the The first value of the first counter is obtained in the security chip. In this way, when the attacker does not know the credentials of the first counter, the credentials of the first counter cannot pass the authentication, and the attacker cannot obtain the first value of the first counter, which ensures the security of the first counter stored in the security chip. First value security.
  • one or more processors invoke computer instructions to cause the electronic device to execute: when the first check value and the second check value are different, the second user data cannot be used.
  • the security chip can also calculate the verification value of the user data based on other factors, including but not limited to one or more of the hardware unique key and the device unique ID. Other factors can also be other values, which are not limited in the embodiments of the present application.
  • the second check value calculated by the security chip based on the second user data and the first value of the first counter is the same as the first check value.
  • the verification value is also different, that is, the verification value of the user data fails, and the electronic device cannot use the forged second user data at this time.
  • one or more processors invoke computer instructions to cause the electronic device to execute: store the first user data, the first check value of the first user data and the credentials of the first counter in a non-secure within the chip. The first value of the first counter and the credentials of the first counter are stored in the security chip.
  • the electronic device stores the first value of the first counter in the security chip, thereby ensuring the security of the first value of the first counter and preventing the first value of the first counter from being acquired by an attacker.
  • the electronic device stores the credentials of the first counter in the security chip, so that when the electronic device uses the stored user data, it performs authentication based on the credentials of the first counter. Only after the authentication is passed, the electronic device can use the stored user data. , ensuring the security of user data stored on electronic devices.
  • one or more processors invoke computer instructions to cause the electronic device to execute: generate the credentials of the first counter through the security chip; store the credentials of the first counter in the security chip.
  • the security chip needs to save the credentials of the first counter in the non-security chip or on the server, so that when the electronic device uses the user data, it can be based on the credentials of the first counter stored in the non-security chip or on the server. Authentication.
  • the credentials of the first counter are obtained outside the security chip; and the credentials of the first counter are stored in the security chip.
  • the first value of the first counter is obtained based on the initial value of the first counter and the first preset value, wherein the initial value of the counter is randomly generated.
  • the initial value of the first counter is randomly generated, which can prevent an attacker from obtaining the first value of the first counter through brute force enumeration, resulting in the leakage of the first value of the first counter stored in the security chip. , improving the security of the first value of the first counter stored in the security chip.
  • one or more processors call computer instructions to cause the electronic device to execute: generating an initial value of the first counter through the security chip. In this way, the initial value of the first counter is generated in the security chip, which improves the security of the value of the counter stored in the security chip.
  • one or more processors call computer instructions to cause the electronic device to execute: obtain the first user data, the identification of the first counter and the first stored in the non-security chip from the non-security chip.
  • the credentials of the counter determine the credentials of the first counter stored in the security chip based on the identity of the first counter through the security chip; in the case where the credentials of the first counter in the non-security chip and the credentials of the first counter in the security chip are the same, Obtain the first value of the first counter; obtain the first verification value of the first user data based on the first value of the first counter and the first user data through the security chip; store the first verification value of the first user data in a non-secure chip.
  • the electronic device when the electronic device stores the first user data, the first verification value will be generated in the security chip based on the first user data and the first value of the first counter.
  • the electronic device After generating the first check value, the electronic device stores the first check value in a non-secure chip, such as a flash chip or on a server.
  • a non-secure chip such as a flash chip or on a server.
  • the attacker forges user data for example, uses the second user data to replace the first user data
  • the second verification value is generated in the security chip based on the second user data and the first value of the first counter. It is also different from the first verification value, causing the verification to fail and preventing attackers from forging user data.
  • Figure 16 is a schematic flowchart of a data protection device provided by an embodiment of the present application.
  • the device 1600 may include an acquisition unit 1601, a processing unit 1602, and a storage unit 1603.
  • the device 1600 can be used to perform a data protection method shown in the embodiment of Figure 15.
  • the obtaining unit 1601 is used to obtain the second user data, the certificate of the first counter and the first check value of the first user data from the non-security chip; wherein, the certificate of the first counter in the non-security chip is used for The first value of the first counter is obtained, and the first verification value and the first value of the first counter are used to verify whether the second user data is the same as the first user data.
  • the obtaining unit 1601 is also used to obtain the certificate of the first counter from the security chip.
  • the acquisition unit 1601 is also configured to obtain the first value of the first counter through the security chip when the credentials of the first counter in the non-security chip are the same as the credentials of the first counter in the security chip;
  • the processing unit 1602 is configured to obtain a second check value of the second user data based on the second user data and the first value of the first counter through the security chip.
  • the processing unit 1602 is also configured to use the second user data when the first check value and the second check value are the same.
  • the non-security chip may be a flash chip, a server, or a storage device such as a hard disk, which is not limited in the embodiments of the present application.
  • the first user data is user data previously stored by the electronic device.
  • the second user data is the first user data stored before being read by the electronic device.
  • the storage location of the first user data is the first storage location. Then the second user data can be the user data read from the first storage location.
  • the attacker may have modified the first user data, for example, modified the first user data to the second user data.
  • the first user data and the second user data are different.
  • User data is different.
  • the storage locations of the first user data and the second user data may be the same.
  • the electronic device uses the second user data, that is, the electronic device uses the first user data.
  • a multi-level authentication mechanism is implemented within the security chip. Only when the authentication is passed, the electronic device can use the second user data, which ensures the security of user data stored on the electronic device and prevents attackers from forging user data.
  • the acquisition unit 1601 is also used to prevent the first counter from being acquired from the secure chip when the credentials of the first counter in the non-secure chip are different from the credentials of the first counter in the secure chip. the first value. In this way, when the attacker does not know the credentials of the first counter, the credentials of the first counter cannot pass the authentication, and the attacker cannot obtain the first value of the first counter, which ensures the security of the first counter stored in the security chip. First value security.
  • the acquisition unit 1601 is also configured to prevent the second user data from being used when the first check value and the second check value are different.
  • the security chip can also calculate the verification value of the user data based on other factors.
  • Other factors include but are not limited to one or more of a hardware unique key and a device unique ID.
  • Other factors can also be other numerical values, which are not limited in the embodiments of this application.
  • the second check value calculated by the security chip based on the second user data and the first value of the first counter is the same as the first check value.
  • the verification value is also different, that is, the verification value of the user data fails, and the electronic device cannot use the forged second user data at this time.
  • the storage unit 1603 is used to store The first user data, the first check value of the first user data and the certificate of the first counter are stored in the non-secure chip, and the first value of the first counter and the certificate of the first counter are stored in the secure chip.
  • the electronic device stores the first value of the first counter in the security chip, ensuring the security of the first value of the first counter and preventing the first value of the first counter from being obtained by an attacker.
  • the electronic device stores the credentials of the first counter in the security chip, so that when the electronic device uses the stored user data, it performs authentication based on the credentials of the first counter. Only after the authentication is passed, the electronic device can use the stored user data. , ensuring the security of user data stored on electronic devices.
  • the storage unit 1603 is specifically configured to generate a certificate of the first counter through a security chip; and store the certificate of the first counter in the security chip.
  • the security chip needs to save the credentials of the first counter in the non-security chip or on the server, so that when the electronic device uses the user data, it can be based on the credentials of the first counter stored in the non-security chip or on the server. Authentication.
  • the storage unit 1603 is specifically used to obtain the credentials of the first counter outside the security chip; and store the credentials of the first counter in the security chip.
  • the first value of the first counter is obtained based on the initial value of the first counter and the first preset value, wherein the initial value of the counter is randomly generated.
  • the initial value of the first counter is randomly generated, which can prevent an attacker from obtaining the first value of the first counter through brute force enumeration, resulting in the leakage of the first value of the first counter stored in the security chip. , improving the security of the first value of the first counter stored in the security chip.
  • the processing unit 1602 before the storage unit 1603 stores the first value of the first counter in the security chip, the processing unit 1602 is also configured to generate an initial value of the first counter through the security chip. In this way, the initial value of the first counter is generated in the security chip, which improves the security of the value of the counter stored in the security chip.
  • the obtaining unit 1601 before the obtaining unit 1601 obtains the second user data, the certificate of the first counter and the first check value of the first user data from the non-secure chip, the obtaining unit 1601 is also used to The first user data, the identification of the first counter and the credentials of the first counter stored in the non-security chip are obtained from the non-security chip; the processing unit 1602 is also used to determine the security chip based on the identification of the first counter through the security chip The certificate of the first counter stored in the chip; the acquisition unit 1601 is also used to obtain the first value of the first counter when the certificate of the first counter in the non-security chip and the certificate of the first counter in the security chip are the same; The processing unit 1602 is also used to obtain the first check value of the first user data based on the first value of the first counter and the first user data through the security chip; the storage unit 1603 is also used to store the first value of the first user data.
  • the check value is stored in the non-secure chip.
  • the electronic device stores the first user data
  • the first verification value will be generated in the security chip based on the first user data and the first value of the first counter.
  • the electronic The device stores the first verification value in a non-secure chip, such as a flash chip or on a server.
  • the attacker forges user data for example, uses the second user data to replace the first user data
  • the second verification value is generated in the security chip based on the second user data and the first value of the first counter. It is also different from the first verification value, causing the verification to fail and preventing attackers from forging user data.
  • the acquisition unit 1601 is also used to acquire the third user data, and the third user data is the changed second user data; the processing unit 1602 , and is also used to send the third user data, the voucher of the first counter in the non-security chip and the identification of the first counter to the security chip; the processing unit 1602 is also used to obtain the first counter based on the identification of the first counter through the security chip.
  • the certificate of the counter is also used to obtain the first value of the first counter through the security chip when the certificate of the first counter in the non-security chip and the certificate of the first counter in the security chip are the same; the processing unit 1602, also configured to obtain the second value of the first counter based on the first value of the first counter and the second preset value; the processing unit 1602, further configured to obtain the second value of the first counter based on the third user data and the second value of the first counter through the security chip.
  • the third verification value of the third user data is obtained; the storage unit 1603 is also used to save the third verification value of the third user data in the non-security chip.
  • the electronic device uses the second user data, causing the second user data to change and obtain the third user data, and the electronic device needs to store the third user data.
  • the electronic device needs to generate a verification value of the third user data in the security chip, that is, the third verification value. So that when the subsequent electronic device uses the third user data, it can verify whether the third user data is forged based on the verification value.
  • This application provides a computer-readable storage medium for storing computer instructions.
  • the computer instructions When the computer instructions are run on an electronic device, the electronic device executes a data protection method shown in Figure 15.
  • This application provides a computer program product.
  • the computer program product When the computer program product is run on an electronic device, it causes the electronic device to execute a data protection method shown in Figure 15.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another, e.g., the computer instructions may be transferred from a website, computer, server, or data center Transmission to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) means.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains one or more available media integrated.
  • the available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, solid state disk (SSD)), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Storage Device Security (AREA)

Abstract

本申请提供了一种数据保护方法及电子设备。电子设备从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值;电子设备从安全芯片内获取到第一计数器的凭证;在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,电子设备通过安全芯片获取到第一计数器的第一值;电子设备通过安全芯片基于第二用户数据和第一计数器的第一值得到第二用户数据的第二校验值;在第一校验值和第二校验值相同的情况下,电子设备才可以使用第二用户数据。这样,在安全芯片内实现多级鉴权机制。只有在鉴权通过的情况下,电子设备才可以使用第二用户数据,保证了电子设备上存储用户数据的安全,避免攻击者伪造用户数据。

Description

一种数据保护方法及电子设备
本申请要求于2022年9月23日提交中国专利局、申请号为202211165829.8、申请名称为“一种数据保护方法及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及数据安全技术领域,尤其涉及一种数据保护方法及电子设备。
背景技术
安全芯片作为硬件级的高安全可信环境,具有防物理攻击的安全强度,被广泛应用于具有高安全需求的移动设备、物联网(internet of things,IOT)设备等设备中。
目前,设备中的安全芯片可用于存储校验用户数据的校验值。在电子设备使用用户数据时,需要校验校验值的正确性,只有在校验值校验通过的情况下,电子设备才可以使用用户数据。如何提高安全芯片中国存储的用户数据的校验值的安全性,有待进一步研究。
发明内容
本申请提供了一种数据保护方法及电子设备,实现了在安全芯片内实现多级鉴权机制。只有在鉴权通过的情况下,电子设备才可以使用第二用户数据,保证了电子设备上存储用户数据的安全,避免攻击者伪造用户数据。
第一方面,本申请提供了一种数据保护方法,方法包括:
电子设备从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值;其中,非安全芯片内第一计数器的凭证用于获取到第一计数器的第一值,第一校验值和第一计数器的第一值用于校验第二用户数据是否和第一用户数据相同;电子设备从安全芯片内获取到第一计数器的凭证;在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,电子设备通过安全芯片获取到第一计数器的第一值;电子设备通过安全芯片基于第二用户数据和第一计数器的第一值得到第二用户数据的第二校验值;在第一校验值和第二校验值相同的情况下,电子设备使用第二用户数据。
非安全芯片可以是flash芯片、也可以是服务器、也可以是硬盘等存储设备,本申请实施例对此不做限定。
其中,第一用户数据为电子设备之前存储的用户数据。第二用户数据为电子设备读取之前存储的第一用户数据。第一用户数据的存储位置为第一存储位置。那么第二用户数据可以从第一存储位置中读取到的用户数据。
在第一校验值和第二校验值不同的情况下,说明攻击者可能修改了第一用户数据,例如将第一用户数据修改为第二用户数据,此时第一用户数据与第二用户数据不同。第一用户数据和第二用户的存储位置可以是一样的。
在第一校验值和第二校验值相同的情况下,说明第二用户数据与第一用户数据相同,电子设备使用第二用户数据,即电子设备使用第一用户数据。
这样,在安全芯片内实现多级鉴权机制。只有在鉴权通过的情况下,电子设备才可以使用第二用户数据,保证了电子设备上存储用户数据的安全,避免攻击者伪造用户数据。
结合第一方面,在一种可能的实现方式中,方法还包括:在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证不同的情况下,电子设备无法从安全芯片内获取到第一计数器的第一值。这样,在攻击者不知道第一计数器的凭证的情况下,第一计数器的凭证无法鉴权通过,攻击者无法获取到第一计数器的第一值,保证了安全芯片中存储的第一计数器的第一值的安全性。
结合第一方面,在一种可能的实现方式中,还包括:在第一校验值和第二校验值不同的情况下,电子设备无法使用第二用户数据。
可选的,安全芯片还可以基于其他的因素计算得到用户数据的校验值,其他的因素包括但不仅限于硬件唯一密钥、设备唯一ID中的一种或几种。其他的因素还可以是其他的数值,本申请实施例对此不做限定。
这样,即使攻击者伪造了用户数据,例如将第一用户数据修改为第二用户数据,安全芯片基于第二用户数据和第一计数器的第一值计算得到的第二校验值与第一校验值也不同,即用户数据的校验值校验不通 过,此时电子设备也无法使用伪造的第二用户数据。
结合第一方面,在一种可能的实现方式中,在电子设备从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值之前,方法还包括:电子设备将第一用户数据、第一用户数据的第一校验值和第一计数器的凭证存储在非安全芯片内。电子设备将第一计数器的第一值和第一计数器的凭证存储在安全芯片内。
这样,电子设备将第一计数器的第一值存储在安全芯片内,保证了第一计数器的第一值的安全性,避免第一计数器的第一值被攻击者获取到。
电子设备将第一计数器的凭证存储在安全芯片内,以便在电子设备使用存储的用户数据时,基于第一计数器的凭证进行鉴权,只有在鉴权通过,电子设备才可以使用存储的用户数据,保证了电子设备上存储用户数据的安全。
结合第一方面,在一种可能的实现方式中,电子设备将第一计数器的凭证存储在安全芯片内,具体包括:电子设备通过安全芯片生成第一计数器的凭证;电子设备将第一计数器的凭证存储在安全芯片内。此时,安全芯片需将第一计数器的凭证保存在非安全芯片内或者服务器上,以使得在电子设备使用该用户数据时,可以基于非安全芯片内或者服务器上存储的第一计数器的凭证进行鉴权。
或者,
电子设备在安全芯片外获取到第一计数器的凭证;电子设备将第一计数器的凭证存储在安全芯片内。
结合第一方面,在一种可能的实现方式中,第一计数器的第一值是基于第一计数器的初始值和第一预设值得到的,其中,计数器的初始值是随机生成的。这样,第一计数器的初始值是随机生成的,可以避免攻击者通过暴力枚举的方式获取到第一计数器的第一值,导致安全芯片中存储的第一计数器的第一值泄露的情况发生,提高了安全芯片内存储的第一计数器的第一值的安全性。
结合第一方面,在一种可能的实现方式中,在电子设备将第一计数器的第一值存储在安全芯片内之前,方法还包括:电子设备通过安全芯片生成第一计数器的初始值。这样,第一计数器的初始值在安全芯片内生成,提高了安全芯片内存储的计数器的数值的安全性。
结合第一方面,在一种可能的实现方式中,在电子设备从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值之前,方法还包括:电子设备从非安全芯片内获取到第一用户数据、第一计数器的标识和非安全芯片内存储的第一计数器的凭证;电子设备通过安全芯片基于第一计数器的标识确定出安全芯片内存储的第一计数器的凭证;在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,电子设备获取到第一计数器的第一值;电子设备通过安全芯片基于第一计数器的第一值和第一用户数据得到第一用户数据的第一校验值;电子设备将第一用户数据的第一校验值存储在非安全芯片内。这样,在电子设备存储第一用户数据时,会在安全芯片内基于第一用户数据和第一计数器的第一值生成第一校验值。在生成第一校验值之后,电子设备在将第一校验值存储在非安全芯片内,例如flash芯片内或者服务器上。这样,即使攻击者将伪造用户数据,例如利用第二用户数据替代第一用户数据,在鉴权时,在安全芯片内基于得到第二用户数据和第一计数器的第一值生成第二校验值也与第一校验值不同,导致校验不通过,避免攻击者伪造用户数据的情况发生。
结合第一方面,在一种可能的实现方式中,在电子设备使用第二用户数据之后,方法还包括:电子设备获取到第三用户数据,第三用户数据为变化后的第二用户数据;电子设备将第三用户数据、非安全芯片内第一计数器的凭证和第一计数器的标识发送至安全芯片;电子设备通过安全芯片基于第一计数器的标识获取到第一计数器的凭证;在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,电子设备通过安全芯片获取到第一计数器的第一值,并基于第一计数器的第一值和第二预设值得到第一计数器的第二值;电子设备通过安全芯片基于第三用户数据和第一计数器的第二值得到第三用户数据的第三校验值;电子设备将第三用户数据的第三校验值保存在非安全芯片内。
也就是说,在第二用户数据鉴权通过之后,电子设备使用了第二用户数据,导致第二用户数据发生改变,得到第三用户数据,电子设备需要存储第三用户数据。在存储第三用户数据的时候,电子设备需在安 全芯片内生成第三用户数据的校验值,即第三校验值。以便后续电子设备在使用第三用户数据时,可以基于校验值校验第三用户数据是否为伪造的数据。
第二方面,本申请提供了一种电子设备,电子设备包括:一个或多个处理器、一个或多个存储器、显示屏;一个或多个存储器、显示屏与一个或多个处理器耦合,一个或多个存储器用于存储计算机程序代码,计算机程序代码包括计算机指令,一个或多个处理器调用计算机指令以使得电子设备执行:从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值;其中,非安全芯片内第一计数器的凭证用于获取到第一计数器的第一值,第一校验值和第一计数器的第一值用于校验第二用户数据是否和第一用户数据相同;从安全芯片内获取到第一计数器的凭证;在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,通过安全芯片获取到第一计数器的第一值;通过安全芯片基于第二用户数据和第一计数器的第一值得到第二用户数据的第二校验值;在第一校验值和第二校验值相同的情况下,使用第二用户数据。
非安全芯片可以是flash芯片、也可以是服务器、也可以是硬盘等存储设备,本申请实施例对此不做限定。
其中,第一用户数据为电子设备之前存储的用户数据。第二用户数据为电子设备读取之前存储的第一用户数据。第一用户数据的存储位置为第一存储位置。那么第二用户数据可以从第一存储位置中读取到的用户数据。
在第一校验值和第二校验值不同的情况下,说明攻击者可能修改了第一用户数据,例如将第一用户数据修改为第二用户数据,此时第一用户数据与第二用户数据不同。第一用户数据和第二用户的存储位置可以是一样的。
在第一校验值和第二校验值相同的情况下,说明第二用户数据与第一用户数据相同,电子设备使用第二用户数据,即电子设备使用第一用户数据。
这样,在安全芯片内实现多级鉴权机制。只有在鉴权通过的情况下,电子设备才可以使用第二用户数据,保证了电子设备上存储用户数据的安全,避免攻击者伪造用户数据。
结合第二方面,在一种可能的实现方式中,一个或多个处理器调用计算机指令以使得电子设备执行:在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证不同的情况下,无法从安全芯片内获取到第一计数器的第一值。这样,在攻击者不知道第一计数器的凭证的情况下,第一计数器的凭证无法鉴权通过,攻击者无法获取到第一计数器的第一值,保证了安全芯片中存储的第一计数器的第一值的安全性。
结合第二方面,在一种可能的实现方式中,一个或多个处理器调用计算机指令以使得电子设备执行:在第一校验值和第二校验值不同的情况下,无法使用第二用户数据。
可选的,安全芯片还可以基于其他的因素计算得到用户数据的校验值,其他的因素包括但不仅限于硬件唯一密钥、设备唯一ID中的一种或几种。其他的因素还可以是其他的数值,本申请实施例对此不做限定。
这样,即使攻击者伪造了用户数据,例如将第一用户数据修改为第二用户数据,安全芯片基于第二用户数据和第一计数器的第一值计算得到的第二校验值与第一校验值也不同,即用户数据的校验值校验不通过,此时电子设备也无法使用伪造的第二用户数据。
结合第二方面,在一种可能的实现方式中,一个或多个处理器调用计算机指令以使得电子设备执行:将第一用户数据、第一用户数据的第一校验值和第一计数器的凭证存储在非安全芯片内。将第一计数器的第一值和第一计数器的凭证存储在安全芯片内。
这样,电子设备将第一计数器的第一值存储在安全芯片内,保证了第一计数器的第一值的安全性,避免第一计数器的第一值被攻击者获取到。
电子设备将第一计数器的凭证存储在安全芯片内,以便在电子设备使用存储的用户数据时,基于第一计数器的凭证进行鉴权,只有在鉴权通过,电子设备才可以使用存储的用户数据,保证了电子设备上存储用户数据的安全。
结合第二方面,在一种可能的实现方式中,一个或多个处理器调用计算机指令以使得电子设备执行: 通过安全芯片生成第一计数器的凭证;将第一计数器的凭证存储在安全芯片内。此时,安全芯片需将第一计数器的凭证保存在非安全芯片内或者服务器上,以使得在电子设备使用该用户数据时,可以基于非安全芯片内或者服务器上存储的第一计数器的凭证进行鉴权。
或者,
在安全芯片外获取到第一计数器的凭证;将第一计数器的凭证存储在安全芯片内。
结合第二方面,在一种可能的实现方式中,第一计数器的第一值是基于第一计数器的初始值和第一预设值得到的,其中,计数器的初始值是随机生成的。这样,第一计数器的初始值是随机生成的,可以避免攻击者通过暴力枚举的方式获取到第一计数器的第一值,导致安全芯片中存储的第一计数器的第一值泄露的情况发生,提高了安全芯片内存储的第一计数器的第一值的安全性。
结合第二方面,在一种可能的实现方式中,一个或多个处理器调用计算机指令以使得电子设备执行:通过安全芯片生成第一计数器的初始值。这样,第一计数器的初始值在安全芯片内生成,提高了安全芯片内存储的计数器的数值的安全性。
结合第二方面,在一种可能的实现方式中,一个或多个处理器调用计算机指令以使得电子设备执行:从非安全芯片内获取到第一用户数据、第一计数器的标识和非安全芯片内存储的第一计数器的凭证;通过安全芯片基于第一计数器的标识确定出安全芯片内存储的第一计数器的凭证;在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,获取到第一计数器的第一值;通过安全芯片基于第一计数器的第一值和第一用户数据得到第一用户数据的第一校验值;将第一用户数据的第一校验值存储在非安全芯片内。这样,在电子设备存储第一用户数据时,会在安全芯片内基于第一用户数据和第一计数器的第一值生成第一校验值。在生成第一校验值之后,电子设备在将第一校验值存储在非安全芯片内,例如flash芯片内或者服务器上。这样,即使攻击者将伪造用户数据,例如利用第二用户数据替代第一用户数据,在鉴权时,在安全芯片内基于得到第二用户数据和第一计数器的第一值生成第二校验值也与第一校验值不同,导致校验不通过,避免攻击者伪造用户数据的情况发生。
结合第二方面,在一种可能的实现方式中,一个或多个处理器调用计算机指令以使得电子设备执行:在电子设备使用第二用户数据之后,获取到第三用户数据,第三用户数据为变化后的第二用户数据;将第三用户数据、非安全芯片内第一计数器的凭证和第一计数器的标识发送至安全芯片;通过安全芯片基于第一计数器的标识获取到第一计数器的凭证;在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,通过安全芯片获取到第一计数器的第一值,并基于第一计数器的第一值和第二预设值得到第一计数器的第二值;通过安全芯片基于第三用户数据和第一计数器的第二值得到第三用户数据的第三校验值;将第三用户数据的第三校验值保存在非安全芯片内。
也就是说,在第二用户数据鉴权通过之后,电子设备使用了第二用户数据,导致第二用户数据发生改变,得到第三用户数据,电子设备需要存储第三用户数据。在存储第三用户数据的时候,电子设备需在安全芯片内生成第三用户数据的校验值,即第三校验值。以便后续电子设备在使用第三用户数据时,可以基于校验值校验第三用户数据是否为伪造的数据。
第三方面,本申请提供了一种计算机可读存储介质,用于存储计算机指令,当计算机指令在电子设上运行时,使得电子设执行上述第一方面中任一可能的实现方式中提供的一种数据保护方法。
第四方面,本申请提供了一种计算机程序产品,当计算机程序产品在电子设上运行时,使得电子设执行上述第一方面中任一可能的实现方式中提供的一种数据保护方法。
对于第二方面至第四方面的有益效果,可以参考第一方面中有益效果的描述,本申请实施例在此不再赘述。
附图说明
图1-图3为本申请实施例提供的几种安全芯片的形态示意图;
图4为本申请实施例提供的一种电子设备存储用户数据的校验值的示意图;
图5为本申请实施例提供的一种电子设备验证用户数据的校验值的示意图;
图6为本申请实施例提供的另一种电子设备存储用户数据的校验值的示意图;
图7为本申请实施例提供的另一种电子设备验证用户数据的校验值的示意图;
图8为本申请实施例提供的一种电子设备100的硬件结构示意图;
图9为本申请实施例提供的一种电子设备100的软件结构示意图;
图10为本申请实施例提供的一种生成计数器的凭证的方法流程示意图;
图11为本申请实施例提供的另一种生成计数器的凭证的方法流程示意图;
图12为本申请实施例提供的一种保护用户数据并生成用户数据的校验值的示意图;
图13为本申请实施例提供的一种在电子设备使用第一用户数据之前在安全芯片中验证第一用户数据的校验值的正确性的方法示意图;
图14为本申请实施例提供的一种保存变化后的第二用户数据的方法示意图;
图15为本申请实施例提供的一种数据保护方法的流程示意图;
图16为本申请实施例提供的一种数据保护装置的流程示意图。
具体实施方式
下面将结合附图对本申请实施例中的技术方案进行清楚、详尽地描述。其中,在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;文本中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况,另外,在本申请实施例的描述中,“多个”是指两个或多于两个。
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为暗示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征,在本申请实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。
本申请以下实施例中的术语“用户界面(user interface,UI)”,是应用程序或操作系统与用户之间进行交互和信息交换的介质接口,它实现信息的内部形式与用户可以接受形式之间的转换。用户界面常用的表现形式是图形用户界面(graphic user interface,GUI),是指采用图形方式显示的与计算机操作相关的用户界面。它可以是在电子设备的显示屏中显示的文本、图标、按钮、菜单、选项卡、文本框、对话框、状态栏、导航栏、Widget等可视的界面元素。
首先对本申请实施例涉及的技术术语进行解释。
1、用户数据的校验值
用户数据的校验值用于保护电子设备上用户数据的安全性。在电子设备存储用户数据之前,会生成用户数据的校验值,并将用户数据的校验值存储在非安全芯片内。在电子设备使用用户数据时,电子设备会在安全芯片内校验该用户数据的校验值的正确性,只有在校验通过的情况下,电子设备才可以获取到并使用用户数据。在用户数据的校验值校验不通过的情况下,电子设备也无法获取到用户数据。
用户数据的校验值,可以是基于用户数据生成的,也可以是基于其他参数生成的,本申请实施例对此不做限定。
电子设备在存储用户数据时,会另外存储一个用户数据的校验值,以便电子设备可以校验用户数据的校验值的正确性。具体的,在电子设备使用用户数据之前,电子设备获取到另外存储的用户数据的校验值,并从安全芯片中获取到用户数据的校验值,在另外存储的用户数据的校验值和安全芯片中计算得到用户数据的校验值一致的情况下,用户数据的校验值校验通过,此时电子设备可以获取到并使用用户数据。否则,电子设备无法获取到也无法使用用户数据。
2、安全芯片
为了保证电子设备内存储的用户数据的校验值的安全性,避免被攻击者获取到用户数据的校验值,一般将身份认证信息存储在电子设备内的安全芯片内,防止电子设备内存储的身份认证信息泄露。
安全芯片在电子设备中有以下几种形态:
形态一:如图1所示,安全芯片位于电子设备内主芯片(SOC芯片)中的内置安全核中。可以是主芯片内划分一部分区域作为安全芯片,或者安全芯片集成在主芯片内部。
形态二:如图2所示,安全芯片位于外置SOC芯片的安全元件(secure element,SE)中,SE是防物理攻击的电子元件,其内部包含微处理器、存储以及加解密硬件等,可独立使用。
形态三:如图3所示,安全芯片由SOC芯片与外置SOC芯片的SE共同组成,完成一些高安全业务, 保证设备的高安全性。
不仅限于以上三种形态,安全芯片还可以是其他的形态,本申请实施例对此不做限定。
图4示出了一种电子设备存储用户数据的校验值的示意图。
示例性的,用户数据的校验值可以是加数器值。
在电子设备存储用户数据之前,会将计数器的值+1,再将更新后的计数器的值存储在安全芯片内。当电子设备使用用户数据导致用户数据变化之后,在存储变化后的用户数据的时候,会更改计数器的值,例如+1,再将更新后的计数器的值存储在安全芯片内。也就是说,用户数据的内容和计数器的值是一一绑定的关系,当用户数据发生变化后,计数器的值也会对应的发生变化。
S401、电子设备获取到用户数据。
电子设备在运行时,产生的数据可以被称为用户数据。
示例性的,用户数据可以是上网数据余额、充值卡余额、公交卡余额等数据。
S402、电子设备获取到计数器值一。
在电子设备存储用户数据之前,电子设备可以获取到计数器值一。
S403、电子设备将用户数据和计数器值一存储在非安全芯片内,并将计数器值一存储至安全芯片内。
示例性的,电子设备可以将用户数据和计数器值一存储在非安全芯片内,非安全芯片可以是flash芯片。
可选的,电子设备可以将用户数据和计数器值一加密后存储在非安全芯片内。
可选的,用户数据和计数器值一可以存储在非安全芯片内的同一个区域,也可以存储在非安全芯片内的不同区域,本申请实施例对此不做限定。
同时,电子设备还需将计数器值一存储至安全芯片内。
图5示出了一种电子设备验证用户数据的校验值的示意图。
基于图4所示的存储用户数据的校验值的方法,图5示出了一种校验用户数据的校验值的方法流程。
S501、电子设备从非安全芯片内获取到计数器值二。
在电子设备需使用用户数据时,电子设备需先验证用户数据的校验值。
首先,电子设备从非安全芯片内获取到计数器值二。例如,电子设备可以从flash芯片内获取到计数器值二。
由于攻击者可能会修改非安全芯片内存储的计数器值,因此电子设备从非安全芯片内获取到的计数器值二与之前存储的计数器值一可能不同。
S502、电子设备从安全芯片内获取到计数器值三。
其次,电子设备还需从安全芯片内获取到计数器值三。
由于攻击者可能会修改安全芯片内存储的计数器值,因此电子设备从安全芯片内获取到的计数器值三与之前存储的计数器值一可能不同。
S503、计数器值二和计数器值三是否相同。
若计数器值二和计数器值三相同,则执行S504。若计数器值二和计数器值三不同,则执行S505。
S504、在计数器值二和计数器值三相同的情况下,电子设备使用用户数据。
在计数器值二和计数器值三相同的情况下,说明攻击者没有修改安全芯片内存储的计数器值一,攻击者也没有修改非安全芯片内存储的计数器值一,则电子设备可以获取到并使用用户数据。
S505、电子设备无法使用用户数据。
在计数器值二和计数器值三不同的情况下,说明攻击者可能修改了安全芯片内存储的计数器值一,攻击者也可能修改了非安全芯片内存储的计数器值一,那么该用户数据的校验值无法检验通过,为了保护用户数据的安全,此时电子设备无法使用用户数据。
但是从图4和图5所示的实施例可以看出,若攻击者修改了安全芯片内存储的计数器的值,将会导致安全芯片内存储的计数器值与非安全芯片内存储的计数器值不一致,导致校验不通过,电子设备也无法使用该用户数据。
其次,若攻击者从安全芯片内获取到存储的计数器值,也从非安全芯片内获取到计数器值,并校验通过。那么攻击者在使用用户数据之前,可能会伪造用户数据,并使用伪造的用户数据。
图6示出了另一种存储用户数据的校验值的示意图。
示例性的,用户数据的校验值可以是基于用户数据计算得到的。
在电子设备存储用户数据之前,会基于用户数据计算得到一个校验值,再将该校验值存储在安全芯片内。当电子设备使用用户数据导致用户数据变化之后,在存储变化后的用户数据的时候,会重新基于变化后的用户数据得到一个校验值,再将更新后的校验值存储在安全芯片内。也就是说,用户数据的内容和校验值是一一绑定的关系,当用户数据发生变化后,用户数据的校验值也会对应的发生变化。
S601、电子设备获取到用户数据。
S602、电子设备基于用户数据得到用户数据的校验值一。
示例性的,电子设备可以计算用户数据的哈希值,将该哈希值作为校验值一。
电子设备还可以通过其他的方式基于用户数据得到用户数据的校验值一,本申请实施例对此不做限定。
S603、电子设备将用户数据的校验值一存储在安全芯片内。
在电子设备存储用户数据时,将用户数据的校验值一存储在安全芯片内。以便后续使用用户数据时,可以校验用户数据的校验值。在校验通过的情况下,在允许电子设备使用用户数据。
图7示出了另一种电子设备验证用户数据的校验值的示意图。
基于图6所示的存储用户数据的校验值的方法,图7示出了另一种校验用户数据的校验值的方法流程。
S701、电子设备从安全芯片内获取到用户数据的校验值二。
在电子设备需使用用户数据时,电子设备需先验证用户数据的校验值。首先,电子设备从安全芯片内获取到用户数据的校验值二。
由于攻击者可能会修改安全芯片内存储的用户数据的校验值,因此电子设备从安全芯片内获取到的用户数据的校验值二与之前存储的用户数据的校验值一可能不同。
S702、电子设备基于用户数据得到用户数据的校验值三。
其次,电子设备还获取到用户数据的校验值三。例如电子设备可以基于非安全芯片中存储的用户数据计算得到用户数据的校验值三。
由于攻击者可能会修改非安全芯片内存储的用户数据,因此电子设备基于非安全芯片中存储的用户数据计算得到用户数据的校验值三与之前基于非安全芯片中存储的用户数据计算得到用户数据的校验值一可能不同。
S703、校验值三和校验值二是否相同。
若校验值三和校验值二相同,则执行S704。若校验值三和校验值二不同,则执行S705。
S704、在校验值三和校验值二相同的情况下,电子设备使用用户数据。
在校验值三和校验值二相同的情况下,说明攻击者没有修改安全芯片内存储的用户数据的校验值,攻击者也没有修改非安全芯片内存储的用户数据,则电子设备可以获取到并使用用户数据。
S705、电子设备无法使用用户数据。
在校验值三和校验值二不同的情况下,说明攻击者可能修改了安全芯片内存储的用户数据的校验值,攻击者也可能修改了非安全芯片内存储的用户数据,那么该用户数据的校验值无法检验通过,为了保护用户数据的安全,此时电子设备无法使用用户数据。
但是从图6和图7实施例可以看出,若攻击者修改了安全芯片内存储的用户数据的校验值,将会导致安全芯片内存储的用户数据的校验值与基于非安全芯片内存储的用户数据计算得到的校验值不一致,导致校验不通过,电子设备也无法使用该用户数据。
基于此,本申请实施例提供了一种数据保护方法,方法包括申请计数器、保护用户数据和使用用户数据两部分。
其中,申请计数器包括以下步骤:
步骤一:电子设备获取到第一用户数据。
步骤二:电子设备获取到第一计数器的凭证,并将第一计数器的数值置为第一值。
可选的,电子设备可以在安全芯片内将第一数器的数值置为第一值,因为安全芯片的安全系数较高,避免第一计数器的数值泄露的情况发生。
步骤三:电子设备将第一计数器的凭证保存在安全芯片内,并将第一计数器的凭证保存在非安全芯片内或者云端。
保护用户数据包括以下步骤:
步骤一:电子设备将第一用户数据和第一计数器的凭证发送至安全芯片。
步骤二:在电子设备发送的第一计数器的凭证和安全芯片内存储的第一计数器的凭证相同的情况下,电子设备基于第一用户数据和第一计数器的第一值计算得到第一校验值。
步骤三:电子设备将第一校验值保存在非安全芯片内或者云端。
使用用户数据包括以下步骤:
步骤一:电子设备将第二用户数据、第一计数器的凭证和第一校验值发送至安全芯片。
步骤二:在电子设备发送的第一计数器的凭证和安全芯片内存储的第一计数器的凭证相同的情况下,电子设备基于第二用户数据和和第一计数器的第一值计算得到第二校验值。
步骤三:在第一校验值和第二校验值相同的情况下,则验证成功,说明第一用户数据和第二用户数据相同,即用户数据没有被更改,电子设备可以使用第一用户数据。在第一校验值和第二校验值不同的情况下,则验证不通过,说明第一用户数据和第二用户数据不同,可能有攻击者更改了第一用户数据,电子设备无法使用第一用户数据。
通过该方法,实现了在电子设备使用用户数据之前,通过多级鉴权机制,只有在安全芯片内鉴权通过后才可以使用用户数据,避免用户数据被攻击者更改的情况发生,保护了用户数据的安全。
图8示出了电子设备100的结构示意图。
电子设备100可以是手机、平板电脑、桌面型计算机、膝上型计算机、手持计算机、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本,以及蜂窝电话、个人数字助理(personal digital assistant,PDA)、增强现实(augmented reality,AR)设备、虚拟现实(virtual reality,VR)设备、人工智能(artificial intelligence,AI)设备、可穿戴式设备、车载设备、智能家居设备和/或智慧城市设备,本申请实施例对该电子设备的具体类型不作特殊限制。
电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。
可以理解的是,本发明实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。
控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。
I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。在一些实施例中,处理器110可以包含多组I2C总线。处理器110可以通过不同的I2C 总线接口分别耦合触摸传感器180K,充电器,闪光灯,摄像头193等。例如:处理器110可以通过I2C接口耦合触摸传感器180K,使处理器110与触摸传感器180K通过I2C总线接口通信,实现电子设备100的触摸功能。
I2S接口可以用于音频通信。在一些实施例中,处理器110可以包含多组I2S总线。处理器110可以通过I2S总线与音频模块170耦合,实现处理器110与音频模块170之间的通信。在一些实施例中,音频模块170可以通过I2S接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。
PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。在一些实施例中,音频模块170与无线通信模块160可以通过PCM总线接口耦合。在一些实施例中,音频模块170也可以通过PCM接口向无线通信模块160传递音频信号,实现通过蓝牙耳机接听电话的功能。所述I2S接口和所述PCM接口都可以用于音频通信。
UART接口是一种通用串行数据总线,用于异步通信。该总线可以为双向通信总线。它将要传输的数据在串行通信与并行通信之间转换。在一些实施例中,UART接口通常被用于连接处理器110与无线通信模块160。例如:处理器110通过UART接口与无线通信模块160中的蓝牙模块通信,实现蓝牙功能。在一些实施例中,音频模块170可以通过UART接口向无线通信模块160传递音频信号,实现通过蓝牙耳机播放音乐的功能。
MIPI接口可以被用于连接处理器110与显示屏194,摄像头193等外围器件。MIPI接口包括摄像头串行接口(camera serial interface,CSI),显示屏串行接口(display serial interface,DSI)等。在一些实施例中,处理器110和摄像头193通过CSI接口通信,实现电子设备100的拍摄功能。处理器110和显示屏194通过DSI接口通信,实现电子设备100的显示功能。
GPIO接口可以通过软件配置。GPIO接口可以被配置为控制信号,也可被配置为数据信号。在一些实施例中,GPIO接口可以用于连接处理器110与摄像头193,显示屏194,无线通信模块160,音频模块170,传感器模块180等。GPIO接口还可以被配置为I2C接口,I2S接口,UART接口,MIPI接口等。
USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备100充电,也可以用于电子设备100与外围设备之间传输数据。也可以用于连接耳机,通过耳机播放音频。该接口还可以用于连接其他电子设备,例如AR设备等。
可以理解的是,本发明实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备100的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,显示屏194,摄像头193,和无线通信模块160等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于处理器110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。
移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些 实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。
在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code division multiple access,CDMA),宽带码分多址(wideband code division multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidou navigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。
摄像头193用于捕获静态图像或视频。物体通过镜头生成光学图像投射到感光元件。感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。在一些实施例中,电子设备100可以包括1个或N个摄像头193,N为大于1的正整数。
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group, MPEG)1,MPEG2,MPEG3,MPEG4等。
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。
内部存储器121可以包括一个或多个随机存取存储器(random access memory,RAM)和一个或多个非易失性存储器(non-volatile memory,NVM)。
随机存取存储器可以包括静态随机存储器(static random-access memory,SRAM)、动态随机存储器(dynamic random access memory,DRAM)、同步动态随机存储器(synchronous dynamic random access memory,SDRAM)、双倍资料率同步动态随机存取存储器(double data rate synchronous dynamic random access memory,DDR SDRAM,例如第五代DDR SDRAM一般称为DDR5SDRAM)等;
非易失性存储器可以包括磁盘存储器件、快闪存储器(flash memory)。
快闪存储器按照运作原理划分可以包括NOR FLASH、NAND FLASH、3D NAND FLASH等,按照存储单元电位阶数划分可以包括单阶存储单元(single-level cell,SLC)、多阶存储单元(multi-level cell,MLC)、三阶储存单元(triple-level cell,TLC)、四阶储存单元(quad-level cell,QLC)等,按照存储规范划分可以包括通用闪存存储(英文:universal flash storage,UFS)、嵌入式多媒体存储卡(embedded multi media Card,eMMC)等。
随机存取存储器可以由处理器110直接进行读写,可以用于存储操作系统或其他正在运行中的程序的可执行程序(例如机器指令),还可以用于存储用户及应用程序的数据等。
非易失性存储器也可以存储可执行程序和存储用户及应用程序的数据等,可以提前加载到随机存取存储器中,用于处理器110直接进行读写。
外部存储器接口120可以用于连接外部的非易失性存储器,实现扩展电子设备100的存储能力。外部的非易失性存储器通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部的非易失性存储器中。
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器110中,或将音频模块170的部分功能模块设置于处理器110中。
扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备100可以通过扬声器170A收听音乐,或收听免提通话。
受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。当电子设备100接听电话或语音信息时,可以通过将受话器170B靠近人耳接听语音。
麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。当拨打电话或发送语音信息时,用户可以通过人嘴靠近麦克风170C发声,将声音信号输入到麦克风170C。电子设备100可以设置至少一个麦克风170C。在另一些实施例中,电子设备100可以设置两个麦克风170C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备100还可以设置三个,四个或更多麦克风170C,实现采集声音信号,降噪,还可以识别声音来源,实现定向录音功能等。
耳机接口170D用于连接有线耳机。耳机接口170D可以是USB接口130,也可以是3.5mm的开放移动电子设备平台(open mobile terminal platform,OMTP)标准接口,美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准接口。
压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器180A可以设置于显示屏194。压力传感器180A的种类很多,如电阻式压力传感器,电感式压力传感器,电容式压力传感器等。电容式压力传感器可以是包括至少两个具有导电材料的平行板。当有力作用于压力传感器180A,电极之间的电容改变。电子设备100根据电容的变化确定压力的强度。当有触摸操作作用于显示屏194,电子设备100根据压力传感器180A检测所述触摸操作强度。电子设备100也可以根据压力传感器180A的检测信号计算触摸的位置。在一些实施例中,作用于相同触摸位置,但不同触摸操作强度的触摸操作,可以对应不同的操作指令。例如:当有触摸操作强度小于第一压力阈值的触摸操作作用于短消息应用图标时,执行查看短消息的指令。当有触摸操作强度大于或等于第一压力阈值的触摸操作作用于短消息应用图标时,执行新建短消息的指令。
陀螺仪传感器180B可以用于确定电子设备100的运动姿态。在一些实施例中,可以通过陀螺仪传感器180B确定电子设备100围绕三个轴(即,x,y和z轴)的角速度。陀螺仪传感器180B可以用于拍摄防抖。示例性的,当按下快门,陀螺仪传感器180B检测电子设备100抖动的角度,根据角度计算出镜头模组需要补偿的距离,让镜头通过反向运动抵消电子设备100的抖动,实现防抖。陀螺仪传感器180B还可以用于导航,体感游戏场景。
气压传感器180C用于测量气压。在一些实施例中,电子设备100通过气压传感器180C测得的气压值计算海拔高度,辅助定位和导航。
磁传感器180D包括霍尔传感器。电子设备100可以利用磁传感器180D检测翻盖皮套的开合。在一些实施例中,当电子设备100是翻盖机时,电子设备100可以根据磁传感器180D检测翻盖的开合。进而根据检测到的皮套的开合状态或翻盖的开合状态,设置翻盖自动解锁等特性。
加速度传感器180E可检测电子设备100在各个方向上(一般为三轴)加速度的大小。当电子设备100静止时可检测出重力的大小及方向。还可以用于识别电子设备姿态,应用于横竖屏切换,计步器等应用。
距离传感器180F,用于测量距离。电子设备100可以通过红外或激光测量距离。在一些实施例中,拍摄场景,电子设备100可以利用距离传感器180F测距以实现快速对焦。
接近光传感器180G可以包括例如发光二极管(LED)和光检测器,例如光电二极管。发光二极管可以是红外发光二极管。电子设备100通过发光二极管向外发射红外光。电子设备100使用光电二极管检测来自附近物体的红外反射光。当检测到充分的反射光时,可以确定电子设备100附近有物体。当检测到不充分的反射光时,电子设备100可以确定电子设备100附近没有物体。电子设备100可以利用接近光传感器180G检测用户手持电子设备100贴近耳朵通话,以便自动熄灭屏幕达到省电的目的。接近光传感器180G也可用于皮套模式,口袋模式自动解锁与锁屏。
环境光传感器180L用于感知环境光亮度。电子设备100可以根据感知的环境光亮度自适应调节显示屏194亮度。环境光传感器180L也可用于拍照时自动调节白平衡。环境光传感器180L还可以与接近光传感器180G配合,检测电子设备100是否在口袋里,以防误触。
指纹传感器180H用于采集指纹。电子设备100可以利用采集的指纹特性实现指纹解锁,访问应用锁,指纹拍照,指纹接听来电等。
温度传感器180J用于检测温度。在一些实施例中,电子设备100利用温度传感器180J检测的温度,执行温度处理策略。例如,当温度传感器180J上报的温度超过阈值,电子设备100执行降低位于温度传感器180J附近的处理器的性能,以便降低功耗实施热保护。在另一些实施例中,当温度低于另一阈值时,电子设备100对电池142加热,以避免低温导致电子设备100异常关机。在其他一些实施例中,当温度低于又一阈值时,电子设备100对电池142的输出电压执行升压,以避免低温导致的异常关机。
触摸传感器180K,也称“触控器件”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于电子设备100的表面,与显示屏194所处的位置不同。
骨传导传感器180M可以获取振动信号。在一些实施例中,骨传导传感器180M可以获取人体声部振动骨块的振动信号。骨传导传感器180M也可以接触人体脉搏,接收血压跳动信号。在一些实施例中,骨传导传感器180M也可以设置于耳机中,结合成骨传导耳机。音频模块170可以基于所述骨传导传感器180M获取的声部振动骨块的振动信号,解析出语音信号,实现语音功能。应用处理器可以基于所述骨传导传感器180M获取的血压跳动信号解析心率信息,实现心率检测功能。
按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。
马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏194不同区域的触摸操作,马达191也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒,接收信息,闹钟,游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。
指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。
SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出, 实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口195可以同时插入多张卡。所述多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容不同类型的SIM卡。SIM卡接口195也可以兼容外部存储卡。电子设备100通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,电子设备100采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备100中,不能和电子设备100分离。
电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本发明实施例以分层架构的Android系统为例,示例性说明电子设备100的软件结构。电子设备100的系统还可以是IOS系统、鸿蒙系统等等,本申请实施例对此不做限定。电子设备100的类型不同,电子设备100的系统也可以不同,本申请实施例以电子设备100的系统为Android系统为例进行说明。
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime)和系统库,以及内核层。本申请实施例对电子设备的软件结构的分层不做限制。参照图9,本申请实施例中可以将安卓运行时和系统库,以及内核层看作一层,称为系统层。应理解,图9在Android系统的基础上还增加了电子设备中的硬件层。
应理解,图9所示的各分层中包括的模块为本申请实施例中涉及到的模块,如下各分层中包括的模块并不构成对电子设备的结构和模块部署的层级(示例说明)的限定。示例性的,如身份认证信息注册模块可以部署在应用程序层,也可以部署在应用程序框架层。在一种实施例中,图9中所示的模块可以单独部署,或者几个模块可以部署在一起,图9中对模块的划分为一种示例。在一种实施例中,图9中所示的模块的名称为示例说明。
应用程序层可以包括一系列应用程序包。
如图9所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,短信息等应用程序。
应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。
如图9所示,应用程序框架层可以包括窗口管理器,内容提供器,电话管理器,资源管理器,防回退服务模块等。
窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕身份认证信息验证模块等。
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。
电话管理器用于提供电子设备100的通信功能。例如通话状态的管理(包括接通,挂断等)。
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。
防回退服务模块主要提供应用和安全芯片之间传递消息的媒介。具体的,在应用保存用户数据之前,在应用申请计数器时,防回退服务模块给应用分配空闲的计数器,获取到计数器的标识,并将计数器的标识发送至安全芯片。
在应用保存用户数据之前,防回退服务模块将计数器的标识发送至安全芯片,使得安全芯片可以修改并保存该计数器的数值。在电子设备需使用该用户数据时,可以基于该计数器的数值得到该用户数据的校验值,只有在校验通过的情况下,电子设备才可以使用该用户数据。
可选的,在用户数据改变之后,对应的计数器的数值也会改变,那么变化后的用户数据的校验值也会改变。
在电子设备使用该用户数据之前,防回退服务模块将用户数据的校验值发送至安全芯片,并将用户数据发送至安全芯片,安全芯片将基于防回退服务模块发送的用户数据和计数器的数值计算得到另一个校验值,在该校验值与之前存储的校验值相同的情况下,则验证通过,防回退服务模块发送至安全芯片的用户数据与之前存储的用户数据相同,电子设备可以使用该应用数据。在该校验值与之前存储的校验值不同的情况下,则验证不通过,防回退服务模块发送至安全芯片的用户数据与之前存储的用户数据不同,可能有攻击者修改了该用户数据,电子设备无法使用该应用数据。
因为本申请实施例中将安卓运行时和系统库,以及内核层看作一层,因此系统层中可以包括安卓运行时和系统库,以及内核层中的功能模块。
系统层可以包括安全芯片,安全芯片的数量可以是一个或多个。
安全芯片内只要用于存储计数器的数值、用户数据的校验值、计数器的凭证等等,并基于计数器的数值、用户数据的校验值、计数器的凭证等进行多级鉴权,保证用户数据的安全性。
对于回退服务模块功能和安全芯片功能的介绍,可以参考后续实施例的描述。
图10为本申请实施例提供的一种生成计数器的凭证的方法流程示意图。
安全芯片在获取得到计数器的具体数值之前,验证安全芯片内存储的计数器的凭证和接收到的计数器的凭证是否相同,在相同的情况下,安全芯片才可以获取到计数器的具体数值。
或者说,安全芯片将计数器的数值基于该计数器的凭证加密,得到加密计数器值。在安全芯片在获取得到计数器的具体数值之前,安全芯片接收计数器的凭证。若安全芯片能够基于接收到的计数器的凭证将加密计数器值解密,则安全芯片可以获取到该计数器的具体数值。
S1001、第一应用获取到计数器的凭证。
在第一应用保存用户数据之前,第一应用获取到计数器的凭证。计数器的凭证可以是一个,也可以是多个。
不同计数器的计数器凭证可以不同,或者多个计数器可以共用一个计数器的凭证,本申请实施例对此不做限定。
可选的,第一应用可以将计数器的凭证保存在非安全芯片中,例如flash芯片中。第一应用也可以将计数器的凭证保存在服务器中。本申请实施例对此不做限定。
第一应用可以通过以下任意一种方式获取到计数器的凭证。
方式一:第一应用从服务器中获取到计数器的凭证。
方式二:第一应用从电子设备的本地获取到计数器的凭证。
方式三:在第一应用需获取到计数器的凭证之前,电子设备可以提示用户输入凭证,该凭证可以作为计数器的凭证。
第一应用还可以通过其他的方式获取到计数器的凭证,本申请实施例对此不做限定。
S1002、第一应用将计数器的凭证发送至防回退服务模块。
S1003、防回退服务模块为第一应用分配第一计数器,并获取到第一计数器的标识。
可选的,电子设备内预置有多个不同的计数器,在防回退服务模块接收到第一应用发送的计数器的凭证后,防回退服务模块可以从多个空闲的计数器中,随机分配一个计数器作为第一计数器。
可选的,防回退服务模块也可以为第一应用同时分配多个计数器。例如,防回退服务模块可以基于计数器的凭证的数量,确定出为第一应用分配计数器的数量。示例性的,若有一个计数器的凭证,那么防回退服务模块可以为第一应用分配一个计数器,若有三个计数器的凭证,那么防回退服务模块可以为第一应用分配三个不同的计数器。
可选的,第一应用在向防回退服务模块发送计数器的凭证的同时,可以发送需分配的计数器的数量。防回退服务模块可以基于第一应用发送的需分配的计数器的数量确定出为第一应用分配计数器的数量。示例性的,若第一应用向防回退服务模块发送的需分配的计数器的数量为一个,则防回退服务模块可以为第一应用分配一个计数器。若第一应用向防回退服务
模块发送的需分配的计数器的数量为三个,则防回退服务模块可以为第一应用分配三个计数器。在一种可能的实现方式中,第一应用向防回退服务模块发送计数器的凭证的数量和需分配的计数器的数量相同。示例性的,若第一应用向防回退服务模块发送的需分配的计数器的数量为一个,那么第一应用向防回退服务模块发送的计数器的凭证的数量也为一个。若第一应用向防回退服务模块发送的需分配的计数器的数量为三个,那么第一应用向防回退服务模块发送的计数器的凭证的数量也为三个。在其他可能的实现方式中,第一应用向防回退服务模块发送计数器的凭证的数量和需分配的计数器的数量可以不同。示例性的,若第一应用向防回退服务模块发送的需分配的计数器的数量为一个,那么第一应用向防回退服务模块发送的计数器的凭证的数量可以为一个。若第一应用向防回退服务模块发送的需分配的计数器的数量为三个,第一应用向防回退服务模块发送的计数器的凭证的数量也为两个,则一个计数器使用一个计数器的凭证,两个计数器共用另一个计数器的凭证。
防回退服务模块还需记录下第一应用与第一计数器的对应关系。因为防回退服务模块可以为多个不同 的应用分配计数器,因此防回退服务模块需记录下每一个应用与每一个计数器的对应关系。
表1
表1示出了防回退服务模块记载的多个不同的应用与各个计数器的赌赢关系。例如第一应用对应的计数器为第一计数器,第二应用对应的计数器为第二计数器和第三计数器,第三应用对应的计数器为第四计数器。
需要说明的是,防回退服务模块还可以记载更多或者更少的应用与计数器的对应关系,本申请实施例对此不做限定。
可选的,在应用超过一定时间(例如一个月内)未使用过该计数器,那么防回退服务模块可以将应用与计数器的绑定关系清除掉,以便该计数器可以被其他应用使用。
可选的,在应用被卸载后,那么防回退服务模块可以将应用与计数器的绑定关系清除掉,以便该计数器可以被其他应用使用。
S1004、防回退服务模块将第一计数器的标识和计数器的凭证发送至安全芯片。
在防回退服务模块为第一应用分派第一计数器之后,将第一计数器的标识和凭证发送至安全芯片。
S1005、安全芯片将第一计数器的初始值置为第一阈值。
计数器的初始值用于在保存不同用户数据时,生成不同用户数据的计数值。
可选的,第一阈值可以是随机生成的,即针对不同的计数器的初始值是不同的。
可选的,第一阈值也可以是预设的,不同的计数器的初始值是一样的。
S1006、安全芯片保存第一计数器的初始值和计数器的凭证,并将计数器的凭证作为第一
计数器的凭证。
安全芯片保存第一计数器的初始值和计数器的凭证,以便后续在保存用户数据时,基于第一计数器的初始值生成用户数据的计数值,并基于计数值生成该用户数据的校验值。计数器的凭证用于安全芯片在使用用户数据前获取到用户数据的校验值之前,验证与接收到的计数器的凭证是否一致,若一致,才允许安全芯片获取到用户数据的校验值,否则,安全芯片无法获取到用户数据的校验值。
表2
表2示出了一种安全芯片内存储的不同应用对应的计数器的初始值和计数器的凭证。例如,第一应用对应有第一计数器,第一计数器的初始值为第一阈值,第一计数器的凭证为第一token。第二应用对应有第二计数器和第三计数器,第二计数器的初始值为第二阈值,第三计数器的初始值为第三阈值,第二计数器的凭证为第二token,第三计数器的凭证为第三token。第三应用对应有第四计数器,第四计数器的初始值为第四阈值,第四计数器的凭证为第四token。
可选的,第一阈值、第二阈值、第三阈值和第四阈值为随机生成的,因此第一阈值、第二阈值、第三阈值和第四阈值可以互不相同,也可以部分相同,也可以全部相同,本申请实施例对此不做限定。
可选的,第二token和第三token可以不同,也可以相同,本申请实施例对此不做限定。
可选的,第一token、二token、第三token和第四token可以互不相同,也可以部分相同,也可以全部相同,本申请实施例对此不做限定。
表3

表3示出了另一种安全芯片内存储的计数器的初始值和计数器的凭证。由于防回退服务模块中存储有不同应用对应的计数器的标识,那么安全芯片内可以不存储不同应用对应的计数器的标识,安全芯片内可以仅存储不同的计数器对应的计数器的初始值和计数器的凭证。例如,第一计数器的初始值为第一阈值,第一计数器的凭证为第一token。第二计数器的初始值为第二阈值,第二计数器的凭证为第二token。第三计数器的初始值为第三阈值,第三计数器的凭证为第三token。第四计数器的初始值为第四阈值,第四计数器的凭证为第四token。
可选的,第一token、二token、第三token和第四token可以互不相同,也可以部分相同,也可以全部相同,本申请实施例对此不做限定。
S1007、安全芯片向防回退服务模块发送计数器已设置完毕的消息。
S1008、防回退服务模块向第一应用发送计数器已设置完毕的消息。
图11示出了另一种生成计数器的凭证的方法流程示意图。
图11实施例为安全芯片生成计数器的凭证的方法流程示意图,图10实施例为第一应用生成计数器的凭证的方法流程示意图。安全芯片的安全系数较高,因此在安全芯片内生成计数器的凭证的安全性更高。
S1101、第一应用向防回退服务模块发送申请计数器的请求。
可选的,可以是第一应用在下载后,在保存用户数据之前,就开始向防回退服务模块发送申请计数器的请求。
S1102、防回退服务模块为第一应用分配第一计数器,并获取到第一计数器的标识。
对于S1102的描述,可以参考图11实施例中针对S1003的描述,本申请实施例在此不再赘述。
S1103、防回退服务模块向安全芯片发送第一计数器的标识。
S1104、安全芯片获取到第一计数器的凭证。
安全芯片可以通过以下任意一种方式获取到第一计数器的凭证。
方式一:安全芯片从服务器中获取到第一计数器的凭证。
方式二:安全芯片从电子设备的本地获取到第一计数器的凭证。
方式三:在安全芯片需获取到第一计数器的凭证之前,电子设备可以提示用户输入凭证,该凭证可以作为第一计数器的凭证。
安全芯片还可以通过其他的方式获取到第一计数器的凭证,本申请实施例对此不做限定。
S1105、安全芯片将第一计数器的初始值置为第一阈值。
计数器的初始值用于在保存不同用户数据时,生成不同用户数据的计数值。
可选的,第一阈值可以是随机生成的,即针对不同的计数器的初始值是不同的。
可选的,第一阈值也可以是预设的,不同的计数器的初始值是一样的。
可选的,S1105也可以在S1104之前执行,S1105和S1104也可以同时执行,本申请实施例对此不做限定。
S1106、安全芯片保存第一计数器的初始值和第一计数器的凭证。
对于S1106的描述,可以参考图11实施例中针对S1006的描述,本申请实施例在此不再赘述。
S1107、安全芯片将第一计数器的凭证发送至防回退服务模块。
S1108、防回退服务模块将第一计数器的凭证发送至第一应用。
表4
表4示出了电子设备的非安全芯片中或者服务器中存储的一个或多个应用对应的一个或多个计数器凭 证。示例性的,第一应用中对应有第一计数器,第一计数器的凭证为第一token。第二应用中对应有第二计数器和第三计数器,第二计数器的凭证为第二token,第三计数器的凭证为第三token。第三应用中对应有第四计数器,第四计数器的凭证为第四token。
可选的,第二token和第三token可以不同,也可以相同,本申请实施例对此不做限定。
可选的,第一token、二token、第三token和第四token可以互不相同,也可以部分相同,也可以全部相同,本申请实施例对此不做限定。
这样,第一应用可以获取到第一计数器的凭证,使得在电子设备使用第一应用中的用户数据之前,可以将第一计数器的凭证发送至安全芯片,在安全芯片中存储的第一计数器的凭证和第一应用发送的第一计数器的凭证相同的情况下,电子设备才可以使用第一应用中的用户数据。
可选的,第一应用可以将第一计数器的凭证保存在非安全芯片中,例如flash芯片中。第一应用也可以将第一计数器的凭证保存在服务器中。本申请实施例对此不做限定。
图12为本申请实施例提供的一种保护用户数据并生成用户数据的校验值的示意图。
在用户数据变化后,电子设备存储变化后的用户数据的时候,SE中计数器的值也会随之更改。那么变化后的用户数据的校验值也会随之变化。
S1201、第一应用获取到第一用户数据。
示例性的,第一用户数据可以是上网流量剩余量,例如上网流量剩余量为30G。
S1202、第一应用将第一用户数据和第一计数器的凭证发送至防回退服务模块。
也就是说,第一应用在保存第一用户数据之前,会从之前申请的计数器中选择一个或多个计数器,开生成第一用户数据的凭证。示例性的,第一应用可以从之前申请的计数器中选择第一计数器。
电子设备的非安全芯片中或者服务器中存储有第一应用之前申请的一个或多个计数器的凭证,第一应用可以从一个或多个计数器的凭证中选择第一计数器的凭证,以便于可以生成第一用户数据的校验值。
在获取到第一计数器的凭证后,第一应用将第一用户数据和第一计数器的凭证发送至防回退服务模块。
S1203、防回退服务模块获取到第一计数器的标识。
防回退服务模块在接收到第一应用发送的第一用户数据和第一计数器的凭证后,获取到第一计数器的标识。
S1204、防回退服务模块将第一计数器的标识、第一用户数据和第一计数器的凭证发送至安全芯片。
S1205、安全芯片基于第一计数器的标识确定出安全芯片内存储的第一计数器的凭证。
由表2和表3可知,安全芯片内存储有多个计数器对应的计数器的凭证。
在安全芯片接收到防回退服务模块发送的第一计数器的标识、第一用户数据和第一计数器的凭证后,安全芯片可以基于第一计数器的标识从安全芯片内获取到第一计数器的凭证。
S1206、在确定出安全芯片确定出防回退服务模块发送的第一计数器的凭证和安全芯片内存储的第一计数器的凭证相同的情况下,安全芯片获取到第一计数器的初始值。
在安全芯片的第一计数器的凭证和防回退服务模块发送的第一计数器的凭证相同的情况下,安全芯片才可以获取到第一计数器的初始值。这样,攻击者在不知道第一计数器的凭证的情况下,也无法获取到第一计数器的初始值。
S1207、在第一计数器的初始值的基础上加上第一预设值,安全芯片得到第一计数器的第一值。
其中,第一预设值可以是固定值,也可以是一个随机数,本申请实施例对此不做限定。
S1208、安全芯片基于第一计数器的第一值和第一用户数据计算得到第一校验值。
在一种可能的实现方式中,安全芯片可以计算第一计数器的第一值和第一用户数据的HMAC值,将该HMAC值作为第一校验值。
可选的,安全芯片还可以基于其他因素、第一计数器的第一值和第一用户数据共同作用计算得到第一校验值。其他因素包括但不仅限于硬件唯一密钥、设备唯一ID中的一种或几种。
这样,第一校验值是基于第一计数器的数值和第一用户数据计算得到的。在电子设备需使用第一用户数据之前,需验证通过第一校验值。若第一计数器的数值和第一用户数据中的任意一个数据发生变化,第一校验值将验证不通过,电子设备也就无法使用第一用户数据。这样,可以避免攻击者篡改第一用户数据的情况发生,提高了电子设备使用第一用户数据的安全性。
可选的,S1207和S1208也可以替换成如下S1207B。
S1207B、安全芯片基于第一计数器的初始值和第一用户数据计算得到第一校验值。
可选的,安全芯片还可以基于其他因素、第一计数器的初始值和第一用户数据共同作用计算得到第一校验值。其他因素包括但不仅限于硬件唯一密钥、设备唯一ID中的一种或几种。
S1209、安全芯片将第一校验值发送至防回退服务模块。
S1210、防回退服务模块将第一校验值发送至第一应用。
可选的,第一应用可以将第一校验值保存在非安全芯片中,例如flash芯片中。第一应用也可以将第一校验值保存在服务器中。本申请实施例对此不做限定。
表5
表5示例性示出了不同用户数据对应的校验值。例如第一应用中有第一用户数据和第三用户数据。其中,第一用户数据的校验值为第一校验值,第三用户数据的校验值为第三校验值。其中,第一用户数据和第三用户数据不同。
可选的,第一校验值、第二校验值和第三校验值可以完全不同,也可以部分相同,也可以全部相同,本申请实施例对此不做限定。
可选的,在一些实施例中,在第一用户数据发生变化后,第一用户数据对应的校验值也会发生变化。
可选的,在电子设备使用第一用户数据之前,需在安全芯片中验证第一用户数据的校验值的正确性。之后在第一用户数据的校验值校验通过之后,电子设备才可以使用第一用户数据。避免攻击者伪造用户数据。
图13示出了在电子设备使用第一用户数据之前在安全芯片中验证第一用户数据的校验值的正确性的方法示意图。
S1301、第一应用将第二用户数据、第一计数器的凭证和第一校验值发送至防回退服务模块。
在第一应用需使用之前保存的第一用户数据之前,需先校验第一用户数据的校验值的正确性。
在一些实施例中,攻击者可能会修改之前保存的第一用户数据。示例性的,第一用户数据可以是上网流量剩余量,例如上网流量剩余量为30G。攻击者为了增加上网流量剩余量,可能会将上网流量剩余量修改为100G,网流量剩余量100G可以被称为第二用户数据。
可选的,第一计数器的凭证和第一校验值可以是第一应用从本地获取到的,也可以是从服务器获取到的,本申请实施例对此不做限定。
S1302、防回退服务模块获取到第一计数器的标识。
防回退服务模块在接收到第一应用发送的第二用户数据、第一计数器的凭证和第一校验值后,获取到第一计数器的标识。
S1303、防回退服务模块将第一计数器的标识、第二用户数据、第一计数器的凭证和第一校验值发送至安全芯片。
S1304、安全芯片基于第一计数器的标识确定出安全芯片内存储的第一计数器的凭证。
由表2和表3可知,安全芯片内存储有多个计数器对应的计数器的凭证。
在安全芯片接收到防回退服务模块发送的第一计数器的标识、第一用户数据和第一计数器的凭证后,安全芯片可以基于第一计数器的标识从安全芯片内获取到第一计数器的凭证。
S1305、在确定出第一计数器的凭证和安全芯片内存储的第一计数器的凭证相同的情况下,安全芯片获取到第一计数器的第一值。
在安全芯片的第一计数器的凭证和防回退服务模块发送的第一计数器的凭证相同的情况下,安全芯片才可以获取到第一计数器的第一值。这样,在攻击者不知道第一计数器的凭证的情况下,攻击者无法获取到第一计数器的第一值,攻击者也无法篡改第一计数器的数值,保证了安全芯片中存储的计数器的数值 的准确性
S1306、安全芯片基于第一计数器的第一值和第二用户数据计算得到第二校验值。
在一种可能的实现方式中,安全芯片可以计算一计数器的第一值和第二用户数据的HMAC值,将该HMAC值作为第一校验值。
可选的,安全芯片还可以基于其他因素、第一计数器的第一值和第二用户数据共同作用计算得到第二校验值。其他因素包括但不仅限于硬件唯一密钥、设备唯一ID中的一种或几种。
需要说明的是,计算第一校验值和第二校验值的算法、参数类型均是相同。
S1307、在第一校验值和第二校验值相同的情况下,安全芯片可以确认出第二用户数据与第一用户数据相同。
在第一校验值和第二校验值相同的情况下,说明第二用户数据与第一用户数据相同,即没有攻击者更改存放在非安全芯片中的第一用户数据。
若攻击者修改了第一用户数据,得到第二用户数据,第一用户数据与第二用户数据不同,那么安全芯片基于第二用户数据和第一计数器的第一值计算得到的第二校验值与安全芯片内之前存储的第一校验值不同。
示例性的,第一校验值可以是基于第一计数器的第一值和第一用户数据得到的第一HMAC值。第二校验值可以是基于第一计数器的第一值和第二用户数据得到的第二HMAC值。在第一HMAC值和第二HMAC值相同的情况下,安全芯片可以确认出第二用户数据与第一用户数据相同。
若攻击者修改了第一用户数据,得到第二用户数据,第一用户数据与第二用户数据不同,那么安全芯片基于第二用户数据和第一计数器的第一值计算得到的HMAC值与安全芯片内之前存储的第一HMAC值不同。
在安全芯片可以确认出第二用户数据与第一用户数据相同的情况下,说明攻击者没有更改存放在非安全芯片中的第一用户数据。那么第一应用使用该第二用户数据。
S1308、安全芯片向防回退服务模块发送校验通过消息。
S1309、防回退服务模块向第一应用发送校验通过消息。
S1310、响应于校验通过消息,第一应用使用第二用户数据。
在确认出第二用户数据与第一用户数据相同的情况下,安全芯片向第一应用发送校验通过消息。响应于校验通过消息,第一应用可以使用第二用户数据。
在确认出第二用户数据与第一用户数据不同的情况下,安全芯片不会向第一应用发送校验通过消息。那么在第一应用没有接收到校验通过消息的情况下,第一应用无法使用第二用户数据。
可选的,在一些实施例中,在电子设备使用了第二用户数据之后,导致第二用户数据发生了变化,电子设备还需将变化后的第二用户数据保存起来。那么在保存变化后的第二用户数据的时候,安全芯片中存储的变化后的第二用户数据对应的计数器值会发生变化。安全芯片会基于变化后的第二用户数据和变化后的第二用户数据对应的计数器值计算得到第三校验值,并将第三校验值保存在安全芯片内,同时还需将第三校验值保存在非安全芯片内或者服务器上。
由图13实施例可知,在第二用户数据与第一用户数据相同的情况下,第一应用才可以使用第二用户数据,那么第二用户数据就是第一用户数据。
示例性的,第一用户数据和第二用户数据可以是上网流量剩余量,例如上网流量剩余量为30G。在用户使用第二用户数据之后,导致第二用户数据发生变化,例如变化后的第二用户数据为10G。电子设备需将变化后的第二用户数据保存起来。
图14为本申请实施例提供的一种保存变化后的第二用户数据的方法示意图。
S1401、获取到变化后的第二用户数据。
在一些实施例中,变化后的第二用户数据也可以被称为第三用户数据。
S1402、第一应用将变化后的第二用户数据和第一计数器的凭证发送至防回退服务模块。
第一应用在保存第一用户数据时,使用的是第一计数器的凭证,那么在保存变化后的第二用户数据时,也可以使用第一计数器的凭证。在其他实施例中,在保存变化后的第二用户数据时,也可以使用其他计数器的凭证,本申请实施例对此不做限定。本申请实施例以保存变化后的第二用户数据时,继续使用第一计数器的凭证为例进行说明。
S1403、防回退服务模块获取到第一计数器的标识。
防回退服务模块在接收到变化后的第二用户数据和第一计数器的凭证后,获取到第一计数器的标识。
S1404、防回退服务模块将第一计数器的标识、变化后的第二用户数据和第一计数器的凭证发送至安全芯片。
S1405、安全芯片基于第一计数器的标识确定出安全芯片内存储的第一计数器的凭证。
由表2和表3可知,安全芯片内存储有多个计数器对应的计数器的凭证。
在安全芯片接收到防回退服务模块发送的第一计数器的标识、变化后的第二用户数据和第一计数器的凭证后,安全芯片可以基于第一计数器的标识从安全芯片内获取到第一计数器的凭证。
S1406、安全芯片确定出第一计数器的凭证和安全芯片内存储的第一计数器的凭证相同,获取到第一计数器的第一值。
在安全芯片的第一计数器的凭证和防回退服务模块发送的第一计数器的凭证相同的情况下,安全芯片才可以获取到第一计数器的第一值。这样,攻击者在不知道第一计数器的凭证的情况下,也无法获取到第一计数器的第一值,攻击者也无法修改第一计数器的数值。保证了安全芯片中存储的计数器的数值的准确性。
S1407、在第一计数器的第一值的基础上加上第二预设值,安全芯片得到第一计数器的第二值。
其中,第二预设值可以是固定值,也可以是一个随机数,本申请实施例对此不做限定。
第二预设值可以与第一预设值相同,第二预设值也可以与第一预设值不同,本申请实施例对此不做限定。
S1408、安全芯片基于第一计数器的第二值和变化后的第二用户数据计算得到第三校验值。
在一种可能的实现方式中,安全芯片可以计算一计数器的第二值和变化后的第二用户数据的HMAC值,将该HMAC值作为第三校验值。
可选的,安全芯片还可以基于其他因素、第一计数器的第二值和变化后的第二用户数据共同作用计算得到第三校验值。其他因素包括但不仅限于硬件唯一密钥、设备唯一ID中的一种或几种。
S1409、安全芯片向防回退服务模块发送第三校验值。
S1410、防回退服务模块向第一应用发送第三校验值。
可选的,第一应用可以将第三校验值保存在非安全芯片中,例如flash芯片中。第一应用也可以将第三校验值保存在服务器中。本申请实施例对此不做限定。
图15为本申请实施例提供的一种数据保护方法的流程示意图。
S1501、电子设备从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值。
其中,第一用户数据为电子设备之前存储的用户数据。第二用户数据为电子设备读取之前存储的第一用户数据。第一用户数据的存储位置为第一存储位置。那么第二用户数据可以从第一存储位置中读取到的用户数据。
在第一校验值和第二校验值不同的情况下,说明攻击者可能修改了第一用户数据,例如将第一用户数据修改为第二用户数据,此时第一用户数据与第二用户数据不同。第一用户数据和第二用户的存储位置可以是一样的。
在第一校验值和第二校验值相同的情况下,说明第二用户数据与第一用户数据相同,电子设备使用第二用户数据,即电子设备使用第一用户数据。
S1502、电子设备从安全芯片内获取到第一计数器的凭证。
在一种可能的实现方式中,电子设备将第一计数器的凭证存储在安全芯片内,具体包括:电子设备通过安全芯片生成第一计数器的凭证;电子设备将第一计数器的凭证存储在安全芯片内。此时,安全芯片需将第一计数器的凭证保存在非安全芯片内或者服务器上,以使得在电子设备使用该用户数据时,可以基于非安全芯片内或者服务器上存储的第一计数器的凭证进行鉴权。
或者,
电子设备在安全芯片外获取到第一计数器的凭证;电子设备将第一计数器的凭证存储在安全芯片内。
S1503、在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,电子设备通过安全芯片获取到第一计数器的第一值。
非安全芯片可以是flash芯片、也可以是服务器、也可以是硬盘等存储设备,本申请实施例对此不做 限定。
在一种可能的实现方式中,方法还包括:在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证不同的情况下,电子设备无法从安全芯片内获取到第一计数器的第一值。这样,在攻击者不知道第一计数器的凭证的情况下,第一计数器的凭证无法鉴权通过,攻击者无法获取到第一计数器的第一值,保证了安全芯片中存储的第一计数器的第一值的安全性。
结合第一方面,在一种可能的实现方式中,还包括:在第一校验值和第二校验值不同的情况下,电子设备无法使用第二用户数据。
可选的,安全芯片还可以基于其他的因素计算得到用户数据的校验值,其他的因素包括但不仅限于硬件唯一密钥、设备唯一ID中的一种或几种。其他的因素还可以是其他的数值,本申请实施例对此不做限定。
这样,即使攻击者伪造了用户数据,例如将第一用户数据修改为第二用户数据,安全芯片基于第二用户数据和第一计数器的第一值计算得到的第二校验值与第一校验值也不同,即用户数据的校验值校验不通过,此时电子设备也无法使用伪造的第二用户数据。
在一种可能的实现方式中,第一计数器的第一值是基于第一计数器的初始值和第一预设值得到的,其中,计数器的初始值是随机生成的。这样,第一计数器的初始值是随机生成的,可以避免攻击者通过暴力枚举的方式获取到第一计数器的第一值,导致安全芯片中存储的第一计数器的第一值泄露的情况发生,提高了安全芯片内存储的第一计数器的第一值的安全性。
在一种可能的实现方式中,在电子设备将第一计数器的第一值存储在安全芯片内之前,方法还包括:电子设备通过安全芯片生成第一计数器的初始值。这样,第一计数器的初始值在安全芯片内生成,提高了安全芯片内存储的计数器的数值的安全性。
S1504、电子设备通过安全芯片基于第二用户数据和第一计数器的第一值得到第二用户数据的第二校验值;在第一校验值和第二校验值相同的情况下,电子设备使用第二用户数据。
安全芯片和非安全芯片可以通过I2C或者SPI总线通信实现数据交互。
这样,在安全芯片内实现多级鉴权机制。只有在鉴权通过的情况下,电子设备才可以使用第二用户数据,保证了电子设备上存储用户数据的安全,避免攻击者伪造用户数据。
在一种可能的实现方式中,在电子设备从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值之前,方法还包括:电子设备将第一用户数据、第一用户数据的第一校验值和第一计数器的凭证存储在非安全芯片内。电子设备将第一计数器的第一值和第一计数器的凭证存储在安全芯片内。
这样,电子设备将第一计数器的第一值存储在安全芯片内,保证了第一计数器的第一值的安全性,避免第一计数器的第一值被攻击者获取到。
电子设备将第一计数器的凭证存储在安全芯片内,以便在电子设备使用存储的用户数据时,基于第一计数器的凭证进行鉴权,只有在鉴权通过,电子设备才可以使用存储的用户数据,保证了电子设备上存储用户数据的安全。
在一种可能的实现方式中,在电子设备从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值之前,方法还包括:电子设备从非安全芯片内获取到第一用户数据、第一计数器的标识和非安全芯片内存储的第一计数器的凭证;电子设备通过安全芯片基于第一计数器的标识确定出安全芯片内存储的第一计数器的凭证;在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,电子设备获取到第一计数器的第一值;电子设备通过安全芯片基于第一计数器的第一值和第一用户数据得到第一用户数据的第一校验值;电子设备将第一用户数据的第一校验值存储在非安全芯片内。这样,在电子设备存储第一用户数据时,会在安全芯片内基于第一用户数据和第一计数器的第一值生成第一校验值。在生成第一校验值之后,电子设备在将第一校验值存储在非安全芯片内,例如flash芯片内或者服务器上。这样,即使攻击者将伪造用户数据,例如利用第二用户数据替代第一用户数据,在鉴权时,在安全芯片内基于得到第二用户数据和第一计数器的第一值生成第二校验值也与第一校验值不同,导致校验不通过,避免攻击者伪造用户数据的情况发生。
在一种可能的实现方式中,在电子设备使用第二用户数据之后,方法还包括:电子设备获取到第三用户数据,第三用户数据为变化后的第二用户数据;电子设备将第三用户数据、非安全芯片内第一计数器的凭证和第一计数器的标识发送至安全芯片;电子设备通过安全芯片基于第一计数器的标识获取到第一计数器的凭证;在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,电子设备通过安全芯片获取到第一计数器的第一值,并基于第一计数器的第一值和第二预设值得到第一计数器的第二值;电子设备通过安全芯片基于第三用户数据和第一计数器的第二值得到第三用户数据的第三校验值;电子设备将第三用户数据的第三校验值保存在非安全芯片内。
也就是说,在第二用户数据鉴权通过之后,电子设备使用了第二用户数据,导致第二用户数据发生改变,得到第三用户数据,电子设备需要存储第三用户数据。在存储第三用户数据的时候,电子设备需在安全芯片内生成第三用户数据的校验值,即第三校验值。以便后续电子设备在使用第三用户数据时,可以基于校验值校验第三用户数据是否为伪造的数据。
本申请还提供了一种电子设备,电子设备包括:一个或多个处理器、一个或多个存储器、显示屏;一个或多个存储器、显示屏与一个或多个处理器耦合,一个或多个存储器用于存储计算机程序代码,计算机程序代码包括计算机指令,一个或多个处理器调用计算机指令以使得电子设备执行:从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值;其中,非安全芯片内第一计数器的凭证用于获取到第一计数器的第一值,第一校验值和第一计数器的第一值用于校验第二用户数据是否和第一用户数据相同;从安全芯片内获取到第一计数器的凭证;在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,通过安全芯片获取到第一计数器的第一值;通过安全芯片基于第二用户数据和第一计数器的第一值得到第二用户数据的第二校验值;在第一校验值和第二校验值相同的情况下,使用第二用户数据。
非安全芯片可以是flash芯片、也可以是服务器、也可以是硬盘等存储设备,本申请实施例对此不做限定。
其中,第一用户数据为电子设备之前存储的用户数据。第二用户数据为电子设备读取之前存储的第一用户数据。第一用户数据的存储位置为第一存储位置。那么第二用户数据可以从第一存储位置中读取到的用户数据。
在第一校验值和第二校验值不同的情况下,说明攻击者可能修改了第一用户数据,例如将第一用户数据修改为第二用户数据,此时第一用户数据与第二用户数据不同。第一用户数据和第二用户的存储位置可以是一样的。
在第一校验值和第二校验值相同的情况下,说明第二用户数据与第一用户数据相同,电子设备使用第二用户数据,即电子设备使用第一用户数据。
这样,在安全芯片内实现多级鉴权机制。只有在鉴权通过的情况下,电子设备才可以使用第二用户数据,保证了电子设备上存储用户数据的安全,避免攻击者伪造用户数据。
在一种可能的实现方式中,一个或多个处理器调用计算机指令以使得电子设备执行:在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证不同的情况下,无法从安全芯片内获取到第一计数器的第一值。这样,在攻击者不知道第一计数器的凭证的情况下,第一计数器的凭证无法鉴权通过,攻击者无法获取到第一计数器的第一值,保证了安全芯片中存储的第一计数器的第一值的安全性。
在一种可能的实现方式中,一个或多个处理器调用计算机指令以使得电子设备执行:在第一校验值和第二校验值不同的情况下,无法使用第二用户数据。
可选的,安全芯片还可以基于其他的因素计算得到用户数据的校验值,其他的因素包括但不仅限于硬件唯一密钥、设备唯一ID中的一种或几种。其他的因素还可以是其他的数值,本申请实施例对此不做限定。
这样,即使攻击者伪造了用户数据,例如将第一用户数据修改为第二用户数据,安全芯片基于第二用户数据和第一计数器的第一值计算得到的第二校验值与第一校验值也不同,即用户数据的校验值校验不通过,此时电子设备也无法使用伪造的第二用户数据。
在一种可能的实现方式中,一个或多个处理器调用计算机指令以使得电子设备执行:将第一用户数据、第一用户数据的第一校验值和第一计数器的凭证存储在非安全芯片内。将第一计数器的第一值和第一计数器的凭证存储在安全芯片内。
这样,电子设备将第一计数器的第一值存储在安全芯片内,保证了第一计数器的第一值的安全性,避免第一计数器的第一值被攻击者获取到。
电子设备将第一计数器的凭证存储在安全芯片内,以便在电子设备使用存储的用户数据时,基于第一计数器的凭证进行鉴权,只有在鉴权通过,电子设备才可以使用存储的用户数据,保证了电子设备上存储用户数据的安全。
在一种可能的实现方式中,一个或多个处理器调用计算机指令以使得电子设备执行:通过安全芯片生成第一计数器的凭证;将第一计数器的凭证存储在安全芯片内。此时,安全芯片需将第一计数器的凭证保存在非安全芯片内或者服务器上,以使得在电子设备使用该用户数据时,可以基于非安全芯片内或者服务器上存储的第一计数器的凭证进行鉴权。
或者,
在安全芯片外获取到第一计数器的凭证;将第一计数器的凭证存储在安全芯片内。
在一种可能的实现方式中,第一计数器的第一值是基于第一计数器的初始值和第一预设值得到的,其中,计数器的初始值是随机生成的。这样,第一计数器的初始值是随机生成的,可以避免攻击者通过暴力枚举的方式获取到第一计数器的第一值,导致安全芯片中存储的第一计数器的第一值泄露的情况发生,提高了安全芯片内存储的第一计数器的第一值的安全性。
一种可能的实现方式中,一个或多个处理器调用计算机指令以使得电子设备执行:通过安全芯片生成第一计数器的初始值。这样,第一计数器的初始值在安全芯片内生成,提高了安全芯片内存储的计数器的数值的安全性。
在一种可能的实现方式中,一个或多个处理器调用计算机指令以使得电子设备执行:从非安全芯片内获取到第一用户数据、第一计数器的标识和非安全芯片内存储的第一计数器的凭证;通过安全芯片基于第一计数器的标识确定出安全芯片内存储的第一计数器的凭证;在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,获取到第一计数器的第一值;通过安全芯片基于第一计数器的第一值和第一用户数据得到第一用户数据的第一校验值;将第一用户数据的第一校验值存储在非安全芯片内。这样,在电子设备存储第一用户数据时,会在安全芯片内基于第一用户数据和第一计数器的第一值生成第一校验值。在生成第一校验值之后,电子设备在将第一校验值存储在非安全芯片内,例如flash芯片内或者服务器上。这样,即使攻击者将伪造用户数据,例如利用第二用户数据替代第一用户数据,在鉴权时,在安全芯片内基于得到第二用户数据和第一计数器的第一值生成第二校验值也与第一校验值不同,导致校验不通过,避免攻击者伪造用户数据的情况发生。
图16为本申请实施例提供的一种数据保护装置的流程示意图。
一种可能的实施方式中,装置1600可以包括获取单元1601、处理单元1602和存储单元1603。该装置1600可用于执行图15实施例所示的一种数据保护方法。
其中,获取单元1601,用于从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值;其中,非安全芯片内第一计数器的凭证用于获取到第一计数器的第一值,第一校验值和第一计数器的第一值用于校验第二用户数据是否和第一用户数据相同。
获取单元1601,还用于从安全芯片内获取到第一计数器的凭证。
获取单元1601,还用于在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,通过安全芯片获取到第一计数器的第一值;
处理单元1602,用于通过安全芯片基于第二用户数据和第一计数器的第一值得到第二用户数据的第二校验值。
处理单元1602,还用于在第一校验值和第二校验值相同的情况下,使用第二用户数据。
非安全芯片可以是flash芯片、也可以是服务器、也可以是硬盘等存储设备,本申请实施例对此不做限定。
其中,第一用户数据为电子设备之前存储的用户数据。第二用户数据为电子设备读取之前存储的第一用户数据。第一用户数据的存储位置为第一存储位置。那么第二用户数据可以从第一存储位置中读取到的用户数据。
在第一校验值和第二校验值不同的情况下,说明攻击者可能修改了第一用户数据,例如将第一用户数据修改为第二用户数据,此时第一用户数据与第二用户数据不同。第一用户数据和第二用户的存储位置可以是一样的。
在第一校验值和第二校验值相同的情况下,说明第二用户数据与第一用户数据相同,电子设备使用第二用户数据,即电子设备使用第一用户数据。
这样,在安全芯片内实现多级鉴权机制。只有在鉴权通过的情况下,电子设备才可以使用第二用户数据,保证了电子设备上存储用户数据的安全,避免攻击者伪造用户数据。
在一种可能的实现方式中,获取单元1601,还用于在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证不同的情况下,无法从安全芯片内获取到第一计数器的第一值。这样,在攻击者不知道第一计数器的凭证的情况下,第一计数器的凭证无法鉴权通过,攻击者无法获取到第一计数器的第一值,保证了安全芯片中存储的第一计数器的第一值的安全性。
在一种可能的实现方式中,获取单元1601,还用于在第一校验值和第二校验值不同的情况下,无法使用第二用户数据。
可选的,安全芯片还可以基于其他的因素计算得到用户数据的校验值,其他的因素包括但不仅限于硬件唯一密钥、设备唯一ID中的一种或几种。其他的因素还可以是其他的数值,本申请实施例对此不做限定。
这样,即使攻击者伪造了用户数据,例如将第一用户数据修改为第二用户数据,安全芯片基于第二用户数据和第一计数器的第一值计算得到的第二校验值与第一校验值也不同,即用户数据的校验值校验不通过,此时电子设备也无法使用伪造的第二用户数据。
在一种可能的实现方式中,在获取单元1601从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值之前,存储单元1603,用于将第一用户数据、第一用户数据的第一校验值和第一计数器的凭证存储在非安全芯片内,将第一计数器的第一值和第一计数器的凭证存储在安全芯片内。
这样,电子设备将第一计数器的第一值存储在安全芯片内,保证了第一计数器的第一值的安全性,避免第一计数器的第一值被攻击者获取到。
电子设备将第一计数器的凭证存储在安全芯片内,以便在电子设备使用存储的用户数据时,基于第一计数器的凭证进行鉴权,只有在鉴权通过,电子设备才可以使用存储的用户数据,保证了电子设备上存储用户数据的安全。
在一种可能的实现方式中,存储单元1603,具体用于通过安全芯片生成第一计数器的凭证;将第一计数器的凭证存储在安全芯片内。此时,安全芯片需将第一计数器的凭证保存在非安全芯片内或者服务器上,以使得在电子设备使用该用户数据时,可以基于非安全芯片内或者服务器上存储的第一计数器的凭证进行鉴权。
或者,存储单元1603,具体用于在安全芯片外获取到第一计数器的凭证;将第一计数器的凭证存储在安全芯片内。
在一种可能的实现方式中,第一计数器的第一值是基于第一计数器的初始值和第一预设值得到的,其中,计数器的初始值是随机生成的。这样,第一计数器的初始值是随机生成的,可以避免攻击者通过暴力枚举的方式获取到第一计数器的第一值,导致安全芯片中存储的第一计数器的第一值泄露的情况发生,提高了安全芯片内存储的第一计数器的第一值的安全性。
在一种可能的实现方式中,在存储单元1603将第一计数器的第一值存储在安全芯片内之前,处理单元1602,还用于通过安全芯片生成第一计数器的初始值。这样,第一计数器的初始值在安全芯片内生成,提高了安全芯片内存储的计数器的数值的安全性。
在一种可能的实现方式中,在获取单元1601从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值之前,获取单元1601,还用于从非安全芯片内获取到第一用户数据、第一计数器的标识和非安全芯片内存储的第一计数器的凭证;处理单元1602,还用于通过安全芯片基于第一计数器的标识确定出安全芯片内存储的第一计数器的凭证;获取单元1601,还用于在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,获取到第一计数器的第一值;处理单元1602,还用于通过安全芯片基于第一计数器的第一值和第一用户数据得到第一用户数据的第一校验值;存储单元1603,还用于将第一用户数据的第一校验值存储在非安全芯片内。这样,在电子设备存储第一用户数据时,会在安全芯片内基于第一用户数据和第一计数器的第一值生成第一校验值。在生成第一校验值之后,电子 设备在将第一校验值存储在非安全芯片内,例如flash芯片内或者服务器上。这样,即使攻击者将伪造用户数据,例如利用第二用户数据替代第一用户数据,在鉴权时,在安全芯片内基于得到第二用户数据和第一计数器的第一值生成第二校验值也与第一校验值不同,导致校验不通过,避免攻击者伪造用户数据的情况发生。
在一种可能的实现方式中,在处理单元1602使用第二用户数据之后,获取单元1601,还用于获取到第三用户数据,第三用户数据为变化后的第二用户数据;处理单元1602,还用于将第三用户数据、非安全芯片内第一计数器的凭证和第一计数器的标识发送至安全芯片;处理单元1602,还用于通过安全芯片基于第一计数器的标识获取到第一计数器的凭证;获取单元1601,还用于在非安全芯片内第一计数器的凭证和安全芯片内第一计数器的凭证相同的情况下,通过安全芯片获取到第一计数器的第一值;处理单元1602,还用于基于第一计数器的第一值和第二预设值得到第一计数器的第二值;处理单元1602,还用于通过安全芯片基于第三用户数据和第一计数器的第二值得到第三用户数据的第三校验值;存储单元1603,还用于将第三用户数据的第三校验值保存在非安全芯片内。
也就是说,在第二用户数据鉴权通过之后,电子设备使用了第二用户数据,导致第二用户数据发生改变,得到第三用户数据,电子设备需要存储第三用户数据。在存储第三用户数据的时候,电子设备需在安全芯片内生成第三用户数据的校验值,即第三校验值。以便后续电子设备在使用第三用户数据时,可以基于校验值校验第三用户数据是否为伪造的数据。
本申请提供了一种计算机可读存储介质,用于存储计算机指令,当计算机指令在电子设上运行时,使得电子设备执行图15所示的一种数据保护方法。
本申请提供了一种计算机程序产品,当计算机程序产品在电子设上运行时,使得电子设备执行图15所示的一种数据保护方法。
本申请的各实施方式可以任意进行组合,以实现不同的技术效果。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(solid state disk,SSD))等。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,该流程可以由计算机程序来指令相关的硬件完成,该程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述各方法实施例的流程。而前述的存储介质包括:ROM或随机存储记忆体RAM、磁碟或者光盘等各种可存储程序代码的介质。
总之,以上所述仅为本发明技术方案的实施例而已,并非用于限定本发明的保护范围。凡根据本发明的揭露,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (12)

  1. 一种数据保护方法,其特征在于,所述方法包括:
    电子设备从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值;其中,所述非安全芯片内第一计数器的凭证用于获取到所述第一计数器的第一值,所述第一校验值和所述第一计数器的第一值用于校验所述第二用户数据是否和所述第一用户数据相同;
    所述电子设备从安全芯片内获取到第一计数器的凭证;
    在所述非安全芯片内第一计数器的凭证和所述安全芯片内第一计数器的凭证相同的情况下,所述电子设备通过所述安全芯片获取到所述第一计数器的第一值;
    所述电子设备通过所述安全芯片基于所述第二用户数据和所述第一计数器的第一值得到所述第二用户数据的第二校验值;
    在所述第一校验值和所述第二校验值相同的情况下,所述电子设备使用所述第二用户数据。
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    在所述非安全芯片内第一计数器的凭证和所述安全芯片内第一计数器的凭证不同的情况下,所述电子设备无法从所述安全芯片内获取到所述第一计数器的第一值。
  3. 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:
    在所述第一校验值和所述第二校验值不同的情况下,所述电子设备无法使用所述第二用户数据。
  4. 根据权利要求1-3任一项所述的方法,其特征在于,在所述电子设备从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值之前,所述方法还包括:
    所述电子设备将所述第一用户数据、所述第一用户数据的所述第一校验值和所述第一计数器的凭证存储在所述非安全芯片内;
    所述电子设备将所述第一计数器的第一值和所述第一计数器的凭证存储在所述安全芯片内。
  5. 根据权利要求4所述的方法,其特征在于,所述电子设备将所述第一计数器的凭证存储在所述安全芯片内,具体包括:
    所述电子设备通过所述安全芯片生成所述第一计数器的凭证;
    所述电子设备将所述第一计数器的凭证存储在所述安全芯片内;
    或者,
    所述电子设备在所述安全芯片外获取到所述第一计数器的凭证;
    所述电子设备将所述第一计数器的凭证存储在所述安全芯片内。
  6. 根据权利要求1-5任一项所述的方法,其特征在于,所述第一计数器的第一值是基于所述第一计数器的初始值和第一预设值得到的,其中,所述计数器的初始值是随机生成的。
  7. 根据权利要求6所述的方法,其特征在于,在所述电子设备将所述第一计数器的第一值存储在所述安全芯片内之前,所述方法还包括:
    所述电子设备通过所述安全芯片生成所述第一计数器的初始值。
  8. 根据权利要求4-6任一项所述的方法,其特征在于,在所述电子设备从非安全芯片内获取到第二用户数据、第一计数器的凭证和第一用户数据的第一校验值之前,所述方法还包括:
    所述电子设备从所述非安全芯片内获取到所述第一用户数据、所述第一计数器的标识和所述非安全芯片内存储的第一计数器的凭证;
    所述电子设备通过所述安全芯片基于所述第一计数器的标识确定出所述安全芯片内存储的第一计数器的凭证;
    在所述非安全芯片内第一计数器的凭证和所述安全芯片内第一计数器的凭证相同的情况下,所述电子设备获取到所述第一计数器的第一值;
    所述电子设备通过所述安全芯片基于所述第一计数器的第一值和所述第一用户数据得到所述第一用 户数据的所述第一校验值;
    所述电子设备将所述第一用户数据的所述第一校验值存储在所述非安全芯片内。
  9. 根据权利要求1-8任一项所述的方法,其特征在于,在所述电子设备使用所述第二用户数据之后,所述方法还包括:
    所述电子设备获取到第三用户数据,所述第三用户数据为变化后的所述第二用户数据;
    所述电子设备将所述第三用户数据、所述非安全芯片内第一计数器的凭证和所述第一计数器的标识发送至所述安全芯片;
    所述电子设备通过所述安全芯片基于所述第一计数器的标识获取到第一计数器的凭证;
    在所述非安全芯片内第一计数器的凭证和所述安全芯片内第一计数器的凭证相同的情况下,所述电子设备通过所述安全芯片获取到所述第一计数器的第一值,并基于所述第一计数器的第一值和第二预设值得到所述第一计数器的第二值;
    所述电子设备通过所述安全芯片基于所述第三用户数据和所述第一计数器的第二值得到所述第三用户数据的第三校验值;
    所述电子设备将所述第三用户数据的第三校验值保存在所述非安全芯片内。
  10. 一种电子设备,其特征在于,所述电子设备包括:一个或多个处理器、一个或多个存储器、显示屏;所述一个或多个存储器、所述显示屏与所述一个或多个处理器耦合,所述一个或多个存储器用于存储计算机程序代码,所述计算机程序代码包括计算机指令,所述一个或多个处理器调用所述计算机指令以使得所述电子设备执行上述权利要求1-9任一项所述的方法。
  11. 一种计算机可读存储介质,其特征在于,用于存储计算机指令,当所述计算机指令在电子设上运行时,使得所述电子设执行上述权利要求1-9任一项所述的方法。
  12. 一种计算机程序产品,其特征在于,当所述计算机程序产品在电子设上运行时,使得所述电子设执行上述权利要求1-9任一项所述的方法。
PCT/CN2023/120459 2022-09-23 2023-09-21 一种数据保护方法及电子设备 WO2024061326A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211165829.8A CN117807605A (zh) 2022-09-23 2022-09-23 一种数据保护方法及电子设备
CN202211165829.8 2022-09-23

Publications (1)

Publication Number Publication Date
WO2024061326A1 true WO2024061326A1 (zh) 2024-03-28

Family

ID=90427254

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/120459 WO2024061326A1 (zh) 2022-09-23 2023-09-21 一种数据保护方法及电子设备

Country Status (2)

Country Link
CN (1) CN117807605A (zh)
WO (1) WO2024061326A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103093150A (zh) * 2013-02-18 2013-05-08 中国科学院软件研究所 一种基于可信芯片的动态完整性保护方法
CN108377190A (zh) * 2018-02-14 2018-08-07 飞天诚信科技股份有限公司 一种认证设备及其工作方法
CN111353148A (zh) * 2020-02-07 2020-06-30 贝壳技术有限公司 一种确定应用程序是否被重打包的方法及设备
US20200296135A1 (en) * 2019-03-12 2020-09-17 Nxp B.V. Certificate provisioning and customer binding mechanisms using device group identification token
CN114817931A (zh) * 2022-04-22 2022-07-29 中国电力科学研究院有限公司 基于星型信任链的终端安全防护方法、装置、设备及介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103093150A (zh) * 2013-02-18 2013-05-08 中国科学院软件研究所 一种基于可信芯片的动态完整性保护方法
CN108377190A (zh) * 2018-02-14 2018-08-07 飞天诚信科技股份有限公司 一种认证设备及其工作方法
US20200296135A1 (en) * 2019-03-12 2020-09-17 Nxp B.V. Certificate provisioning and customer binding mechanisms using device group identification token
CN111353148A (zh) * 2020-02-07 2020-06-30 贝壳技术有限公司 一种确定应用程序是否被重打包的方法及设备
CN114817931A (zh) * 2022-04-22 2022-07-29 中国电力科学研究院有限公司 基于星型信任链的终端安全防护方法、装置、设备及介质

Also Published As

Publication number Publication date
CN117807605A (zh) 2024-04-02

Similar Documents

Publication Publication Date Title
WO2020238728A1 (zh) 智能终端的登录方法及电子设备
WO2021253975A1 (zh) 应用程序的权限管理方法、装置和电子设备
EP4270230A1 (en) Access control method, electronic device and system
WO2020107463A1 (zh) 一种电子设备的控制方法及电子设备
WO2022160991A1 (zh) 权限控制方法和电子设备
EP4152198A1 (en) Method and apparatus for storing ciphertext
WO2021057982A1 (zh) 应用程序的处理方法及相关产品
WO2022022422A1 (zh) 一种权限管理方法及终端设备
WO2022111469A1 (zh) 一种文件共享方法、装置及电子设备
WO2023284555A1 (zh) 安全调用服务的方法、安全注册服务的方法及装置
CN115017498B (zh) 小应用程序的操作方法和电子设备
EP4280090A1 (en) Access control method, electronic device, and system
CN113590346B (zh) 处理业务请求的方法和电子设备
CN114006698B (zh) token刷新方法、装置、电子设备及可读存储介质
EP4134903A1 (en) Image data calling method and system for application, and electronic device and storage medium
WO2024061326A1 (zh) 一种数据保护方法及电子设备
CN114692119A (zh) 校验应用的方法和电子设备
WO2024046418A1 (zh) 一种数据保护方法及电子设备
WO2023221917A1 (zh) 账户屏蔽方法、通信系统及电子设备
WO2024002137A1 (zh) 通信方法、通信系统及电子设备
US20240232428A9 (en) Access control method, electronic device, and system
RU2809740C2 (ru) Способ обработки файла, хранящегося во внешней памяти
WO2024022310A1 (zh) 一种设备安全处理方法及电子设备
WO2022042273A1 (zh) 密钥使用方法及相关产品
CN117668863A (zh) 一种数据保护方法及电子设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23867611

Country of ref document: EP

Kind code of ref document: A1