WO2018233583A1 - Terminal device and data processing method - Google Patents

Terminal device and data processing method Download PDF

Info

Publication number
WO2018233583A1
WO2018233583A1 PCT/CN2018/091749 CN2018091749W WO2018233583A1 WO 2018233583 A1 WO2018233583 A1 WO 2018233583A1 CN 2018091749 W CN2018091749 W CN 2018091749W WO 2018233583 A1 WO2018233583 A1 WO 2018233583A1
Authority
WO
WIPO (PCT)
Prior art keywords
data block
count value
value
processor
mac
Prior art date
Application number
PCT/CN2018/091749
Other languages
French (fr)
Chinese (zh)
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 WO2018233583A1 publication Critical patent/WO2018233583A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • H04L9/3242Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions involving keyed hash functions, e.g. message authentication codes [MACs], CBC-MAC or HMAC
    • 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/77Protecting 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 smart cards
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M1/00Substation equipment, e.g. for use by subscribers
    • H04M1/72Mobile telephones; Cordless telephones, i.e. devices for establishing wireless links to base stations without route selection
    • H04M1/724User interfaces specially adapted for cordless or mobile telephones
    • H04M1/72403User interfaces specially adapted for cordless or mobile telephones with means for local support of applications that increase the functionality
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M1/00Substation equipment, e.g. for use by subscribers
    • H04M1/72Mobile telephones; Cordless telephones, i.e. devices for establishing wireless links to base stations without route selection
    • H04M1/725Cordless telephones

Definitions

  • the present application relates to the field of computer technologies, and in particular, to a terminal device and a data processing method.
  • the SE chip is connected to a dedicated Secure Flash via a custom interface.
  • the dedicated Secure Flash is added to the terminal device, the cost of the terminal device is inevitably increased, and the layout complexity of the terminal device is high.
  • the application when the counter is an OTP, the application has data anti-return capability while maintaining the existing chip architecture. Add dedicated Secure Flash to the prior art.
  • the terminal device provided by the present application can reduce cost and layout complexity.
  • the counter is an NVM or other counter in the SE chip, it is equivalent to adding a small-capacity (for counting only) counter to the existing SE chip, and therefore, dedicated Secure Flash is added with respect to the prior art.
  • the terminal device provided by the present application can reduce cost and layout complexity.
  • the terminal device further includes: a transmitter, where the processor is configured to: when the first value of the target data block and the second value of the target data block are the same, determine that the target data block does not fall back; when the target data When the first value of the block is different from the second value of the target data block, the second count value is updated to obtain a third count value, and the third count value and the first MAC corresponding to the target data block are used to calculate the target data block.
  • the processor is configured to: when the first value of the target data block and the second value of the target data block are the same, determine that the target data block does not fall back; when the target data When the first value of the block is different from the second value of the target data block, the second count value is updated to obtain a third count value, and the third count value and the first MAC corresponding to the target data block are used to calculate the target data block.
  • the first algorithm having the same first value calculates the third value of the target data block; when the first value of the target data block is different from the third value of the target data block, determining that the target data block is rolled back, and triggering the transmitter to send the prompt Message, the prompt message is used to prompt the target data block to roll back.
  • the processor is further configured to: when the first value of the target data block and the third value of the target data block are the same, determine that the security chip is powered down.
  • the processor is specifically configured to: obtain a first count value according to the first value of the target data block and the first MAC corresponding to the target data block; determine whether the target data block occurs according to the first count value and the second count value. go back.
  • the terminal device further includes: a transmitter, where the processor is configured to: when the first count value and the second count value are the same, determine that the target data block does not roll back; when the first count value and the second count value When the difference is different, the second count value is updated to obtain a third count value; when the first count value and the third count value are not the same, it is determined that the target data block is rolled back, and the transmitter is triggered to send a prompt message, and the prompt message is used for Prompt that the target data block has rolled back.
  • a transmitter where the processor is configured to: when the first count value and the second count value are the same, determine that the target data block does not roll back; when the first count value and the second count value When the difference is different, the second count value is updated to obtain a third count value; when the first count value and the third count value are not the same, it is determined that the target data block is rolled back, and the transmitter is triggered to send a prompt message, and the prompt message is used for Prompt that the target
  • the processor is further configured to: when the first count value and the third count value are the same, determine that the security chip is powered off.
  • the terminal device can determine whether the security chip is powered off according to the first count value and the third count value, thereby improving the reliability of the terminal device.
  • the first memory adopts the secondary storage mode
  • the terminal device updates the third data block
  • the first value of each first data block corresponding to the second data block needs to be updated to a new one. a value and updating the second data block based on the new first value. Thereby improving the accuracy of the data in the terminal device.
  • the processor is further configured to: read the first value of the fourth data block to the second memory, where the fourth data block is any first data of the new first data block corresponding to the second data block And determining, according to the first value of the fourth data block and the first count value, a first MAC corresponding to the fourth data block, and storing the first MAC corresponding to the fourth data block to the second memory.
  • the first MAC of the fourth data block can be effectively obtained by this method.
  • the processor is further configured to: when the security chip is powered off, read the fifth value of each first data block corresponding to the fifth data block after the security chip is powered on, where the fifth data block For the actual data block corresponding to the new second data block, the fifth value is the actual value corresponding to the new first value; the fifth value corresponding to the first data block corresponding to the fifth data block corresponds to the fifth data block.
  • the fourth count value of each first data block starting from the sixth data block is updated once to obtain a new first count value, wherein
  • the sixth data block is a first data block corresponding to the fifth data block, and satisfies a condition: a fourth count value of each first data block starting from the sixth data block and each first before the sixth data block
  • the fourth count value of the data block is different; a first count value and a first MAC corresponding to each first data block starting from the sixth data block, and calculating a new one of each first data block starting from the sixth data block by using the same algorithm as calculating the first value a first value, and updating a fourth value of each first data block starting from the sixth data block to a new first value; updating
  • the security chip When the security chip is powered off, after the security chip is powered on, the accuracy of the data can be ensured by the method, thereby improving the reliability of the terminal device.
  • the present application provides a processor that is the processor of the first aspect or the alternative of the first aspect.
  • the corresponding content and effects will not be described here.
  • the present application provides a chip comprising the counter of the first aspect or the alternative of the first aspect and the processor of the first aspect or the alternative of the first aspect.
  • a chip comprising the counter of the first aspect or the alternative of the first aspect and the processor of the first aspect or the alternative of the first aspect.
  • the present application provides a data processing method, where the method is applied to a processor, the processor is included in a security chip, the security chip further includes: a second memory and a counter; the security chip is coupled to the first memory; the first memory For storing the M first data blocks, where each first data block is obtained by encrypting a plaintext data block and a first message authentication code MAC corresponding to the plaintext data block, where M is greater than or equal to 1.
  • the integer is used to count the number of updates of the M first data blocks to obtain a count value, and the counter value cannot be rolled back; the method includes:
  • the block is stored in the first memory; determining, according to the second data block and the second count value of the counter, whether the target data block is backed off; wherein the target data block is any one of the M first data blocks; the second count value is The processor determines whether the target data block is backed up, and the count value corresponding to the M first data blocks.
  • the application provides a terminal device, including: a security chip and a first memory coupled to the security chip, wherein the security chip includes: a processor, a second memory, and a non-volatile memory NVM; Counting the number of times of updating the encrypted data block to obtain a count value, and the count value of the NVM is not retractable; the processor is configured to: obtain the first corresponding to the plaintext data block by using the message authentication code MAC of the plaintext data block and the first count value of the NVM a value; the first count value is a count value corresponding to the plaintext data block when the processor calculates the first value; encrypting the first value and the plaintext data block to obtain an encrypted data block, and storing the encrypted data block in the first memory; The processor is further configured to determine, according to the encrypted data block and the second count value of the NVM, whether the encrypted data block is rolled back; wherein the second count value corresponds to the encrypted data block; and the second count value is the processor determines the encrypted data
  • the terminal device provided by the present application can reduce cost and layout complexity.
  • the processor is specifically configured to: calculate, by using the same algorithm as calculating the first value, a second value of the plaintext data block for the second count value and the MAC of the plaintext data block; and determining the plaintext according to the first value and the second value Whether the data block has rolled back.
  • the processor is further configured to: when the first value and the third value are the same, determine that the security chip is powered off.
  • the terminal device can determine whether the security chip is powered off according to the first value and the third value of the target data block, thereby improving the reliability of the terminal device.
  • the processor is specifically configured to: decrypt the first value, obtain a first count value of the MAC and NVM of the plaintext data block; and determine, according to the first count value and the second count value, whether the plaintext data block is rolled back.
  • the method further includes: a transmitter, and correspondingly, the processor is configured to: when the first count value and the second count value are the same, determine that the plaintext data block does not roll back; when the first count value and the second count When the values are different, the second count value is obtained by the third time; when the first count value and the third count value are different, it is determined that the plaintext data block is rolled back, and the sender is triggered to send the prompt message, and the prompt message is sent. Used to prompt the plaintext data block to roll back.
  • the processor is further configured to: when the first count value and the third count value are the same, determine that the security chip is powered off.
  • the terminal device can determine whether the security chip is powered off according to the first count value and the third count value, thereby improving the reliability of the terminal device.
  • the present application provides a processor, which is the processor in the fifth aspect or the optional aspect of the fifth aspect.
  • the corresponding content and effects will not be described here.
  • the present application provides a chip, comprising the non-volatile memory NVM in the fifth aspect or the alternative aspect of the fifth aspect, and the processor in the fifth aspect or the alternative aspect of the fifth aspect.
  • a chip comprising the non-volatile memory NVM in the fifth aspect or the alternative aspect of the fifth aspect, and the processor in the fifth aspect or the alternative aspect of the fifth aspect.
  • the present application provides a data processing method, where the method is applied to a processor, where the processor is included in a security chip, the security chip further includes: a second memory and a non-volatile memory NVM; and the security chip is coupled to the first memory NVM is used to count the number of updates of the encrypted data block to obtain a count value, and the count value of the NVM cannot be rolled back; the method includes:
  • the first value corresponding to the plaintext data block is obtained; the first count value is a count value corresponding to the plaintext data block when the processor calculates the first value; Encrypting a block of values and a plaintext block to obtain an encrypted block of data, and storing the block of encrypted data in the first memory; determining whether the block of the encrypted block is rolled back according to the second count value of the encrypted block and the NVM; wherein, the second count The value corresponds to the encrypted data block; the second count value is a count value corresponding to the encrypted data block when the processor determines whether the encrypted data block is rolled back.
  • the terminal device in the foregoing fifth aspect or the optional mode in the fifth aspect may be used to execute the data processing method, and the corresponding content and effect are the same, and details are not described herein again.
  • the present application provides a computer storage medium for storing computer software instructions for use in the terminal device, including a program for performing the fourth aspect described above.
  • the embodiment of the present application provides a computer storage medium for storing computer software instructions used by the terminal device, which includes a program designed to execute the foregoing eighth aspect.
  • the present application provides a computer program product comprising instructions which, when executed by a computer, cause the computer to perform the functions performed by the terminal device in the eighth aspect and the optional method described above.
  • the application provides a terminal device and a data processing method.
  • the first memory is configured to store M first data blocks, wherein each first data block is obtained by performing an encryption operation on the plaintext data block and the first MAC corresponding to the plaintext data block.
  • the counter is used to count the number of updates of the M first data blocks to obtain a count value, and the counter value of the counter cannot be rolled back.
  • the counter may be an OTP or a counter such as an NVM in the SE chip.
  • the application has data anti-return capability while maintaining the existing chip architecture. Add dedicated Secure Flash to the prior art.
  • the terminal device provided by the present application can reduce cost and layout complexity.
  • the counter is an NVM or other counter in the SE chip, it is equivalent to adding a small-capacity (for counting only) counter to the existing SE chip, and therefore, dedicated Secure Flash is added with respect to the prior art.
  • the terminal device provided by the present application can reduce cost and layout complexity.
  • FIG. 1 is a schematic structural diagram of a chip of a terminal device provided by the prior art
  • FIG. 2 is a schematic structural diagram of a terminal device according to an embodiment of the present disclosure
  • 3A is a schematic diagram of secondary storage of a first memory according to an embodiment of the present disclosure
  • FIG. 3B is a schematic diagram of secondary storage of a first memory according to another embodiment of the present application.
  • FIG. 5 is a flowchart of a data processing method according to an embodiment of the present application.
  • FIG. 6 is a schematic diagram of a terminal device according to an embodiment of the present disclosure.
  • FIG. 7 is a schematic diagram of a primary storage of a first memory according to an embodiment of the present disclosure.
  • FIG. 8 is a flowchart of a data processing method according to another embodiment of the present application.
  • an SE chip is integrated in an AP SOC of a terminal device to implement a mobile payment and multi-service public platform.
  • the SE chip includes an OTP, a ROM, and a RAM, and the system program, application, and application data are stored in an EMMB of eMMC/UFS (Non-Volatile Memory (NVM)).
  • EMMB Non-Volatile Memory
  • System programs, application and application data need to be read from the RPMB to run in internal RAM when the system is running.
  • the security level of SE is very high. For NVM data requirements, there are mainly the following:
  • the off-chip RPMB is a partition provided by an external UFS/eMMC storage device manufacturer, its anti-return capability is available, but the security level has not been checked and verified; and because of the cost, the off-chip RPMB anti-return capability does not have any eMMC/ UFS storage device manufacturers can actually achieve EAL4+ security protection level or above; therefore, relying on the anti-return of RPMB area can not achieve EAL4+ security protection level.
  • the application provides a terminal device and a data processing method.
  • the present application can be based on the chip architecture shown in FIG. 1 without adding dedicated Secure Flash, and there is no need for eMMC/UFS storage device manufacturers to increase security protection RPMB to meet EAL5+ certification requirements. That is, based on the current chip architecture shown in Figure 1, the SE chip can meet the security requirements and certification of the EAL5+ in the NVM.
  • the implementation principle of the present application is: implementing the data anti-backoff function by using the OTP in the SE chip.
  • the OTP bit is programmed one bit at a time, starting with 0 bits per bit, and can be written as 1 by programming, so the number of bits programmed to 1 will be more and more, and cannot be rolled back.
  • the count value of the OTP can be logically operated with the MAC corresponding to the plaintext data block. If the plaintext data block 1 is rolled back, the processor reads the MAC address corresponding to the back-off plaintext data block (plaintext data block 2) and the count value of the OTP corresponding to the plaintext data block 2 for logical operation. result.
  • the processor when the processor performs a logical operation on the current count value of the OTP and the MAC corresponding to the plaintext data block 2, the logical value of the MAC corresponding to the plaintext data block 2 and the OTP corresponding to the plaintext data block 2 must be logically operated.
  • the results obtained are different. That is, since the result corresponding to the plaintext data block 2 is calculated using the previous OTP count, when the plaintext data block 2 is updated to the plaintext data block 1, the current OTP count value must be increased, based on this.
  • the processor can determine that a data rollback has occurred in plaintext block 1.
  • FIG. 2 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
  • the terminal device includes a security chip 21 and a first memory 22 coupled to the security chip 21, wherein the security chip 21 includes a processor 211, a second memory 212, and a counter 213.
  • the first memory 22 is configured to store M first data blocks, where each first data block is performed by using a plaintext data block and a first message authentication code (MAC) corresponding to the plaintext data block. Obtained by the encryption operation, M is an integer greater than or equal to 1.
  • the counter 213 is configured to count the number of updates of the M first data blocks to obtain a count value, and the count value of the counter 213 cannot be rolled back.
  • the processor 211 is configured to: perform a logical operation by using a first count value of the counter 213 and a first MAC corresponding to each first data block, to obtain M first values that are in one-to-one correspondence with the M first data blocks;
  • the first count value is a count value corresponding to the M first data blocks when the processor 211 performs a logic operation. Encrypting the M first values and the second MAC corresponding to the M first values to obtain a second data block, and storing the second data block in the first memory 22. Determining whether the target data block is backed off according to the second data block and the second count value of the counter 213; wherein the target data block is any one of the M first data blocks; the second count value is the processor 211 determining the target data. The count value corresponding to the M first data blocks when the block is rolled back.
  • the processor calculates the first MAC of the plaintext data block, and may adopt a MAC algorithm such as SHA256-hMAC or AES-CMAC in the prior art.
  • a MAC algorithm such as SHA256-hMAC or AES-CMAC in the prior art.
  • the second MAC that calculates the M first values in the present application may also adopt a MAC algorithm such as SHA256-hMAC or AES-CMAC in the prior art.
  • the M first value can be regarded as a whole and can be understood as a data block, and an existing MAC algorithm can be used for the data block. This application does not limit this.
  • the counter 213 is used to count the number of updates of the M first data blocks to obtain a count value. Therefore, after any one of the M first data blocks is updated, the count values corresponding to the M first data blocks are updated, for example, one of the first data blocks of the M first data blocks is updated. Then the corresponding count value is increased by 1. Therefore, the first count value is a count value corresponding to the M first data blocks when the processor 211 performs a logic operation. The first count value here must be the latest first count value obtained when the most recent logical operation is performed. Suppose there are two first data blocks. They are the first data block 1 and the first data block 2, respectively.
  • updating the first data block involved in the present application means storing a new first data block, and deleting the historical first data block corresponding to the new first data block.
  • the first value read by the processor 211 is actually the first MAC of the first data block B.
  • the first count value corresponding to the first data block B is calculated.
  • the second count value should be the count value obtained after the first count value corresponding to the first data block B is updated once.
  • the processor 211 calculates the second value by the second count value and the first MAC of the first data block B. Since the first value and the second value are not the same, it indicates that the target data block A may fall back. Considering that it is possible that the SE chip is powered down, the first value and the second value are different.
  • the second count value may be the previous first count value. Therefore, even if the target data block A does not fall back, in this case, the first value read by the processor 211 is the first MAC of the target data block A and the first count value corresponding to the target data block A (the The first count value is already the latest first count value) is calculated.
  • the processor 211 calculates the second value by the second count value (previous first count value) and the first MAC of the target data block A. Therefore, in this case, the first value and the second value may also be different, and the reason why the first value and the second value are different is not that the target data block A has been retracted. Instead, the SE chip is powered down.
  • the processor 211 determines whether the target data block is rolled back.
  • the processor 211 is specifically configured to: calculate, by using the same algorithm as the first value of the calculation target data block, a second value corresponding to the first value of the calculation target data block for the second count value and the first MAC corresponding to the target data block; according to the target data block A value and a second value of the target data block determine whether the target data block has rolled back.
  • the terminal device further includes: a transmitter; and correspondingly, the processor 211 is configured to: when the first value of the target data block and the second value of the target data block are the same, determine that the target data block does not fall back; When the first value of the target data block and the second value of the target data block are different, the second count value is updated to obtain a third count value, and the third count value and the first MAC corresponding to the target data block are used and calculated.
  • An algorithm in which the first value of the target data block is the same calculates a third value of the target data block; when the first value of the target data block is different from the third value of the target data block, determining that the target data block is rolled back and triggering the sending
  • the device sends a prompt message, and the prompt message is used to prompt the target data block to roll back.
  • the processor 211 is further configured to: when the first value of the target data block and the third value of the target data block are the same, determine that the security chip is powered off.
  • the addition of the second value also requires the addition algorithm
  • the calculation of the third value also requires the addition algorithm.
  • the calculation of the second value also requires an exclusive OR operation
  • the calculation of the third value also requires an exclusive OR operation.
  • the processor 211 determines whether the target data block has been rolled back, the processor 211 usually acquires the read. Taking the request, the processor 211 reads the target data block according to the read request. Then, the processor 211 determines whether the target data block has rolled back, and the transmitter transmits a read response. When the target data block has not rolled back, the read response is used to indicate that the read was successful. When the target data block is rolled back, the read response is the above-mentioned prompt message, and the prompt message is used to prompt the target data block to roll back.
  • the processor 211 targets the first MAC value corresponding to the target data block. Reading the data block to the second memory, and decrypting the target data block, obtaining a plaintext data block of the target data block and a first MAC of the target data block, and verifying whether the first MAC is correct; When the MAC is correct, the second data block corresponding to the target data block is read to the second memory, and the second data block is decrypted, the second MAC of the second data block is obtained, and the second MAC is verified to be correct; When the second MAC is verified to be correct, the processor 211 calculates the second value of the target data block by using the same algorithm as the first value of the calculation target data block for the second count value and the first MAC corresponding to the target data block.
  • the processor 211 is configured to: obtain a first count value according to the first value of the target data block and the first MAC corresponding to the target data block; and determine the target data according to the first count value and the second count value. Whether the block has rolled back.
  • the terminal device further includes: a transmitter.
  • the processor 211 is specifically configured to: when the first count value and the second count value are the same, determine that the target data block does not fall back; when the first count value and the second count value are not the same, update the second count value to obtain The third count value; when the first count value and the third count value are different, determining that the target data block is rolled back, and triggering the sender to send a prompt message, the prompt message is used to prompt the target data block to roll back.
  • the processor 211 is further configured to: when the first count value and the third count value are the same, determine that the security chip is powered off.
  • the processor 211 obtains the first count value according to the first value of the target data block and the first MAC corresponding to the target data block, and the algorithm used is the inverse of the addition algorithm.
  • the operation that is, the subtraction algorithm is used to calculate the first count value.
  • the processor 211 obtains the first count value according to the first value of the target data block and the first MAC corresponding to the target data block, and the algorithm used is the inverse of the multiplication operation.
  • the operation that is, the division operation is used to calculate the first count value.
  • the processor 211 determines whether the target data block has been rolled back, the processor 211 usually acquires the read. Taking the request, the processor 211 reads the target data block according to the read request. Then, the processor 211 determines whether the target data block has rolled back, and the transmitter transmits a read response. When the target data block has not rolled back, the read response is used to indicate that the read was successful. When the target data block is rolled back, the read response is the above-mentioned prompt message, and the prompt message is used to prompt the target data block to roll back.
  • the processor 211 reads the target data block to the second memory, and decrypts the target.
  • Data block obtaining a plaintext data block corresponding to the target data block and a first MAC of the target data block, and verifying whether the first MAC is correct; when verifying that the first MAC is correct, corresponding to the target data block Reading the second data block to the second memory, and decrypting the second data block, obtaining a first value corresponding to the second MAC and the target data block of the second data block, and verifying whether the second MAC is correct;
  • the processor 211 obtains the first count value according to the first value of the target data block and the first MAC corresponding to the target data block.
  • the above counter may be an OTP or an NVM.
  • the bit of the counter can be divided into a plurality of bit segments, and each bit segment constitutes a count value, that is, the counter can include a plurality of count values at the same time.
  • Each count value may correspond to at least one first data block.
  • the counter value of the counter is in one-to-one correspondence with the second data block.
  • FIG. 3B is a schematic diagram of secondary storage of a first memory provided by another embodiment of the present application. As shown in FIG. 3B, the bits of the timer are divided into 3 bit segments, each of which constitutes a calculated value.
  • the first memory stores M1 first data blocks and second data blocks corresponding to M1 first data blocks.
  • the first memory stores M2 first data blocks and second data blocks corresponding to M2 first data blocks.
  • the first memory stores M3 first data blocks and second data blocks corresponding to M3 first data blocks.
  • bit segment corresponding to each partition can be set according to the application write times. For example, bit segment 1 is used to store the application, and the update frequency of the application is relatively low, so the number of bits in bit segment 1 can be set less. It is assumed that the bit segment 2 is used to store application data, and the update frequency of the application data is very high. That is, the application data is updated more frequently, so the number of bits of the bit segment 2 can be set more. For example, the bit segment 2 can reach tens of thousands of bits, but the storage space can be smaller. Similarly, the number of bits in bit segment 3 can also be set.
  • the processor may implement application application calls by using a plurality of application programming interfaces (APIs) of the first memory to the multi-bit segment, or may be directly specified.
  • APIs application programming interfaces
  • the storage mode of the multi-bit segment makes the count value between different partitions unaffected, thereby reducing the complexity of the terminal device.
  • the present application provides a terminal device, including: a security chip and a first memory coupled to the security chip, wherein the security chip includes: a processor, a second memory, and a counter.
  • the first memory is configured to store M first data blocks, wherein each first data block is obtained by performing an encryption operation on the plaintext data block and the first MAC corresponding to the plaintext data block.
  • the counter is used to count the number of updates of the M first data blocks to obtain a count value, and the counter value of the counter cannot be rolled back.
  • the processor is configured to: perform a logical operation by using a first count value of the counter and a first MAC corresponding to each first data block, to obtain M first values corresponding to the M first data blocks; wherein, the first The count value is the count value corresponding to the M first data blocks when the processor performs a logical operation. Encrypting the M first values and the second MAC corresponding to the M first values to obtain a second data block, and storing the second data block in the first memory.
  • the counter may be an OTP or a counter such as an NVM in the SE chip.
  • the application has data anti-return capability while maintaining the existing chip architecture. Add dedicated Secure Flash to the prior art.
  • the terminal device provided by the present application can reduce cost and layout complexity.
  • the counter is an NVM or other counter in the SE chip, it is equivalent to adding a small-capacity (for counting only) counter to the existing SE chip, and therefore, dedicated Secure Flash is added with respect to the prior art.
  • the terminal device provided by the present application can reduce cost and layout complexity.
  • the processor 211 is further configured to: update the third data block to a new first data block, and update the first count value to obtain a new first count value; wherein the third data block is M Any one of the data blocks; respectively calculating, for each new first count value and the first MAC corresponding to each first data block corresponding to the second data block, using the same algorithm as calculating the first value a new first value of the data block, and updating the first value of each first data block to a new first value; the M new first value and the M new first corresponding to the second data block The new second MAC encryption corresponding to the value obtains a new second data block; and updates the second data block to a new second data block; the counter is further configured to update the first count value to the new first count value.
  • the third data block is the first updated data block of the first of the M first data blocks.
  • the manner of updating the first data block is similar to that of the foregoing processor 211, and details are not described herein again.
  • the M first data blocks are the first data block 1, the first data block 2, ... the first data block M, respectively. It is assumed that the first updated first data block is the first data block 1, and the first data block 1 is the third data block.
  • the processor updates the first data block 1 to the new first data block 1, the first count value needs to be updated once to obtain a new first count value. Since the first count value has changed, the first value of the new first data block 1, the first data block 2, ... the first data block M needs to be updated to the new first value.
  • the new first value is calculated using the new first count value.
  • the counter is further configured to update the first count value to the new first count value.
  • the processor 211 is further configured to: read the first value of the fourth data block to the second memory 212, where the fourth data block is any one of the new first data blocks corresponding to the second data block a first data block; determining a first MAC corresponding to the fourth data block according to the first value of the fourth data block and the first count value; storing the first MAC corresponding to the fourth data block to the second memory.
  • the processor 211 calculates a new first value by using the first MAC of the fourth data block, the first MAC needs to be obtained in the foregoing manner.
  • the processor 211 determines the first MAC corresponding to the fourth data block according to the first value of the fourth data block and the first count value, and the adopted algorithm is an inverse operation for calculating the first value. Assuming that the first value is calculated using an addition operation, the processor 211 can obtain the first MAC using a subtraction operation.
  • the processor 211 is in the process of calculating a new first value of each first data block corresponding to the second data block, or after updating the second data block to a new second data block, the counter will count the first
  • the SE chip may be powered down before the value is updated to the new first count value.
  • the present application provides a SE chip power down protection strategy.
  • the terminal device provided by the present application can ensure that the first count value of the first data block, the second data block, and the counter is accurate when the SE chip is powered off.
  • FIG. 4 is a schematic diagram of a storage area of a first memory according to an embodiment of the present disclosure.
  • the storage area of the first memory may include three parts: a common secure storage area, and an authentication secure storage using a count value. Area and program area. The main difference between the normal security storage area and the authentication security storage area that uses the count value is whether the anti-backoff function can achieve EAL5+ authentication.
  • a normal secure storage area can be used to store data blocks that are not critical to data fallback.
  • the authentication secure storage area using the count value is the area for secondary storage provided by the present application, and the area is used for storing the first data block and the second data block described above.
  • the present application provides different APIs for the three different regions described above.
  • Option 1 Provide a new API for the authenticated secure storage area that utilizes the count value.
  • Static configuration specifies an authenticated secure storage area that uses a common secure storage area and uses count values.
  • the present application further provides a processor, which is a processor in the foregoing SE chip, and the function of the processor is as described above, and the details are not described herein again.
  • the application also provides a chip including the above counter and the processor.
  • the functions of the counter and the functions of the processor are as described above, and the present application will not be repeated here.
  • the chip may be the above-mentioned SE chip, or may be an AP SOC, and the AP SOC includes the SE chip.
  • FIG. 5 is a flowchart of a data processing method according to an embodiment of the present application. As shown in FIG. 2 and FIG. 5, the method is applied to the processor 211.
  • the processor 211 is included in the security chip 21, and the security chip further includes: a second memory 212 and a counter 213; the security chip 21 and the A memory 22 is coupled to each other; the first memory 22 is configured to store M first data blocks, wherein each first data block is authenticated by a plaintext data block and a first message corresponding to the plaintext data block
  • the code MAC is obtained by performing an encryption operation, and M is an integer greater than or equal to 1.
  • the counter 213 is configured to count the number of updates of the M first data blocks to obtain a count value, and the counter value of the counter 213 is not available. Fallback; the method includes:
  • Step S501 performing a logical operation on the first count value of the counter and the first MAC corresponding to each first data block, respectively, to obtain M first values corresponding to the M first data blocks one by one; wherein, the first count The value is the count value corresponding to the M first data blocks when the processor performs a logical operation.
  • Step S502 Perform an encryption operation on the M first values and the second MAC corresponding to the M first values to obtain a second data block, and store the second data block in the first memory.
  • Step S503 determining, according to the second data block and the second count value of the counter, whether the target data block is rolled back; wherein the target data block is any one of the M first data blocks; and the second count value is the processor determining the target. The count value corresponding to the M first data blocks when the data block is rolled back.
  • FIG. 6 is a schematic diagram of a terminal device according to an embodiment of the present disclosure.
  • the terminal device includes: a security chip 61 and a first memory 62 coupled to the security chip, where
  • the security chip 61 includes a processor 611, a second memory 612, and a non-volatile memory NVM 613.
  • the NVM 613 is configured to count the number of updates of the encrypted data block to obtain a count value, and the count value of the NVM 613 cannot be returned.
  • the first memory may also store a plurality of encrypted data blocks, and the bits of the NVM may be divided into a plurality of bit segments, each of the bit segments constituting a count value, and each of the count values may correspond to at least one encrypted data block.
  • the terminal device further includes: a transmitter; the processor 611 is specifically configured to: when the first value and the second value are the same, determine that the plaintext data block does not roll back; when the first value and the When the second value is different, updating the second count value to obtain a third count value, and calculating, by using the same algorithm as calculating the first value, the clear text for the third count value and the MAC a third value of the data block; when the first value and the third value are different, determining that the plaintext data block is rolled back, and triggering the sender to send a prompt message, where the prompt message is used for prompting The plaintext data block is rolled back.
  • processor 611 is further configured to: when the first value and the third value are the same, determine that the security chip is powered off.
  • the terminal device further includes: a transmitter; the processor 611 is specifically configured to: when the first count value and the second count value are the same, determine that the plaintext data block does not roll back; when the first When the count value and the second count value are different, the second count value obtains a third count value a second time; when the first count value and the third count value are not the same, the clear text is determined
  • the data block is rolled back, and the sender is triggered to send a prompt message, where the prompt message is used to prompt that the plaintext data block is rolled back.
  • the processor 611 is further configured to: when the first count value and the third count value are the same, determine that the security chip is powered off.
  • the present application provides a terminal device including: a security chip and a first memory coupled to the security chip, wherein the security chip includes: a processor, a second memory, and a non-volatile memory
  • the NVM is configured to count the number of updates of the encrypted data block to obtain a count value, and the count value of the NVM is not backed off;
  • the processor is configured to: use the message authentication code MAC of the plaintext data block and the NVM a first count value, the first value corresponding to the plaintext data block is obtained; the first count value is a count value corresponding to the plaintext data block when the processor calculates the first value; Encrypting the encrypted data block with the value and the plaintext data block, and storing the encrypted data block to the first memory;
  • the processor is further configured to: according to the encrypted data block and the NVM a second count value, determining whether the encrypted data block has a rollback; wherein the second count value corresponds to the encrypted data block; and the second count value is determined by the processor to determine the
  • the present application further provides a processor, which is the processor shown in FIG. 6.
  • the function of the processor is as described above, and the details are not described herein again.
  • the application also provides a chip including the above NVM and the processor.
  • the functions of the NVM and the functions of the processor are as described above, and the application will not be repeated herein.
  • the chip may be the above-mentioned SE chip, or may be an AP SOC, and the AP SOC includes the SE chip.
  • FIG. 8 is a flowchart of a data processing method according to another embodiment of the present application.
  • the method is applied to the processor 611, and the processor 611 is included in the security chip 61.
  • the security chip 61 further includes: a second memory 612 and a non-volatile memory NVM 613;
  • the security chip 61 is coupled to the first memory 62.
  • the NVM 613 is configured to count the number of updates of the encrypted data block to obtain a count value, and the count value of the NVM 613 cannot be rolled back;
  • the method includes:
  • Step S801 Using the message authentication code MAC of the plaintext data block and the first count value of the NVM, obtaining a first value corresponding to the plaintext data block; the first count value is corresponding to the plaintext data block when the processor calculates the first value. Count value.
  • Step S802 encrypting the first value and the plaintext data block, obtaining an encrypted data block, and storing the encrypted data block to the first memory;
  • Step S803 determining, according to the second count value of the encrypted data block and the NVM, whether the encrypted data block is backed off; wherein the second count value corresponds to the encrypted data block; and the second count value is determining whether the encrypted data block is generated back.
  • the count value corresponding to the data block is encrypted.
  • the data processing method provided by the present application is executed by the processor shown in FIG. 6, and the corresponding content and effect are the same, and details are not described herein again.

