WO2020192406A1 - 数据存储、验证方法及装置 - Google Patents

数据存储、验证方法及装置 Download PDF

Info

Publication number
WO2020192406A1
WO2020192406A1 PCT/CN2020/078528 CN2020078528W WO2020192406A1 WO 2020192406 A1 WO2020192406 A1 WO 2020192406A1 CN 2020078528 W CN2020078528 W CN 2020078528W WO 2020192406 A1 WO2020192406 A1 WO 2020192406A1
Authority
WO
WIPO (PCT)
Prior art keywords
storage space
user data
version information
information
data
Prior art date
Application number
PCT/CN2020/078528
Other languages
English (en)
French (fr)
Inventor
吴彩娣
Original Assignee
阿里巴巴集团控股有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 阿里巴巴集团控股有限公司 filed Critical 阿里巴巴集团控股有限公司
Publication of WO2020192406A1 publication Critical patent/WO2020192406A1/zh
Priority to US17/481,131 priority Critical patent/US20220006617A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • 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/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/088Usage controlling of secret information, e.g. techniques for restricting cryptographic keys to pre-authorized uses, different access levels, validity of crypto-period, different key- or password length, or different strong and weak cryptographic algorithms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/604Tools and structures for managing or administering access control systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/52Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow
    • G06F21/53Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow by executing in a restricted environment, e.g. sandbox or secure virtual machine
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/57Certifying or maintaining trusted computer platforms, e.g. secure boots or power-downs, version controls, system software checks, secure updates or assessing vulnerabilities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • 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/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0877Generation of secret information including derivation or calculation of cryptographic keys or passwords using additional device, e.g. trusted platform module [TPM], smartcard, USB or hardware security module [HSM]
    • 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/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0894Escrow, recovery or storing of secret information, e.g. secret key escrow or cryptographic key storage
    • H04L9/0897Escrow, recovery or storing of secret information, e.g. secret key escrow or cryptographic key storage involving additional devices, e.g. trusted platform module [TPM], smartcard or USB
    • 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/14Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using a plurality of keys or algorithms
    • 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/3247Cryptographic 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 involving digital signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1873Versioning file systems, temporal file systems, e.g. file system supporting different historic versions of files