Abstract

The present application provides a terminal device and a data processing method. The device comprises a secure chip and a first memory, the secure chip comprising a processor, a second memory and a counter. The first memory is used for storing M first data blocks, the first data blocks being obtained by performing an encryption operation on a plaintext data block and a first MAC of the plaintext data block. The counter is used for counting the number of times of updates of the M first data blocks to obtain a count value, and the count value of the counter cannot be rolled back. The processor performs a logic operation on a first count value of the counter and the first MAC corresponding to each first data block, to obtain M first numeric values; and performs an encryption operation on the M first numeric values and a corresponding second MAC to obtain a second data block, and stores the second data block to the first memory. Whether a target data block has been rolled back according to the second block and a second count value of the counter is determined. The terminal device can reduce costs and the complexity of a deployment board.

Description

终端设备及数据处理方法Terminal device and data processing method
本申请要求于2017年6月19日提交中国专利局、申请号为201710464774.3、申请名称为“终端设备及数据处理方法”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims the priority of the Chinese Patent Application, filed on Jun.
技术领域Technical field
本申请涉及计算机技术领域,尤其涉及一种终端设备及数据处理方法。The present application relates to the field of computer technologies, and in particular, to a terminal device and a data processing method.
背景技术Background technique
随着终端技术的不断发展,用户对终端设备的移动支付、移动金融、汽车钥匙等承载百万级财产的安全应用也逐步有了需求。未来终端设备可能具备银行卡,公交卡,钥匙,身份证的功能。实现这些功能不能只依赖软件应用(Application,App),还需要终端设备的芯片提供硬件级的支持。With the continuous development of terminal technologies, users have gradually demanded the security applications of mobile devices such as mobile payment, mobile finance, and car keys that carry millions of assets. Future terminal equipment may have the functions of bank card, bus card, key, and ID card. Implementing these functions cannot rely solely on software applications (Applications, App), but also requires hardware support at the end device's chip.
图1为现有技术提供的终端设备的芯片的结构示意图,如图1所示,应用处理器(Application Processor,AP)片上系统(System on Chip,SOC)中集成安全(Secure,SE)芯片。SE芯片包括一次性可编程(One Time Programmable,OTP)、(Read-Only Memory,ROM)以及随机存取存储器(Random Access Memory,RAM),对于系统程序、应用程序和应用数据存储在外部嵌入式的多媒体存储卡(Embedded Multi Media Card,eMMC)/通用闪存存储(Universal Flash Storage,简称UFS)的防重放保护存储块(Replay Protect Memory Block,简称RPMB)中。当系统运行时需要将系统程序、应用程序和应用数据从RPMB中读取到内部RAM中运行。由于RPMB是外部UFS/eMMC存储器件厂商提供的分区,其虽然有防回退的能力,但是由于成本问题,片外RPMB的数据防回退(Anti-rollback)能力暂没有哪个eMMC/UFS存储器件厂商实际能做到EAL4+安全防护等级以上。FIG. 1 is a schematic structural diagram of a chip of a terminal device provided by the prior art. As shown in FIG. 1 , an application processor (AP) integrated system (Secure, SE) chip is integrated in a system on chip (SOC). The SE chip includes One Time Programmable (OTP), Read-Only Memory (ROM), and Random Access Memory (RAM), which are externally embedded for system programs, applications, and application data. The Multi-Media Card (EMMC)/Universal Flash Storage (UFS) Replay Protect Memory Block (RPMB). System programs, application and application data need to be read from the RPMB to run in internal RAM when the system is running. Since RPMB is a partition provided by an external UFS/eMMC storage device manufacturer, although it has anti-backoff capability, due to cost, the anti-rollback capability of the off-chip RPMB does not have any eMMC/UFS storage device. Manufacturers can actually achieve EAL4+ security protection level or above.
目前存在一种EAL5+安全防护的专用安全闪存(Secure Flash)器件。SE芯片通过自定义的接口与专用Secure Flash连接。但是如果在终端设备上增加该专用Secure Flash,势必造成终端设备成本的增加,并且造成终端设备的布板复杂度较高。There is currently a dedicated Secure Flash device for EAL5+ security protection. The SE chip is connected to a dedicated Secure Flash via a custom interface. However, if the dedicated Secure Flash is added to the terminal device, the cost of the terminal device is inevitably increased, and the layout complexity of the terminal device is high.
发明内容Summary of the invention
本申请提供一种终端设备及数据处理方法。从而可以降低终端设备的成本以及布板复杂度。The application provides a terminal device and a data processing method. Thereby, the cost of the terminal device and the layout complexity can be reduced.
第一方面,本申请提供一种终端设备,包括:安全芯片和耦合至安全芯片的第一存储器,其中,安全芯片包括:处理器、第二存储器和计数器;第一存储器,用于存储M个第一数据块,其中,每个第一数据块是通过对明文数据块以及与明文数据块对应的第一消息认证码MAC进行加密运算得到的,M为大于等于1的整数;计数器,用于对M个第一数 据块的更新次数进行计数,得到计数值,计数器的计数值不可回退;处理器用于:分别利用计数器的第一计数值以及每个第一数据块对应的第一MAC进行逻辑运算,得到与M个第一数据块一一对应的M个第一数值;其中,第一计数值为处理器进行逻辑运算时,M个第一数据块对应的计数值;对M个第一数值和与M个第一数值对应的第二MAC进行加密运算,得到第二数据块,并将第二数据块存储至第一存储器;根据第二数据块以及计数器的第二计数值,判断目标数据块是否发生回退;其中,目标数据块是M个第一数据块的任一个;第二计数值为处理器判断目标数据块是否发生回退时,M个第一数据块对应的计数值。In a first aspect, the application provides a terminal device, including: a security chip and a first memory coupled to the security chip, wherein the security chip includes: a processor, a second memory, and a counter; and the first memory is configured to store M a first data block, wherein each of the first data blocks is obtained by encrypting a plaintext data block and a first message authentication code MAC corresponding to the plaintext data block, where M is an integer greater than or equal to 1; a counter is used for Counting the number of updates of the M first data blocks to obtain a count value, and the counter value of the counter is not backed off; the processor is configured to: use the first count value of the counter and the first MAC corresponding to each first data block respectively The logic operation obtains M first values corresponding to the M first data blocks one by one; wherein, the first count value is a count value corresponding to the M first data blocks when the processor performs a logic operation; And performing a cryptographic operation on the second MAC corresponding to the M first values to obtain a second data block, and storing the second data block in the first memory; And determining, by the second count value of the counter, whether the target data block is rolled back; wherein the target data block is any one of the M first data blocks; and the second count value is when the processor determines whether the target data block is rolled back. The count value corresponding to the M first data blocks.
综上,当该计数器是OTP时,即本申请在保持现有芯片架构不变的情况下,具有数据防回退能力。相对于现有技术增加专用Secure Flash。本申请提供的终端设备可以降低成本以及布板复杂度。当该计数器是SE芯片中的NVM或者其他计数器时,相当于在现有的SE芯片中增加了一个小容量(只用于计数)的计数器,因此,相对于现有技术增加专用Secure Flash。本申请提供的终端设备可以降低成本以及布板复杂度。In summary, when the counter is an OTP, the application has data anti-return capability while maintaining the existing chip architecture. Add dedicated Secure Flash to the prior art. The terminal device provided by the present application can reduce cost and layout complexity. When the counter is an NVM or other counter in the SE chip, it is equivalent to adding a small-capacity (for counting only) counter to the existing SE chip, and therefore, dedicated Secure Flash is added with respect to the prior art. The terminal device provided by the present application can reduce cost and layout complexity.
可选地,处理器具体用于:对第二计数值和目标数据块对应的第一MAC,采用与计算目标数据块的第一数值相同的算法计算目标数据块的第二数值;根据目标数据块的第一数值和目标数据块的第二数值判断目标数据块是否发生回退。Optionally, the processor is specifically configured to: calculate, by using the same algorithm as the first value of the calculation target data block, a second value corresponding to the first value of the calculation target data block for the second count value and the first MAC corresponding to the target data block; according to the target data The first value of the block and the second value of the target data block determine whether the target data block has rolled back.
可选地,该终端设备还包括:发送器;处理器具体用于:当目标数据块的第一数值和目标数据块的第二数值相同时,确定目标数据块未发生回退;当目标数据块的第一数值和目标数据块的第二数值不相同时,更新一次第二计数值得到第三计数值,对第三计数值和目标数据块对应的第一MAC,采用与计算目标数据块的第一数值相同的算法计算目标数据块的第三数值;当目标数据块的第一数值和目标数据块的第三数值不相同时,确定目标数据块发生回退,并触发发送器发送提示消息,提示消息用于提示目标数据块发生回退。Optionally, the terminal device further includes: a transmitter, where the processor is configured to: when the first value of the target data block and the second value of the target data block are the same, determine that the target data block does not fall back; when the target data When the first value of the block is different from the second value of the target data block, the second count value is updated to obtain a third count value, and the third count value and the first MAC corresponding to the target data block are used to calculate the target data block. The first algorithm having the same first value calculates the third value of the target data block; when the first value of the target data block is different from the third value of the target data block, determining that the target data block is rolled back, and triggering the transmitter to send the prompt Message, the prompt message is used to prompt the target data block to roll back.
本申请中在保持现有芯片架构不变的情况下,或者相当于在现有的SE芯片中增加了一个小容量(只用于计数)的计数器时,可以有效的判断目标数据块是否发生回退。In the present application, when the existing chip architecture is kept unchanged, or when a counter of a small capacity (for counting only) is added to the existing SE chip, it is possible to effectively judge whether the target data block is generated back. Retreat.
可选地,处理器还用于:当目标数据块的第一数值和目标数据块的第三数值相同时,确定安全芯片发生掉电。Optionally, the processor is further configured to: when the first value of the target data block and the third value of the target data block are the same, determine that the security chip is powered down.
即终端设备可以根据目标数据块的第一数值和目标数据块的第三数值判断安全芯片是否发生掉电,进而提高终端设备的可靠性。That is, the terminal device can determine whether the security chip is powered off according to the first value of the target data block and the third value of the target data block, thereby improving the reliability of the terminal device.
可选地,处理器具体用于:根据目标数据块的第一数值和目标数据块对应的第一MAC,得到第一计数值;根据第一计数值和第二计数值判断目标数据块是否发生回退。Optionally, the processor is specifically configured to: obtain a first count value according to the first value of the target data block and the first MAC corresponding to the target data block; determine whether the target data block occurs according to the first count value and the second count value. go back.
可选地,终端设备还包括:发送器;处理器具体用于:当第一计数值和第二计数值相同时,确定目标数据块未发生回退;当第一计数值和第二计数值不相同时,更新一次第二计数值得到第三计数值;当第一计数值和第三计数值不相同时,确定目标数据块发生回退,并触发发送器发送提示消息,提示消息用于提示目标数据块发生回退。Optionally, the terminal device further includes: a transmitter, where the processor is configured to: when the first count value and the second count value are the same, determine that the target data block does not roll back; when the first count value and the second count value When the difference is different, the second count value is updated to obtain a third count value; when the first count value and the third count value are not the same, it is determined that the target data block is rolled back, and the transmitter is triggered to send a prompt message, and the prompt message is used for Prompt that the target data block has rolled back.
本申请中在保持现有芯片架构不变的情况下,或者相当于在现有的SE芯片中增加了一个小容量(只用于计数)的计数器时,可以有效的判断目标数据块是否发生回退。In the present application, when the existing chip architecture is kept unchanged, or when a counter of a small capacity (for counting only) is added to the existing SE chip, it is possible to effectively judge whether the target data block is generated back. Retreat.
可选地,处理器还用于:当第一计数值和第三计数值相同时,确定安全芯片发生掉电。Optionally, the processor is further configured to: when the first count value and the third count value are the same, determine that the security chip is powered off.
即终端设备可以根据第一计数值和第三计数值判断安全芯片是否发生掉电,进而提高终端设备的可靠性。That is, the terminal device can determine whether the security chip is powered off according to the first count value and the third count value, thereby improving the reliability of the terminal device.
可选地,处理器还用于:将第三数据块更新为新的第一数据块,并更新一次第一计数值得到新的第一计数值;其中,第三数据块是M个第一数据块的任一个;分别对新的第一计数值和第二数据块对应的每个第一数据块对应的第一MAC,采用与计算第一数值相同的算法计算每个第一数据块的新的第一数值,并将每个第一数据块的第一数值更新为新的第一数值;对第二数据块对应的M个新的第一数值和M个新的第一数值对应的新的第二MAC加密,得到新的第二数据块;并将第二数据块更新为新的第二数据块;计数器,还用于将第一计数值更新为新的第一计数值。Optionally, the processor is further configured to: update the third data block to the new first data block, and update the first count value to obtain a new first count value; wherein the third data block is M first Any one of the data blocks; respectively calculating, for each new first count value and the first MAC corresponding to each first data block corresponding to the second data block, using the same algorithm as calculating the first value a new first value, and updating the first value of each first data block to a new first value; corresponding to the M new first values corresponding to the second data block and the M new first values The new second MAC is encrypted to obtain a new second data block; and the second data block is updated to a new second data block; the counter is further configured to update the first count value to the new first count value.
本申请中,由于第一存储器采用二级存储方式,因此,在终端设备更新完第三数据块之后,需要将第二数据块对应的每个第一数据块的第一数值更新为新的第一数值,并根据该新的第一数值更新第二数据块。从而提高终端设备中数据的准确性。In the present application, since the first memory adopts the secondary storage mode, after the terminal device updates the third data block, the first value of each first data block corresponding to the second data block needs to be updated to a new one. a value and updating the second data block based on the new first value. Thereby improving the accuracy of the data in the terminal device.
可选地,处理器还用于:将第四数据块的第一数值读取至第二存储器,第四数据块为第二数据块对应的除新的第一数据块的任一第一数据块;根据第四数据块的第一数值和第一计数值确定第四数据块对应的第一MAC;将第四数据块对应的第一MAC存储至第二存储器。Optionally, the processor is further configured to: read the first value of the fourth data block to the second memory, where the fourth data block is any first data of the new first data block corresponding to the second data block And determining, according to the first value of the fourth data block and the first count value, a first MAC corresponding to the fourth data block, and storing the first MAC corresponding to the fourth data block to the second memory.
通过该方法可以有效获得第四数据块的第一MAC。The first MAC of the fourth data block can be effectively obtained by this method.
可选地,处理器还用于:当安全芯片发生掉电,则在安全芯片上电之后,读取第五数据块对应的每个第一数据块的第五数值,其中,第五数据块为新的第二数据块对应的实际数据块,第五数值为新的第一数值对应的实际数值;根据第五数据块对应的每个第一数据块的第五数值和第五数据块对应的每个第一数据块的第一MAC确定用于计算第五数值的第四计数值;判断第五数据块对应的每个第一数据块的第四计数值是否相同;当确定第五数据块对应的每个第一数据块的第四计数值不完全相同时,对从第六数据块开始的每个第一数据块的第四计数值更新一次,得到新的第一计数值,其中第六数据块为第五数据块对应的一个第一数据块,且满足条件:从第六数据块开始的每个第一数据块的第四计数值与第六数据块之前的每个第一数据块的第四计数值不同;对新的第一计数值和从第六数据块开始的每个第一数据块对应的第一MAC,采用与计算第一数值相同的算法计算从第六数据块开始的每个第一数据块的新的第一数值,并将从第六数据块开始的每个第一数据块的第四数值更新为新的第一数值;将第五数据块对应的第二MAC更新为新的第二MAC;对第五数据块对应的M个新的第一数值和M个新的第一数值对应的新的第二MAC加密,得到新的第二数据块,并将第五数据块更新为新的第二数据块;计数器,还用于将第一计数值更新为新的第一计数值。Optionally, the processor is further configured to: when the security chip is powered off, read the fifth value of each first data block corresponding to the fifth data block after the security chip is powered on, where the fifth data block For the actual data block corresponding to the new second data block, the fifth value is the actual value corresponding to the new first value; the fifth value corresponding to the first data block corresponding to the fifth data block corresponds to the fifth data block. Determining, by the first MAC of each first data block, a fourth count value for calculating a fifth value; determining whether a fourth count value of each first data block corresponding to the fifth data block is the same; and determining the fifth data When the fourth count value of each first data block corresponding to the block is not completely the same, the fourth count value of each first data block starting from the sixth data block is updated once to obtain a new first count value, wherein The sixth data block is a first data block corresponding to the fifth data block, and satisfies a condition: a fourth count value of each first data block starting from the sixth data block and each first before the sixth data block The fourth count value of the data block is different; a first count value and a first MAC corresponding to each first data block starting from the sixth data block, and calculating a new one of each first data block starting from the sixth data block by using the same algorithm as calculating the first value a first value, and updating a fourth value of each first data block starting from the sixth data block to a new first value; updating the second MAC corresponding to the fifth data block to a new second MAC; Encrypting the new first MAC corresponding to the M new first value and the M new first value to obtain a new second data block, and updating the fifth data block to a new one The second data block; the counter is further configured to update the first count value to the new first count value.
当安全芯片发生掉电,则在安全芯片上电之后,通过该方法可以保证数据的准确性,从而提高终端设备的可靠性。When the security chip is powered off, after the security chip is powered on, the accuracy of the data can be ensured by the method, thereby improving the reliability of the terminal device.
可选地,计数器为一次性编程芯片OTP或者非易失性存储器NVM。Optionally, the counter is a one-time programming chip OTP or a non-volatile memory NVM.
第二方面,本申请提供一种处理器,该处理器为第一方面或者第一方面的可选方式中的处理器。对应内容和效果在此不再赘述。In a second aspect, the present application provides a processor that is the processor of the first aspect or the alternative of the first aspect. The corresponding content and effects will not be described here.
第三方面,本申请提供一种芯片,包括如第一方面或者第一方面的可选方式中的计数器和如第一方面或者第一方面的可选方式中的处理器。对应内容和效果在此不再赘述。In a third aspect, the present application provides a chip comprising the counter of the first aspect or the alternative of the first aspect and the processor of the first aspect or the alternative of the first aspect. The corresponding content and effects will not be described here.
第四方面,本申请提供一种数据处理方法,该方法应用于处理器,处理器包含于安全芯片,安全芯片还包括:第二存储器和计数器;安全芯片与第一存储器耦合连接;第一存 储器,用于存储M个第一数据块,其中,每个第一数据块是通过对明文数据块以及与明文数据块对应的第一消息认证码MAC进行加密运算得到的,M为大于等于1的整数;计数器,用于对M个第一数据块的更新次数进行计数,得到计数值,计数器的计数值不可回退;方法包括:In a fourth aspect, the present application provides a data processing method, where the method is applied to a processor, the processor is included in a security chip, the security chip further includes: a second memory and a counter; the security chip is coupled to the first memory; the first memory For storing the M first data blocks, where each first data block is obtained by encrypting a plaintext data block and a first message authentication code MAC corresponding to the plaintext data block, where M is greater than or equal to 1. The integer is used to count the number of updates of the M first data blocks to obtain a count value, and the counter value cannot be rolled back; the method includes:
分别利用计数器的第一计数值以及每个第一数据块对应的第一MAC进行逻辑运算,得到与M个第一数据块一一对应的M个第一数值;其中,第一计数值为处理器进行逻辑运算时,M个第一数据块对应的计数值;对M个第一数值和与M个第一数值对应的第二MAC进行加密运算,得到第二数据块,并将第二数据块存储至第一存储器;根据第二数据块以及计数器的第二计数值,判断目标数据块是否发生回退;其中,目标数据块是M个第一数据块的任一个;第二计数值为处理器判断目标数据块是否发生回退时,M个第一数据块对应的计数值。Performing a logical operation by using a first count value of the counter and a first MAC corresponding to each first data block, respectively, to obtain M first values corresponding to the M first data blocks; wherein, the first count value is processed The count value corresponding to the M first data blocks when the logic operation is performed; the M first value and the second MAC corresponding to the M first values are encrypted to obtain the second data block, and the second data is obtained The block is stored in the first memory; determining, according to the second data block and the second count value of the counter, whether the target data block is backed off; wherein the target data block is any one of the M first data blocks; the second count value is The processor determines whether the target data block is backed up, and the count value corresponding to the M first data blocks.
上述的终端设备可以用于执行该数据处理方法,对应内容和效果相同,在此不再赘述。The foregoing terminal device can be used to execute the data processing method, and the corresponding content and effect are the same, and details are not described herein again.
第五方面,本申请提供一种终端设备,包括:安全芯片和耦合至安全芯片的第一存储器,其中,安全芯片包括:处理器、第二存储器和非易失性存储器NVM;NVM,用于对加密数据块的更新次数进行计数,得到计数值,NVM的计数值不可回退;处理器用于:利用明文数据块的消息认证码MAC和NVM的第一计数值,得到明文数据块对应的第一数值;第一计数值是处理器计算第一数值时,明文数据块对应的计数值;对第一数值和明文数据块加密,得到加密数据块,并将加密数据块存储至第一存储器;处理器,还用于根据加密数据块和NVM的第二计数值,判断加密数据块是否发生回退;其中,第二计数值与加密数据块对应;第二计数值为处理器判断加密数据块是否发生回退时,加密数据块对应的计数值。In a fifth aspect, the application provides a terminal device, including: a security chip and a first memory coupled to the security chip, wherein the security chip includes: a processor, a second memory, and a non-volatile memory NVM; Counting the number of times of updating the encrypted data block to obtain a count value, and the count value of the NVM is not retractable; the processor is configured to: obtain the first corresponding to the plaintext data block by using the message authentication code MAC of the plaintext data block and the first count value of the NVM a value; the first count value is a count value corresponding to the plaintext data block when the processor calculates the first value; encrypting the first value and the plaintext data block to obtain an encrypted data block, and storing the encrypted data block in the first memory; The processor is further configured to determine, according to the encrypted data block and the second count value of the NVM, whether the encrypted data block is rolled back; wherein the second count value corresponds to the encrypted data block; and the second count value is the processor determines the encrypted data block. Whether the count value corresponding to the encrypted data block is generated when the rollback occurs.
本申请中,相当于在现有的SE芯片中增加了一个小容量(只用于计数)的NVM,因此,相对于现有技术增加专用Secure Flash。本申请提供的终端设备可以降低成本以及布板复杂度。In the present application, it is equivalent to adding a small capacity (for counting only) NVM to an existing SE chip, and therefore, dedicated Secure Flash is added to the prior art. The terminal device provided by the present application can reduce cost and layout complexity.
可选地,处理器具体用于:对第二计数值和明文数据块的MAC,采用与计算第一数值相同的算法计算明文数据块的第二数值;根据第一数值和第二数值判断明文数据块是否发生回退。Optionally, the processor is specifically configured to: calculate, by using the same algorithm as calculating the first value, a second value of the plaintext data block for the second count value and the MAC of the plaintext data block; and determining the plaintext according to the first value and the second value Whether the data block has rolled back.
可选地,该终端设备还包括:发送器;处理器具体用于:当第一数值和第二数值相同时,确定明文数据块未发生回退;当第一数值和第二数值不相同时,更新一次第二计数值,得到第三计数值,对第三计数值和MAC,采用与计算第一数值相同的算法计算明文数据块的第三数值;当第一数值和第三数值不相同时,确定明文数据块发生回退,并触发发送器发送提示消息,提示消息用于提示明文数据块发生回退。Optionally, the terminal device further includes: a transmitter, where the processor is configured to: when the first value and the second value are the same, determine that the plaintext data block does not roll back; when the first value and the second value are different Updating the second count value to obtain a third count value, and calculating a third value of the plaintext data block by using the same algorithm as calculating the first value for the third count value and the MAC; when the first value and the third value are not At the same time, it is determined that the plaintext data block is rolled back, and the sender is triggered to send a prompt message, and the prompt message is used to prompt the plaintext data block to roll back.
本申请中在保持现有芯片架构不变的情况下,或者相当于在现有的SE芯片中增加了一个小容量(只用于计数)的计数器时,可以有效的判断目标数据块是否发生回退。In the present application, when the existing chip architecture is kept unchanged, or when a counter of a small capacity (for counting only) is added to the existing SE chip, it is possible to effectively judge whether the target data block is generated back. Retreat.
可选地,处理器还用于:当第一数值和第三数值相同时,确定安全芯片发生掉电。Optionally, the processor is further configured to: when the first value and the third value are the same, determine that the security chip is powered off.
即终端设备可以根据第一数值和目标数据块的第三数值判断安全芯片是否发生掉电,进而提高终端设备的可靠性。That is, the terminal device can determine whether the security chip is powered off according to the first value and the third value of the target data block, thereby improving the reliability of the terminal device.
可选地,处理器具体用于:解密第一数值,得到明文数据块的MAC和NVM的第一计数值;根据第一计数值和第二计数值判断明文数据块是否发生回退。Optionally, the processor is specifically configured to: decrypt the first value, obtain a first count value of the MAC and NVM of the plaintext data block; and determine, according to the first count value and the second count value, whether the plaintext data block is rolled back.
可选地,还包括:发送器;相应的,处理器具体用于:当第一计数值和第二计数值相同时,确定明文数据块未发生回退;当第一计数值和第二计数值不相同时,更次一次第二计数值得到第三计数值;当第一计数值和第三计数值不相同时,确定明文数据块发生回退,并触发发送器发送提示消息,提示消息用于提示明文数据块发生回退。Optionally, the method further includes: a transmitter, and correspondingly, the processor is configured to: when the first count value and the second count value are the same, determine that the plaintext data block does not roll back; when the first count value and the second count When the values are different, the second count value is obtained by the third time; when the first count value and the third count value are different, it is determined that the plaintext data block is rolled back, and the sender is triggered to send the prompt message, and the prompt message is sent. Used to prompt the plaintext data block to roll back.
本申请中在保持现有芯片架构不变的情况下,或者相当于在现有的SE芯片中增加了一个小容量(只用于计数)的计数器时,可以有效的判断目标数据块是否发生回退。In the present application, when the existing chip architecture is kept unchanged, or when a counter of a small capacity (for counting only) is added to the existing SE chip, it is possible to effectively judge whether the target data block is generated back. Retreat.
可选地,处理器还用于:当第一计数值和第三计数值相同时,确定安全芯片发生掉电。Optionally, the processor is further configured to: when the first count value and the third count value are the same, determine that the security chip is powered off.
即终端设备可以根据第一计数值和第三计数值判断安全芯片是否发生掉电,进而提高终端设备的可靠性。That is, the terminal device can determine whether the security chip is powered off according to the first count value and the third count value, thereby improving the reliability of the terminal device.
第六方面,本申请提供一种处理器,该处理器为第五方面或者第五方面的可选方式中的处理器。对应内容和效果在此不再赘述。In a sixth aspect, the present application provides a processor, which is the processor in the fifth aspect or the optional aspect of the fifth aspect. The corresponding content and effects will not be described here.
第七方面,本申请提供一种芯片,包括如第五方面或者第五方面的可选方式中的非易失性存储器NVM和如第五方面或者第五方面的可选方式中的处理器。对应内容和效果在此不再赘述。In a seventh aspect, the present application provides a chip, comprising the non-volatile memory NVM in the fifth aspect or the alternative aspect of the fifth aspect, and the processor in the fifth aspect or the alternative aspect of the fifth aspect. The corresponding content and effects will not be described here.
第八方面,本申请提供一种数据处理方法,方法应用于处理器,处理器包含于安全芯片,安全芯片还包括:第二存储器和非易失性存储器NVM;安全芯片与第一存储器耦合连接;NVM,用于对加密数据块的更新次数进行计数,得到计数值,NVM的计数值不可回退;方法包括:In an eighth aspect, the present application provides a data processing method, where the method is applied to a processor, where the processor is included in a security chip, the security chip further includes: a second memory and a non-volatile memory NVM; and the security chip is coupled to the first memory NVM is used to count the number of updates of the encrypted data block to obtain a count value, and the count value of the NVM cannot be rolled back; the method includes:
利用明文数据块的消息认证码MAC和NVM的第一计数值,得到明文数据块对应的第一数值;第一计数值是处理器计算第一数值时,明文数据块对应的计数值;对第一数值和明文数据块加密,得到加密数据块,并将加密数据块存储至第一存储器;根据加密数据块和NVM的第二计数值,判断加密数据块是否发生回退;其中,第二计数值与加密数据块对应;第二计数值为处理器判断加密数据块是否发生回退时,加密数据块对应的计数值。Using the first authentication value of the message authentication code MAC and the NVM of the plaintext data block, the first value corresponding to the plaintext data block is obtained; the first count value is a count value corresponding to the plaintext data block when the processor calculates the first value; Encrypting a block of values and a plaintext block to obtain an encrypted block of data, and storing the block of encrypted data in the first memory; determining whether the block of the encrypted block is rolled back according to the second count value of the encrypted block and the NVM; wherein, the second count The value corresponds to the encrypted data block; the second count value is a count value corresponding to the encrypted data block when the processor determines whether the encrypted data block is rolled back.
上述第五方面或者第五方面的可选方式中的终端设备可以用于执行该数据处理方法,对应内容和效果相同,在此不再赘述。The terminal device in the foregoing fifth aspect or the optional mode in the fifth aspect may be used to execute the data processing method, and the corresponding content and effect are the same, and details are not described herein again.
第九方面,本申请提供一种计算机存储介质,用于储存为上述终端设备所用的计算机软件指令,其包含用于执行上述第四方面所涉及的程序。In a ninth aspect, the present application provides a computer storage medium for storing computer software instructions for use in the terminal device, including a program for performing the fourth aspect described above.
第十方面,本申请提供一种计算机程序产品,其包含指令,当所述计算机程序被计算机所执行时,该指令使得计算机执行上述第四方面及可选方法中终端设备所执行的功能。In a tenth aspect, the application provides a computer program product comprising instructions which, when executed by a computer, cause the computer to perform the functions performed by the terminal device in the fourth aspect and the optional method described above.
第十一方面,本申请实施例提供一种计算机存储介质,用于储存为上述终端设备所用的计算机软件指令,其包含用于执行上述第八方面所设计的程序。In an eleventh aspect, the embodiment of the present application provides a computer storage medium for storing computer software instructions used by the terminal device, which includes a program designed to execute the foregoing eighth aspect.
第十二方面,本申请提供一种计算机程序产品,其包含指令,当所述计算机程序被计算机所执行时,该指令使得计算机执行上述第八方面及可选方法中终端设备所执行的功能。In a twelfth aspect, the present application provides a computer program product comprising instructions which, when executed by a computer, cause the computer to perform the functions performed by the terminal device in the eighth aspect and the optional method described above.
本申请提供一种终端设备及数据处理方法。安全芯片和耦合至安全芯片的第一存储器,其中,该安全芯片包括:处理器、第二存储器和计数器。第一存储器,用于存储M个第一数据块,其中,每个第一数据块是通过对明文数据块以及与该明文数据块对应的第一MAC进行加密运算得到的。计数器,用于对M个第一数据块的更新次数进行计数,得到计数值,计数器的计数值不可回退。处理器用于:分别利用计数器的第一计数值以及每个第一数据块对应的第一MAC进行逻辑运算,得到与M个第一数据块一一对应的M个第一数值; 其中,第一计数值为处理器进行逻辑运算时,M个第一数据块对应的计数值。对M个第一数值和与M个第一数值对应的第二MAC进行加密运算,得到第二数据块,并将第二数据块存储至第一存储器。根据第二数据块以及计数器的第二计数值,判断目标数据块是否发生回退;其中,目标数据块是M个第一数据块的任一个;第二计数值为处理器判断目标数据块是否发生回退时,M个第一数据块对应的计数值。其中该计数器可以是OTP或者是SE芯片中的NVM等计数器。当该计数器是OTP时,即本申请在保持现有芯片架构不变的情况下,具有数据防回退能力。相对于现有技术增加专用Secure Flash。本申请提供的终端设备可以降低成本以及布板复杂度。当该计数器是SE芯片中的NVM或者其他计数器时,相当于在现有的SE芯片中增加了一个小容量(只用于计数)的计数器,因此,相对于现有技术增加专用Secure Flash。本申请提供的终端设备可以降低成本以及布板复杂度。The application provides a terminal device and a data processing method. A security chip and a first memory coupled to the security chip, wherein the security chip includes: a processor, a second memory, and a counter. The first memory is configured to store M first data blocks, wherein each first data block is obtained by performing an encryption operation on the plaintext data block and the first MAC corresponding to the plaintext data block. The counter is used to count the number of updates of the M first data blocks to obtain a count value, and the counter value of the counter cannot be rolled back. The processor is configured to: perform a logic operation by using a first count value of the counter and a first MAC corresponding to each first data block, to obtain M first values corresponding to the M first data blocks; wherein, the first The count value is the count value corresponding to the M first data blocks when the processor performs a logical operation. Encrypting the M first values and the second MAC corresponding to the M first values to obtain a second data block, and storing the second data block in the first memory. Determining whether the target data block is backed off according to the second data block and the second count value of the counter; wherein the target data block is any one of the M first data blocks; and the second count value is determining whether the target data block is The count value corresponding to the M first data blocks when the rollback occurs. The counter may be an OTP or a counter such as an NVM in the SE chip. When the counter is an OTP, the application has data anti-return capability while maintaining the existing chip architecture. Add dedicated Secure Flash to the prior art. The terminal device provided by the present application can reduce cost and layout complexity. When the counter is an NVM or other counter in the SE chip, it is equivalent to adding a small-capacity (for counting only) counter to the existing SE chip, and therefore, dedicated Secure Flash is added with respect to the prior art. The terminal device provided by the present application can reduce cost and layout complexity.
附图说明DRAWINGS
图1为现有技术提供的终端设备的芯片的结构示意图;1 is a schematic structural diagram of a chip of a terminal device provided by the prior art;
图2为本申请一实施例提供的终端设备的结构示意图;FIG. 2 is a schematic structural diagram of a terminal device according to an embodiment of the present disclosure;
图3A为本申请一实施例提供的第一存储器的二级存储示意图;3A is a schematic diagram of secondary storage of a first memory according to an embodiment of the present disclosure;
图3B为本申请另一实施例提供的第一存储器的二级存储示意图;FIG. 3B is a schematic diagram of secondary storage of a first memory according to another embodiment of the present application; FIG.
图4为本申请一实施例提供的第一存储器的存储区域示意图;FIG. 4 is a schematic diagram of a storage area of a first memory according to an embodiment of the present disclosure;
图5为本申请一实施例提供的一种数据处理方法的流程图;FIG. 5 is a flowchart of a data processing method according to an embodiment of the present application;
图6为本申请一实施例提供的一种终端设备的示意图;FIG. 6 is a schematic diagram of a terminal device according to an embodiment of the present disclosure;
图7为本申请一实施例提供的第一存储器的一级存储示意图;FIG. 7 is a schematic diagram of a primary storage of a first memory according to an embodiment of the present disclosure;
图8为本申请另一实施例提供的一种数据处理方法的流程图。FIG. 8 is a flowchart of a data processing method according to another embodiment of the present application.
具体实施方式Detailed ways
随着终端技术的不断发展,用户对终端设备的移动支付、移动金融、汽车钥匙等承载百万级财产的安全应用也逐步有了需求。未来终端设备可能具备银行卡,公交卡,钥匙,身份证的功能。实现这些功能不能只依赖软件应用(Application,App),还需要终端设备的芯片提供硬件级的支持。With the continuous development of terminal technologies, users have gradually demanded the security applications of mobile devices such as mobile payment, mobile finance, and car keys that carry millions of assets. Future terminal equipment may have the functions of bank card, bus card, key, and ID card. Implementing these functions cannot rely solely on software applications (Applications, App), but also requires hardware support at the end device's chip.
现有技术中,在终端设备的AP SOC中集成SE芯片,实现移动支付和多业务公用平台。如图1所示,SE芯片包括OTP、ROM以及RAM,对于系统程序、应用程序和应用数据存储在eMMC/UFS(非易失存储器(Non-Volatile Memory,NVM))的RPMB中。当系统运行时需要将系统程序、应用程序和应用数据从RPMB中读取到内部RAM中运行。SE的安全级别是非常高的,对于NVM的数据要求,主要有以下几个:In the prior art, an SE chip is integrated in an AP SOC of a terminal device to implement a mobile payment and multi-service public platform. As shown in FIG. 1, the SE chip includes an OTP, a ROM, and a RAM, and the system program, application, and application data are stored in an EMMB of eMMC/UFS (Non-Volatile Memory (NVM)). System programs, application and application data need to be read from the RPMB to run in internal RAM when the system is running. The security level of SE is very high. For NVM data requirements, there are mainly the following:
具有抵抗非易失存储的数据泄露的保护能力(confidentiality)。Has a confidence in resisting data leakage from non-volatile storage.
具有抵抗非易失存储的抗干扰的保护能力(integrity)。It has an anti-interference protection against non-volatile storage.
具有抵抗非易失存储的抗修改能力或者具有防回退能力(integrity&anti-rollback)。It has anti-modification ability against non-volatile storage or has anti-return capability (integrity & anti-rollback).
现有技术中,在抵抗非易失存储的数据泄露的保护能力、以及抵抗非易失存储的抗干扰的保护能力方面,已经很成功了。现有技术中使用片外RPMB机制进行数据防回退。In the prior art, it has been very successful in resisting the protection of data leakage of nonvolatile storage and the protection against the interference of nonvolatile storage. In the prior art, an off-chip RPMB mechanism is used for data anti-backoff.
由于片外RPMB是外部UFS/eMMC存储器件厂商提供的分区,其防回退的能力虽有, 但安全等级没有经过检查认证;而且由于成本,片外RPMB的防回退能力暂没有哪个eMMC/UFS存储器件厂商实际能做到EAL4+安全防护等级以上;故直接依赖RPMB区域的防回退是无法达到EAL4+安全防护等级。Since the off-chip RPMB is a partition provided by an external UFS/eMMC storage device manufacturer, its anti-return capability is available, but the security level has not been checked and verified; and because of the cost, the off-chip RPMB anti-return capability does not have any eMMC/ UFS storage device manufacturers can actually achieve EAL4+ security protection level or above; therefore, relying on the anti-return of RPMB area can not achieve EAL4+ security protection level.
目前存在一种EAL5+安全防护的专用安全闪存(Secure Flash)器件。SE芯片通过自定义的接口与专用Secure Flash连接。但是如果在终端设备上增加该专用Secure Flash,势必造成终端设备成本的增加,并且造成终端设备的布板复杂度较高。There is currently a dedicated Secure Flash device for EAL5+ security protection. The SE chip is connected to a dedicated Secure Flash via a custom interface. However, if the dedicated Secure Flash is added to the terminal device, the cost of the terminal device is inevitably increased, and the layout complexity of the terminal device is high.
因此,为了解决现有技术中由于增加专用Secure Flash,而造成终端设备成本增加以及布板复杂度较高的问题。本申请提供一种终端设备及数据处理方法。Therefore, in order to solve the problem in the prior art that the cost of the terminal device increases and the layout complexity is high due to the addition of the dedicated Secure Flash. The application provides a terminal device and a data processing method.
一种情况,本申请可以基于如图1所示的芯片架构,无需增加专用Secure Flash,也无需要eMMC/UFS存储器件厂商增加安全防护RPMB达到EAL5+认证需求。即基于当前如图1所示的芯片架构,SE芯片就可以满足EAL5+在NVM的安全要求和认证。In one case, the present application can be based on the chip architecture shown in FIG. 1 without adding dedicated Secure Flash, and there is no need for eMMC/UFS storage device manufacturers to increase security protection RPMB to meet EAL5+ certification requirements. That is, based on the current chip architecture shown in Figure 1, the SE chip can meet the security requirements and certification of the EAL5+ in the NVM.
目前,NVM的访问基本单元是数据块,SE芯片中的处理器需要对明文数据块和该明文数据块对应的MAC采用加密算法得到加密数据块。并将该加密数据块存入RPMB中。其中加密算法可以采用现有技术中的高级加密标准(Advanced Encryption Standard,AES)256等。处理器针对每个明文数据块采用的加密密钥都不相同,例如加密密钥和明文数据块的存储地址关联。处理器可以采用SHA256-hMAC,AES-CMAC等MAC算法计算明文数据块对应的MAC。At present, the access basic unit of the NVM is a data block, and the processor in the SE chip needs to obtain an encrypted data block by using an encryption algorithm for the plaintext data block and the MAC corresponding to the plaintext data block. And the encrypted data block is stored in the RPMB. The encryption algorithm may be an Advanced Encryption Standard (AES) 256 or the like in the prior art. The encryption key used by the processor for each plaintext block is different, for example, the encryption key is associated with the storage address of the plaintext block. The processor can calculate the MAC corresponding to the plaintext data block by using a MAC algorithm such as SHA256-hMAC or AES-CMAC.
本申请的实现原理是:利用SE芯片中的OTP实现数据防回退功能。OTP的比特位是一次性逐1比特进行编程的,初始每比特为0,通过编程可以写为1,故通过编程为1的比特数会越来越多,且无法回退。具体地,如果要实现数据防回退的功能,可以将OTP的计数值与明文数据块对应的MAC进行逻辑运算。如果明文数据块1发生了回退,则处理器读取到的是回退的明文数据块(明文数据块2)对应的MAC以及该明文数据块2对应的OTP的计数值进行逻辑运算得到的结果。因此,当处理器对OTP当前的计数值与明文数据块2对应的MAC进行逻辑运算得到的结果,一定与明文数据块2对应的MAC以及该明文数据块2对应的OTP的计数值进行逻辑运算得到的结果不同。也就是说,由于明文数据块2对应的结果是利用之前的OTP计数计算的,当明文数据块2更新为明文数据块1时,当前的OTP的计数值一定增加了,基于此。处理器可以确定明文数据块1发生了数据回退。The implementation principle of the present application is: implementing the data anti-backoff function by using the OTP in the SE chip. The OTP bit is programmed one bit at a time, starting with 0 bits per bit, and can be written as 1 by programming, so the number of bits programmed to 1 will be more and more, and cannot be rolled back. Specifically, if the data anti-backoff function is to be implemented, the count value of the OTP can be logically operated with the MAC corresponding to the plaintext data block. If the plaintext data block 1 is rolled back, the processor reads the MAC address corresponding to the back-off plaintext data block (plaintext data block 2) and the count value of the OTP corresponding to the plaintext data block 2 for logical operation. result. Therefore, when the processor performs a logical operation on the current count value of the OTP and the MAC corresponding to the plaintext data block 2, the logical value of the MAC corresponding to the plaintext data block 2 and the OTP corresponding to the plaintext data block 2 must be logically operated. The results obtained are different. That is, since the result corresponding to the plaintext data block 2 is calculated using the previous OTP count, when the plaintext data block 2 is updated to the plaintext data block 1, the current OTP count value must be increased, based on this. The processor can determine that a data rollback has occurred in plaintext block 1.
由于OTP总的比特位或者容量有限,因此需要多个明文数据块共用一个计数值。但是,当多个明文数据块共用一个计数值时,当更新其中任一个明文数据块时,该计数值就要更新一次,就要对更新后的计数值与各个明文数据块对应的MAC进行一次逻辑运算。这样势必导致运算量的增加,从而造成对硬件资源的消耗。Since the total bit size or capacity of the OTP is limited, it is required that a plurality of plaintext data blocks share a single count value. However, when a plurality of plaintext data blocks share a count value, when updating any one of the plaintext data blocks, the count value is updated once, and the updated count value and the MAC corresponding to each plaintext data block are once performed. logic operation. This will inevitably lead to an increase in the amount of computation, resulting in the consumption of hardware resources.
由于通常数据块的长度远远大于MAC的长度(MAC的长度通常为16字节或32字节,而数据块可以设置到几百字节,甚至更大)。因此,基于上述分析,在本申请中第一存储器可以采用二级存储的方式。下面将结合该二级存储介绍本申请提供的一种终端设备及数据处理方法。Since the length of the data block is usually much larger than the length of the MAC (the length of the MAC is usually 16 bytes or 32 bytes, and the data block can be set to several hundred bytes or even larger). Therefore, based on the above analysis, the first memory in the present application can adopt the method of secondary storage. A terminal device and a data processing method provided by the present application will be described below in conjunction with the secondary storage.
需要说明的是,为了满足业务要求,上述的OTP的计数功能还可以通过NVM来代替。该NVM设置在SE芯片内部。该NVM仅仅用于计数,因此它的存储容量比较小。比如:该NVM的容量可以是4字节,4字节可以是实现40亿次的计数。It should be noted that, in order to meet the service requirements, the above-mentioned OTP counting function can also be replaced by NVM. The NVM is set inside the SE chip. This NVM is only used for counting, so its storage capacity is relatively small. For example, the capacity of the NVM can be 4 bytes, and the 4 bytes can be a count of 4 billion times.
基于上述内容,本申请提供一种终端设备。具体地,图2为本申请一实施例提供的终端设备的结构示意图。如图2所示,该终端设备包括:安全芯片21和耦合至安全芯片21的第一存储器22,其中,该安全芯片21包括:处理器211、第二存储器212和计数器213。Based on the above content, the present application provides a terminal device. Specifically, FIG. 2 is a schematic structural diagram of a terminal device according to an embodiment of the present application. As shown in FIG. 2, the terminal device includes a security chip 21 and a first memory 22 coupled to the security chip 21, wherein the security chip 21 includes a processor 211, a second memory 212, and a counter 213.
第一存储器22,用于存储M个第一数据块,其中,每个第一数据块是通过对明文数据块以及与该明文数据块对应的第一消息认证码(Message Authentication Code,MAC)进行加密运算得到的,M为大于等于1的整数。The first memory 22 is configured to store M first data blocks, where each first data block is performed by using a plaintext data block and a first message authentication code (MAC) corresponding to the plaintext data block. Obtained by the encryption operation, M is an integer greater than or equal to 1.
计数器213,用于对M个第一数据块的更新次数进行计数,得到计数值,计数器213的计数值不可回退。The counter 213 is configured to count the number of updates of the M first data blocks to obtain a count value, and the count value of the counter 213 cannot be rolled back.
处理器211用于:分别利用计数器213的第一计数值以及每个第一数据块对应的第一MAC进行逻辑运算,得到与M个第一数据块一一对应的M个第一数值;其中,第一计数值为处理器211进行逻辑运算时,M个第一数据块对应的计数值。对M个第一数值和与M个第一数值对应的第二MAC进行加密运算,得到第二数据块,并将第二数据块存储至第一存储器22。根据第二数据块以及计数器213的第二计数值,判断目标数据块是否发生回退;其中,目标数据块是M个第一数据块的任一个;第二计数值为处理器211判断目标数据块是否发生回退时,M个第一数据块对应的计数值。The processor 211 is configured to: perform a logical operation by using a first count value of the counter 213 and a first MAC corresponding to each first data block, to obtain M first values that are in one-to-one correspondence with the M first data blocks; The first count value is a count value corresponding to the M first data blocks when the processor 211 performs a logic operation. Encrypting the M first values and the second MAC corresponding to the M first values to obtain a second data block, and storing the second data block in the first memory 22. Determining whether the target data block is backed off according to the second data block and the second count value of the counter 213; wherein the target data block is any one of the M first data blocks; the second count value is the processor 211 determining the target data. The count value corresponding to the M first data blocks when the block is rolled back.
具体地,上述M个第一数据块与上述第二数据块对应。第一存储器用于存储M个第一数据块和对应的第二数据块。即第一数据块采用二级存储方式。图3A为本申请一实施例提供的第一存储器的二级存储示意图。如图3A所示,第一存储器存储了M个第一数据块。M个第一数据块分别是第一数据块1,第一数据块2……第一数据块M。第一存储器还存储了M个第一数据块对应的第二数据块,该第二数据块是处理器211对第一数据块1的第一数值、第一数据块2的第一数值……第一数据块M的第一数值,以及M个第一数值的第二MAC加密得到的。Specifically, the M first data blocks correspond to the second data block. The first memory is configured to store M first data blocks and corresponding second data blocks. That is, the first data block adopts a secondary storage mode. FIG. 3A is a schematic diagram of secondary storage of a first memory according to an embodiment of the present application. As shown in FIG. 3A, the first memory stores M first data blocks. The M first data blocks are a first data block 1, a first data block 2, ... a first data block M, respectively. The first memory further stores a second data block corresponding to the M first data blocks, where the second data block is a first value of the first data block 1 by the processor 211, and a first value of the first data block 2... The first value of the first data block M and the second MAC of the first value are encrypted.
本申请中,处理器计算明文数据块的第一MAC可以采用现有技术中的SHA256-hMAC,AES-CMAC等MAC算法。本申请对此不做限制。本申请计算M个第一数值的第二MAC也可以采用现有技术中的SHA256-hMAC,AES-CMAC等MAC算法。其中这M个第一数值可以看作一个整体,可以被理解为一个数据块,对该数据块可以采用现有的MAC算法。本申请对此不做限制。In this application, the processor calculates the first MAC of the plaintext data block, and may adopt a MAC algorithm such as SHA256-hMAC or AES-CMAC in the prior art. This application does not limit this. The second MAC that calculates the M first values in the present application may also adopt a MAC algorithm such as SHA256-hMAC or AES-CMAC in the prior art. The M first value can be regarded as a whole and can be understood as a data block, and an existing MAC algorithm can be used for the data block. This application does not limit this.
进一步地,本申请中处理器对明文数据块以及与该明文数据块对应的第一MAC进行加密运算,具体采用的加密算法可以是现有的AES 256等算法。同样的,本申请中处理器也可以对M个第一数值和M个第一数值对应的第二MAC采用现有的AES 256等算法。本申请对此不做限制。Further, in the application, the processor performs encryption operation on the plaintext data block and the first MAC corresponding to the plaintext data block, and the specific encryption algorithm may be an existing AES 256 algorithm. Similarly, in the present application, the processor may also use an existing algorithm such as AES 256 for the second MAC corresponding to the M first value and the M first values. This application does not limit this.
更进一步地,处理器利用计数器213的第一计数值以及每个第一数据块对应的第一MAC进行逻辑运算,得到与M个第一数据块一一对应的M个第一数值。该逻辑运算可以是加法运算、减法运算、乘法运算、除法运算或者是计算机领域中的“与”运算、“或”运算、“异或”运算以及一些高级算法等。只要计数器213的第一计数值可以参与运算即可,本申请对此不做限制。Further, the processor performs a logical operation by using the first count value of the counter 213 and the first MAC corresponding to each first data block to obtain M first values that are in one-to-one correspondence with the M first data blocks. The logical operation may be an addition operation, a subtraction operation, a multiplication operation, a division operation, or an AND operation, an OR operation, an exclusive OR operation, and some advanced algorithms in the computer field. As long as the first count value of the counter 213 can participate in the operation, the present application does not limit this.
需要说明的是,由于计数器213,用于对M个第一数据块的更新次数进行计数,得到计数值。因此,M个第一数据块中的任意一个第一数据块发生更新后,M个第一数据块对应的计数值都会更新,例如:M个第一数据块中一个第一数据块发生更新,则对应的计数 值加1。因此,第一计数值为处理器211进行逻辑运算时,M个第一数据块对应的计数值。这里的第一计数值一定是进行最近一次逻辑运算时,得到的最新的第一计数值。假设存在两个第一数据块。它们分别是第一数据块1和第一数据块2。当更新第一数据块1时,该第一数据块1对应的第一计数值更新一次得到新的第一计数值。通过新的第一计数值以及更新后的第一数据块1的第一MAC计算新的第一数值。同样的,由于第一数据块2的第一数据块1对应相同的计数值。因此,需要通过新的第一计数值以及更新后的第一数据块2的第一MAC计算第一数据块2对应的新的第一数值。这种情况下,之前的第一计数值被更新为最新的第一计数值。It should be noted that the counter 213 is used to count the number of updates of the M first data blocks to obtain a count value. Therefore, after any one of the M first data blocks is updated, the count values corresponding to the M first data blocks are updated, for example, one of the first data blocks of the M first data blocks is updated. Then the corresponding count value is increased by 1. Therefore, the first count value is a count value corresponding to the M first data blocks when the processor 211 performs a logic operation. The first count value here must be the latest first count value obtained when the most recent logical operation is performed. Suppose there are two first data blocks. They are the first data block 1 and the first data block 2, respectively. When the first data block 1 is updated, the first count value corresponding to the first data block 1 is updated once to obtain a new first count value. A new first value is calculated by the new first count value and the updated first MAC of the first data block 1. Likewise, since the first data block 1 of the first data block 2 corresponds to the same count value. Therefore, it is necessary to calculate a new first value corresponding to the first data block 2 by the new first count value and the updated first MAC of the first data block 2. In this case, the previous first count value is updated to the latest first count value.
值得一提的是,本申请中涉及的更新第一数据块,表示存储新的第一数据块,并删除该新的第一数据块对应的历史第一数据块。It is worth mentioning that updating the first data block involved in the present application means storing a new first data block, and deleting the historical first data block corresponding to the new first data block.
假设目标数据块A发生回退,且假设目标数据块回退后的数据块是第一数据块B,则处理器211读取到的第一数值实际上是第一数据块B的第一MAC和该第一数据块B对应的第一计数值计算得到。假设其他第一数据块没有更新,则第二计数值应该是该第一数据块B对应的第一计数值更新一次后得到的计数值。这种情况下,处理器211通过第二计数值和第一数据块B的第一MAC计算第二数值。由于第一数值和第二数值不相同,表示目标数据块A有可能发生回退。考虑到有可能是SE芯片发生掉电造成第一数值和第二数值不同,例如:当SE芯片发生掉电时,第二计数值有可能还是前一次的第一计数值。因此,即使目标数据块A未发生回退,这种情况下,处理器211读取到的第一数值是目标数据块A的第一MAC和该目标数据块A对应的第一计数值(该第一计数值已经是最新的第一计数值)计算得到。而处理器211通过第二计数值(前一次的第一计数值)和目标数据块A的第一MAC计算第二数值。因此这种情况下,第一数值和第二数值也有可能不同,造成第一数值和第二数值不同的原因,并不是目标数据块A发生了回退。而是SE芯片发生了掉电。Assuming that the target data block A is rolled back, and the data block after the target data block is backed up is the first data block B, the first value read by the processor 211 is actually the first MAC of the first data block B. The first count value corresponding to the first data block B is calculated. Assuming that the other first data block is not updated, the second count value should be the count value obtained after the first count value corresponding to the first data block B is updated once. In this case, the processor 211 calculates the second value by the second count value and the first MAC of the first data block B. Since the first value and the second value are not the same, it indicates that the target data block A may fall back. Considering that it is possible that the SE chip is powered down, the first value and the second value are different. For example, when the SE chip is powered off, the second count value may be the previous first count value. Therefore, even if the target data block A does not fall back, in this case, the first value read by the processor 211 is the first MAC of the target data block A and the first count value corresponding to the target data block A (the The first count value is already the latest first count value) is calculated. The processor 211 calculates the second value by the second count value (previous first count value) and the first MAC of the target data block A. Therefore, in this case, the first value and the second value may also be different, and the reason why the first value and the second value are different is not that the target data block A has been retracted. Instead, the SE chip is powered down.
考虑到上述原因,进一步地,处理器211判断目标数据块是否发生回退具体可以采用如下方式:For the above reasons, further, the processor 211 determines whether the target data block is rolled back.
处理器211具体用于:对第二计数值和目标数据块对应的第一MAC,采用与计算目标数据块的第一数值相同的算法计算目标数据块的第二数值;根据目标数据块的第一数值和目标数据块的第二数值判断目标数据块是否发生回退。可选地,终端设备还包括:发送器;相应的,处理器211具体用于:当目标数据块的第一数值和目标数据块的第二数值相同时,确定目标数据块未发生回退;当目标数据块的第一数值和目标数据块的第二数值不相同时,更新一次第二计数值得到第三计数值,对第三计数值和目标数据块对应的第一MAC,采用与计算目标数据块的第一数值相同的算法计算目标数据块的第三数值;当目标数据块的第一数值和目标数据块的第三数值不相同时,确定目标数据块发生回退,并触发发送器发送提示消息,提示消息用于提示目标数据块发生回退。The processor 211 is specifically configured to: calculate, by using the same algorithm as the first value of the calculation target data block, a second value corresponding to the first value of the calculation target data block for the second count value and the first MAC corresponding to the target data block; according to the target data block A value and a second value of the target data block determine whether the target data block has rolled back. Optionally, the terminal device further includes: a transmitter; and correspondingly, the processor 211 is configured to: when the first value of the target data block and the second value of the target data block are the same, determine that the target data block does not fall back; When the first value of the target data block and the second value of the target data block are different, the second count value is updated to obtain a third count value, and the third count value and the first MAC corresponding to the target data block are used and calculated. An algorithm in which the first value of the target data block is the same calculates a third value of the target data block; when the first value of the target data block is different from the third value of the target data block, determining that the target data block is rolled back and triggering the sending The device sends a prompt message, and the prompt message is used to prompt the target data block to roll back.
可选地,处理器211还用于:当目标数据块的第一数值和目标数据块的第三数值相同时,确定安全芯片发生掉电。Optionally, the processor 211 is further configured to: when the first value of the target data block and the third value of the target data block are the same, determine that the security chip is powered off.
具体地,当计算第一数值使用的加法算法,则计算第二数值也需要采用加法算法,计算第三数值也需要采用加法算法。同样的,当计算第一数值使用的“异或”运算,则计算第二数值也需要采用“异或”运算,则计算第三数值也需要采用“异或”运算。Specifically, when calculating the addition algorithm used by the first value, the addition of the second value also requires the addition algorithm, and the calculation of the third value also requires the addition algorithm. Similarly, when calculating the XOR operation of the first value, the calculation of the second value also requires an exclusive OR operation, and the calculation of the third value also requires an exclusive OR operation.
进一步地,考虑到判断目标数据块是否发生回退通常应用在“黑客”入侵的场景下,因此,上述处理器211在判断目标数据块是否发生回退之前,通常,处理器211会获取到读取请求,处理器211根据该读取请求读取目标数据块。然后,处理器211判断目标数据块是否发生回退,发送器发送读取响应。当目标数据块未发生回退,则该读取响应用于指示读取成功。当目标数据块发生回退,则该读取响应即为上述的提示消息,该提示消息用于提示目标数据块发生回退。Further, in consideration of determining whether the target data block is rolled back, it is usually applied in a scenario of "hacker" intrusion. Therefore, before the processor 211 determines whether the target data block has been rolled back, the processor 211 usually acquires the read. Taking the request, the processor 211 reads the target data block according to the read request. Then, the processor 211 determines whether the target data block has rolled back, and the transmitter transmits a read response. When the target data block has not rolled back, the read response is used to indicate that the read was successful. When the target data block is rolled back, the read response is the above-mentioned prompt message, and the prompt message is used to prompt the target data block to roll back.
并且基于上述场景,所述对第二计数值和目标数据块对应的第一MAC,采用与计算目标数据块的第一数值相同的算法计算目标数据块的第二数值之前,处理器211将目标数据块读取至第二存储器,并解密目标数据块,得到该目标数据块的明文数据块和该目标数据块的第一MAC,且校验该第一MAC是否正确;当校验该第一MAC正确时,将目标数据块对应的第二数据块读取至第二存储器,并解密该第二数据块,得到该第二数据块的第二MAC,且校验第二MAC是否正确;当校验该第二MAC正确时,处理器211对第二计数值和目标数据块对应的第一MAC,采用与计算目标数据块的第一数值相同的算法计算目标数据块的第二数值。And based on the above scenario, before the second MAC value corresponding to the first data value of the target data block is calculated by using the same algorithm as the first value of the calculation target data block, the processor 211 targets the first MAC value corresponding to the target data block. Reading the data block to the second memory, and decrypting the target data block, obtaining a plaintext data block of the target data block and a first MAC of the target data block, and verifying whether the first MAC is correct; When the MAC is correct, the second data block corresponding to the target data block is read to the second memory, and the second data block is decrypted, the second MAC of the second data block is obtained, and the second MAC is verified to be correct; When the second MAC is verified to be correct, the processor 211 calculates the second value of the target data block by using the same algorithm as the first value of the calculation target data block for the second count value and the first MAC corresponding to the target data block.
处理器211判断目标数据块是否发生回退具体还可以采用比较计数值的方式:The processor 211 determines whether the target data block has a rollback. Specifically, the method of comparing the count values may be adopted:
可选地,处理器211具体用于:根据目标数据块的第一数值和目标数据块对应的第一MAC,得到第一计数值;根据第一计数值和所述第二计数值判断目标数据块是否发生回退。可选地,终端设备还包括:发送器。处理器211具体用于:当第一计数值和第二计数值相同时,确定目标数据块未发生回退;当第一计数值和第二计数值不相同时,更新一次第二计数值得到第三计数值;当第一计数值和第三计数值不相同时,确定目标数据块发生回退,并触发发送器发送提示消息,提示消息用于提示目标数据块发生回退。Optionally, the processor 211 is configured to: obtain a first count value according to the first value of the target data block and the first MAC corresponding to the target data block; and determine the target data according to the first count value and the second count value. Whether the block has rolled back. Optionally, the terminal device further includes: a transmitter. The processor 211 is specifically configured to: when the first count value and the second count value are the same, determine that the target data block does not fall back; when the first count value and the second count value are not the same, update the second count value to obtain The third count value; when the first count value and the third count value are different, determining that the target data block is rolled back, and triggering the sender to send a prompt message, the prompt message is used to prompt the target data block to roll back.
可选地,处理器211还用于:当第一计数值和第三计数值相同时,确定安全芯片发生掉电。Optionally, the processor 211 is further configured to: when the first count value and the third count value are the same, determine that the security chip is powered off.
具体地,假设计算第一数值采用的是加法运算,则处理器211根据目标数据块的第一数值和目标数据块对应的第一MAC得到第一计数值,所采用的算法为加法算法的逆运算,即采用减法算法计算第一计数值。同样的,假设计算第一数值采用的是乘法运算,则处理器211根据目标数据块的第一数值和目标数据块对应的第一MAC得到第一计数值,所采用的算法为乘法运算的逆运算,即采用除法运算计算第一计数值。Specifically, if the calculation of the first value is an addition operation, the processor 211 obtains the first count value according to the first value of the target data block and the first MAC corresponding to the target data block, and the algorithm used is the inverse of the addition algorithm. The operation, that is, the subtraction algorithm is used to calculate the first count value. Similarly, if the calculation of the first value is a multiplication operation, the processor 211 obtains the first count value according to the first value of the target data block and the first MAC corresponding to the target data block, and the algorithm used is the inverse of the multiplication operation. The operation, that is, the division operation is used to calculate the first count value.
进一步地,考虑到判断目标数据块是否发生回退通常应用在“黑客”入侵的场景下,因此,上述处理器211在判断目标数据块是否发生回退之前,通常,处理器211会获取到读取请求,处理器211根据该读取请求读取目标数据块。然后,处理器211判断目标数据块是否发生回退,发送器发送读取响应。当目标数据块未发生回退,则该读取响应用于指示读取成功。当目标数据块发生回退,则该读取响应即为上述的提示消息,该提示消息用于提示目标数据块发生回退。Further, in consideration of determining whether the target data block is rolled back, it is usually applied in a scenario of "hacker" intrusion. Therefore, before the processor 211 determines whether the target data block has been rolled back, the processor 211 usually acquires the read. Taking the request, the processor 211 reads the target data block according to the read request. Then, the processor 211 determines whether the target data block has rolled back, and the transmitter transmits a read response. When the target data block has not rolled back, the read response is used to indicate that the read was successful. When the target data block is rolled back, the read response is the above-mentioned prompt message, and the prompt message is used to prompt the target data block to roll back.
并且基于上述场景,所述根据目标数据块的第一数值和目标数据块对应的第一MAC,得到第一计数值之前,处理器211将目标数据块读取至第二存储器,并解密该目标数据块,得到该目标数据块对应的明文数据块和该目标数据块的第一MAC,且校验第一MAC是否正确;当校验该第一MAC正确时,将该目标数据块对应的第二数据块读取至第二存储器,并解密该第二数据块,得到该第二数据块的第二MAC和目标数据块对应的第一数值,且 校验该第二MAC是否正确;当校验该第二MAC正确时,处理器211根据目标数据块的第一数值和目标数据块对应的第一MAC,得到第一计数值。And based on the foregoing scenario, before the first value corresponding to the target data block and the first MAC corresponding to the target data block, before the first count value is obtained, the processor 211 reads the target data block to the second memory, and decrypts the target. Data block, obtaining a plaintext data block corresponding to the target data block and a first MAC of the target data block, and verifying whether the first MAC is correct; when verifying that the first MAC is correct, corresponding to the target data block Reading the second data block to the second memory, and decrypting the second data block, obtaining a first value corresponding to the second MAC and the target data block of the second data block, and verifying whether the second MAC is correct; When the second MAC is correct, the processor 211 obtains the first count value according to the first value of the target data block and the first MAC corresponding to the target data block.
可选地,上述的计数器可以是OTP或者NVM。其中该计数器的比特位可以被划分为多个位段,每个位段构成一个计数值,即该计数器在同一时刻可以包括多个计数值。每个计数值可以与至少一个第一数据块对应。或者说,该计数器的计数值与第二数据块一一对应。具体地,图3B为本申请另一实施例提供的第一存储器的二级存储示意图。如图3B所示,计时器的比特位被划分为3个位段,每个位段构成一个计算值。第一存储器存储了M1个第一数据块以及M1个第一数据块对应的第二数据块。第一存储器存储了M2个第一数据块以及M2个第一数据块对应的第二数据块。第一存储器存储了M3个第一数据块以及M3个第一数据块对应的第二数据块。Optionally, the above counter may be an OTP or an NVM. The bit of the counter can be divided into a plurality of bit segments, and each bit segment constitutes a count value, that is, the counter can include a plurality of count values at the same time. Each count value may correspond to at least one first data block. In other words, the counter value of the counter is in one-to-one correspondence with the second data block. Specifically, FIG. 3B is a schematic diagram of secondary storage of a first memory provided by another embodiment of the present application. As shown in FIG. 3B, the bits of the timer are divided into 3 bit segments, each of which constitutes a calculated value. The first memory stores M1 first data blocks and second data blocks corresponding to M1 first data blocks. The first memory stores M2 first data blocks and second data blocks corresponding to M2 first data blocks. The first memory stores M3 first data blocks and second data blocks corresponding to M3 first data blocks.
需要说明的是,计数器总的比特位是有限的。每个分区对应的位段可以根据应用写入次数要求设定。例如位段1用来存储应用程序,而应用程序的更新频率比较低,故可以将位段1的比特数设定的少一些。假设位段2用于存储应用数据,而应用数据的更新频率非常高。即应用数据的更新次数较多,因此可以将位段2的比特数设定多一些,例如:位段2可以达到几万比特,但存储空间可以小一点。同样的,还可以设定位段3的比特数。It should be noted that the total bits of the counter are limited. The bit segment corresponding to each partition can be set according to the application write times. For example, bit segment 1 is used to store the application, and the update frequency of the application is relatively low, so the number of bits in bit segment 1 can be set less. It is assumed that the bit segment 2 is used to store application data, and the update frequency of the application data is very high. That is, the application data is updated more frequently, so the number of bits of the bit segment 2 can be set more. For example, the bit segment 2 can reach tens of thousands of bits, but the storage space can be smaller. Similarly, the number of bits in bit segment 3 can also be set.
针对计数器的多位段,处理器可以采用第一存储器到多位段的的多个应用程序编程接口(Application Programming Interface,API)实现应用应用调用,也可以是直接指定。For the multi-bit segment of the counter, the processor may implement application application calls by using a plurality of application programming interfaces (APIs) of the first memory to the multi-bit segment, or may be directly specified.
通过这种多分区,多位段的存储方式,使得不同分区之间的计数值不受影响,从而可以降低终端设备的复杂度。Through this multi-partition, the storage mode of the multi-bit segment makes the count value between different partitions unaffected, thereby reducing the complexity of the terminal device.
综上,本申请提供一种终端设备,包括:安全芯片和耦合至安全芯片的第一存储器,其中,该安全芯片包括:处理器、第二存储器和计数器。第一存储器,用于存储M个第一数据块,其中,每个第一数据块是通过对明文数据块以及与该明文数据块对应的第一MAC进行加密运算得到的。计数器,用于对M个第一数据块的更新次数进行计数,得到计数值,计数器的计数值不可回退。处理器用于:分别利用计数器的第一计数值以及每个第一数据块对应的第一MAC进行逻辑运算,得到与M个第一数据块一一对应的M个第一数值;其中,第一计数值为处理器进行逻辑运算时,M个第一数据块对应的计数值。对M个第一数值和与M个第一数值对应的第二MAC进行加密运算,得到第二数据块,并将第二数据块存储至第一存储器。根据第二数据块以及计数器的第二计数值,判断目标数据块是否发生回退;其中,目标数据块是M个第一数据块的任一个;第二计数值为处理器判断目标数据块是否发生回退时,M个第一数据块对应的计数值。其中该计数器可以是OTP或者是SE芯片中的NVM等计数器。当该计数器是OTP时,即本申请在保持现有芯片架构不变的情况下,具有数据防回退能力。相对于现有技术增加专用Secure Flash。本申请提供的终端设备可以降低成本以及布板复杂度。当该计数器是SE芯片中的NVM或者其他计数器时,相当于在现有的SE芯片中增加了一个小容量(只用于计数)的计数器,因此,相对于现有技术增加专用Secure Flash。本申请提供的终端设备可以降低成本以及布板复杂度。In summary, the present application provides a terminal device, including: a security chip and a first memory coupled to the security chip, wherein the security chip includes: a processor, a second memory, and a counter. The first memory is configured to store M first data blocks, wherein each first data block is obtained by performing an encryption operation on the plaintext data block and the first MAC corresponding to the plaintext data block. The counter is used to count the number of updates of the M first data blocks to obtain a count value, and the counter value of the counter cannot be rolled back. The processor is configured to: perform a logical operation by using a first count value of the counter and a first MAC corresponding to each first data block, to obtain M first values corresponding to the M first data blocks; wherein, the first The count value is the count value corresponding to the M first data blocks when the processor performs a logical operation. Encrypting the M first values and the second MAC corresponding to the M first values to obtain a second data block, and storing the second data block in the first memory. Determining whether the target data block is backed off according to the second data block and the second count value of the counter; wherein the target data block is any one of the M first data blocks; and the second count value is determining whether the target data block is The count value corresponding to the M first data blocks when the rollback occurs. The counter may be an OTP or a counter such as an NVM in the SE chip. When the counter is an OTP, the application has data anti-return capability while maintaining the existing chip architecture. Add dedicated Secure Flash to the prior art. The terminal device provided by the present application can reduce cost and layout complexity. When the counter is an NVM or other counter in the SE chip, it is equivalent to adding a small-capacity (for counting only) counter to the existing SE chip, and therefore, dedicated Secure Flash is added with respect to the prior art. The terminal device provided by the present application can reduce cost and layout complexity.
可选地,处理器211还用于:将第三数据块更新为新的第一数据块,并更新一次第一计数值得到新的第一计数值;其中,第三数据块是M个第一数据块的任一个;分别对新的第一计数值和第二数据块对应的每个第一数据块对应的第一MAC,采用与计算第一数值相同的算法计算所述每个第一数据块的新的第一数值,并将每个第一数据块的第一数值更 新为新的第一数值;对第二数据块对应的M个新的第一数值和M个新的第一数值对应的新的第二MAC加密,得到新的第二数据块;并将第二数据块更新为新的第二数据块;计数器,还用于将第一计数值更新为新的第一计数值。Optionally, the processor 211 is further configured to: update the third data block to a new first data block, and update the first count value to obtain a new first count value; wherein the third data block is M Any one of the data blocks; respectively calculating, for each new first count value and the first MAC corresponding to each first data block corresponding to the second data block, using the same algorithm as calculating the first value a new first value of the data block, and updating the first value of each first data block to a new first value; the M new first value and the M new first corresponding to the second data block The new second MAC encryption corresponding to the value obtains a new second data block; and updates the second data block to a new second data block; the counter is further configured to update the first count value to the new first count value.
其中,这里假设第三数据块是上述M个第一数据块中第一个更新的第一数据块。后续更新第一数据块的方式与上述处理器211所采用的方法类似,在此不再赘述。Here, it is assumed here that the third data block is the first updated data block of the first of the M first data blocks. The manner of updating the first data block is similar to that of the foregoing processor 211, and details are not described herein again.
例如:M个第一数据块分别是第一数据块1,第一数据块2……第一数据块M。假设第一个更新的第一数据块是第一数据块1,该第一数据块1即为所述第三数据块。处理器将该第一数据块1更新为新的第一数据块1后,需要更新一次第一计数值得到新的第一计数值。由于第一计数值发生了变化,因此,新的第一数据块1、第一数据块2……第一数据块M的第一数值都需要更新为新的第一数值。当然,计算新的第一数值用的是新的第一计数值。对第二数据块对应的M个新的第一数值和M个新的第一数值对应的新的第二MAC加密,得到新的第二数据块;并将第二数据块更新为新的第二数据块;计数器,还用于将第一计数值更新为新的第一计数值。For example, the M first data blocks are the first data block 1, the first data block 2, ... the first data block M, respectively. It is assumed that the first updated first data block is the first data block 1, and the first data block 1 is the third data block. After the processor updates the first data block 1 to the new first data block 1, the first count value needs to be updated once to obtain a new first count value. Since the first count value has changed, the first value of the new first data block 1, the first data block 2, ... the first data block M needs to be updated to the new first value. Of course, the new first value is calculated using the new first count value. Encrypting the M new first value corresponding to the second data block and the new second MAC corresponding to the M new first values to obtain a new second data block; and updating the second data block to a new one The second data block; the counter is further configured to update the first count value to the new first count value.
进一步地,处理器211还用于:将第四数据块的第一数值读取至第二存储器212,第四数据块为第二数据块对应的除所述新的第一数据块的任一第一数据块;根据第四数据块的第一数值和第一计数值确定第四数据块对应的第一MAC;将第四数据块对应的第一MAC存储至第二存储器。Further, the processor 211 is further configured to: read the first value of the fourth data block to the second memory 212, where the fourth data block is any one of the new first data blocks corresponding to the second data block a first data block; determining a first MAC corresponding to the fourth data block according to the first value of the fourth data block and the first count value; storing the first MAC corresponding to the fourth data block to the second memory.
即处理器211在利用第四数据块的第一MAC计算新的第一数值之前,需要通过上述方式获取第一MAC。其中处理器211根据第四数据块的第一数值和第一计数值确定第四数据块对应的第一MAC,所采用的算法为计算第一数值的逆运算。假设计算第一数值采用的是加法运算,则处理器211可以采用减法运算获取第一MAC。That is, before the processor 211 calculates a new first value by using the first MAC of the fourth data block, the first MAC needs to be obtained in the foregoing manner. The processor 211 determines the first MAC corresponding to the fourth data block according to the first value of the fourth data block and the first count value, and the adopted algorithm is an inverse operation for calculating the first value. Assuming that the first value is calculated using an addition operation, the processor 211 can obtain the first MAC using a subtraction operation.
上述处理器211在计算第二数据块对应的每个第一数据块的新的第一数值的过程中,或者在将第二数据块更新为新的第二数据块之后,计数器将第一计数值更新为新的第一计数值之前,SE芯片有可能发生掉电,本申请提供一种SE芯片掉电保护策略。The processor 211 is in the process of calculating a new first value of each first data block corresponding to the second data block, or after updating the second data block to a new second data block, the counter will count the first The SE chip may be powered down before the value is updated to the new first count value. The present application provides a SE chip power down protection strategy.
可选地,处理器211还用于:当SE芯片发生掉电,则在SE芯片上电之后,读取第五数据块对应的每个第一数据块的第五数值,其中,第五数据块为新的第二数据块对应的实际数据块,第五数值为新的第一数值对应的实际数值;根据第五数据块对应的每个第一数据块的第五数值和第五数据块对应的每个第一数据块的第一MAC确定用于计算第五数值的第四计数值;判断第五数据块对应的每个第一数据块的第四计数值是否相同;当确定第五数据块对应的每个第一数据块的第四计数值不完全相同时,对从第六数据块开始的每个第一数据块的第四计数值更新一次,得到新的第一计数值,其中第六数据块为第五数据块对应的一个第一数据块,且满足条件:从第六数据块开始的每个第一数据块的第四计数值与第六数据块之前的每个第一数据块的第四计数值不同;对新的第一计数值和从第六数据块开始的每个第一数据块对应的第一MAC,采用与计算第一数值相同的算法计算从第六数据块开始的每个第一数据块的新的第一数值,并将从第六数据块开始的每个第一数据块的第四数值更新为新的第一数值;将第五数据块对应的第二MAC更新为新的第二MAC;对第五数据块对应的M个新的第一数值和M个新的第一数值对应的新的第二MAC加密,得到新的第二数据块,并将第五数据块更新为新的第二数据块;计数器,还用于将第一计数值更新为新的第一计数值。Optionally, the processor 211 is further configured to: when the SE chip is powered off, read the fifth value of each first data block corresponding to the fifth data block after the SE chip is powered on, where the fifth data is The block is the actual data block corresponding to the new second data block, and the fifth value is the actual value corresponding to the new first value; the fifth value and the fifth data block of each of the first data blocks corresponding to the fifth data block Determining, by the first MAC of each first data block, a fourth count value for calculating a fifth value; determining whether a fourth count value of each first data block corresponding to the fifth data block is the same; When the fourth count value of each first data block corresponding to the data block is not completely the same, the fourth count value of each first data block starting from the sixth data block is updated once to obtain a new first count value, The sixth data block is a first data block corresponding to the fifth data block, and satisfies a condition: a fourth count value of each first data block starting from the sixth data block and each of the sixth data block The fourth count value of a data block is different; for new a first count value and a first MAC corresponding to each first data block starting from the sixth data block, calculating a new one of each first data block starting from the sixth data block by using an algorithm identical to calculating the first value a first value, and updating a fourth value of each first data block starting from the sixth data block to a new first value; updating the second MAC corresponding to the fifth data block to a new second MAC; The M new first value corresponding to the fifth data block and the new second MAC corresponding to the M new first values are encrypted, and a new second data block is obtained, and the fifth data block is updated to a new second. The data block; the counter is further configured to update the first count value to the new first count value.
即本申请提供的终端设备,当SE芯片发生掉电后,可以保证第一数据块、第二数据块以及计数器的第一计数值准确无误。That is, the terminal device provided by the present application can ensure that the first count value of the first data block, the second data block, and the counter is accurate when the SE chip is powered off.
进一步地,图4为本申请一实施例提供的第一存储器的存储区域示意图,如图4所示,第一存储器的存储区域可以包括三部分:普通安全存储区域、利用计数值的认证安全存储区域以及程序区域。其中普通安全存储区域与利用计数值的认证安全存储区域主要区别就是防回退功能是否能达到EAL5+认证。普通安全存储区域可以用来保存对数据防回退没有严格要求的数据块。利用计数值的认证安全存储区域即为本申请提供的采用二级存储的区域,该区域用于存储上述的第一数据块和第二数据块。Further, FIG. 4 is a schematic diagram of a storage area of a first memory according to an embodiment of the present disclosure. As shown in FIG. 4, the storage area of the first memory may include three parts: a common secure storage area, and an authentication secure storage using a count value. Area and program area. The main difference between the normal security storage area and the authentication security storage area that uses the count value is whether the anti-backoff function can achieve EAL5+ authentication. A normal secure storage area can be used to store data blocks that are not critical to data fallback. The authentication secure storage area using the count value is the area for secondary storage provided by the present application, and the area is used for storing the first data block and the second data block described above.
对于上述三个不同的区域,本申请提供不同的API。The present application provides different APIs for the three different regions described above.
方案一:为利用计数值的认证安全存储区域提供新的API。如Secure_antirollback_NVM_Malloc和Secure_antirollback_NVM_Free;为普通安全存储区域提供普通的Malloc和Free。Option 1: Provide a new API for the authenticated secure storage area that utilizes the count value. Such as Secure_antirollback_NVM_Malloc and Secure_antirollback_NVM_Free; provide common Malloc and Free for normal secure storage areas.
方案二:静态配置指定使用普通安全存储区域和利用计数值的认证安全存储区域。Option 2: Static configuration specifies an authenticated secure storage area that uses a common secure storage area and uses count values.
本申请还提供一种处理器,该处理器为上述SE芯片中的处理器,该处理器的功能如上所述,本申请在此不再赘述。The present application further provides a processor, which is a processor in the foregoing SE chip, and the function of the processor is as described above, and the details are not described herein again.
本申请还提供一种芯片,包括上述计数器和所述处理器。该计数器的功能和处理器的功能如上所述,本申请在此不再赘述。其中该芯片可以是上述的SE芯片,也可以是AP SOC,该AP SOC包括该SE芯片。The application also provides a chip including the above counter and the processor. The functions of the counter and the functions of the processor are as described above, and the present application will not be repeated here. The chip may be the above-mentioned SE chip, or may be an AP SOC, and the AP SOC includes the SE chip.
图5为本申请一实施例提供的一种数据处理方法的流程图。结合图2和图5所示,该方法应用于处理器211,所述处理器211包含于安全芯片21,所述安全芯片还包括:第二存储器212和计数器213;所述安全芯片21与第一存储器22耦合连接;所述第一存储器22,用于存储M个第一数据块,其中,每个第一数据块是通过对明文数据块以及与所述明文数据块对应的第一消息认证码MAC进行加密运算得到的,M为大于等于1的整数;所述计数器213,用于对所述M个第一数据块的更新次数进行计数,得到计数值,所述计数器213的计数值不可回退;所述方法包括:FIG. 5 is a flowchart of a data processing method according to an embodiment of the present application. As shown in FIG. 2 and FIG. 5, the method is applied to the processor 211. The processor 211 is included in the security chip 21, and the security chip further includes: a second memory 212 and a counter 213; the security chip 21 and the A memory 22 is coupled to each other; the first memory 22 is configured to store M first data blocks, wherein each first data block is authenticated by a plaintext data block and a first message corresponding to the plaintext data block The code MAC is obtained by performing an encryption operation, and M is an integer greater than or equal to 1. The counter 213 is configured to count the number of updates of the M first data blocks to obtain a count value, and the counter value of the counter 213 is not available. Fallback; the method includes:
步骤S501:分别利用计数器的第一计数值以及每个第一数据块对应的第一MAC进行逻辑运算,得到与M个第一数据块一一对应的M个第一数值;其中,第一计数值为处理器进行逻辑运算时,M个第一数据块对应的计数值。Step S501: performing a logical operation on the first count value of the counter and the first MAC corresponding to each first data block, respectively, to obtain M first values corresponding to the M first data blocks one by one; wherein, the first count The value is the count value corresponding to the M first data blocks when the processor performs a logical operation.
步骤S502:对M个第一数值和与M个第一数值对应的第二MAC进行加密运算,得到第二数据块,并将第二数据块存储至第一存储器。Step S502: Perform an encryption operation on the M first values and the second MAC corresponding to the M first values to obtain a second data block, and store the second data block in the first memory.
步骤S503:根据第二数据块以及计数器的第二计数值,判断目标数据块是否发生回退;其中,目标数据块是M个第一数据块的任一个;第二计数值为处理器判断目标数据块是否发生回退时,M个第一数据块对应的计数值。Step S503: determining, according to the second data block and the second count value of the counter, whether the target data block is rolled back; wherein the target data block is any one of the M first data blocks; and the second count value is the processor determining the target. The count value corresponding to the M first data blocks when the data block is rolled back.
本申请提供的数据处理方法,由上述的处理器执行,对应内容和效果相同,在此不再赘述。The data processing method provided by the present application is executed by the above processor, and the corresponding content and effect are the same, and details are not described herein again.
当上述的计数器是NVM时,由于NVM的存储容量比上述OTP的存储容量可以大一些,因此,针对计数器是NVM的情况,上述第一存储器可以采用一级存储的方式。When the above counter is NVM, since the storage capacity of the NVM can be larger than the storage capacity of the OTP, the first memory can be stored in a primary storage manner in the case where the counter is the NVM.
具体地,图6为本申请一实施例提供的一种终端设备的示意图,如图6所示,该终端设备包括:安全芯片61和耦合至所述安全芯片的第一存储器62,其中,所述安全芯片61 包括:处理器611、第二存储器612和非易失性存储器NVM613;所述NVM613,用于对加密数据块的更新次数进行计数,得到计数值,所述NVM613的计数值不可回退;处理器611用于:利用明文数据块的消息认证码MAC和所述NVM的第一计数值,得到所述明文数据块对应的第一数值;所述第一计数值是所述处理器计算所述第一数值时,所述明文数据块对应的计数值;对所述第一数值和所述明文数据块加密,得到所述加密数据块,并将所述加密数据块存储至所述第一存储器;所述处理器611,还用于根据所述加密数据块和所述NVM的第二计数值,判断所述加密数据块是否发生回退;其中,所述第二计数值与所述加密数据块对应;所述第二计数值为所述处理器判断所述加密数据块是否发生回退时,所述加密数据块对应的计数值。Specifically, FIG. 6 is a schematic diagram of a terminal device according to an embodiment of the present disclosure. As shown in FIG. 6, the terminal device includes: a security chip 61 and a first memory 62 coupled to the security chip, where The security chip 61 includes a processor 611, a second memory 612, and a non-volatile memory NVM 613. The NVM 613 is configured to count the number of updates of the encrypted data block to obtain a count value, and the count value of the NVM 613 cannot be returned. The processor 611 is configured to: obtain a first value corresponding to the plaintext data block by using a message authentication code MAC of the plaintext data block and a first count value of the NVM; the first count value is the processor And calculating, by the first value, a count value corresponding to the plaintext data block; encrypting the first value and the plaintext data block to obtain the encrypted data block, and storing the encrypted data block to the a first memory; the processor 611 is further configured to determine, according to the encrypted data block and the second count value of the NVM, whether the encrypted data block is backed off; wherein the second count value is Description Corresponding to the encrypted data block; the second processor determines whether the count value of the encrypted blocks of data back-off occurs, the encrypted data block corresponding to the count value.
图7为本申请一实施例提供的第一存储器的一级存储示意图。如图7所示,该第一存储器包括M个加密数据块,每个加密数据块是对明文数据块和该明文数据块的第一数值加密得到的,其中第一数值是利用明文数据块的消息认证码MAC和NVM的第一计数值得到的。例如:加密数据块1是对明文数据块1和该明文数据块1的第一数值1加密得到的。加密数据块2是对明文数据块2和该明文数据块2的第一数值2加密得到的。加密数据块M是对明文数据块M和该明文数据块M的第一数值M加密得到的。FIG. 7 is a schematic diagram of a primary storage of a first memory according to an embodiment of the present application. As shown in FIG. 7, the first memory includes M encrypted data blocks, each of which is obtained by encrypting a plaintext data block and a first value of the plaintext data block, wherein the first value is a plaintext data block. The message authentication code MAC and the first count value of the NVM are obtained. For example, the encrypted data block 1 is obtained by encrypting the plaintext data block 1 and the first value 1 of the plaintext data block 1. The encrypted data block 2 is obtained by encrypting the plaintext data block 2 and the first value 2 of the plaintext data block 2. The encrypted data block M is obtained by encrypting the plaintext data block M and the first value M of the plaintext data block M.
具体地,计算该第一数值的方法可以采用加法运算、减法运算、乘法运算、除法运算或者是计算机领域中的“与”运算、“或”运算、“异或”运算以及一些高级算法等。只要NVM的第一计数值可以参与运算即可,本申请对此不做限制。Specifically, the method of calculating the first value may be an addition operation, a subtraction operation, a multiplication operation, a division operation, or an AND operation, an OR operation, an exclusive OR operation, and some advanced algorithms in the computer field. As long as the first count value of the NVM can participate in the operation, the present application does not limit this.
当然,该第一存储器还可以存储多个加密数据块,可以将NVM的比特位分为多个位段,每个位段构成一个计数值,每个计数值可以与至少一个加密数据块对应。Of course, the first memory may also store a plurality of encrypted data blocks, and the bits of the NVM may be divided into a plurality of bit segments, each of the bit segments constituting a count value, and each of the count values may correspond to at least one encrypted data block.
进一步地,处理器611判断加密数据块是否发生回退的方法可以是:Further, the method for the processor 611 to determine whether the encrypted data block is rolled back may be:
一种可选方式:处理器611具体用于:对第二计数值和明文数据块的MAC,采用与计算第一数值相同的算法计算明文数据块的第二数值;根据第一数值和第二数值判断明文数据块是否发生回退。该终端设备还包括:发送器;处理器611具体用于:当所述第一数值和所述第二数值相同时,确定所述明文数据块未发生回退;当所述第一数值和所述第二数值不相同时,更新一次所述第二计数值,得到第三计数值,对所述第三计数值和所述MAC,采用与计算所述第一数值相同的算法计算所述明文数据块的第三数值;当所述第一数值和所述第三数值不相同时,确定所述明文数据块发生回退,并触发所述发送器发送提示消息,所述提示消息用于提示所述明文数据块发生回退。An optional method is: the processor 611 is configured to: calculate, by using the same algorithm as calculating the first value, a second value of the plaintext data block for the second count value and the MAC of the plaintext data block; according to the first value and the second value The value determines whether the plaintext data block has been rolled back. The terminal device further includes: a transmitter; the processor 611 is specifically configured to: when the first value and the second value are the same, determine that the plaintext data block does not roll back; when the first value and the When the second value is different, updating the second count value to obtain a third count value, and calculating, by using the same algorithm as calculating the first value, the clear text for the third count value and the MAC a third value of the data block; when the first value and the third value are different, determining that the plaintext data block is rolled back, and triggering the sender to send a prompt message, where the prompt message is used for prompting The plaintext data block is rolled back.
进一步地,处理器611还用于:当所述第一数值和所述第三数值相同时,确定所述安全芯片发生掉电。Further, the processor 611 is further configured to: when the first value and the third value are the same, determine that the security chip is powered off.
另一种可选方式:处理器611具体用于:解密所述第一数值,得到所述明文数据块的MAC和所述NVM的第一计数值;根据所述第一计数值和所述第二计数值判断所述明文数据块是否发生回退。终端设备还包括:发送器;所述处理器611具体用于:当所述第一计数值和所述第二计数值相同时,确定所述明文数据块未发生回退;当所述第一计数值和所述第二计数值不相同时,更次一次所述第二计数值得到第三计数值;当所述第一计数值和所述第三计数值不相同时,确定所述明文数据块发生回退,并触发所述发送器发送提示消息,所述提示消息用于提示所述明文数据块发生回退。Another optional mode: the processor 611 is specifically configured to: decrypt the first value, obtain a MAC of the plaintext data block, and a first count value of the NVM; according to the first count value and the first The second count value determines whether the plaintext data block has rolled back. The terminal device further includes: a transmitter; the processor 611 is specifically configured to: when the first count value and the second count value are the same, determine that the plaintext data block does not roll back; when the first When the count value and the second count value are different, the second count value obtains a third count value a second time; when the first count value and the third count value are not the same, the clear text is determined The data block is rolled back, and the sender is triggered to send a prompt message, where the prompt message is used to prompt that the plaintext data block is rolled back.
可选地,所述处理器611还用于:当所述第一计数值和所述第三计数值相同时,确定 所述安全芯片发生掉电。Optionally, the processor 611 is further configured to: when the first count value and the third count value are the same, determine that the security chip is powered off.
其中,一级存储和上述的二级存储判断数据回退的方式类似,本申请在此不再赘述。The manner in which the primary storage and the second-level storage determine the data fallback is similar, and the application is not described herein again.
综上,本申请提供一种终端设备,该终端设备包括:安全芯片和耦合至所述安全芯片的第一存储器,其中,所述安全芯片包括:处理器、第二存储器和非易失性存储器NVM;所述NVM,用于对加密数据块的更新次数进行计数,得到计数值,所述NVM的计数值不可回退;处理器用于:利用明文数据块的消息认证码MAC和所述NVM的第一计数值,得到所述明文数据块对应的第一数值;所述第一计数值是所述处理器计算所述第一数值时,所述明文数据块对应的计数值;对所述第一数值和所述明文数据块加密,得到所述加密数据块,并将所述加密数据块存储至所述第一存储器;所述处理器,还用于根据所述加密数据块和所述NVM的第二计数值,判断所述加密数据块是否发生回退;其中,所述第二计数值与所述加密数据块对应;所述第二计数值为所述处理器判断所述加密数据块是否发生回退时,所述加密数据块对应的计数值。相当于在现有的SE芯片中增加了一个小容量(只用于计数)的NVM,因此,相对于现有技术增加专用Secure Flash。本申请提供的终端设备可以降低成本以及布板复杂度。In summary, the present application provides a terminal device including: a security chip and a first memory coupled to the security chip, wherein the security chip includes: a processor, a second memory, and a non-volatile memory The NVM is configured to count the number of updates of the encrypted data block to obtain a count value, and the count value of the NVM is not backed off; the processor is configured to: use the message authentication code MAC of the plaintext data block and the NVM a first count value, the first value corresponding to the plaintext data block is obtained; the first count value is a count value corresponding to the plaintext data block when the processor calculates the first value; Encrypting the encrypted data block with the value and the plaintext data block, and storing the encrypted data block to the first memory; the processor is further configured to: according to the encrypted data block and the NVM a second count value, determining whether the encrypted data block has a rollback; wherein the second count value corresponds to the encrypted data block; and the second count value is determined by the processor to determine the encryption According to whether a rollback occurs when the block count value corresponding to the encrypted data block. This is equivalent to adding a small capacity (for counting only) NVM to the existing SE chip, so the dedicated Secure Flash is added relative to the prior art. The terminal device provided by the present application can reduce cost and layout complexity.
本申请还提供一种处理器,该处理器为图6所示的处理器,该处理器的功能如上所述,本申请在此不再赘述。The present application further provides a processor, which is the processor shown in FIG. 6. The function of the processor is as described above, and the details are not described herein again.
本申请还提供一种芯片,包括上述NVM和所述处理器。该NVM的功能和处理器的功能如上所述,本申请在此不再赘述。其中该芯片可以是上述的SE芯片,也可以是AP SOC,该AP SOC包括该SE芯片。The application also provides a chip including the above NVM and the processor. The functions of the NVM and the functions of the processor are as described above, and the application will not be repeated herein. The chip may be the above-mentioned SE chip, or may be an AP SOC, and the AP SOC includes the SE chip.
图8为本申请另一实施例提供的一种数据处理方法的流程图。结合图6和图8所示,所述方法应用于处理器611,所述处理器611包含于安全芯片61,所述安全芯片61还包括:第二存储器612和非易失性存储器NVM613;所述安全芯片61与第一存储器62耦合连接;所述NVM613,用于对加密数据块的更新次数进行计数,得到计数值,所述NVM613的计数值不可回退;FIG. 8 is a flowchart of a data processing method according to another embodiment of the present application. The method is applied to the processor 611, and the processor 611 is included in the security chip 61. The security chip 61 further includes: a second memory 612 and a non-volatile memory NVM 613; The security chip 61 is coupled to the first memory 62. The NVM 613 is configured to count the number of updates of the encrypted data block to obtain a count value, and the count value of the NVM 613 cannot be rolled back;
所述方法包括:The method includes:
步骤S801:利用明文数据块的消息认证码MAC和NVM的第一计数值,得到明文数据块对应的第一数值;第一计数值是所述处理器计算第一数值时,明文数据块对应的计数值。Step S801: Using the message authentication code MAC of the plaintext data block and the first count value of the NVM, obtaining a first value corresponding to the plaintext data block; the first count value is corresponding to the plaintext data block when the processor calculates the first value. Count value.
步骤S802:对第一数值和明文数据块加密,得到加密数据块,并将加密数据块存储至第一存储器;Step S802: encrypting the first value and the plaintext data block, obtaining an encrypted data block, and storing the encrypted data block to the first memory;
步骤S803:根据加密数据块和NVM的第二计数值,判断加密数据块是否发生回退;其中,第二计数值与加密数据块对应;第二计数值为处理器判断加密数据块是否发生回退时,加密数据块对应的计数值。Step S803: determining, according to the second count value of the encrypted data block and the NVM, whether the encrypted data block is backed off; wherein the second count value corresponds to the encrypted data block; and the second count value is determining whether the encrypted data block is generated back. When the time is retired, the count value corresponding to the data block is encrypted.
本申请提供的数据处理方法,由图6所示的处理器执行,对应内容和效果相同,在此不再赘述。The data processing method provided by the present application is executed by the processor shown in FIG. 6, and the corresponding content and effect are the same, and details are not described herein again.