Definitions

  • the present invention relates to the technical field of data security, in particular to a data storage and verification method and device.
  • Terminal equipment is becoming more and more popular, and its types and quantities are increasing.
  • the data security issues brought by this have gradually attracted people's attention.
  • Data version rollback will bring security risks to user data.
  • the terminal device usually stores the user's password, fingerprint and other data, and the user may modify these data when using the terminal device. If the modified data is rolled back to the previous version, the lighter case may cause the terminal device to fail to operate normally, and the severer case may cause the user's significant property loss.
  • the new version of the application usually fixes the security vulnerabilities in the old version of the application. If the new version of the application is rolled back to the old version, the security vulnerabilities will recur, which may cause the user's sensitive information to be leaked or property damage.
  • the present invention provides a data storage and verification method and device to try to solve or at least alleviate the above problems.
  • a data storage method which is executed in a trusted execution environment, the method comprising: encrypting user data and version information of the user data using a first key to generate a first key A ciphertext, storing the first ciphertext in a common storage space; generating verification information of the user data; storing the version information and the verification information in a secure storage space.
  • a data verification method executed in a trusted execution environment, the method comprising: obtaining and decrypting a first ciphertext from a common storage space to obtain user data and version information; Obtain version information and verification information from the secure storage space; calculate the verification information of the user data; when the version information obtained by decrypting the first ciphertext is the same as the version information obtained from the secure storage space, and calculate When the verification information of is the same as the verification information obtained from the secure storage space, it is determined that the user data and its version information are safe.
  • a computing device including: at least one processor; and a memory storing program instructions, when the program instructions are read and executed by the processor, the calculation The device executes the data storage method and data verification method as described above.
  • a readable storage medium storing program instructions.
  • the computing device executes the data storage method and Data verification method.
  • the present invention first provides a safe storage solution for user data and version information.
  • the first key is used in the trusted execution environment to encrypt the user data and the version information of the user data, and the first ciphertext is generated and stored in a common storage space; and the version information and user data are stored
  • the verification information is stored in a safe storage space.
  • the trusted execution environment is an isolated and trusted environment.
  • the first key is kept in the trusted execution environment, which can avoid the acquisition and tampering of related data during the process of generating the first ciphertext.
  • the secure storage space is a partition with security features in the storage device.
  • the version information and verification information are stored in the secure storage space to ensure the security of the version information and verification information and prevent it from being tampered with.
  • storing user data usually a large amount of data
  • version information and verification information a small amount of data
  • the present invention also provides a solution capable of verifying whether the user data version is rolled back.
  • the first ciphertext is obtained from the ordinary storage space and decrypted to obtain user data and version information, and the verification information of the user data is calculated according to the verification information; the version information and verification information are obtained from the secure storage space. If the version information obtained by decrypting the first ciphertext is the same as the version information obtained from the secure storage space, it indicates that the version information has not been rolled back. If the calculated verification information is the same as the verification information obtained from the secure storage space, it indicates that the user data has not been tampered with, which avoids the situation where the version information remains unchanged and only the user data is rolled back to the old version.
  • Fig. 1 shows a schematic diagram of a terminal device 100 according to an embodiment of the present invention
  • Figure 2 shows a schematic diagram of partitions of an embedded memory card according to an embodiment of the present invention
  • FIG. 3 shows a flowchart of a data storage method 300 according to an embodiment of the present invention
  • FIG. 4 shows a flowchart of a data verification method 400 according to an embodiment of the present invention.
  • FIG. 5 shows a schematic diagram of a computing device 500 according to an embodiment of the present invention.
  • Fig. 1 shows a schematic diagram of a terminal device 100 according to an embodiment of the present invention.
  • the terminal device 100 can be implemented as any device, such as a mobile phone, a tablet computer, a smart wearable device, a smart home appliance, a car machine, a drone, etc., but is not limited thereto.
  • a trusted execution environment Trusted Execution Environment, TEE
  • a rich execution environment Rich Execution Environment, REE
  • the trusted execution environment and the rich execution environment have mutually isolated hardware and independent operating systems to meet the operating requirements of applications with different security levels.
  • the hardware isolation between the trusted execution environment and the rich execution environment can be realized by, for example, the security extension technology of ARM TrustZone or C-SKY, but is not limited to this.
  • the operating system of the rich execution environment can be a general operating system such as Android, iOS, RTOS real-time operating system, and the operating system can run ordinary applications that do not require high security, such as instant messaging, photographing, and weather query.
  • the operating system of the trusted execution environment is usually a closed, relatively simple secure operating system, on which trusted applications with high security requirements, such as fingerprint recognition, identity authentication, electronic payment, and smart locks, run Wait.
  • Trusted applications in the trusted execution environment can be called by ordinary applications in the rich execution environment to implement corresponding functions.
  • ordinary application A is a shopping application located in a rich execution environment
  • trusted application B is a fingerprint verification application located in a trusted execution environment.
  • the user purchases goods on the normal application A he can choose the fingerprint payment method to complete the payment.
  • ordinary application A calls trusted application B to implement the fingerprint verification function.
  • the trusted application B reads the stored fingerprint template, compares it with the fingerprint input by the user, and returns the comparison result to the ordinary application A.
  • the storage device shown in Figure 1 is used to store user data.
  • User data can be any form of data objects stored on the terminal device, such as applications, files, identity information (such as passwords, fingerprints, iris, etc.), but it is not limited thereto.
  • the storage device can be divided into multiple independent partitions, and the functions, security, and stored data content of each partition are different.
  • the storage device is divided into a normal storage space 140 and a secure storage space 150.
  • Corresponding file systems (File System, FS for short) can be respectively configured on the ordinary storage space 140 and the secure storage space 150, and the file system is a kind of software for managing and storing file information.
  • the file system includes, for example, Ext4 (Fourth extended file system), FUSE (Filesystem in Userspace, user space file system), vfat (Virtual File Allocation Table, virtual file allocation table), but not limited to this.
  • the ordinary storage space 140 is a storage space without a security verification mechanism, which can be accessed by any application in a rich execution environment or a trusted execution environment.
  • the secure storage space 150 is a storage space with a security verification mechanism. When data is written into the secure storage space 150, the legality of the data needs to be verified, and the writing is allowed after the legality verification is passed. When reading data, a signature mechanism is provided to ensure that the data read is the data inside the secure storage space 150, not data forged by an attacker. It should be noted that in order to realize the functions of storage device partitioning, data reading and writing, security verification, etc., it is usually necessary to configure the corresponding drive application 120 in the rich execution environment, and the drive application 120 implements functions such as reading and writing of the storage device. .
  • any application in the rich execution environment or the trusted execution environment that can provide a legal signature and pass the verification can access the secure storage space 150.
  • the secure storage space 150 may be further defined and divided, so that a specific area in the secure storage space 150 can only be accessed by certain specific applications in a rich execution environment or a trusted execution environment.
  • each trusted application corresponds to a private storage area.
  • the private storage area corresponding to the trusted application is located in the secure storage space. That is, the secure storage space 150 may be divided into multiple disjoint areas, some areas are private storage areas of trusted applications, and correspondingly, this area can only be accessed by corresponding trusted applications.
  • the trusted storage space 150 includes a storage area 152 and a storage area 154.
  • the storage area 152 is a private storage area of the version management application 110 (trusted application). Accordingly, only the version management application 110 can download Read and write data in the storage area 152, as shown by the path numbered 1.
  • the storage area 154 is not specifically defined. Any application that can pass the security check can access the storage area 154. For example, both the version management application 110 and the ordinary application 130 can access the storage area 154.
  • the path for the ordinary application 130 to access the storage area 154 As shown by number 2.
  • the storage device may be implemented as an embedded memory card (Embedded Multi Media Card, eMMC for short, also known as an embedded multimedia card).
  • eMMC embedded Multi Media Card
  • Fig. 2 shows a schematic diagram of partitions of an embedded multimedia card according to an embodiment of the present invention. As shown in Figure 2, the embedded multimedia card includes the first boot partition (BOOT Area Partition 1), the second boot partition (BOOT Area Partition 2), the security partition (RPMB, Replay Protected Memory Block), and the user data partition (User Data).
  • the embedded multimedia card includes the first boot partition (BOOT Area Partition 1), the second boot partition (BOOT Area Partition 2), the security partition (RPMB, Replay Protected Memory Block), and the user data partition (User Data).
  • the first boot partition and the second boot partition are used to store key data such as device startup or debugging configuration parameters;
  • the RPMB partition is a partition with security features used to store some special data that requires access authorization;
  • user data The partition is used to store various user data;
  • the reserved partition is a partition reserved by the manufacturer, which is invisible to the user and cannot be operated by the user, and stores the eMMC firmware version number, startup key and other data.
  • the storage capacity of the user data partition is relatively large, usually accounting for more than 90% of the entire memory card capacity; and the storage capacity of the first boot partition, the second boot partition, the RPMB partition, and the reserved partition is usually small.
  • the storage device of the terminal device 100 when the storage device of the terminal device 100 is implemented as an eMMC memory card, the common storage space 140 is the user data partition of the eMMC memory card, and the secure storage area 150 is the eMMC memory card.
  • RPMB partition secure partition
  • the trusted execution environment includes a version management application 110.
  • the version management application 110 is specifically used to manage user data and its version information, to prevent data version rollbacks, and to ensure the data on the terminal device and Property safety.
  • the version management application 110 may provide a data storage solution for securely storing user data and version information.
  • the first key is used to encrypt the user data and the version information of the user data, and the first ciphertext is generated and stored in a common storage space; the version information and the verification information of the user data are stored in a secure storage space.
  • the version management application 110 may also provide a data verification solution for verifying whether the user data version is rolled back.
  • the first ciphertext is obtained from the common storage space and decrypted.
  • FIG. 3 shows a flowchart of a data storage method 300 according to an embodiment of the present invention.
  • the method 300 is executed in the trusted execution environment of the terminal device, for example, as shown in FIG. 1, it is executed by the version management application 110 in the trusted execution environment. As shown in FIG. 3, the method 300 starts at step S310.
  • step S310 the user data and the version information of the user data are encrypted using the first key to generate a first ciphertext, and the first ciphertext is stored in a common storage space.
  • User data can be data objects in any format, such as applications, files, identity information (such as passwords, fingerprints, iris, etc.), but it is not limited to this.
  • the version information of the user data is used to indicate how old the user data is.
  • the version information may include, for example, the version number, the version update time, etc., but is not limited thereto.
  • the first key is dynamically generated in the trusted execution environment, for example, by the version management application 110 in the trusted execution environment according to certain rules.
  • the so-called dynamic generation means that when the version management application 110 stores each group of user data, it will generate the first key for each group of user data, so that each group of user data corresponds to a first key.
  • the first key corresponding to the user data is different.
  • the process of using the first key to encrypt user data and version information can use any algorithm, and the present invention does not limit the encryption algorithm used to generate the first ciphertext.
  • the encryption algorithm may be AES (Advanced Encryption Standard, Advanced Encryption Standard), DES (Data Encryption Standard, Data Encryption Standard), RSA encryption algorithm, etc., but is not limited to this.
  • the first ciphertext is stored in a common storage space.
  • the common storage space is the user data partition of the embedded memory card eMMC. Accordingly, after the version management application 110 in the trusted execution environment generates the first ciphertext, it drives through the eMMC in the rich execution environment The application 120 writes the first ciphertext into the user data partition of the eMMC.
  • step S320 verification information of the user data is generated.
  • the verification information is used to verify the user data to prevent the user data from being tampered with and to ensure the integrity of the user data.
  • the verification information is a mapping value obtained by mapping user data using a preset mapping algorithm. It should be noted that those skilled in the art can use any mapping algorithm to map user data to obtain a mapping value, and the present invention does not limit the specific type of the mapping algorithm.
  • the mapping algorithm may be, for example, a hash (Hash) algorithm, a message authentication code (MAC) algorithm, a Base64 encoding algorithm, etc., but it is not limited thereto.
  • step S330 the version information and the verification information are stored in a secure storage space.
  • the version management application 110 stores the version information and verification information in a private storage area of the version management application 110 located in a secure storage space, such as the storage area 152 in FIG. 1.
  • the secure storage space is a secure partition of the embedded memory card eMMC, that is, the RPMB partition.
  • the version management application 110 in the trusted execution environment uses the eMMC driver application located in the rich execution environment to transfer the version information
  • the sum check information is stored in the RPMB partition of the eMMC.
  • the RPMB partition of eMMC requires security verification when writing data.
  • the version information and verification information are written into the RPMB partition according to the following steps:
  • the version information and the verification information are formed into a data frame conforming to the write verification format of the secure storage space.
  • the data frame includes version information, verification information, write count value, and signature value.
  • the write count value is the value of a count variable (Write Counter) stored in eMMC, and the value of Write Counter will automatically increase by one every time the RPMB performs a legal write operation.
  • the write count value is read in advance from the eMMC by the version management application. Both the trusted execution environment and the eMMC store the second key used to verify the security of the RPMB.
  • the write count value can be read according to the following steps:
  • the version management application 110 initiates a request to read the Write Counter to the eMMC, and at the same time generates a random number, and sends it to the eMMC. Subsequently, the eMMC takes out the Write Counter value, and uses the second key to calculate the signature of the Write Counter value and the received random number through the HMAC SHA-256 algorithm. Subsequently, the eMMC sends the Write Counter value, the received random number, and the calculated signature to the version management application 110. After the version management application 110 receives the data sent by the eMMC, it first compares whether the random number is consistent with the random number sent before.
  • the same second key is used to compare the WriteCounter value and the value through the HMAC SHA-256 algorithm.
  • the random number is used for signing. If the signature is consistent with the signature sent by the eMMC, it can be determined that the WriteCounter value is correct data, not the data forged by the attacker.
  • the signature value in the data frame is a cipher text obtained by using the second key to encrypt the version information, verification information, and write count value.
  • the encryption algorithm used to generate the signature value may be, for example, the HMAC SHA-256 algorithm, but is not limited to this.
  • the version management application 110 After the version management application 110 generates a data frame including version information, verification information, a write count value, and a signature value, the data frame is sent to the eMMC for verification.
  • the validity of the write operation can be verified according to the following steps: First, determine whether the write count value is consistent with the WriteCounter value stored in eMMC. If they are consistent, use the second key to calculate the version through the HMAC SHA-256 algorithm. The signature value of the information, verification information, and WriteCounter value. If the calculated signature value is consistent with the signature value sent by the version management application 110, the authentication is passed and the write operation is legal. After determining that the write operation is legal according to the write count value and the signature value, the version information and verification information are stored in a secure storage space, that is, the version information and verification information are stored in the RPMB partition of the eMMC.
  • the second key is burned in the trusted execution environment, managed by a specific application (for example, the version management application 110) in the trusted execution environment, and will not be exposed to the rich execution environment, thereby enabling secure storage space
  • the version information and verification information in can only be read by specific applications in the trusted execution environment, and other applications cannot obtain the version information and verification information because they do not know the second key.
  • the first key is dynamically generated in the trusted execution environment, and the second key is a fixed value burned in the trusted execution environment.
  • the first ciphertext is stored in a relatively insecure common storage space. Therefore, it is necessary to increase its protection accordingly and generate a different first key for each group of user data.
  • the version information and verification information are stored in the secure storage space. The combination of the secure storage space and the trusted execution environment can better protect the security of the version information and verification information.
  • the second key is only used for secure storage. The space read and write operations are authenticated.
  • the method 300 is executed in a trusted execution environment.
  • the first key and the second key are kept in the trusted execution environment, which can avoid obtaining the relevant data during the process of generating the first ciphertext and reading and writing to the secure storage space. ,tamper.
  • the first ciphertext of user data and version information is stored in the ordinary storage space, and the version information and verification information are stored in the secure storage space.
  • the secure storage space is a partition with security features in the storage device.
  • the version information and verification information are stored in the secure storage space to ensure the security of the version information and verification information and prevent it from being tampered with.
  • the data volume of user data is usually large, and the data volume of version information and verification information is small. Store user data in a large-capacity ordinary storage space, and store version information and verification information to a limited capacity. In the storage space, it is possible to improve storage efficiency while ensuring data security.
  • FIG. 4 shows a flowchart of a data verification method 400 according to an embodiment of the present invention.
  • the method 400 corresponds to the method 300, and is used to provide a data verification solution for verifying whether the user data version is rolled back based on the data storage solution provided by the method 300. For example, when user data needs to be read or called, the method 400 is first executed to verify whether the user data is safe, that is, to verify whether the version of the user data is rolled back. After verifying the security of the user data, call the user data.
  • the method 400 is executed in the trusted execution environment of the terminal device, for example, as shown in FIG. 1, it is executed by the version management application 110 in the trusted execution environment. As shown in FIG. 4, the method 400 starts at step S410.
  • step S410 the first ciphertext is obtained from the common storage space and decrypted to obtain user data and version information.
  • the version management application 110 reads the first ciphertext from the ordinary storage space 140 through the driver application 120 in the rich execution environment, and uses the first key to decrypt the first ciphertext to restore the output User data and version information.
  • the normal storage space is the user data partition of the embedded memory card eMMC, and accordingly, the version management application 110 reads the first ciphertext from the user data partition through the eMMC driver application 120 in the rich execution environment .
  • step S420 version information and verification information are obtained from the secure storage space.
  • the version management application 110 reads version information and verification information from the secure storage space 150 through the driver application 120 in the rich execution environment.
  • the secure storage space is a secure partition of the embedded memory card eMMC, that is, the RPMB partition.
  • the version management application 110 reads the version information from the RPMB partition through the eMMC driver application 120 in the rich execution environment And check information.
  • the process of reading version information and verification information from the RPMB partition is as follows:
  • the version management application 110 initiates a request to read version information and verification information to the eMMC, and at the same time generates a random number, and sends it to the eMMC. Subsequently, eMMC retrieves the version information and verification information from the RPMB partition, and uses the second key to calculate the signature after the version information, verification information and the received random number are spliced together through the HMAC SHA-256 algorithm. Subsequently, the eMMC sends the version information, verification information, the received random number, and the calculated signature to the version management application 110 together. After the version management application 110 receives the data sent by eMMC, it first compares whether the random number is consistent with the random number sent before.
  • the version information and verification information are the correct data stored in the RPMB, rather than the data forged by the attacker.
  • step S430 the verification information of the user data is calculated.
  • step S410 the same mapping algorithm as that in step S320 is used to calculate the verification information of the user data.
  • step S440 when the version information obtained by decrypting the first ciphertext is the same as the version information obtained from the secure storage space, and the calculated verification information is the same as the verification information obtained from the secure storage space When the same, make sure that the user data and its version information are safe.
  • the version information obtained by decrypting the first ciphertext is the same as the version information obtained from the secure storage space, indicating that the version information has not been maliciously tampered with, that is, the version information itself has not been rolled back.
  • the calculated verification information is the same as the verification information obtained from the secure storage space, which indicates that the user data has not been tampered with, thus avoiding the attacker from cracking the storage format of the user data, and does not modify the version information but only the user data Revert to the old version.
  • the present invention provides a technical solution that can prevent the user data version from rolling back, which can effectively avoid rolling back version information, or retaining version information and only rolling back user data.
  • the methods 300 and 400 provide a preferred embodiment of version anti-rollback. In addition to the methods 300 and 400, other embodiments may also be used to prevent version rollback.
  • user data can be encrypted in a trusted execution environment, and then all encrypted user data can be written into a secure storage space (such as the RPMB partition of eMMC) to prevent user data from being tampered with.
  • a secure storage space such as the RPMB partition of eMMC
  • the capacity of the current secure storage space is usually small.
  • the amount of user data is large (for example, when the user data is fingerprints or iris information)
  • the user data cannot be completely stored in the secure storage space.
  • the secure storage space has a security verification mechanism, its read and write performance is usually poor.
  • the amount of user data is large, it takes a long time to read and write data, there will be a delay, and the user experience is poor.
  • user data can be encrypted in a trusted execution environment, and the encrypted user data can be stored in a common storage space (for example, the user data partition of eMMC); the version information of the user data can be written into the secure Storage space (such as the RPMB partition of eMMC) to prevent version information from being tampered with.
  • a common storage space for example, the user data partition of eMMC
  • the version information of the user data can be written into the secure Storage space (such as the RPMB partition of eMMC) to prevent version information from being tampered with.
  • this solution lacks a complete verification link for user data. If an attacker knows the format of a file storing user data in ordinary storage space, he can accurately modify user data without modifying the version information. In this way, the version information remains unchanged and the new version remains, but the user data is rolled back. Therefore, this scheme still has potential safety hazards.
  • FIG. 5 shows a schematic diagram of a computing device 500 according to an embodiment of the present invention.
  • the computing device 500 includes a processor 510 and a memory 520.
  • the memory 520 stores program instructions.
  • the computing device 500 executes the data storage method 300 and the data verification method 400 of the present invention.
  • the computing device 500 is implemented as a terminal device of the present invention, such as the terminal device 100 in FIG. 1 described above.
  • the various technologies described here can be implemented in combination with hardware or software, or a combination of them. Therefore, the method and device of the present invention, or some aspects or parts of the method and device of the present invention may be embedded in a tangible medium, such as a removable hard disk, U disk, floppy disk, CD-ROM, or any other machine-readable storage medium
  • program code ie, instructions
  • the machine becomes a device for practicing the present invention.
  • the computing device When the program code is executed on a programmable computer, the computing device generally includes a processor, a storage medium readable by the processor (including volatile and nonvolatile memory and/or storage elements), and at least one input device, And at least one output device.
  • the memory is configured to store program code; the processor is configured to execute the data storage and data verification method of the present invention according to instructions in the program code stored in the memory.
  • readable media include readable storage media and communication media.
  • the readable storage medium stores information such as computer readable instructions, data structures, program modules, or other data.
  • Communication media generally embody computer readable instructions, data structures, program modules or other data in modulated data signals such as carrier waves or other transmission mechanisms, and include any information delivery media. Combinations of any of the above are also included in the scope of readable media.
  • the algorithms and displays are not inherently related to any particular computer, virtual system or other equipment.
  • Various general-purpose systems can also be used with the examples of the present invention. From the above description, the structure required to construct this type of system is obvious.
  • the present invention is not directed to any specific programming language. It should be understood that various programming languages can be used to implement the content of the present invention described herein, and the above description of a specific language is to disclose the best embodiment of the present invention.
  • modules or units or components of the device in the example disclosed herein can be arranged in the device as described in this embodiment, or alternatively can be positioned differently from the device in this example In one or more devices.
  • the modules in the foregoing examples can be combined into one module or further divided into multiple sub-modules.
  • modules or units or components in the embodiments can be combined into one module or unit or component, and in addition, they can be divided into multiple sub-modules or sub-units or sub-components. Except that at least some of such features and/or processes or units are mutually exclusive, any combination can be used to compare all features disclosed in this specification (including the accompanying claims, abstract and drawings) and any method or methods disclosed in this manner or All the processes or units of the equipment are combined. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
  • some of the embodiments are described herein as methods or combinations of method elements that can be implemented by a processor of a computer system or by other devices that perform the described functions. Therefore, a processor with the necessary instructions for implementing the method or method element forms a device for implementing the method or method element.
  • the elements described herein of the device embodiments are examples of devices for implementing functions performed by the elements for the purpose of implementing the invention.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Automation & Control Theory (AREA)
  • Storage Device Security (AREA)

Abstract

一种数据存储、验证方法及装置,在可信执行环境中执行,该方法包括:采用第一密钥对用户数据和用户数据的版本信息进行加密以生成第一密文,将第一密文存储至普通存储空间(S310);生成用户数据的校验信息(S320);将版本信息和校验信息存储至安全存储空间(S330)。可以有效地防止用户数据版本回退。

Description

数据存储、验证方法及装置
本申请要求2019年03月22日递交的申请号为201910221335.9、发明名称为“数据存储、验证方法及装置”中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及数据安全技术领域,尤其涉及一种数据存储、验证方法及装置。
背景技术
终端设备日益普及,其种类及数量越来越多,由此带来的数据安全问题逐渐引起人们的重视。
数据版本回退会对用户数据带来安全隐患。例如,终端设备上通常存储有用户的密码、指纹等数据,用户在使用终端设备的过程中可能会对这些数据进行修改。若修改后的数据被回退至前一版本,则轻者可造成终端设备无法正常使用,重者可能造成用户的重大财产损失。又例如,新版本的应用通常修复了旧版本应用中存在的安全漏洞,若新版本的应用被回退到旧版本,则安全漏洞复现,可能会造成用户的敏感信息泄露或财产损失。
因此,需要提供一种能够防止数据版本回退的技术方案。
发明内容
为此,本发明提供一种数据存储、验证方法及装置,以力图解决或至少缓解上面存在的问题。
根据本发明的第一个方面,提供一种数据存储方法,在可信执行环境中执行,所述方法包括:采用第一密钥对用户数据和所述用户数据的版本信息进行加密以生成第一密文,将所述第一密文存储至普通存储空间;生成所述用户数据的校验信息;将所述版本信息和所述校验信息存储至安全存储空间。
根据本发明的第二个方面,提供一种数据验证方法,在可信执行环境中执行,所述方法包括:从普通存储空间中获取第一密文并解密,以得到用户数据和版本信息;从安全存储空间中获取版本信息和校验信息;计算所述用户数据的校验信息;当解密第一密文所得到的版本信息与从安全存储空间中获取到的版本信息相同,且计算出的校验信息与从安全存储空间中获取到的校验信息相同时,确定所述用户数据及其版本信息安全。
根据本发明的第三个方面,提供一种计算设备,包括:至少一个处理器;和存储有程序指令的存储器,当所述程序指令被所述处理器读取并执行时,使得所述计算设备执行如上所述的数据存储方法和数据验证方法。
根据本发明的第四个方面,提供一种存储有程序指令的可读存储介质,当所述程序指令被计算设备读取并执行时,使得所述计算设备执行如上所述的数据存储方法和数据验证方法。
本发明首先提供了一种用户数据和版本信息的安全存储方案。在该方案中,在可信执行环境中采用第一密钥对用户数据和用户数据的版本信息进行加密,生成第一密文并将其存储至普通存储空间;并将版本信息和用户数据的校验信息存储至安全存储空间。
可信执行环境是一个孤立、可信的环境,第一密钥在可信执行环境中保管,可以避免生成第一密文的过程中相关数据被获取、篡改。安全存储空间是存储装置中具有安全特性的分区,将版本信息及校验信息存储至安全存储空间,可以保证版本信息和校验信息的安全性,防止其被篡改。另外,将用户数据(数据量通常较大)存储在容量较大的普通存储空间中,版本信息及校验信息(数据量较小)存储在容量有限的安全存储空间中,可以在保证数据安全性的同时,提高了存储效率。
与上述安全存储方案相对应地,本发明还提供了一种能够验证用户数据版本是否回退的方案。在该方案中,从普通存储空间中获取第一密文并解密,以得到用户数据和版本信息,并根据计算用户数据的校验信息;从安全存储空间中获取版本信息和校验信息。若解密第一密文所得到的版本信息与从安全存储空间中获取到的版本信息相同,则表明版本信息未回退。若计算出的校验信息与从安全存储空间中获取到的校验信息相同,则表明用户数据未被篡改,避免了版本信息不变而仅将用户数据回退至旧版本的情况。
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。
附图说明
为了实现上述以及相关目的,本文结合下面的描述和附图来描述某些说明性方面,这些方面指示了可以实践本文所公开的原理的各种方式,并且所有方面及其等效方面旨在落入所要求保护的主题的范围内。通过结合附图阅读下面的详细描述,本公开的上述以及其它目的、特征和优势将变得更加明显。遍及本公开,相同的附图标记通常指代相 同的部件或元素。
图1示出了根据本发明一个实施例的终端设备100的示意图;
图2示出了根据本发明一个实施例的嵌入式存储卡的分区示意图;
图3示出了根据本发明一个实施例的数据存储方法300的流程图;
图4示出了根据本发明一个实施例的数据验证方法400的流程图;以及
图5示出了根据本发明一个实施例的计算设备500的示意图。
具体实施方式
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。
图1示出了根据本发明一个实施例的终端设备100的示意图。终端设备100可以实现为任意设备,例如手机、平板电脑、智能可穿戴设备、智能家电、车机、无人机等,但不限于此。
如图1所示,终端设备100中部署有可信执行环境(Trusted Execution Environment,简称TEE)和富执行环境(Rich Execution Environment,简称REE)。可信执行环境与富执行环境具有相互隔离的硬件、以及独立的操作***,用于满足不同安全级别的应用的运行要求。可信执行环境与富执行环境的硬件隔离例如可以通过ARM TrustZone或C-SKY的安全扩展技术来实现,但不限于此。
富执行环境的操作***可以是Android、iOS、RTOS实时操作***等通用操作***,该操作***上可以运行对安全性要求不高的普通应用,例如即时通讯、拍照、天气查询等。可信执行环境的操作***通常为一个封闭的、功能相对简单的安全操作***,在该操作***上运行对安全性要求较高的可信应用,例如指纹识别、身份认证、电子支付、智能锁等。可信执行环境中的可信应用可以被富执行环境中的普通应用调用以实现相应功能。例如,普通应用A为位于富执行环境中的购物应用,可信应用B为位于可信执行环境中的指纹校验应用。当用户在普通应用A上购买商品时,可以选择指纹支付的方式来完成付款。这时,普通应用A调用可信应用B来实现指纹校验功能。具体地,可信应用B读取已存储的指纹模板,与用户输入的指纹进行比对,并将比对结果返回给普通应 用A。
图1所示的存储装置用于存储用户数据。用户数据可以是终端设备上存储的任意形式的数据对象,例如应用、文件、身份信息(例如密码、指纹、虹膜等)等,但不限于此。存储装置可以被划分为多个独立的分区,各个分区的功能、安全性、存储的数据内容等有所区别。
在本发明的实施例中,如图1所示,存储装置被划分为普通存储空间140和安全存储空间150。普通存储空间140和安全存储空间150上可以分别配置相应的文件***(File System,简称FS),文件***是一种用于管理和存储文件信息的软件。文件***例如包括Ext4(Fourth extended filesystem,***扩展文件***)、FUSE(Filesystem in Userspace,用户空间文件***)、vfat(Virtual File Allocation Table,虚拟文件分配表)等,但不限于此。
普通存储空间140为没有安全校验机制的存储空间,其可以被富执行环境或可信执行环境中的任意应用访问。安全存储空间150为具有安全校验机制的存储空间,当数据写入安全储存空间150时,需要校验数据的合法性,合法性校验通过后才允许写入。在读取数据时,提供了签名机制,保证读取到的数据是安全存储空间150内部的数据,而不是攻击者伪造的数据。需要说明的是,为了实现存储装置的分区以及数据读写、安全性校验等功能,通常需要在富执行环境中配置相应的驱动应用120,由驱动应用120来实现存储装置的读写等功能。
在没有特殊定义的情况下,富执行环境或可信执行环境中的能够提供合法的签名并通过校验的任意应用都可以访问安全存储空间150。根据一种实施例,安全存储空间150可以进一步被定义、划分,使得安全存储空间150中的特定区域只能由富执行环境或可信执行环境中的某些特定应用可以访问。
在一些实施例中,每一个可信应用都对应有一个私有的存储区域。为了保证数据的安全性,可信应用所对应的私有存储区域位于安全存储空间中。即,安全存储空间150可以被划分为多个互不相交的区域,某些区域为可信应用的私有存储区域,相应地,该区域只能由相应的可信应用访问。如图1所示,可信存储空间150包括存储区域152和存储区域154,其中,存储区域152为版本管理应用110(可信应用)的私有存储区域,相应地,只有版本管理应用110可以向存储区域152中读写数据,如编号为①的路径所示。存储区域154则没有特殊定义,任意可以通过安全性校验的应用均可以访问存储区域154,例如,版本管理应用110和普通应用130均可以访问存储区域154,普通应用 130访问存储区域154的路径如编号②所示。
需要说明的是,本发明对存储装置的具体实现形式不做限制,只要存储装置中的存储区域包括无安全校验的普通存储区域和有安全校验的安全存储区域,则这样的存储装置否在本发明的保护范围之内。根据一种实施例,存储装置可以实现为嵌入式存储卡(Embedded Multi Media Card,简称eMMC,又称嵌入式多媒体卡)。图2示出了根据本发明一个实施例的嵌入式多媒体卡的分区示意图。如图2所示,嵌入式多媒体卡包括第一引导分区(BOOT Area Partition 1)、第二引导分区(BOOT Area Partition 2)、安全分区(RPMB,Replay Protected Memory Block)、用户数据分区(User Data Area)和保留分区(Vender private area)。其中,第一引导分区、第二引导分区用于存储设备启动或调试配置参数等关键数据;RPMB分区是一块具有安全特性的分区,用于存储一些特殊的、需要进行访问授权的数据;用户数据分区用于存储各种用户数据;保留分区是生产厂家预留的分区,对用户不可见且用户不能进行操作,其中存储有eMMC的固件版本号、启动密钥等数据。在上述分区中,用户数据分区的存储容量较大,通常占到整个存储卡容量的90%以上;而第一引导分区、第二引导分区、RPMB分区、保留分区的存储容量通常较小。
对应于本发明的实施例,如图1所示,当终端设备100的存储装置实现为eMMC存储卡时,普通存储空间140为eMMC存储卡的用户数据分区,安全存储区域150为eMMC存储卡的RPMB分区(安全分区)。
在本发明的实施例中,可信执行环境包括版本管理应用110,版本管理应用110具体用于管理用户数据及其版本信息,防止出现数据版本回退的情况,以保证终端设备上的数据以及财产安全。具体地,版本管理应用110可以提供一种安全存储用户数据和版本信息的数据存储方案。在该方案中,采用第一密钥对用户数据和用户数据的版本信息进行加密,生成第一密文并将其存储至普通存储空间;将版本信息和用户数据的校验信息存储至安全存储空间。
与上述数据存储方案相对应地,版本管理应用110还可以提供一种用于验证用户数据版本是否回退的数据验证方案,在该方案中,从普通存储空间中获取第一密文并解密,以得到用户数据和版本信息,并根据计算用户数据的校验信息;从安全存储空间中获取版本信息和校验信息。若解密第一密文所得到的版本信息与从安全存储空间中获取到的版本信息相同,则表明版本信息未回退。若计算出的校验信息与从安全存储空间中获取到的校验信息相同,则表明用户数据未被篡改,避免了版本信息不变而仅将用户数据回 退至旧版本的情况。
以下将对本发明的数据存储方法和数据验证方法进行详述。
图3示出了根据本发明一个实施例的数据存储方法300的流程图。方法300在终端设备的可信执行环境中执行,例如,如图1所示,由可信执行环境中的版本管理应用110执行。如图3所示,方法300始于步骤S310。
在步骤S310中,采用第一密钥对用户数据和用户数据的版本信息进行加密以生成第一密文,将第一密文存储至普通存储空间。
用户数据可以是任意格式的数据对象,例如应用、文件、身份信息(例如密码、指纹、虹膜等信息)等,但不限于此。用户数据的版本信息用于表示用户数据的新旧程度。版本信息例如可以包括版本号、版本更新时间等,但不限于此。
第一密钥在可信执行环境中动态生成,例如,由可信执行环境中的版本管理应用110按照一定的规则来动态生成。所谓动态生成,指的是版本管理应用110在存储各组用户数据时,会分别生成针对每一组用户数据的第一密钥,使得每组用户数据都对应于一个第一密钥,不同的用户数据所对应的第一密钥不同。
需要说明的是,采用第一密钥对用户数据和版本信息进行加密的过程可以采用任意算法,本发明对生成第一密文所采用的加密算法不做限制。例如,加密算法可以是AES(Advanced Encryption Standard,高级加密标准)、DES(Data Encryption Standard,数据加密标准)、RSA加密算法等,但不限于此。
在生成第一密文后,将第一密文存储至普通存储空间。根据一种实施例,普通存储空间为嵌入式存储卡eMMC的用户数据分区,相应地,可信执行环境中的版本管理应用110在生成第一密文后,通过位于富执行环境中的eMMC驱动应用120来将第一密文写入eMMC的用户数据分区。
随后,在步骤S320中,生成用户数据的校验信息。
校验信息用于对用户数据进行校验,以避免用户数据被篡改,保证用户数据的完整性。根据一种实施例,校验信息为采用预设的映射算法对用户数据进行映射所得到的映射值。需要说明的是,本领域技术人员可以采用任意映射算法来对用户数据进行映射以得到映射值,本发明对映射算法的具体类型不做限制。映射算法例如可以是哈希(Hash)算法、消息认证码(MAC)算法、Base64编码算法等,但不限于此。
随后,在步骤S330中,将版本信息和校验信息存储至安全存储空间。
根据一种实施例,版本管理应用110将版本信息和校验信息存储至位于安全存储空 间中的,版本管理应用110的私有存储区域,例如图1中的存储区域152。
根据一种实施例,安全存储空间为嵌入式存储卡eMMC的安全分区,即RPMB分区,相应地,可信执行环境中的版本管理应用110通过位于富执行环境中的eMMC驱动应用来将版本信息和校验信息存储至eMMC的RPMB分区。
eMMC的RPMB分区在写入数据时需要进行安全性校验。相应地,版本信息和校验信息按照以下步骤被写入RPMB分区:
首先,将版本信息和校验信息组成符合安全存储空间的写校验格式的数据帧,该数据帧包括版本信息、校验信息、写计数值和签名值。其中,写计数值为eMMC中存储的一个计数变量(Write Counter)的值,RPMB每进行一次合法的写入操作时,Write Counter的值就会自动加一。写计数值由版本管理应用从eMMC处预先读取。可信执行环境处和eMMC处均存储有用于对RPMB进行安全性校验的第二密钥。写计数值可以按照以下步骤读取:
首先,版本管理应用110向eMMC发起读取Write Counter的请求,同时生成一个随机数,发送给eMMC。随后,eMMC取出Write Counter的值,并使用第二密钥通过HMAC SHA-256算法计算Write Counter值和接收到的随机数拼接到一起后的签名。随后,eMMC将Write Counter值、接收到的随机数、计算得到的签名一并发送至版本管理应用110。版本管理应用110接收到eMMC发来的数据后,首先比较随机数是否与自己之前发送的随机数一致,如果一致,再用同样的第二密钥通过HMAC SHA-256算法对Write Counter值和随机数进行签名,若签名与eMMC发送的签名一致,则可以确定Write Counter值为正确数据,而不是攻击者伪造的数据。
数据帧中的签名值为采用第二密钥对版本信息、校验信息和写计数值进行加密所得到的密文。生成签名值所采用的加密算法例如可以是HMAC SHA-256算法,但不限于此。
版本管理应用110在生成包括版本信息、校验信息、写计数值和签名值的数据帧后,将该数据帧发送至eMMC进行校验。写入操作的合法性可以按照以下步骤来校验:首先,判断写计数值是否与eMMC中存储的Write Counter值一致,若一致,则再采用第二密钥通过HMAC SHA-256算法来计算版本信息、校验信息和Write Counter值的签名值,若计算出来的签名值与版本管理应用110发送的签名值一致,则鉴权通过,本次写入操作合法。在根据写计数值和签名值确定本次写入操作合法后,将版本信息和校验信息存储至安全存储空间,即将版本信息和校验信息存储至eMMC的RPMB分区。
根据一种实施例,第二密钥烧录于可信执行环境中,由可信执行环境中的特定应用 (例如版本管理应用110)管理,不会暴露给富执行环境,从而使得安全存储空间中的版本信息和校验信息仅能由可信执行环境中的特定应用读取,其他应用则由于不知晓第二密钥而无法获取版本信息和校验信息。
需要说明的是,在步骤S310中,第一密钥在可信执行环境中动态生成,第二密钥为烧录于可信执行环境中的固定值。这是因为,第一密文存储于相对更加不安全的普通存储空间,因此,需要相应增加其保护力度,为每组用户数据分别生成不同的第一密钥。而版本信息和校验信息存储于安全存储空间中,安全存储空间与可信执行环境的组合已经可以较好地保护版本信息和校验信息的安全性,第二密钥仅用于对安全存储空间的读写操作进行鉴权。
方法300在可信执行环境中执行,第一密钥、第二密钥在可信执行环境中保管,可以避免生成第一密文、以及对安全存储空间进行读写的过程中相关数据被获取、篡改。经过方法300,普通存储空间中存储有用户数据和版本信息的第一密文,安全存储空间中存储有版本信息和校验信息。安全存储空间是存储装置中具有安全特性的分区,将版本信息及校验信息存储至安全存储空间,可以保证版本信息和校验信息的安全性,防止其被篡改。另外,用户数据的数据量通常较大,版本信息及校验信息的数据量较小,将用户数据存储至容量较大的普通存储空间中,将版本信息及校验信息存储至容量有限的安全存储空间中,可以在保证数据安全性的同时,提高存储效率。
图4示出了根据本发明一个实施例的数据验证方法400的流程图。方法400与方法300相对应,用于在方法300提供的数据存储方案的基础上,提供一种用于验证用户数据版本是否回退的数据验证方案。例如,在需要读取或调用用户数据时,首先执行方法400验证用户数据是否安全,即,验证用户数据的版本是否发生回退。在验证用户数据安全后,再对用户数据进行调用。
方法400在终端设备的可信执行环境中执行,例如,如图1所示,由可信执行环境中的版本管理应用110执行。如图4所示,方法400始于步骤S410。
在步骤S410中,从普通存储空间中获取第一密文并解密,以得到用户数据和版本信息。
根据一种实施例,版本管理应用110通过富执行环境中的驱动应用120从普通存储空间140中读取出第一密文,并采用第一密钥对第一密文进行解密,以恢复出用户数据和版本信息。
根据一种实施例,普通存储空间为嵌入式存储卡eMMC的用户数据分区,相应地,版 本管理应用110通过富执行环境中的eMMC驱动应用120来从用户数据分区中读取出第一密文。
随后,在步骤S420中,从安全存储空间中获取版本信息和校验信息。
根据一种实施例,版本管理应用110通过富执行环境中的驱动应用120从安全存储空间150中读取出版本信息和校验信息。
根据一种实施例,安全存储空间为嵌入式存储卡eMMC的安全分区,即RPMB分区,相应地,版本管理应用110通过富执行环境中的eMMC驱动应用120来从RPMB分区中读取出版本信息和校验信息。从RPMB分区中读取版本信息和校验信息的过程如下:
首先,版本管理应用110向eMMC发起读取版本信息和校验信息的请求,同时生成一个随机数,发送给eMMC。随后,eMMC从RPMB分区中取出版本信息和校验信息,并采用第二密钥通过HMAC SHA-256算法计算版本信息、校验信息和接收到的随机数拼接到一起后的签名。随后,eMMC将版本信息、校验信息、接收到的随机数、计算得到的签名一并发送至版本管理应用110。版本管理应用110接收到eMMC发来的数据后,首先比较随机数是否与自己之前发送的随机数一致,如果一致,再用同样的第二密钥通过HMAC SHA-256算法对版本信息、校验信息和随机数进行签名,若签名与eMMC发送的签名一致,则可以确定版本信息、校验信息为RPMB中存储的正确数据,而不是攻击者伪造的数据。
随后,在步骤S430中,计算用户数据的校验信息。
根据步骤S410中解密得出的用户数据,采用与前述步骤S320中相同的映射算法来计算用户数据的校验信息。
随后,在步骤S440中,当解密第一密文所得到的版本信息与从安全存储空间中获取到的版本信息相同,且计算出的校验信息与从安全存储空间中获取到的校验信息相同时,确定用户数据及其版本信息安全。
解密第一密文所得到的版本信息与从安全存储空间中获取到的版本信息相同,表明版本信息未被恶意篡改,即版本信息本身未回退。计算出的校验信息与从安全存储空间中获取到的校验信息相同,则表明用户数据未被篡改,从而避免了攻击者破解出用户数据的存储格式,不修改版本信息而仅将用户数据回退至旧版本的情况。
基于方法300和方法400,本发明提供了一种能够防止用户数据版本回退的技术方案,可以有效地避免回退版本信息,或者保留版本信息而仅回退用户数据等情况。方法300、400提供了版本防回退的一种较佳的实施例。除方法300、400之外,还可以采用其他的实施例来防止版本回退。
例如,根据一种实施例,可以在可信执行环境中对用户数据进行加密,然后将加密后的用户数据全部写入安全存储空间(例如eMMC的RPMB分区),以防止用户数据被篡改。不过目前安全存储空间的容量通常较小,当用户数据的数据量较大时(例如用户数据为指纹、虹膜信息时),用户数据无法完全存储安全存储空间中。另外,由于安全存储空间具有安全校验机制,其读写性能通常较差。当用户数据的数据量较大时,读写数据耗时较长,会有延迟,用户体验较差。
根据另一种实施例,可以在可信执行环境中,对用户数据进行加密,将加密后的用户数据存储至普通存储空间(例如eMMC的用户数据分区);将用户数据的版本信息写入安全存储空间(例如eMMC的RPMB分区),以防止版本信息被篡改。不过在该方案中缺少对用户数据的完整校验链路,如果攻击者知道普通存储空间中存储有用户数据的文件的格式,则可以对用户数据进行精准的修改,而不修改版本信息。这样,版本信息不变,仍然为新版本,但是用户数据回退。因此该方案仍存在安全隐患。
图5示出了根据本发明一个实施例的计算设备500的示意图。如图5所示,计算设备500包括处理器510和存储器520。存储器520中存储有程序指令,当程序指令被处理器510读取并执行时,使得计算设备500执行本发明的数据存储方法300和数据验证方法400。当存储器520中存储有用于执行本发明的数据存储方法300和数据验证方法400的程序指令时,计算设备500实现为本发明的终端设备,例如前述图1中的终端设备100。
这里描述的各种技术可结合硬件或软件,或者它们的组合一起实现。从而,本发明的方法和设备,或者本发明的方法和设备的某些方面或部分可采取嵌入有形媒介,例如可移动硬盘、U盘、软盘、CD-ROM或者其它任意机器可读的存储介质中的程序代码(即指令)的形式,其中当程序被载入诸如计算机之类的机器,并被所述机器执行时,所述机器变成实践本发明的设备。
在程序代码在可编程计算机上执行的情况下,计算设备一般包括处理器、处理器可读的存储介质(包括易失性和非易失性存储器和/或存储元件),至少一个输入装置,和至少一个输出装置。其中,存储器被配置用于存储程序代码;处理器被配置用于根据该存储器中存储的所述程序代码中的指令,执行本发明的数据存储和数据验证方法。
以示例而非限制的方式,可读介质包括可读存储介质和通信介质。可读存储介质存储诸如计算机可读指令、数据结构、程序模块或其它数据等信息。通信介质一般以诸如载波或其它传输机制等已调制数据信号来体现计算机可读指令、数据结构、程序模块或 其它数据,并且包括任何信息传递介质。以上的任一种的组合也包括在可读介质的范围之内。
在此处所提供的说明书中,算法和显示不与任何特定计算机、虚拟***或者其它设备固有相关。各种通用***也可以与本发明的示例一起使用。根据上面的描述,构造这类***所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下被实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。
本领域那些技术人员应当理解在本文所公开的示例中的设备的模块或单元或组件可以布置在如该实施例中所描述的设备中,或者可替换地可以定位在与该示例中的设备不同的一个或多个设备中。前述示例中的模块可以组合为一个模块或者此外可以分成多个子模块。
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中 所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。
此外,所述实施例中的一些在此被描述成可以由计算机***的处理器或者由执行所述功能的其它装置实施的方法或方法元素的组合。因此,具有用于实施所述方法或方法元素的必要指令的处理器形成用于实施该方法或方法元素的装置。此外,装置实施例的在此所述的元素是如下装置的例子:该装置用于实施由为了实施该发明的目的的元素所执行的功能。
如在此所使用的那样,除非另行规定,使用序数词“第一”、“第二”、“第三”等等来描述普通对象仅仅表示涉及类似对象的不同实例,并且并不意图暗示这样被描述的对象必须具有时间上、空间上、排序方面或者以任意其它方式的给定顺序。
尽管根据有限数量的实施例描述了本发明,但是受益于上面的描述,本技术领域内的技术人员明白,在由此描述的本发明的范围内,可以设想其它实施例。此外,应当注意,本说明书中使用的语言主要是为了可读性和教导的目的而选择的,而不是为了解释或者限定本发明的主题而选择的。因此,在不偏离所附权利要求书的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。对于本发明的范围,对本发明所做的公开是说明性的而非限制性的,本发明的范围由所附权利要求书限定。