Claims (24)

  1. 一种终端设备,其特征在于,包括:安全芯片和耦合至所述安全芯片的第一存储器,其中,所述安全芯片包括:处理器、第二存储器和计数器;A terminal device, comprising: a security chip and a first memory coupled to the security chip, wherein the security chip comprises: a processor, a second memory, and a counter;
    所述第一存储器,用于存储M个第一数据块,其中,每个第一数据块是通过对明文数据块以及与所述明文数据块对应的第一消息认证码MAC进行加密运算得到的,M为大于等于1的整数;The first memory is configured to store M first data blocks, where each first data block is obtained by encrypting a plaintext data block and a first message authentication code MAC corresponding to the plaintext data block. , M is an integer greater than or equal to 1;
    所述计数器,用于对所述M个第一数据块的更新次数进行计数,得到计数值,所述计数器的计数值不可回退;The counter is configured to count the number of updates of the M first data blocks to obtain a count value, and the counter value of the counter cannot be rolled back;
    所述处理器用于:The processor is used to:
    分别利用所述计数器的第一计数值以及每个第一数据块对应的第一MAC进行逻辑运算,得到与所述M个第一数据块一一对应的M个第一数值;其中,所述第一计数值为所述处理器进行所述逻辑运算时,所述M个第一数据块对应的计数值;Performing a logical operation by using a first count value of the counter and a first MAC corresponding to each first data block, respectively, to obtain M first values that are in one-to-one correspondence with the M first data blocks; The first count value is a count value corresponding to the M first data blocks when the processor performs the logic operation;
    对所述M个第一数值和与所述M个第一数值对应的第二MAC进行加密运算,得到第二数据块,并将所述第二数据块存储至所述第一存储器;Performing an encryption operation on the M first values and the second MAC corresponding to the M first values to obtain a second data block, and storing the second data block in the first memory;
    根据所述第二数据块以及所述计数器的第二计数值,判断目标数据块是否发生回退;其中,所述目标数据块是所述M个第一数据块的任一个;所述第二计数值为所述处理器判断所述目标数据块是否发生回退时,所述M个第一数据块对应的计数值。Determining, according to the second data block and the second count value of the counter, whether the target data block is backed off; wherein the target data block is any one of the M first data blocks; the second The count value is a count value corresponding to the M first data blocks when the processor determines whether the target data block has a rollback.
  2. 根据权利要求1所述的终端设备,其特征在于,所述处理器具体用于:The terminal device according to claim 1, wherein the processor is specifically configured to:
    对所述第二计数值和所述目标数据块对应的第一MAC,采用与计算所述目标数据块的第一数值相同的算法计算所述目标数据块的第二数值;And calculating, by the second count value and the first MAC corresponding to the target data block, a second value of the target data block by using an algorithm that is the same as calculating a first value of the target data block;
    根据所述目标数据块的第一数值和所述目标数据块的第二数值判断所述目标数据块是否发生回退。Determining whether the target data block is backed off according to the first value of the target data block and the second value of the target data block.
  3. 根据权利要求1所述的终端设备,其特征在于,还包括:发送器;The terminal device according to claim 1, further comprising: a transmitter;
    所述处理器具体用于:The processor is specifically configured to:
    当所述目标数据块的第一数值和所述目标数据块的第二数值相同时,确定所述目标数据块未发生回退;Determining that the target data block does not fall back when the first value of the target data block and the second value of the target data block are the same;
    当所述目标数据块的第一数值和所述目标数据块的第二数值不相同时,更新一次所述第二计数值得到第三计数值,对所述第三计数值和所述目标数据块对应的第一MAC,采用与计算所述目标数据块的第一数值相同的算法计算所述目标数据块的第三数值;Updating the second count value to obtain a third count value, the third count value and the target data, when the first value of the target data block is different from the second value of the target data block a first MAC corresponding to the block, calculating a third value of the target data block by using an algorithm that is the same as calculating a first value of the target data block;
    当所述目标数据块的第一数值和所述目标数据块的第三数值不相同时,确定所述目标数据块发生回退,并触发所述发送器发送提示消息,所述提示消息用于提示所述目标数据块发生回退。Determining that the target data block is rolled back when the first value of the target data block and the third value of the target data block are different, and triggering the sender to send a prompt message, where the prompt message is used Prompting that the target data block is rolled back.
  4. 根据权利要求3所述的终端设备,其特征在于,所述处理器还用于:The terminal device according to claim 3, wherein the processor is further configured to:
    当所述目标数据块的第一数值和所述目标数据块的第三数值相同时,确定所述安全芯片发生掉电。When the first value of the target data block and the third value of the target data block are the same, it is determined that the security chip is powered down.
  5. 根据权利要求1所述的终端设备,其特征在于,所述处理器具体用于:The terminal device according to claim 1, wherein the processor is specifically configured to:
    根据所述目标数据块的第一数值和所述目标数据块对应的第一MAC,得到所述第一 计数值;Obtaining the first count value according to the first value of the target data block and the first MAC corresponding to the target data block;
    根据所述第一计数值和所述第二计数值判断所述目标数据块是否发生回退。Determining whether the target data block is backed off according to the first count value and the second count value.
  6. 根据权利要求5所述的终端设备,其特征在于,还包括:发送器;The terminal device according to claim 5, further comprising: a transmitter;
    所述处理器具体用于:The processor is specifically configured to:
    当所述第一计数值和所述第二计数值相同时,确定所述目标数据块未发生回退;Determining that the target data block does not fall back when the first count value and the second count value are the same;
    当所述第一计数值和所述第二计数值不相同时,更新一次所述第二计数值得到第三计数值;When the first count value and the second count value are not the same, updating the second count value to obtain a third count value;
    当所述第一计数值和所述第三计数值不相同时,确定所述目标数据块发生回退,并触发所述发送器发送提示消息,所述提示消息用于提示所述目标数据块发生回退。Determining that the target data block is rolled back when the first count value and the third count value are different, and triggering the sender to send a prompt message, where the prompt message is used to prompt the target data block A rollback occurred.
  7. 根据权利要求6所述的终端设备,其特征在于,所述处理器还用于:The terminal device according to claim 6, wherein the processor is further configured to:
    当所述第一计数值和所述第三计数值相同时,确定所述安全芯片发生掉电。When the first count value and the third count value are the same, it is determined that the security chip is powered down.
  8. 根据权利要求1-7任一项所述的终端设备,其特征在于,所述处理器还用于:The terminal device according to any one of claims 1 to 7, wherein the processor is further configured to:
    将第三数据块更新为新的第一数据块,并更新一次所述第一计数值得到新的第一计数值;其中,所述第三数据块是所述M个第一数据块的任一个;Updating the third data block to a new first data block, and updating the first count value to obtain a new first count value; wherein the third data block is any one of the M first data blocks One;
    分别对所述新的第一计数值和所述第二数据块对应的每个第一数据块对应的第一MAC,采用与计算所述第一数值相同的算法计算所述每个第一数据块的新的第一数值,并将所述每个第一数据块的第一数值更新为新的第一数值;Calculating each of the first data by using the same algorithm as calculating the first value, respectively, for the new first count value and the first MAC corresponding to each first data block corresponding to the second data block. a new first value of the block, and updating the first value of each of the first data blocks to a new first value;
    对所述第二数据块对应的M个新的第一数值和所述M个新的第一数值对应的新的第二MAC加密,得到新的第二数据块;并将第二数据块更新为所述新的第二数据块;Encrypting the M new first value corresponding to the second data block and the new second MAC corresponding to the M new first values to obtain a new second data block; and updating the second data block For the new second data block;
    所述计数器,还用于将第一计数值更新为新的第一计数值。The counter is further configured to update the first count value to a new first count value.
  9. 根据权利要求8所述的终端设备,其特征在于,所述处理器还用于:The terminal device according to claim 8, wherein the processor is further configured to:
    将第四数据块的第一数值读取至所述第二存储器,所述第四数据块为第二数据块对应的除所述新的第一数据块的任一第一数据块;Reading a first value of the fourth data block to the second memory, where the fourth data block is any first data block corresponding to the new first data block corresponding to the second data block;
    根据所述第四数据块的第一数值和第一计数值确定所述第四数据块对应的第一MAC;Determining, according to the first value of the fourth data block and the first count value, a first MAC corresponding to the fourth data block;
    将所述第四数据块对应的第一MAC存储至所述第二存储器。And storing the first MAC corresponding to the fourth data block to the second memory.
  10. 根据权利要求8或9所述的终端设备,其特征在于,所述处理器还用于:The terminal device according to claim 8 or 9, wherein the processor is further configured to:
    当所述安全芯片发生掉电,则在所述安全芯片上电之后,读取第五数据块对应的每个第一数据块的第五数值,其中,所述第五数据块为所述新的第二数据块对应的实际数据块,所述第五数值为所述新的第一数值对应的实际数值;After the security chip is powered off, after the security chip is powered on, reading a fifth value of each first data block corresponding to the fifth data block, where the fifth data block is the new The actual data block corresponding to the second data block, wherein the fifth value is an actual value corresponding to the new first value;
    根据所述第五数据块对应的每个第一数据块的第五数值和所述第五数据块对应的每个第一数据块的第一MAC确定用于计算所述第五数值的第四计数值;Determining a fourth value for calculating the fifth value according to a fifth value of each first data block corresponding to the fifth data block and a first MAC of each first data block corresponding to the fifth data block Count value
    判断所述第五数据块对应的每个第一数据块的第四计数值是否相同;Determining whether the fourth count value of each first data block corresponding to the fifth data block is the same;
    当确定所述第五数据块对应的每个第一数据块的第四计数值不完全相同时,对从第六数据块开始的每个第一数据块的第四计数值更新一次,得到所述新的第一计数值,其中所述第六数据块为所述第五数据块对应的一个第一数据块,且满足条件:从所述第六数据块开始的每个第一数据块的第四计数值与所述第六数据块之前的每个第一数据块的第四计数值不同;When it is determined that the fourth count value of each first data block corresponding to the fifth data block is not completely the same, the fourth count value of each first data block starting from the sixth data block is updated once, and the Describe a new first count value, wherein the sixth data block is a first data block corresponding to the fifth data block, and satisfies a condition: each first data block from the sixth data block The fourth count value is different from the fourth count value of each of the first data blocks preceding the sixth data block;
    对所述新的第一计数值和从所述第六数据块开始的每个第一数据块对应的第一MAC, 采用与计算所述第一数值相同的算法计算从所述第六数据块开始的每个第一数据块的新的第一数值,并将从所述第六数据块开始的每个第一数据块的第四数值更新为新的第一数值;Calculating from the sixth data block by using the same algorithm as calculating the first value, using the new first count value and the first MAC corresponding to each first data block starting from the sixth data block a new first value of each of the first data blocks that is started, and updating a fourth value of each of the first data blocks from the sixth data block to a new first value;
    将所述第五数据块对应的第二MAC更新为所述新的第二MAC;Updating the second MAC corresponding to the fifth data block to the new second MAC;
    对所述第五数据块对应的M个新的第一数值和所述M个新的第一数值对应的新的第二MAC加密,得到所述新的第二数据块,并将所述第五数据块更新为所述新的第二数据块;Encrypting the new first MAC value corresponding to the fifth data block and the new second MAC address corresponding to the M new first values to obtain the new second data block, and Five data blocks are updated to the new second data block;
    所述计数器,还用于将第一计数值更新为所述新的第一计数值。The counter is further configured to update the first count value to the new first count value.
  11. 根据权利要求1-10任一项所述的终端设备,其特征在于,所述计数器为一次性编程芯片OTP或者非易失性存储器NVM。The terminal device according to any one of claims 1 to 10, wherein the counter is a one-time programming chip OTP or a non-volatile memory NVM.
  12. 一种处理器,其特征在于,所述处理器为权利要求1-11任一项所述的处理器。A processor, characterized in that the processor is the processor of any one of claims 1-11.
  13. 一种芯片,其特征在于,包括如权利要求1-11任一项所述的计数器和如权利要求1-11任一项所述的处理器。A chip, comprising the counter of any of claims 1-11 and the processor of any of claims 1-11.
  14. 一种数据处理方法,其特征在于,所述方法应用于处理器,所述处理器包含于安全芯片,所述安全芯片还包括:第二存储器和计数器;所述安全芯片与第一存储器耦合连接;所述第一存储器,用于存储M个第一数据块,其中,每个第一数据块是通过对明文数据块以及与所述明文数据块对应的第一消息认证码MAC进行加密运算得到的,M为大于等于1的整数;所述计数器,用于对所述M个第一数据块的更新次数进行计数,得到计数值,所述计数器的计数值不可回退;所述方法包括:A data processing method, the method is applied to a processor, the processor is included in a security chip, the security chip further includes: a second memory and a counter; the security chip is coupled to the first memory The first memory is configured to store M first data blocks, wherein each first data block is obtained by encrypting a plaintext data block and a first message authentication code MAC corresponding to the plaintext data block. And M is an integer greater than or equal to 1; the counter is configured to count the number of updates of the M first data blocks to obtain a count value, and the counter value of the counter cannot be rolled back; the method includes:
    分别利用所述计数器的第一计数值以及每个第一数据块对应的第一MAC进行逻辑运算,得到与所述M个第一数据块一一对应的M个第一数值;其中,所述第一计数值为所述处理器进行逻辑运算时,所述M个第一数据块对应的计数值;Performing a logical operation by using a first count value of the counter and a first MAC corresponding to each first data block, respectively, to obtain M first values that are in one-to-one correspondence with the M first data blocks; The first count value is a count value corresponding to the M first data blocks when the processor performs a logic operation;
    对所述M个第一数值和与所述M个第一数值对应的第二MAC进行加密运算,得到第二数据块,并将所述第二数据块存储至所述第一存储器;Performing an encryption operation on the M first values and the second MAC corresponding to the M first values to obtain a second data block, and storing the second data block in the first memory;
    根据所述第二数据块以及所述计数器的第二计数值,判断目标数据块是否发生回退;其中,所述目标数据块是所述M个第一数据块的任一个;所述第二计数值为所述处理器判断所述目标数据块是否发生回退时,所述M个第一数据块对应的计数值。Determining, according to the second data block and the second count value of the counter, whether the target data block is backed off; wherein the target data block is any one of the M first data blocks; the second The count value is a count value corresponding to the M first data blocks when the processor determines whether the target data block has a rollback.
  15. 一种终端设备,其特征在于,包括:安全芯片和耦合至所述安全芯片的第一存储器,其中,所述安全芯片包括:处理器、第二存储器和非易失性存储器NVM;A terminal device, comprising: a security chip and a first memory coupled to the security chip, wherein the security chip comprises: a processor, a second memory, and a non-volatile memory NVM;
    所述NVM,用于对加密数据块的更新次数进行计数,得到计数值,所述NVM的计数值不可回退;The NVM is configured to count the number of updates of the encrypted data block to obtain a count value, and the count value of the NVM cannot be rolled back;
    所述处理器用于:The processor is used to:
    利用明文数据块的消息认证码MAC和所述NVM的第一计数值,得到所述明文数据块对应的第一数值;所述第一计数值是所述处理器计算所述第一数值时,所述明文数据块对应的计数值;Obtaining a first value corresponding to the plaintext data block by using a message authentication code MAC of the plaintext data block and a first count value of the NVM; the first count value is when the processor calculates the first value a count value corresponding to the plaintext data block;
    对所述第一数值和所述明文数据块加密,得到所述加密数据块,并将所述加密数据块存储至所述第一存储器;Encrypting the first value and the plaintext data block to obtain the encrypted data block, and storing the encrypted data block to the first memory;
    所述处理器,还用于根据所述加密数据块和所述NVM的第二计数值,判断所述加密 数据块是否发生回退;其中,所述第二计数值与所述加密数据块对应;所述第二计数值为所述处理器判断所述加密数据块是否发生回退时,所述加密数据块对应的计数值。The processor is further configured to determine, according to the encrypted data block and the second count value of the NVM, whether the encrypted data block is backed off; wherein the second count value corresponds to the encrypted data block And the second count value is a count value corresponding to the encrypted data block when the processor determines whether the encrypted data block is backed off.
  16. 根据权利要求15所述的终端设备,其特征在于,所述处理器具体用于:The terminal device according to claim 15, wherein the processor is specifically configured to:
    对所述第二计数值和所述明文数据块的MAC,采用与计算所述第一数值相同的算法计算所述明文数据块的第二数值;And calculating, by the second count value and the MAC of the plaintext data block, a second value of the plaintext data block by using an algorithm that is the same as calculating the first value;
    根据所述第一数值和所述第二数值判断所述明文数据块是否发生回退。Determining, according to the first value and the second value, whether the plaintext data block is rolled back.
  17. 根据权利要求16所述的终端设备,其特征在于,还包括:发送器;The terminal device according to claim 16, further comprising: a transmitter;
    所述处理器具体用于:The processor is specifically configured to:
    当所述第一数值和所述第二数值相同时,确定所述明文数据块未发生回退;Determining that the plaintext data block has not been rolled back when the first value and the second value are the same;
    当所述第一数值和所述第二数值不相同时,更新一次所述第二计数值,得到第三计数值,对所述第三计数值和所述MAC,采用与计算所述第一数值相同的算法计算所述明文数据块的第三数值;And updating, when the first value and the second value are different, the second count value is updated to obtain a third count value, and the first count value and the MAC are used to calculate the first An algorithm having the same value calculates a third value of the plaintext block;
    当所述第一数值和所述第三数值不相同时,确定所述明文数据块发生回退,并触发所述发送器发送提示消息,所述提示消息用于提示所述明文数据块发生回退。When the first value and the third value are different, determining that the plaintext data block is rolled back, and triggering the sender to send a prompt message, where the prompt message is used to prompt the plaintext data block to be sent back. Retreat.
  18. 根据权利要求17所述的终端设备,其特征在于,所述处理器还用于:The terminal device according to claim 17, wherein the processor is further configured to:
    当所述第一数值和所述第三数值相同时,确定所述安全芯片发生掉电。When the first value and the third value are the same, it is determined that the security chip is powered down.
  19. 根据权利要求15所述的终端设备,其特征在于,所述处理器具体用于:The terminal device according to claim 15, wherein the processor is specifically configured to:
    解密所述第一数值,得到所述明文数据块的MAC和所述NVM的第一计数值;Decrypting the first value to obtain a MAC of the plaintext data block and a first count value of the NVM;
    根据所述第一计数值和所述第二计数值判断所述明文数据块是否发生回退。Determining whether the plaintext data block is rolled back according to the first count value and the second count value.
  20. 根据权利要求19所述的终端设备,其特征在于,还包括:发送器;The terminal device according to claim 19, further comprising: a transmitter;
    所述处理器具体用于:The processor is specifically configured to:
    当所述第一计数值和所述第二计数值相同时,确定所述明文数据块未发生回退;Determining that the plaintext data block has not been rolled back when the first count value and the second count value are the same;
    当所述第一计数值和所述第二计数值不相同时,更次一次所述第二计数值得到第三计数值;When the first count value and the second count value are not the same, the second count value obtains a third count value;
    当所述第一计数值和所述第三计数值不相同时,确定所述明文数据块发生回退,并触发所述发送器发送提示消息,所述提示消息用于提示所述明文数据块发生回退。When the first count value and the third count value are different, determining that the plaintext data block is rolled back, and triggering the sender to send a prompt message, where the prompt message is used to prompt the plaintext data block A rollback occurred.
  21. 根据权利要求20所述的终端设备,其特征在于,所述处理器还用于:The terminal device according to claim 20, wherein the processor is further configured to:
    当所述第一计数值和所述第三计数值相同时,确定所述安全芯片发生掉电。When the first count value and the third count value are the same, it is determined that the security chip is powered down.
  22. 一种处理器,其特征在于,所述处理器为权利要求15-21任一项所述的处理器。A processor, characterized in that the processor is the processor of any one of claims 15-21.
  23. 一种芯片,其特征在于,包括如权利要求15-21任一项所述的非易失性存储器NVM和如权利要求15-21任一项所述的处理器。A chip, comprising the non-volatile memory NVM of any one of claims 15-21, and the processor of any one of claims 15-21.
  24. 一种数据处理方法,其特征在于,所述方法应用于处理器,所述处理器包含于安全芯片,所述安全芯片还包括:第二存储器和非易失性存储器NVM;所述安全芯片与第一存储器耦合连接;所述NVM,用于对加密数据块的更新次数进行计数,得到计数值,所述NVM的计数值不可回退;A data processing method, the method is applied to a processor, the processor is included in a security chip, the security chip further includes: a second memory and a non-volatile memory NVM; the security chip and a first memory coupled connection; the NVM is configured to count the number of updates of the encrypted data block to obtain a count value, and the count value of the NVM cannot be rolled back;
    所述方法包括:The method includes:
    利用明文数据块的消息认证码MAC和所述NVM的第一计数值,得到所述明文数据块对应的第一数值;所述第一计数值是所述处理器计算所述第一数值时,所述明文数据块 对应的计数值;Obtaining a first value corresponding to the plaintext data block by using a message authentication code MAC of the plaintext data block and a first count value of the NVM; the first count value is when the processor calculates the first value a count value corresponding to the plaintext data block;
    对所述第一数值和所述明文数据块加密,得到所述加密数据块,并将所述加密数据块存储至所述第一存储器;Encrypting the first value and the plaintext data block to obtain the encrypted data block, and storing the encrypted data block to the first memory;
    根据所述加密数据块和所述NVM的第二计数值,判断所述加密数据块是否发生回退;其中,所述第二计数值与所述加密数据块对应;所述第二计数值为所述处理器判断所述加密数据块是否发生回退时,所述加密数据块对应的计数值。Determining, according to the encrypted data block and the second count value of the NVM, whether the encrypted data block is backed off; wherein the second count value corresponds to the encrypted data block; the second count value is And the processor determines, according to whether the encrypted data block is rolled back, a count value corresponding to the encrypted data block.