Claims (12)

  1. 一种数据存储方法,在可信执行环境中执行,所述方法包括:
    采用第一密钥对用户数据和所述用户数据的版本信息进行加密以生成第一密文,将所述第一密文存储至普通存储空间;
    生成所述用户数据的校验信息;
    将所述版本信息和所述校验信息存储至安全存储空间。
  2. 如权利要求1所述的方法,其中,所述校验信息为采用预设的映射算法对所述用户数据进行映射所得到的映射值。
  3. 如权利要求1所述的方法,所述第一密钥在所述可信执行环境中动态生成。
  4. 如权利要求1所述的方法,其中,所述普通存储空间包括嵌入式存储卡的用户数据分区,所述安全存储空间包括嵌入式存储卡的安全分区。
  5. 如权利要求1或4所述的方法,其中,所述将所述版本信息和所述校验信息存储至安全存储空间的步骤包括:
    通过富执行环境中的存储驱动来将所述版本信息和所述校验信息存储至所述安全存储空间。
  6. 如权利要求5所述的方法,其中,所述通过富执行环境中的存储驱动来将所述版本信息和所述校验信息存储至所述安全存储空间的步骤包括:
    将所述版本信息和所述校验信息组成符合所述安全存储空间的写校验格式的数据帧,所述数据帧包括所述版本信息、校验信息、写计数值和签名值,所述签名值为采用第二密钥对所述版本信息、校验信息和写计数值进行加密所得到的密文;
    当所述存储驱动根据所述写计数值和签名值确定本次写入操作合法后,将所述版本信息和所述校验信息存储至所述安全存储空间。
  7. 如权利要求6所述的方法,其中,所述第二密钥烧录于所述可信执行环境中。
  8. 一种数据验证方法,在可信执行环境中执行,所述方法包括:
    从普通存储空间中获取第一密文并解密,以得到用户数据和版本信息;
    从安全存储空间中获取版本信息和校验信息;
    计算所述用户数据的校验信息;
    当解密第一密文所得到的版本信息与从安全存储空间中获取到的版本信息相同,且计算出的校验信息与从安全存储空间中获取到的校验信息相同时,确定所述用户数据及其版本信息安全。
  9. 如权利要求8所述的方法,其中,所述计算所述用户数据的校验信息包括:采用预设的映射算法对所述用户数据进行映射,以得到校验信息。
  10. 如权利要求8所述的方法,其中,所述普通存储空间包括嵌入式存储卡的用户数据分区,所述安全存储空间包括嵌入式存储器的安全分区。
  11. 一种计算设备,包括:
    至少一个处理器;和
    存储有程序指令的存储器,当所述程序指令被所述处理器读取并执行时,使得所述计算设备执行如权利要求1-10中任一项所述的方法。
  12. 一种存储有程序指令的可读存储介质,当所述程序指令被计算设备读取并执行时,使得所述计算设备执行如权利要求1-10中任一项所述的方法。
PCT/CN2020/078528 2019-03-22 2020-03-10 数据存储、验证方法及装置 WO2020192406A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US17/481,131 US20220006617A1 (en) 2019-03-22 2021-09-21 Method and apparatus for data storage and verification

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910221335.9A CN111723383B (zh) 2019-03-22 2019-03-22 数据存储、验证方法及装置
CN201910221335.9 2019-03-22

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/481,131 Continuation US20220006617A1 (en) 2019-03-22 2021-09-21 Method and apparatus for data storage and verification

Publications (1)

Publication Number Publication Date
WO2020192406A1 true WO2020192406A1 (zh) 2020-10-01

Family

ID=72563539

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/078528 WO2020192406A1 (zh) 2019-03-22 2020-03-10 数据存储、验证方法及装置

Country Status (4)

Country Link
US (1) US20220006617A1 (zh)
CN (1) CN111723383B (zh)
TW (1) TW202036347A (zh)
WO (1) WO2020192406A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115562573A (zh) * 2022-08-30 2023-01-03 荣耀终端有限公司 一种存储数据的方法、通信***、电子设备及存储介质

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109960582B (zh) * 2018-06-19 2020-04-28 华为技术有限公司 在tee侧实现多核并行的方法、装置及***
US12008146B2 (en) * 2021-03-31 2024-06-11 Seagate Technology Llc Code-based signatures for secure programs
CN113505363B (zh) * 2021-08-04 2022-11-29 上海瓶钵信息科技有限公司 通过软件方式实现存储空间防重放的方法和***
CN114257877A (zh) * 2021-12-02 2022-03-29 展讯通信(上海)有限公司 宽带数字视频保护hdcp的秘钥部署及使用方法以及装置
CN114491657A (zh) * 2021-12-24 2022-05-13 ***股份有限公司 一种模型保护方法、数据处理方法、装置、设备及介质
CN114826689B (zh) * 2022-03-31 2024-01-12 北京极感科技有限公司 信息录入方法、安全认证方法和电子设备
CN114528603B (zh) * 2022-04-24 2022-07-15 广州万协通信息技术有限公司 嵌入式***的隔离动态保护方法、装置、设备和存储介质
CN116089967B (zh) * 2022-05-12 2024-03-26 荣耀终端有限公司 数据防回滚方法和电子设备
CN115357930A (zh) * 2022-08-12 2022-11-18 维沃移动通信有限公司 数据删除方法和电子设备
WO2024071861A1 (ko) * 2022-09-30 2024-04-04 삼성전자 주식회사 업데이트 방법 및 이를 위한 전자 장치
CN116886356B (zh) * 2023-07-04 2024-02-02 广州链融信息技术有限公司 一种芯片级透明文件加密存储***、方法及设备

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101231595A (zh) * 2007-01-23 2008-07-30 索尼株式会社 管理***、管理方法、终端设备、管理服务器和程序
CN104079539A (zh) * 2013-03-28 2014-10-01 阿里巴巴集团控股有限公司 一种数据保密存储方法及客户端
CN104156451A (zh) * 2014-08-18 2014-11-19 深圳市一五一十网络科技有限公司 数据存储管理方法及***
US10129252B1 (en) * 2015-12-17 2018-11-13 Wells Fargo Bank, N.A. Identity management system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6179155B2 (ja) * 2013-03-27 2017-08-16 セイコーエプソン株式会社 振動デバイス、電子機器、および移動体

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101231595A (zh) * 2007-01-23 2008-07-30 索尼株式会社 管理***、管理方法、终端设备、管理服务器和程序
CN104079539A (zh) * 2013-03-28 2014-10-01 阿里巴巴集团控股有限公司 一种数据保密存储方法及客户端
CN104156451A (zh) * 2014-08-18 2014-11-19 深圳市一五一十网络科技有限公司 数据存储管理方法及***
US10129252B1 (en) * 2015-12-17 2018-11-13 Wells Fargo Bank, N.A. Identity management system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115562573A (zh) * 2022-08-30 2023-01-03 荣耀终端有限公司 一种存储数据的方法、通信***、电子设备及存储介质