PCT/CN2018/091749 2017-06-19 2018-06-19 Terminal device and data processing method WO2018233583A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710464774.3 2017-06-19
CN201710464774.3A CN109150534B (en) 2017-06-19 2017-06-19 Terminal device and data processing method

Publications (1)

Publication Number Publication Date
WO2018233583A1 true WO2018233583A1 (en) 2018-12-27

Family

ID=64735898

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/091749 WO2018233583A1 (en) 2017-06-19 2018-06-19 Terminal device and data processing method

Country Status (2)

Country Link
CN (1) CN109150534B (en)
WO (1) WO2018233583A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109885442B (en) * 2019-02-13 2020-03-27 上海燧原智能科技有限公司 Performance analysis method, device, equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1997016003A1 (en) * 1995-10-25 1997-05-01 Siemens Aktiengesellschaft Security chip
CN1707464A (en) * 2005-03-17 2005-12-14 联想(北京)有限公司 Embedded safety ship of real-time clock and method for correcting real-time clock thereof
US20060050931A1 (en) * 2004-09-07 2006-03-09 Sony Corporation Biometric identification system
CN103839012A (en) * 2012-11-23 2014-06-04 景幂机械(上海)有限公司 Flash encrypted storage device
CN106127483A (en) * 2016-06-30 2016-11-16 华为技术有限公司 Method of mobile payment, SOC(system on a chip) and terminal
CN106372540A (en) * 2016-08-29 2017-02-01 北京中电华大电子设计有限责任公司 Secure transmission method and circuit of chip security information

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140250290A1 (en) * 2013-03-01 2014-09-04 St-Ericsson Sa Method for Software Anti-Rollback Recovery
US10318271B2 (en) * 2015-01-05 2019-06-11 Irdeto Canada Corporation Updating software components in a program
US9792229B2 (en) * 2015-03-27 2017-10-17 Intel Corporation Protecting a memory
CN106406939A (en) * 2016-09-05 2017-02-15 惠州Tcl移动通信有限公司 EMMC chip-based mobile terminal rollback prevention method and system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1997016003A1 (en) * 1995-10-25 1997-05-01 Siemens Aktiengesellschaft Security chip
US20060050931A1 (en) * 2004-09-07 2006-03-09 Sony Corporation Biometric identification system
CN1707464A (en) * 2005-03-17 2005-12-14 联想(北京)有限公司 Embedded safety ship of real-time clock and method for correcting real-time clock thereof
CN103839012A (en) * 2012-11-23 2014-06-04 景幂机械(上海)有限公司 Flash encrypted storage device
CN106127483A (en) * 2016-06-30 2016-11-16 华为技术有限公司 Method of mobile payment, SOC(system on a chip) and terminal
CN106372540A (en) * 2016-08-29 2017-02-01 北京中电华大电子设计有限责任公司 Secure transmission method and circuit of chip security information