Also Published As

Publication number Publication date
CN111723383B (zh) 2024-03-19
US20220006617A1 (en) 2022-01-06
CN111723383A (zh) 2020-09-29
TW202036347A (zh) 2020-10-01

Similar Documents

Publication Publication Date Title
WO2020192406A1 (zh) 数据存储、验证方法及装置
TWI676116B (zh) 安全儲存系統以及用於安全儲存的方法
US11469885B2 (en) Remote grant of access to locked data storage device
CN102646077B (zh) 一种基于可信密码模块的全盘加密的方法
US11368299B2 (en) Self-encryption drive (SED)
TWI667586B (zh) 用以核對uefi認證變量變化之系統及方法
KR100996784B1 (ko) 공개 키 암호화에 기초한 데이터의 저장 및 검색을 위한, 컴퓨팅 장치에서 구현되는 방법, 시스템 및 복수의 명령어를 저장하는 하나 이상의 컴퓨터 판독가능 매체
US7986786B2 (en) Methods and systems for utilizing cryptographic functions of a cryptographic co-processor
EP3197089B1 (en) Secure information configuration method, secure authentication method and related chip
US9064129B2 (en) Managing data
CN105718807B (zh) 基于软tcm和可信软件栈的安卓***及其可信认证***与方法
CN107908574B (zh) 固态盘数据存储的安全保护方法
KR102030858B1 (ko) 디지털 서명 권한자 의존형 플랫폼 기밀 생성 기법
KR20090007123A (ko) 보안 부팅 방법 및 그 방법을 사용하는 반도체 메모리시스템
US9071581B2 (en) Secure storage with SCSI storage devices
WO2013107362A1 (zh) 一种保护数据的方法和***
CN110795126A (zh) 一种固件安全升级***
EP2503482A1 (en) Electronic device with flash memory component
WO2022052665A1 (zh) 无线终端及无线终端在Uboot模式下的接口访问鉴权方法
US8499357B1 (en) Signing a library file to verify a callback function
CN110837634A (zh) 基于硬件加密机的电子签章方法
US11216571B2 (en) Credentialed encryption
US20170262640A1 (en) Database operation method and device
CN110659522B (zh) 存储介质安全认证方法、装置、计算机设备和存储介质
US11088832B2 (en) Secure logging of data storage device events

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

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

Country of ref document: EP

Kind code of ref document: A1