Also Published As

Publication number Publication date
CN109150534B (en) 2021-10-01
CN109150534A (en) 2019-01-04

Similar Documents

Publication Publication Date Title
US11574061B2 (en) Rollback resistant security
EP3274850B1 (en) Protecting a memory
EP3274848B1 (en) Providing enhanced replay protection for a memory
US10223289B2 (en) Secure handling of memory caches and cached software module identities for a method to isolate software modules by means of controlled encryption key management
KR100692348B1 (en) Sleep protection
WO2020192406A1 (en) Method and apparatus for data storage and verification
TWI436280B (en) Authentication method for accessing profile of basic input/output system
US20080320263A1 (en) Method, system, and apparatus for encrypting, integrity, and anti-replay protecting data in non-volatile memory in a fault tolerant manner
US7945790B2 (en) Low-cost pseudo-random nonce value generation system and method
US20210223968A1 (en) Memory system, information processing apparatus, and information processing system
KR20160111455A (en) Key extraction during secure boot
CN109445705B (en) Firmware authentication method and solid state disk
CN110659506A (en) Replay protection of memory based on key refresh
CN109891425B (en) Sequence verification
CN109891823B (en) Method, system, and non-transitory computer readable medium for credential encryption
US10354094B2 (en) Systems and methods for cache memory authentication
WO2018233583A1 (en) Terminal device and data processing method
US11468159B2 (en) Memory system
US9218484B2 (en) Control method and information processing apparatus
US11429722B2 (en) Data protection in a pre-operation system environment based on an embedded key of an embedded controller
US20220284088A1 (en) Authentication of write requests
KR101765209B1 (en) Apparatus and method for safe booting

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: 18820069

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18820069

Country of ref document: EP

Kind code of ref document: A1