WO2020000491A1 - 一种文件存储方法、装置及存储介质 - Google Patents

一种文件存储方法、装置及存储介质 Download PDF

Info

Publication number
WO2020000491A1
WO2020000491A1 PCT/CN2018/093929 CN2018093929W WO2020000491A1 WO 2020000491 A1 WO2020000491 A1 WO 2020000491A1 CN 2018093929 W CN2018093929 W CN 2018093929W WO 2020000491 A1 WO2020000491 A1 WO 2020000491A1
Authority
WO
WIPO (PCT)
Prior art keywords
hash
file
updated
data block
hash value
Prior art date
Application number
PCT/CN2018/093929
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 华为技术有限公司
Priority to CN201880093094.8A priority Critical patent/CN112088376A/zh
Priority to PCT/CN2018/093929 priority patent/WO2020000491A1/zh
Publication of WO2020000491A1 publication Critical patent/WO2020000491A1/zh

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/70Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer
    • G06F21/78Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure storage of data

Definitions

  • the present application relates to the technical field of data security, and in particular, to a file storage method, device, and storage medium.
  • a file storage method generally includes: obtaining a file to be stored, generating a key, using the key to encrypt the file to be stored, obtaining an encrypted file, and writing the encrypted file to a memory.
  • CMOS complementary metal-oxide-semiconductor
  • EMMC embedded Embedded multimedia memory card
  • RPMB playback protected memory block
  • UFS universal flash storage
  • the size of the secure partition in the non-volatile storage medium is limited and cannot support the secure storage of large files, so the security of the stored files is still low.
  • Embodiments of the present application provide a file storage method, device, and storage medium, which are used to improve the security of a stored file.
  • an embodiment of the present application provides a file storage method.
  • the method includes: under a trusted execution environment TEE, encrypting a first file to obtain a second file, and performing a hash operation on the second file to obtain The first hash value; writing the first hash value to a secure partition in a memory; and writing the second file to a normal partition in the memory; the secure partition is used to prevent a file from being Tampering and / or preventing a file from being rolled back; the first hash value is used to verify whether the second file is legitimate when the second file is decrypted to obtain the first file.
  • both the encryption of the first file and the hash operation of the second file are performed in the TEE. Therefore, the security of the encryption process and the hash operation process can be improved.
  • the corresponding first hash value of the second file is written into the secure partition in the memory, and the secure partition is used to prevent the file from being tampered with and / or preventing the file from being rolled back. Therefore, the first hash value of the secure partition It can be prevented from being tampered with and / or rolled back, and the first hash value has a smaller amount of data relative to the second file, and the occupied memory is also smaller. In this way, the first hash value that takes up less memory can be used to prevent The second file was tampered with and / or rolled back.
  • the first file in order to implement partial update of the first file, includes M data blocks; the second file includes M encrypted data blocks; wherein M is greater than or equal to 2 An integer; the encrypting the first file to obtain a second file includes: performing an encryption operation on the M data blocks to obtain the M encrypted data blocks; and hashing the second file
  • the operation to obtain the first hash value includes: performing a hash operation on the M encrypted data blocks to obtain M second hash values; and performing a hash operation on the M second hash values.
  • the first hash value is obtained, wherein the M encrypted data blocks correspond to the M second hash values one-to-one.
  • the amount of data for each encryption and hash operation can be reduced, and the encryption and hash rate can be improved.
  • Greek operation efficiency on the other hand, the first hash value is obtained by encrypting the M second hash values, so that the efficiency of calculating the first hash value can be further improved.
  • the hash operation is performed on the M second hash values to obtain the first hash.
  • the Greek value includes performing a hash message authentication code HMAC operation on the M second hash values to obtain the first hash value.
  • the M second hash values may be written into a common partition, and the first hash value may be written into a secure partition.
  • the data amount of the first hash value is small, and can be used.
  • the smaller data amount of the first hash value prevents the larger data amount of the second file from being tampered with and / or rolled back.
  • the M second hash values and the first hash value may also be written into the secure partition.
  • the security of the second file can be improved; on the other hand, the second hash value can be used to prevent each encrypted data
  • the block is tampered with and / or rolled back, that is, the second file can be prevented from being tampered with and / or rolled back through a more efficient operation.
  • the M second hash values may be The hash block is written into the ordinary partition as a storage unit; or the M second hash values may also be written into the secure partition using the hash block as a storage unit; wherein one hash block includes at least one The second hash value; the size of the hash block may be determined according to the granularity of data accessed by the processor and the size of the second hash value.
  • the size of the hash block is related to the granularity of the processor's access to the data.
  • Writing the hash value to the memory according to the hash block as the storage unit can achieve memory alignment, and subsequent processors can also press the hash when reading data.
  • Block reads reduce the number of times the processor accesses, which can improve the efficiency of the processor's read and write data.
  • the secure partition includes a playback protected memory block RPMB partition.
  • an update request is received; the update request includes a data block identifier and data to be updated, and the data block identifier is used to indicate an encrypted data block to be updated in the ordinary partition;
  • the data block identifier obtaining the encrypted data block to be updated from the ordinary partition; obtaining a second hash value corresponding to the encrypted data block to be updated; and according to the encrypted data to be updated
  • the second hash value corresponding to the block determines that the encrypted data block to be updated is valid, and then updates the encrypted data block to be updated according to the data to be updated; and updates the encrypted data block to be updated The corresponding second hash value.
  • updating the encrypted data block to be updated according to the data to be updated may be: decrypting the encrypted data block to be updated to obtain the data block to be updated Updating the data block to be updated with the data to be updated to obtain an updated data block; encrypting the updated data block to obtain an updated encrypted data block; updating the to-be-updated data block
  • the second hash value corresponding to the encrypted data block includes: performing a hash operation on the updated encrypted data block to obtain a third hash value; and converting a second hash value corresponding to the encrypted data block to be updated.
  • the Greek value is updated to the third hash value. In this way, the entire second file does not need to be decrypted, encrypted, and then the updated hash value of the entire second file is calculated, which reduces the overhead caused by the overall encryption, decryption, and hash operations.
  • an embodiment of the present application provides a file storage device including a processor and a memory; the processor is configured to encrypt a first file under a trusted execution environment TEE to obtain a second file, and Performing a hash operation on the second file to obtain a first hash value; the processor is further configured to write the first hash value into a secure partition in the memory, and write the second file into a secure partition; The ordinary partition in the memory; the secure partition is used to prevent the file from being tampered with and / or the file is rolled back; the first hash value is used to correct the second file when the second file is decrypted to obtain the first file Verify whether the second file is legal.
  • the first file includes M data blocks
  • the second file includes M encrypted data blocks, where M is an integer greater than or equal to 2
  • the processor is specifically used
  • performing encryption operations on the M data blocks to obtain the M encrypted data blocks performing hash operations on the M encrypted data blocks to obtain M second hash values
  • Hash operations are performed on two second hash values to obtain the first hash value, wherein the M encrypted data blocks are in one-to-one correspondence with the M second hash values.
  • the processor is specifically configured to perform a hash message authentication code HMAC operation on the M second hash values to obtain the first hash value.
  • the processor is further configured to: write the M second hash values into the ordinary partition; or write the M second hash values into the common partition Safe partition.
  • the processor is specifically configured to: write the M second hash values into the ordinary partition using a hash block as a storage unit; or, write the M second hash values
  • the hash value is written into the secure partition with a hash block as a storage unit; wherein one hash block includes at least one of the second hash values; the size of the hash block is based on the processor read and write data granularity and The size of the second hash value is determined.
  • the secure partition includes a playback protected memory block RPMB partition.
  • the apparatus further includes an interface; the interface is configured to: receive an update request; the update request includes a data block identifier and data to be updated, and the data block identifier is used to indicate the An encrypted data block to be updated in an ordinary partition; the processor is further configured to: obtain the encrypted data block to be updated from the ordinary partition according to the data block identifier; and acquire the to-be-updated The second hash value corresponding to the encrypted data block; if it is determined that the encrypted data block to be updated is legal according to the second hash value corresponding to the encrypted data block to be updated, according to the data to be updated Updating the encrypted data block to be updated; updating a second hash value corresponding to the encrypted data block to be updated.
  • the processor is specifically configured to: decrypt the encrypted data block to be updated to obtain the data block to be updated; and update the data to be updated with the data to be updated Updating the updated data block to obtain an updated data block; encrypting the updated data block to obtain an updated encrypted data block; performing a hash operation on the updated encrypted data block to obtain a third hash Value; updating a second hash value corresponding to the encrypted data block to be updated to the third hash value.
  • an embodiment of the present application provides a file storage device including an encryption unit, a processing unit, a secure partition, and an ordinary partition;
  • the encryption unit is configured to encrypt a first file in a trusted execution environment to obtain a first file; Two files, and performing a hash operation on the second file to obtain a first hash value;
  • the processing unit is configured to write the first hash value into the secure partition in the memory, and write the first hash value
  • the second file is written into the ordinary partition in the memory;
  • the secure partition is used to prevent the file from being tampered with and / or the file is rolled back;
  • the first hash value is used to store data from the storage other than the secure partition When the area obtains the second file, it is checked whether the second file is legal.
  • the first file includes M data blocks
  • the second file includes M encrypted data blocks
  • M is an integer greater than or equal to 2
  • the encryption unit is specifically configured to: Perform encryption operations on the M data blocks to obtain the M encrypted data blocks; perform hash operations on the M encrypted data blocks to obtain M second hash values; A hash operation is performed on the two hash values to obtain the first hash value, wherein the M encrypted data blocks correspond to the M second hash values one to one.
  • the encryption unit is specifically configured to perform a hash message authentication code HMAC operation on the M second hash values to obtain the first hash value.
  • the processing unit is further configured to: write the M second hash values into a common partition; or write the M second hash values into a secure partition.
  • the processing unit is specifically configured to: write the M second hash values into a common partition using a hash block as a processing unit; or, write the M second hash values as A hash block is written into the secure partition for a storage unit; wherein one hash block includes a hash value of at least one encrypted data block; the size of the hash block is based on the granularity of data accessed by the processor and the The size of the second hash value is determined.
  • the secure partition includes a playback protected memory block RPMB partition.
  • the device further includes a transceiver unit; the transceiver unit is configured to: receive an update request; the update request includes a data block identifier and data to be updated, and the data block identifier is used to indicate the The encrypted data block to be updated in the ordinary partition; the processing unit is further configured to: obtain the encrypted data block to be updated from the ordinary partition according to the data block identifier; and acquire the encrypted data block to be updated A second hash value corresponding to the encrypted data block; if it is determined that the encrypted data block to be updated is legal according to the second hash value corresponding to the encrypted data block to be updated, according to the data to be updated, Updating the encrypted data block to be updated; updating a second hash value corresponding to the encrypted data block to be updated.
  • the processing unit is specifically configured to: decrypt the encrypted data block to be updated to obtain the data block to be updated; and update the to-be-updated data with the data to be updated Data blocks to obtain updated data blocks; encrypt the updated data blocks to obtain updated encrypted data blocks; perform hash operations on the updated encrypted data blocks to obtain a third hash value; Update the second hash value corresponding to the encrypted data block to be updated to the third hash value.
  • an embodiment of the present application provides a computer storage medium.
  • the computer storage medium stores instructions, and when the computer storage medium is run on a computer, the computer executes the method in the first aspect or any possible implementation manner of the first aspect. .
  • an embodiment of the present application provides a computer program product containing instructions, which when executed on a computer, causes the computer to execute the method in the first aspect or any possible implementation manner of the first aspect.
  • FIG. 1 is a schematic diagram of a software framework of a trusted environment of a terminal device according to an embodiment of the present application
  • FIG. 2 is a schematic structural diagram of software and hardware of a terminal device according to an embodiment of the present application.
  • FIG. 3 is a schematic flowchart of a file storage method according to an embodiment of the present application.
  • FIG. 4 is a schematic flowchart of another file storage method according to an embodiment of the present application.
  • 4a is a schematic structural diagram of storing a first file according to an embodiment of the present application.
  • FIG. 5 is a schematic flowchart of a method for reading data from a RPMB partition of a UFS according to an embodiment of the present application
  • FIG. 6 is a schematic flowchart of a method for writing data to an RPMB partition of a UFS according to an embodiment of the present application
  • FIG. 7 is a schematic structural diagram of data of an RPMB partition according to an embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of a file storage device according to an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of a file storage device according to an embodiment of the present application.
  • At least one (a), a, b, or c can represent: a, b, c, "a and b", “a and c", “b and c", or "a and b and c" ", Where a, b, and c can be single or multiple.
  • FIG. 1 schematically illustrates a software framework of a trusted environment of a terminal device according to an embodiment of the present application.
  • the software framework of the trusted environment of the terminal device includes a REE software architecture and a TEE software architecture.
  • REE is usually an operating environment for terminal device operating systems such as Android or Apple's mobile operating system (iPhone operating system, iOS).
  • the REE software architecture includes client applications, TEE functional application programming interfaces (APIs), TEE client APIs, and common operating systems.
  • Client applications can be provided to users by client applications, which can be operator's client applications, or third-party client applications, such as WeChat or Alipay. Client applications may have files that need to be stored securely.
  • the TEE function API provides a set of interfaces for client applications to access TEE security services (such as storage and encryption algorithms).
  • the TEE client API can provide a client application running in the REE environment to access a trusted application (TA) in the TEE environment and a communication interface for data exchange with the TA.
  • TA trusted application
  • Common operating systems include public device driver modules and REE communication agent modules.
  • the public device driver module can provide an interface between the hardware device and the common operating system, and is used to notify the function of the hardware device to the common operating system, and convert the instructions of the common operating system into commands that the hardware device can recognize.
  • the REE communication agent can be used for messaging between the client application and the TA.
  • TEE provides a more secure closed execution environment, which can ensure that various sensitive files are stored and protected in a trusted environment.
  • TEE software architecture includes TA, TEE internal API and trusted operating system.
  • TA runs in TEE.
  • TA can provide security services (such as secure storage and encryption) to its users.
  • TA and TA can communicate through the TEE internal API.
  • the TEE internal API can define a set of APIs for the TA running in the TEE. This set of APIs defines the development interface of the TA running inside the TEE. Specifically, it can provide scheduling, communication and memory management interfaces, and provide secure storage, passwords. APIs for services and encryption.
  • the trusted operating system includes a TEE communication agent module, a trusted core framework module, and a trusted function module. The TEE communication agent and the REE communication agent can be combined to realize the secure transmission of messages between the client application and the TA.
  • the trusted core framework provides trusted operating system functions to the TA. Trusted function modules can provide auxiliary facilities support to application
  • FIG. 2 exemplarily illustrates a schematic architecture of a terminal device software and hardware provided by an embodiment of the present application.
  • the terminal device includes the software and hardware architecture of the REE, and the software and hardware architecture of the TEE.
  • REE's software and hardware architecture includes REE hardware, REE hardware driver modules, common operating systems, TEE client APIs, and client applications.
  • REE hardware includes input / output interfaces, memory, and central processing unit (CPU) and other devices.
  • the REE hardware driver can provide general execution environment hardware device drivers under common operating systems, such as drivers for hardware devices such as EMMC. When common operating systems need to use hardware devices, such as writing files to EMMC, the common operating system will first send corresponding instructions to EMMC driver. After receiving the instruction, the EMMC driver translates the instruction into an electronic signal command that can be recognized by the EMMC, so as to write a file to the EMMC.
  • Common operating systems include REE communication agents and REE applications under common operating systems, such as client applications in REE that access the TA in TEE.
  • the TEE client API provides an interface for client applications to access the TA, and the GP client standard interface can be used.
  • TEE's software and hardware architecture includes secure hardware, secure hardware drivers, trusted operating systems, TEE's internal core APIs, and TA.
  • Security hardware includes devices such as secure input / output interfaces, secure processors, secure memories, and trusted devices.
  • the security input / output interface in the security hardware may be a security mode of the input / output interface of the REE, or an input / output interface isolated from the input / output interface of the REE; a security processor It can be a secure mode of the CPU in the REE, or a processor isolated from the CPU; the secure memory can be a partition of the memory in the REE, or it can be a secure mode of the memory in the REE.
  • the secure hardware driver can provide drivers for secure hardware devices, such as the fingerprint device driver, which is used to read the fingerprint information of the fingerprint collection device (trusted device), and the fingerprint information is the file to be stored; the EMMC driver can be used to read the EMMC Files or write files to EMMC.
  • the trusted operating system can provide trusted operating system functions, such as core security function modules such as storage, encryption (such as hash operations, encryption operations), and TEE communication agents.
  • the processing module can provide a unified secure data storage service and API under the TEE environment.
  • the encryption module can provide security services such as encryption and decryption, private key signature, and hash calculation under the TEE environment.
  • FIG. 3 exemplarily illustrates a schematic flowchart of a file storage method provided by an embodiment of the present application.
  • the file storage method is executed in the TEE of FIG. 1 or FIG. 2 described above. Executing the file storage method in the TEE can improve the security of the storage process.
  • the method includes:
  • Step S301 Encrypt the first file to obtain a second file, and perform a hash operation on the second file to obtain a first hash value.
  • the first file is a file to be stored, and may be in a form of text or picture.
  • the first file may be encrypted by using a symmetric key encryption or an asymmetric key encryption.
  • Hardware encryption can be used; symmetric keys are used for encryption, and the encryption rate is high.
  • encrypting the first file and hashing the second file may be performed by an encryption module in a trusted operating system in the TEE in FIG. 2 described above.
  • Step S302 Write the first hash value to a secure partition in the memory, and write a second file to the ordinary partition in the memory;
  • the secure partition is used to prevent a file from being tampered with and / or prevent a file from being rolled back; the first hash value is used to verify the second file when the second file is decrypted to obtain the first file. Whether the file is legal.
  • the ordinary partition of the memory may be a storage area other than the secure partition.
  • a second file is obtained from the ordinary partition in the memory, and the same hash operation is performed on the obtained second file to obtain a hash.
  • Greek value if it is determined that the calculated hash value is the same as the first hash value obtained from the secure partition, then the obtained second file is valid.
  • the encryption of the first file and the hash operation of the second file are performed in the TEE. Therefore, the encryption process and the hash can be improved. The security of the computing process. Moreover, the tampering of the second file can be achieved only after both the second file and the first hash value have been tampered with.
  • the second file is written into a common partition in the memory, and the first hash value is Writing to a secure partition, that is, storing the corresponding first hash value of the second file and the second file separately. Separate storage can increase the difficulty of tampering with the second file and help improve the security of the second file.
  • the corresponding first hash value of the second file is written into a secure partition in the memory, and the secure partition is used to prevent the file from being tampered with and / or rolled back. Therefore, the first hash value of the secure partition can be prevented from being Tampering and / or rollback, and the first hash value has a smaller amount of data relative to the second file, and the occupied memory is also smaller. In this way, the first hash value that takes up less memory can be used to prevent the second file Tampered with and / or rolled back.
  • FIG. 4 exemplarily illustrates a schematic flow chart of another file storage method provided by an embodiment of the present application.
  • the file storage method shown in FIG. 4 can implement partial update of a stored file, thereby improving file update efficiency.
  • the file storage method includes:
  • step S401 the first file is divided into M data blocks, where M is an integer greater than or equal to 2.
  • the size of the data block can be determined according to the granularity of the data accessed by the processor.
  • the processor treats the memory as a block, and the block size can be 2, 4, 8, or 16 bytes, so When the processor reads the memory, it reads one by one.
  • the size of the block is called the granularity of data stored by the processor.
  • the processor accesses the memory according to 32 bits, that is, 4 bytes are read or written at one time, for example, a 16-byte memory with a memory address of 0x0 to 0xF. For this processor, it is not regarded as 16 single bytes, but 4 blocks, each with 4 bytes.
  • the granularity of data accessed by the processor is 4 bytes.
  • the size of the data block can be determined as a positive integer multiple of 4 bytes.
  • memory alignment can be achieved.
  • the processor needs to read data, it can read one data block at a time, which can reduce the number of processor accesses, which can improve the processor read. Data efficiency.
  • the remaining data of the first file is insufficient to be divided into the size of one data block, such as less than a positive integer multiple of 4 bytes, and the first file may be left Part of the data is assembled into a complete data block in the form of zero complement.
  • the complement of 0 is removed.
  • Step S402 performing encryption operations on M data blocks to obtain M encrypted data blocks; the second file includes M encrypted data blocks.
  • the M data blocks may be encrypted by a symmetric key, or by an asymmetric key, or by hardware encryption.
  • the key for encrypting the M data blocks may be the same key or different keys, and using the same key to separately encrypt the M data blocks may increase the efficiency of encryption, and The need to store a key can reduce the number of keys stored.
  • different keys can also be used for encryption, which can strengthen the security of the first file storage.
  • the encrypted key can be stored in a secure partition of the memory to improve the security of the key.
  • Step S403 Perform hash operations on the M encrypted data blocks to obtain M second hash values, and perform hash operations on the M second hash values to obtain the first hash value.
  • the M encrypted data blocks correspond to the M second hash values in a one-to-one manner.
  • M second hash values are obtained.
  • the hash operation input is an encrypted data block, and the encrypted data block is compared with the entire second data block.
  • the amount of data in the file is small, so the calculation efficiency of the second hash value can be improved.
  • the M second hash value is used as an input to perform a hash operation.
  • the first hash value of the second file is obtained.
  • the M second hash values are smaller than the data amount of the M encrypted data blocks. In this way, the operation efficiency of calculating the first hash value can be further improved.
  • a hash operation is performed on the M second hash values to obtain the first hash value, which may be a hash message authentication code (HMAC) on the M second hash values.
  • HMAC operation is a key-based hashing algorithm. Its implementation principle is to use a hash function, key, and message to generate a fixed-length value as an authentication identifier, and use this identifier to authenticate the integrity of the message. Specifically, a shared key and message with the receiving end are used as the input of the HMAC operation, and a message digest (that is, a fixed-length value) is generated as an output, and the message digest and the message are transmitted to the receiving end together.
  • a shared key and message with the receiving end are used as the input of the HMAC operation, and a message digest (that is, a fixed-length value) is generated as an output, and the message digest and the message are transmitted to the receiving end together.
  • the shared key is used to authenticate the receiving end, such as the legitimacy of the receiving end and the integrity of the message.
  • the shared key is pre-approved by double sending.
  • Hashing functions include, but are not limited to, the fifth version of the message digest algorithm (MD5), secure hash algorithm (SHA), such as SHA-1 and SHA-2 (SHA-256, SHA-384, and SHA-512).
  • MD5 message digest algorithm
  • SHA secure hash algorithm
  • SHA-1 and SHA-2 SHA-256, SHA-384, and SHA-512
  • the above steps S402 and S403 may be performed in an encryption module in a trusted operating system of the TEE.
  • the shared key may be stored in a secure partition of the memory and isolated from the REE. The shared key cannot be obtained by the REE. In this way, the security of the shared key can be improved.
  • step S404 the second file and the M second hash values are written into the ordinary partition, and the first hash value is written into the secure partition. That is, only the first hash value is written to the secure partition.
  • the first hash value has a small amount of data, and the first hash value with a smaller amount of data is stored in a secure partition.
  • the first hash value with a smaller amount of data can prevent the second file from being tampered with and / or Roll back.
  • the ordinary partition where the second file is stored in the memory can realize the storage of the second file with a larger amount of data, and the first hash value with a smaller amount of data in the secure partition can be used to prevent the entire second file from being Tampering and / or rollback.
  • Step S405 Write the second file into the ordinary partition, and write the M second hash values and the first hash value into the secure partition.
  • the M encrypted data blocks and the M second hash values are stored separately, and the security of the M encrypted data blocks is improved. Further, preventing each encrypted data block from being tampered with and / or rolled back can be achieved by each second hash value of the M second hash values in the secure partition.
  • the M second hash values are written into the ordinary partition using the hash block as a storage unit; or, the M second hash values are written into the secure partition using the hash block as the storage unit.
  • One hash block includes at least one second hash value; the size of the hash block is determined according to the granularity of the data accessed by the processor and the size of the second hash value. For example, if the granularity of data accessed by the processor is 4 bytes, the size of the hash block can be determined as a positive integer multiple of 4 bytes.
  • one hash block includes 128 second hashes. If the size of the hash block is determined to be 4 bytes, and the hash value of the encrypted data block is calculated through SHA-512, and the size of the second hash value obtained is 512 bits, one hash block includes 64 second hashes. In this way, by writing the M second hash values into a secure partition of the memory or a normal partition in the memory with the hash block as a storage unit, the efficiency of the processor in accessing data can be improved.
  • step S404 or step S405 is performed after step S403. That is, if step S404 is performed after step S403, step S405 is not performed, and if step S405 is performed, step S404 is not performed.
  • FIG. 4a exemplarily illustrates a schematic architecture of storing a first file according to an embodiment of the present application.
  • the first file includes M data blocks; the size of each data block can be determined according to the granularity of data accessed by the processor.
  • This embodiment uses a 32-bit processor as an example. It is assumed that the The size is determined to be 4 bytes.
  • the M data blocks are respectively encrypted to obtain M encrypted data blocks, and the M encrypted data blocks form a second file.
  • Hash operations are performed on M encrypted data blocks to obtain M second hash values, and HMAC operations are performed on the M second hash values to obtain the first hash value; where SHA-256 is used for the hash operation , The size of the second hash value is 256 bits, and the size of the 128 second hash values is 4K. Therefore, a hash block includes 128 second hash values, and the size of the hash block is 4 bytes. , The M second hash values are written to the secure partition according to the hash block as the storage unit, or are written to the ordinary partition.
  • a comparison may be performed according to a hash operation when calculating the second hash value and a granularity of data accessed by the processor.
  • M data blocks are grouped. For example, if the hash operation to calculate the second hash value uses SHA-256, the size of the second hash value is 256 bits, and if the granularity of the processor to access the data is 4 bytes, 128 second Kazakhs are required.
  • the Greek values form a hash block, and a second hash value corresponds to an encrypted data block. Therefore, 128 data blocks can be divided into a data group. In other words, a data group corresponds to 128 second hash values, forming a hash block, and using the hash block as a storage unit to store M second hash values.
  • the embodiment of the present application provides an optional implementation manner of updating some files in the first file after storing the first file according to the storage method of steps S401 to S402.
  • An optional implementation manner is: receiving an update request; the update request includes a data block identifier and data to be updated, where the data block identifier is used to indicate an encrypted data block to be updated in the ordinary partition; according to the A data block identifier, obtaining the encrypted data block to be updated from the ordinary partition; obtaining a second hash value corresponding to the encrypted data block to be updated; and according to the encrypted data block to be updated
  • the corresponding second hash value determines that the encrypted data block to be updated is valid, and then updates the encrypted data block to be updated according to the data to be updated; and updates the corresponding encrypted data block to be updated The second hash.
  • the block After obtaining the second hash value corresponding to the encrypted data block to be updated and the encrypted data block to be updated, use the same hash operation on the obtained encrypted data to be updated.
  • the block performs a hash operation. If the calculated hash value is the same as the second hash value corresponding to the obtained encrypted data block to be updated, it is determined that the encrypted data block to be updated is legal.
  • the (M-1) second hash value and the third hash value are updated.
  • the value is hashed to obtain a new hash value corresponding to the second file, and the first hash value is updated with the new hash value.
  • the secure partition includes an RPMB partition; or other secure partitions based on the RPMB partition technology.
  • the RPMB partition may be a partition with security features in the EMMC, or a partition with security features in universal flash storage (universal flash storage).
  • the RPMB partition or other secure partitions based on the RPMB partition technology have the characteristics of preventing files written in the secure partition from being tampered and / or rolled back illegally. Therefore, in practical applications, some important files are usually written in the secure partition. , Such as fingerprint files, key files, serial numbers, and digital rights management files.
  • the embodiment of the present application provides an optional implementation manner of writing the first hash value into the RPMB partition of the UFS.
  • the terminal device when the terminal device writes data to the RPMB partition of the UFS, the UFS checks the legitimacy of the terminal device, and only a specific terminal device can write to it.
  • the terminal device when the terminal device reads data from the RPMB partition of the UFS, it also provides a check mechanism to ensure that the data read by the terminal device is data on the RPMB partition, not data forged by an attacker.
  • FIG. 5 exemplarily shows a schematic flowchart of a method for reading data from a RPMB partition of a UFS according to an embodiment of the present application. This embodiment is described by taking a count value in an RPMB partition of UFS as an example. As shown in Figure 5, the method includes:
  • Step S501 The terminal device sends a request for reading the count value in the RPMB partition to the UFS.
  • the request for reading the count value in the RPMB partition further includes a first random number, and the first random number is randomly generated by the terminal device.
  • step S502 the UFS reads the first count value from the RPMB partition according to the request for reading the count value in the RPMB partition, and the first count value is the current count value in the RPMB partition.
  • the UFS maintains a count value, and the initial value of the count value is zero. Each time data is successfully written to the RPMB partition, the count value is increased by one, and the count value cannot be restored.
  • step S503 the UFS uses the shared secret key, the first random number, and the first count value as the input of the HMAC operation to generate a first Message Authentication Code (MAC).
  • MAC Message Authentication Code
  • the shared key is pre-agreed by the legal terminal device and UFS, and is burned into the RPMB partition of UFS when UFS leaves the factory.
  • MAC is essentially a hash value.
  • a characteristic of the hash operation is that even if only one bit of data is changed, the hash values of the two are completely different. If a malicious attacker tampers with the data during the data transmission process, the message authentication code generated by UFS based on the received data and shared key is different from the message authentication code received. If the authentication fails, the data will not be written to UFS. .
  • Step S504 The UFS sends the first MAC, the received first random number, and the read first count value to the terminal device.
  • Step S505 After receiving the first MAC, the first random number, and the first count value sent by the UFS, the terminal device determines that the received first random number and the request for reading the count value in the RPMB partition in step S501 include the first Whether the random numbers are consistent; if they are consistent, go to step S506; if they are not consistent, go to step S509.
  • Step S506 The terminal device uses the locally stored shared key, the first random number, and the received first count value as inputs of the HMAC operation to generate a second MAC.
  • step S507 the terminal device determines whether the second MAC and the first MAC are the same; if they are the same, step S508 is performed; if they are not the same, step S509 is performed.
  • Step S508 The terminal device determines that the read first count value is the first count value in the RPMB partition of the UFS.
  • Step S509 The terminal device discards the read data.
  • the terminal device reads the first count value in the RPMB partition of the UFS and needs to be authenticated.
  • the UFS calculates the first message authentication code, and then the terminal device generates the first message authentication code and generates the The second message authentication code authenticates the data.
  • a malicious attacker can be prevented from replacing the first count value with malicious data during the data transmission process (from UFS to the terminal device).
  • the first count value read by the terminal device can be guaranteed to be the first in the RPMB partition of the UFS Count value, not forged data by the attacker.
  • the process of reading other data from the RPMB partition of the UFS is the same as the above-mentioned process of reading the first count value, and details are not described herein again.
  • FIG. 6 exemplarily illustrates a schematic flow chart of a method for writing data to the RPMB partition of the UFS provided by the embodiment of the present application.
  • the data to be stored is a first hash value, and as shown in FIG. 6, the method includes:
  • Step S601 The terminal device uses the shared key, the read first count value, and the first hash value as inputs of the HMAC operation to generate a third MAC.
  • the shared key is the same as the shared key in step S503.
  • Step S602 The terminal device sends the first hash value, the first count value, and the third MAC to the UFS.
  • Step S603 After receiving the first hash value, the first count value, and the third MAC sent by the terminal device, the UFS determines whether the received first count value is consistent with the current count value in the RPMB partition of the UFS; if they are consistent, Step S604 is performed; if they are not consistent, step S607 is performed;
  • Step S604 The UFS uses the received first hash value, first count value, and shared key as inputs of the HMAC operation to generate a fourth MAC;
  • Step S605 the UFS determines whether the fourth MAC is the same as the received third MAC; if they are the same, step S606 is performed; if they are not the same, step S607 is performed;
  • Step S606 The UFS writes the first hash value into the RPMB partition.
  • the first implementation is to write the first hash value to the RPMB partition of the REE through the TEE client API and shared memory.
  • the encryption module can call the TEE client API to write the first hash value to the share.
  • the ordinary execution environment hardware driver module (RPMB driver) in the ordinary execution environment is notified, and the data in the shared memory is written into the RPMB partition.
  • Another implementation method is through the TEE communication agent and the REE communication agent. Specifically, the TEE communication agent sends the first hash value to the REE communication agent. After the REE communication agent receives the first hash value, it sends the RPMB driver An instruction to write the first hash value to the RPMB partition, and the RPMB driver writes the first hash value to the RPMB partition.
  • Step S607 UFS rejects the writing of the first hash value.
  • the first count value in the RPMB partition is incremented by one. In this way, even if a malicious attacker steals the first hash value, the first count value, and the third MAC in step S602, the third MAC is generated by calculating the first count value and the first hash value.
  • the first count value in the RPMB partition is increased by one, and a stealer cannot generate a MAC after the first count value is increased by one. Therefore, it is not possible to repeatedly write to the RPMB partition of the UFS.
  • the first hash value In this way, data written to the RPMB partition can be prevented from being rolled back (also referred to as playback).
  • the process of writing the M second hash values into the secure partition is the same as the process of writing the first hash values into the secure partition, and details are not described herein again.
  • FIG. 7 exemplarily illustrates a structure diagram of data of an RPMB partition provided by an embodiment of the present application.
  • the data of the RPMB partition includes a start field, a stuff bytes field, a MAC field, a data field, a random number field, a write counter field, Data address (data address) field, logical block count (block count) field, operation result (operation) result field, request / response (request / response) field, cyclic redundancy check (cyclic redundancy check, CRC) field, End field.
  • the cyclic redundancy check field is used to detect errors in the data transmission function, perform multiple calculations on the data, and append the calculated results to the data.
  • the receiving device also executes similar algorithms to ensure the correctness of data transmission and Integrity, 2 bytes in length.
  • the request / response field defines the request type / response type. The length is 2 bytes. When writing data to the RPMB partition, this field is the request type; when data is read from the RPMB partition, this field indicates the response type.
  • the count value field is used to indicate the number of successful data writes, and is 4 bytes long.
  • the MAC field depends on the request type / response type and is 32 bytes in length.
  • the operation result field contains status information (valid, expired) about writing the calculated value, and is 2 bytes in length.
  • the data address field is used to indicate the logical address for reading or writing data to the RPMB partition. It is 2 bytes in length and can be the serial number of a series of accessed half sectors.
  • the first address is 0x0000.
  • the random number is a random number generated when the terminal device sends a request to the memory, and the length is 16 bytes.
  • the data represents the data to be written or the data to be read.
  • the data to be written may be a first hash value and / or M second hash values.
  • the read data may be a count value and the length of the data. It is 256 bytes.
  • the block count value field is used to indicate the number of read logical blocks (half sector, 256 bytes), or the number of logical blocks written, with a length of 2 bytes.
  • Filler words can be used for memory.
  • M second hash values are stored in the RPMB partition in the form of hash blocks
  • the second hash value that does not satisfy a hash block can be made up with 0 padding bytes.
  • FIG. 8 exemplarily shows a schematic structural diagram of a file storage device provided in the present application.
  • the file storage device 800 includes a processor 801, a memory 802, and a bus 803.
  • the processor 801 and the memory 802 may They are connected to each other via a bus 803.
  • a processor 801 configured to encrypt a first file to obtain a second file under a trusted execution environment TEE, and perform a hash operation on the second file to obtain the first hash value;
  • the hash value is written into a secure partition in the memory 802, and the second file is written into an ordinary partition in the memory 802; the secure partition is used to prevent the file from being tampered with and / or rolled back; the first
  • the hash value is used to verify whether the second file is legal when the second file is decrypted to obtain the first file.
  • the processor 801 may be a central processing unit 801 (central processing unit, CPU), a network processor 801 (network processor, NP), or a combination of a CPU and an NP.
  • the processor 801 may further include a hardware chip.
  • the above hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof.
  • the PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a general array logic (GAL), or any combination thereof.
  • the memory 802 is configured to store software instructions, and the processor 801 calls the stored program instructions, and may execute one or more steps in the embodiment shown in the foregoing solution, or an optional implementation manner thereof.
  • the memory 802 may include non-volatile memory 802 (non-volatile memory), such as UFS, EMMC, flash memory 802, hard disk (HDD), or solid-state drive (SSD) );
  • the memory 802 may further include a combination of the above-mentioned types of the memory 802.
  • the bus 803 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, or the like.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in FIG. 8, but it does not mean that there is only one bus or one type of bus.
  • the memory 802 may also be integrated with the processor 801.
  • the first file includes M data blocks
  • the second file includes M encrypted data blocks; wherein M is an integer greater than or equal to 2; and the processor 801 specifically Used to: perform encryption operations on the M data blocks to obtain the M encrypted data blocks; perform hash operations on the M encrypted data blocks to obtain M second hash values; A hash operation is performed on the M second hash values to obtain the first hash value, where the M encrypted data blocks correspond to the M second hash values one-to-one.
  • the processor 801 is specifically configured to perform a hash message authentication code HMAC operation on the M second hash values to obtain the first hash value.
  • the processor 801 is further configured to: write the M second hash values into the ordinary partition; or, write the M second hash values into an ordinary partition.
  • the security partition is described.
  • the processor 801 is specifically configured to: write the M second hash values into the ordinary partition using a hash block as a storage unit; or, write the M second hash values into the ordinary partition; The two hash values are written into the secure partition using a hash block as a storage unit; wherein one hash block includes at least one of the second hash values; the size of the hash block is based on the processor read and write data granularity And the size of the second hash value is determined.
  • the secure partition includes a playback protected memory block RPMB partition.
  • the device further includes an interface; the interface is configured to: receive an update request; the update request includes a data block identifier and data to be updated, and the data block identifier is used to indicate the An encrypted data block to be updated in an ordinary partition; the processor is further configured to: obtain the encrypted data block to be updated from the ordinary partition according to the data block identifier; and acquire the to-be-updated The second hash value corresponding to the encrypted data block; if it is determined that the encrypted data block to be updated is legal according to the second hash value corresponding to the encrypted data block to be updated, according to the data to be updated Updating the encrypted data block to be updated; updating a second hash value corresponding to the encrypted data block to be updated.
  • the processor 801 is specifically configured to: decrypt the encrypted data block to be updated to obtain the data block to be updated; and update the to-be-updated data with the data to be updated The updated data block to obtain an updated data block; encrypt the updated data block to obtain an updated encrypted data block; perform a hash operation on the updated encrypted data block to obtain a third hash Greek value; updating the second hash value corresponding to the encrypted data block to be updated to the third hash value.
  • FIG. 9 exemplarily shows a schematic structural diagram of a file storage device provided in the present application.
  • the file storage device 900 includes an encryption unit 901, a processing unit 902, a secure partition 903, and a normal partition 904.
  • the encryption unit 901 is configured to: in a trusted execution environment, encrypt a first file to obtain a second file, and perform a hash operation on the second file to obtain a first hash value;
  • the processing unit 902 is configured to write the first hash value into the secure partition in the memory, and write the second file into a normal partition in the memory; the secure partition is used to prevent the file from being Tampering and / or preventing file rollback; the first hash value is used to verify whether the second file is legitimate when the second file is decrypted to obtain the first file.
  • each unit of the above file storage device is only a division of logical functions. In actual implementation, it may be fully or partially integrated into a physical entity, or it may be physically separated.
  • the encryption unit 901 and the processing unit 902 related to FIG. 9 may be implemented by the processor 801 of FIG. 8 described above. That is, in the embodiment of the present application, the encryption unit 901 and the processing unit 902 may execute the solution executed by the processor 801 in FIG. 8 described above. For the remaining contents, refer to the foregoing contents, and details are not described herein again.
  • a computer program product includes one or more instructions.
  • the computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
  • the instructions may be stored in a computer storage medium or transmitted from one computer storage medium to another computer storage medium.
  • the instructions may be transmitted from a website site, computer, server, or data center via a wired (e.g., coaxial cable, fiber optic, twisted Wire) or wireless (such as infrared, wireless, microwave, etc.) to another website site, computer, server or data center.
  • a computer storage medium may be any medium that can be accessed by a computer or a data storage device such as a server, a data center, or the like that includes one or more media integrations.
  • the medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape, a magneto-optical disk (MO), etc.), an optical medium (for example, an optical disk), or a semiconductor medium (for example, ROM, EPROM, EEPROM, solid state disk (SSD)) )Wait.
  • a magnetic medium for example, a floppy disk, a hard disk, a magnetic tape, a magneto-optical disk (MO), etc.
  • an optical medium for example, an optical disk
  • a semiconductor medium for example, ROM, EPROM, EEPROM, solid state disk (SSD)
  • Embodiments of the present application are described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowcharts and / or block diagrams, and combinations of processes and / or blocks in the flowcharts and / or block diagrams can be implemented by instructions. These instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine such that instructions executed by the processor of a computer or other programmable data processing device are generated for implementation Means of a function specified in one block or blocks of a flowchart or block and block diagrams.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to work in a specific manner such that the instructions stored in the computer-readable memory produce a manufactured article including an instruction device, the instructions
  • the device implements the functions specified in one or more flowcharts and / or one or more blocks of the block diagram.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of steps can be performed on the computer or other programmable device to produce a computer-implemented process, which can be executed on the computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more flowcharts and / or one or more blocks of the block diagrams.

Landscapes

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

Abstract

一种文件存储方法、装置及存储介质,其中方法包括在可信任执行环境TEE下,对第一文件进行加密得到第二文件,并对第二文件进行哈希运算得到第一哈希值;将第一哈希值写入存储器中的安全分区,以及将第二文件写入存储器中的普通分区;安全分区用于防止文件被篡改和/或回滚;所述第一哈希值用于在将所述第二文件解密得到所述第一文件时校验所述第二文件是否合法。TEE中可保证加密和哈希运算过程的安全性。将第二文件和第一哈希值分开存储,可提高篡改第二文件的难度。第二文件的对应的第一哈希值写入安全分区,第二文件写入普通分区,可通过占用较小内存的第一哈希值实现防止第二文件被篡改和/或回滚。

Description

一种文件存储方法、装置及存储介质 技术领域
本申请涉及数据安全技术领域,特别涉及一种文件存储方法、装置及存储介质。
背景技术
随着互联网技术的蓬勃发展,终端设备需要存储的文件也在不断的增长,特别是一些重要的文件越来越需要得到妥善的保存。现有技术中文件的存储方法一般是:获取待存储的文件,生成密钥,使用密钥将待存储的文件进行加密,得到加密后的文件,将加密后的文件写入存储器中。采用该方式存储文件,文件的安全性较低,因此,存储的文件容易被篡改。
为了进一步提高存储的文件的安全性,特别是一些敏感文件(比如指纹信息、密钥等)的安全性,目前是将这些敏感的文件存储在非易失性存储介质中的安全分区,比如嵌入式多媒体存储卡(embedded multi media card,EMMC)的回放受保护的内存块(replay protected memory block,RPMB)分区,或者通用闪存存储(universal flash storage,UFS)的RPMB分区等。
然而,非易失性存储介质中的安全分区的大小有限,无法支持大文件安全存储,因此,存储的文件的安全性仍较低。
发明内容
本申请实施例提供一种文件存储方法、装置及存储介质,用于提高存储的文件的安全性。
第一方面,本申请实施例提供一种文件存储方法,该方法包括:在可信任执行环境TEE下,对第一文件进行加密得到第二文件,并对所述第二文件进行哈希运算得到所述第一哈希值;将所述第一哈希值写入存储器中的安全分区,以及将所述第二文件写入所述存储器中的普通分区;所述安全分区用于防止文件被篡改和/或防止文件被回滚;所述第一哈希值用于在将所述第二文件解密得到所述第一文件时校验所述第二文件是否合法。
本申请实施例中,对第一文件进行加密、以及对第二文件进行哈希运算均是在TEE中执行的,因此,可提高加密过程和哈希运算过程的安全性。而且,第二文件的对应的第一哈希值写入了存储器中的安全分区,且安全分区用于防止文件被篡改和/或防止文件被回滚,因此,安全分区的第一哈希值可以防止被篡改和/或回滚,而且第一哈希值相对于第二文件的数据量较小,占用的内存也较小,如此,可通过占用较小内存的第一哈希值实现防止第二文件被篡改和/或回滚。
在一种可能地实现方式中,为了实现第一文件的部分更新,所述第一文件包括M个数据块;所述第二文件包括M个加密数据块;其中,所述M为大于等于2的整数;所述对第一文件进行加密得到第二文件,包括:分别对所述M个数据块进行加密运算,得到所述M个加密数据块;所述对所述第二文件进行哈希运算得到所述第一哈希值,包括:分别对所述M个加密数据块进行哈希运算,得到M个第二哈希值;并对所述M个第二哈希值进行哈希运算得到所述第一哈希值,其中,所述M个加密数据块与所述M个第二哈希值一一对应。通过分别对M个数据块进行加密得到M个加密数据,以及分别对M个加密数据 进行哈希运算,一方面,可以减小每次加密及哈希运算的数据量,进而可提高加密和哈希运算的效率;另一方面,第一哈希值是对M个第二哈希值进行加密得到的,如此,进一步可提高计算第一哈希值的效率。
在一种可能地实现方式中,为了保证写入安全分区数据的完整性以及向安全分区写数据的终端设备的合法性,所述对M个第二哈希值进行哈希运算得到第一哈希值,包括对所述M个第二哈希值进行哈希消息认证码HMAC运算,得到所述第一哈希值。
一种可能的实施方式中,可以将所述M个第二哈希值写入普通分区,将第一哈希值写入安全分区,如此,第一哈希值的数据量较小,可以用较小数据量的第一哈希值防止数据量较大的第二文件被篡改和/或回滚。或者也可以将所述M个第二哈希值和第一哈希值写入安全分区。如此,一方面,通过将M个加密数据块和M个第二哈希值分开存储,可提高第二文件的安全性;另一方面,可以分别用第二哈希值来防止每个加密数据块被篡改和/或回滚,也就是说,可以通过较高效率的运算来防止第二文件被篡改和/或回滚。
在一种可能地实现方式中,处理器在读取存储器中的数据的时候是一块一块进行读取的,为了提高处理器存取数据的效率,可以将所述M个第二哈希值以哈希块为存储单元写入所述普通分区;或者也可以将所述M个第二哈希值以哈希块为存储单元写入所述安全分区;其中,一个哈希块中包括至少一个所述第二哈希值;所述哈希块的大小可以是根据处理器存取数据粒度和所述第二哈希值的大小来确定的。
可选地,哈希块的大小与处理器存取数据的粒度有关,将哈希值按照哈希块为存储单位写入存储器可以实现内存对齐,后续处理器读取数据时也可以按哈希块读取,减小处理器访问的次数,进而可提高处理器读写数据的效率。
在一种可能地实现方式中,所述安全分区包括回放受保护的内存块RPMB分区。
在一种可能地实现方式中,接收更新请求;所述更新请求包括数据块标识和待更新的数据,所述数据块标识用于指示所述普通分区中待被更新的加密数据块;根据所述数据块标识,从所述普通分区中获取所述待被更新的加密数据块;获取所述待被更新的加密数据块对应的第二哈希值;若根据所述待被更新的加密数据块对应的第二哈希值确定所述待被更新的加密数据块合法,则根据所述待更新的数据,更新所述待被更新的加密数据块;更新所述待被更新的加密数据块对应的第二哈希值。如此,当需要更新第二文件的部分数据时,可以实现部分更新加密数据块,进而可提高更新加密数据块的更新效率。
在一种可能地实现方式中,根据所述待更新的数据,更新所述待被更新的加密数据块可以为:对所述待被更新的加密数据块进行解密,得到待被更新的数据块;用所述待更新的数据更新所述待被更新的数据块,得到更新后的数据块;对所述更新后的数据块进行加密,得到更新后的加密数据块;更新所述待被更新的加密数据块对应的第二哈希值,包括:对所述更新后的加密数据块进行哈希运算,得到第三哈希值;将所述待被更新的加密数据块对应的第二哈希值更新为所述第三哈希值。如此,不需要对整个第二文件进行解密、加密再计算更新后的整个第二文件的哈希值,降低了整体加密、解密、哈希运算带来的开销。
第二方面,本申请实施例提供文件存储装置,包括:处理器和存储器;所述处理器,用于在可信任执行环境TEE下,对第一文件进行加密得到第二文件,并对所述第二文件进行哈希运算得到第一哈希值;所述处理器,还用于将所述第一哈希值写入所述存储器中的安全分区,以及将所述第二文件写入所述存储器中的普通分区;所述安全分区用于防止文件被篡改和/或防止文件回滚;所述第一哈希值用于在将所述第二文件解密得到所述第一文 件时校验所述第二文件是否合法。
在一种可能地实现方式中,所述第一文件包括M个数据块,所述第二文件包括M个加密数据块;其中,所述M为大于等于2的整数;所述处理器具体用于:分别对所述M个数据块进行加密运算,得到所述M个加密数据块;分别对所述M个加密数据块进行哈希运算,得到M个第二哈希值;对所述M个第二哈希值进行哈希运算得到所述第一哈希值,其中,所述M个加密数据块与所述M个第二哈希值一一对应。
在一种可能地实现方式中,所述处理器具体用于:对所述M个第二哈希值进行哈希消息认证码HMAC运算,得到所述第一哈希值。
在一种可能地实现方式中,所述处理器还用于:将所述M个第二哈希值写入所述普通分区;或者,将所述M个第二哈希值写入所述安全分区。
在一种可能地实现方式中,所述处理器具体用于:将所述M个第二哈希值以哈希块为存储单元写入所述普通分区;或者,将所述M个第二哈希值以哈希块为存储单元写入所述安全分区;其中,一个哈希块中包括至少一个所述第二哈希值;所述哈希块的大小根据处理器读写数据粒度和所述第二哈希值的大小确定。
在一种可能地实现方式中,所述安全分区包括回放受保护的内存块RPMB分区。
在一种可能地实现方式中,所述装置还包括接口;所述接口用于:接收更新请求;所述更新请求包括数据块标识和待更新的数据,所述数据块标识用于指示所述普通分区中待被更新的加密数据块;所述处理器,还用于:根据所述数据块标识,从所述普通分区中获取所述待被更新的加密数据块;获取所述待被更新的加密数据块对应的第二哈希值;若根据所述待被更新的加密数据块对应的第二哈希值确定所述待被更新的加密数据块合法,则根据所述待更新的数据,更新所述待被更新的加密数据块;更新所述待被更新的加密数据块对应的第二哈希值。
在一种可能地实现方式中,所述处理器具体用于:对所述待被更新的加密数据块进行解密,得到待被更新的数据块;用所述待更新的数据更新所述待被更新的数据块,得到更新后的数据块;对所述更新后的数据块进行加密,得到更新后的加密数据块;对所述更新后的加密数据块进行哈希运算,得到第三哈希值;将所述待被更新的加密数据块对应的第二哈希值更新为所述第三哈希值。
第三方面,本申请实施例提供一种文件存储装置包括:加密单元、处理单元、安全分区和普通分区;所述加密单元,用于在可信任执行环境下,对第一文件进行加密得到第二文件,并对所述第二文件进行哈希运算得到第一哈希值;所述处理单元,用于将所述第一哈希值写入存储器中的所述安全分区,以及将所述第二文件写入所述存储器中的普通分区;所述安全分区用于防止文件被篡改和/或防止文件回滚;所述第一哈希值用于在从所述除安全分区以外的存储区域获取所述第二文件时校验所述第二文件是否合法。
在一个可能的设计中,所述第一文件包括M个数据块,所述第二文件包括M个加密数据块;其中,所述M为大于等于2的整数;所述加密单元具体用于:分别对所述M个数据块进行加密运算,得到所述M个加密数据块;分别对所述M个加密数据块进行哈希运算,得到M个第二哈希值;对所述M个第二哈希值进行哈希运算得到所述第一哈希值,其中,所述M个加密数据块与所述M个第二哈希值一一对应。
在一个可能的设计中,所述加密单元具体用于:对所述M个第二哈希值进行哈希消息认证码HMAC运算,得到所述第一哈希值。
在一个可能的设计中,所述处理单元还用于:将所述M个第二哈希值写入普通分区;或者,将所述M个第二哈希值写入安全分区。
在一个可能的设计中,所述处理单元具体用于:将所述M个第二哈希值以哈希块为处理单元写入普通分区;或者,将所述M个第二哈希值以哈希块为存储单元写入所述安全分区;其中,一个哈希块中包括至少一个加密后的数据块的哈希值;所述哈希块的大小根据处理器存取数据粒度和所述第二哈希值的大小确定。
在一个可能的设计中,所述安全分区包括回放受保护的内存块RPMB分区。
在一个可能的设计中,所述装置还包括收发单元;所述收发单元用于:接收更新请求;所述更新请求包括数据块标识和待更新的数据,所述数据块标识用于指示所述普通分区中待被更新的加密数据块;所述处理单元还用于:根据所述数据块标识,从所述普通分区中获取所述待被更新的加密数据块;获取所述待被更新的加密数据块对应的第二哈希值;若根据所述待被更新的加密数据块对应的第二哈希值确定所述待被更新的加密数据块合法,则根据所述待更新的数据,更新所述待被更新的加密数据块;更新所述待被更新的加密数据块对应的第二哈希值。
在一个可能的设计中,所述处理单元具体用于:对所述待被更新的加密数据块进行解密,得到待被更新的数据块;用所述待更新的数据更新所述待被更新的数据块,得到更新后的数据块;对所述更新后的数据块进行加密,得到更新后的加密数据块;对所述更新后的加密数据块进行哈希运算,得到第三哈希值;将所述待被更新的加密数据块对应的第二哈希值更新为所述第三哈希值。
第四方面,本申请实施例提供一种计算机存储介质,计算机存储介质中存储有指令,当其在计算机上运行时,使得计算机执行第一方面或第一方面的任意可能的实现方式中的方法。
第五方面,本申请实施例提供一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行第一方面或第一方面的任意可能的实现方式中的方法。
附图说明
图1为本申请实施例提供的一种终端设备的可信环境的软件框架示意图;
图2为本申请实施例提供的一种终端设备软件和硬件的架构示意图;
图3为本申请实施例提供的一种文件存储方法流程示意图;
图4为本申请实施例提供的另一种文件存储方法流程示意图;
图4a为本申请实施例提供的一种将第一文件进行存储的架构示意图;
图5为本申请实施例提供的一种向UFS的RPMB分区读取数据的方法流程示意图;
图6为本申请实施例提供的一种向UFS的RPMB分区写数据的方法流程示意图;
图7为本申请实施例提供的一种RPMB分区的数据的结构示意图;
图8为本申请实施例提供的一种文件存储装置的结构示意图;
图9为本申请实施例提供的一种文件存储装置的结构示意图。
具体实施方式
本申请的说明书实施例和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。此外,术语“包括”和“具有” 以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元。方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
应当理解,在本申请中,“至少一个(项)”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,用于描述关联对象的关联关系,表示可以存在三种关系,例如,“A和/或B”可以表示:只存在A,只存在B以及同时存在A和B三种情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项(个)”或其类似表达,是指这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b或c中的至少一项(个),可以表示:a,b,c,“a和b”,“a和c”,“b和c”,或“a和b和c”,其中a,b,c可以是单个,也可以是多个。
终端设备的各种功能的实现,需要依赖于终端设备内的可信环境,终端设备的可信环境通过混合使用硬件和软件的方法在物理上隔离出两个并存的执行环境,即:普通的非保密执行环境和安全的保密环境。其中,可以称普通非保密执行环境为普通执行环境(rich execution environment,REE),称安全的保密环境为可信任执行环境(trusted execution environment,TEE)。本申请实施例以TEE是智能卡及终端设备安全的标准组织全球平台组织(global platform,GP)提出的概念为例说明,终端设备可以是智能手机、智能电视、平板电脑、机顶盒和网络视频播放机等。图1示例性示出了本申请实施例提供的一种终端设备的可信环境的软件框架示意图。如图1所示,该终端设备的可信环境的软件框架包括REE软件架构和TEE软件架构。
REE通常是安卓或苹果公司的移动操作系统(iPhone operating system,iOS)等终端设备操作系统的运行环境。REE软件架构包括客户端应用、TEE功能应用程序编程接口(application programming interface,API)、TEE客户端API和普通操作系统等。客户端应用可提供给用户使用的客户端应用,可以是运营商的客户端应用,也可以是第三方客户端应用,比如微信或支付宝等。客户端应用可能会有需要进行安全存储的文件。TEE功能API可提供给客户端应用一套访问TEE安全服务(比如存储和加密算法)的接口。TEE客户端API可提供运行于REE环境的客户端应用访问TEE环境中的可信应用(trusted application,TA)及与TA进行数据交换的通信接口。普通操作系统包含公共设备驱动模块及REE通信代理模块等。公共设备驱动模块可提供硬件设备和普通操作系统之间的接口,用于将硬件设备的功能通知普通操作系统,将普通操作系统的指令,转化为硬件设备能够识别的命令。REE通信代理可用于客户端应用与TA之间的消息传送。
TEE提供了一个较安全的封闭的执行环境,可确保各种敏感文件在一个可信环境中被存储和受到保护。TEE软件架构包括TA、TEE内部API和可信操作系统。TA运行于TEE中,TA可向它的用户提供安全服务(比如安全存储和加密),TA与TA之间可通过TEE内部API进行通信。TEE内部API可为运行于TEE内的TA定义一套APIs,这套APIs定义运行在TEE内部的TA的开发接口,具体来说,可以提供调度、通信和内存管理接口,以及提供安全存储、密码服务和加密等APIs接口。可信操作系统包括TEE通信代理模块、可信核心框架模块和可信功能模块等。TEE通信代理与REE通信代理可结合实现客户端应用与TA之间消息的安全传送。可信核心框架向TA提供可信操作系统功能。可信功能模块可向应用开发者提供辅助设施支撑。
图2示例性示出了本申请实施例提供的一种终端设备软件和硬件的架构示意图。如图2 所示,该终端设备包括REE的软件和硬件架构、以及TEE的软件和硬件架构。
REE的软件和硬件架构包括REE硬件、REE硬件驱动模块、普通操作系统、TEE客户端API和客户端应用等。REE硬件包括输入/输出接口、存储器和中央处理器(central processing unit,CPU)等设备。REE硬件驱动可提供普通操作系统下的普通执行环境硬件设备驱动,如EMMC等硬件设备的驱动,当普通操作系统需要使用硬件设备时,比如向EMMC写文件,普通操作系统会先发送相应指令到EMMC的驱动程序,EMMC的驱动程序接收到指令后,将指令翻译成EMMC能识别的电子信号命令,从而实现向EMMC写文件。普通操作系统包括REE通信代理及普通操作系统下的REE应用,比如可以是访问TEE中TA的REE中客户端应用。TEE客户端API可为客户端应用提供访问TA的接口,可采用GP客户端标准接口。
TEE的软件和硬件架构包括安全硬件、安全硬件驱动、可信操作系统、TEE内部核心API及TA等。安全硬件包括安全输入/输出接口、安全处理器、安全存储器及可信设备等设备。一种可能实现方式中,安全硬件中的安全输入/输出接口可以是REE的输入/输出接口的一种安全模式,也可以是与REE的输入/输出接口隔离的输入/输出接口;安全处理器可以是REE中的CPU的一种安全模式,也可以是与CPU隔离的一个处理器;安全存储器可以是REE中的存储器的分区,也可以是REE的存储器的一种安全模式。安全硬件驱动可提供安全硬件设备的驱动,比如指纹设备驱动,用于读取指纹采集设备(可信设备)的指纹信息,指纹信息为待存储的文件;EMMC驱动,可用于读取EMMC中的文件或者向EMMC写入文件等。可信操作系统可提供可信操作系统功能,例如存储、加密(如哈希运算、加密运算)和TEE通信代理等核心安全功能模块。处理模块在TEE环境下可提供统一安全数据存储服务及API。加密模块可提供在TEE环境下的加解密、私钥签名和哈希运算等安全服务。
基于上述内容,图3示例性示出了本申请实施例提供的一种文件存储方法流程示意图。该文件存储方法是在上述图1或图2的TEE中执行的,在TEE中执行文件存储方法可提高存储过程的安全性。如图3所示,该方法包括:
步骤S301,对第一文件进行加密得到第二文件,并对第二文件进行哈希运算得到第一哈希值。
一种可能的实施方式中,第一文件是待存储的文件,可以是文字或者图片等形式,对第一文件的加密方式可以是使用对称密钥加密,也可以使用非对称密钥加密,也可以采用硬件加密的方式;采用对称密钥进行加密,加密的速率较高。可选地,对所述第一文件进行加密和对第二文件进行哈希运算可以是上述图2的TEE中的可信操作系统中的加密模块执行。
步骤S302,将第一哈希值写入存储器中的安全分区,以及将第二文件写入存储器中的普通分区;
其中,所述安全分区用于防止文件被篡改和/或防止文件回滚;所述第一哈希值用于在将所述第二文件解密得到所述第一文件时校验所述第二文件是否合法。
一种可能的实现方式中,存储器的普通分区可以是除所述安全分区以外的存储区域,从存储器中的普通分区获取到第二文件,对获取到第二文件进行相同的哈希运算得到哈希值,若确定计算得到的哈希值与从安全分区获取到的第一哈希值相同,则说明获取到的第二文件合法。
本申请实施例中,通过上述步骤S301和步骤S302可以看出,对第一文件进行加密、 以及对第二文件进行哈希运算均是在TEE中进行的,因此,可提高加密过程和哈希运算过程的安全性。而且,只有当第二文件和第一哈希值均被篡改之后,才能实现对第二文件的篡改,但是本申请实施例将第二文件写入存储器中的普通分区,将第一哈希值写入安全分区,即将第二文件和第二文件的对应的第一哈希值分开存储,分开存储可以提高篡改第二文件的难度,有助于提高第二文件的安全性。
进一步,第二文件的对应的第一哈希值写入了存储器中的安全分区,且安全分区用于防止文件被篡改和/或回滚,因此,安全分区的第一哈希值可以防止被篡改和/或回滚,而且第一哈希值相对于第二文件的数据量较小,占用的内存也较小,如此,可通过占用较小内存的第一哈希值实现防止第二文件被篡改和/或回滚。
在上述步骤S301中,为了提高对第二文件的更新效率,一种可能的实施方式是对第二文件中需要更新的部分进行更新。图4示例性示出了本申请实施例提供的另一种文件存储方法流程示意图,以图4所示的文件存储方法可以实现存储的文件的部分更新,进而可提高文件的更新效率。如图4所示,该文件存储方法包括:
步骤S401,将第一文件分为M个数据块;其中,M为大于等于2的整数。
一种可能的实施方式中,数据块的大小可根据处理器存取数据的粒度确定,处理器是把内存当成一块一块的,块的大小可以是2、4、8或16个字节,因此,处理器在读取内存的时候是一块一块进行读取的,块的大小称为处理器存储数据粒度。示例性的,在32位处理器中,处理器访问内存是按照32位进行的,即一次读取或写入都是4个字节,比如,内存地址0x0~0xF这16字节的内存,对于该处理器来说,不是将其看作16个单一字节,而是4个块,每块4个字节,即此种情况下,该处理器存取数据粒度为4个字节,则数据块的大小可以确定为4字节的正整数倍。当将数据块进行加密后存储时,可以实现内存对齐,如此,处理器需要读取数据的时候,可以一次读取一个数据块,可减小处理器访问的次数,进而可提高处理器读取数据的效率。可选地,当第一文件被划分为若干个数据块后,第一文件剩余部分的数据不足划分为一个数据块的大小,比如不足4字节的正整数倍,可以将该第一文件剩余部分的数据按照补0的方式凑成一个完整的数据块。相对应地,在对该按照补0的方式凑成的数据块在进行解密时,将补的0去掉。
步骤S402,分别对M个数据块进行加密运算,得到M个加密数据块;所述第二文件包括M个加密数据块。
一种可选地实施方式中,对M个数据块进行加密的方式可以是通过对称密钥的方式,或者通过非对称密钥的方式,或者采用硬件加密的方式。可选地,对M个数据块进行加密的密钥可以是同一个密钥,也可以是不同的密钥,使用同一个密钥分别对M个数据块进行加密,可以增加加密的效率,且需要存储一个密钥,可以减小密钥的存储数量。针对不同的数据块也可使用不同的密钥进行加密,如此可以加强第一文件存储的安全性。可选地,加密的密钥均可存储在存储器的安全分区,以提高密钥的安全性。
步骤S403,分别对M个加密数据块进行哈希运算,得到M个第二哈希值,并对M个第二哈希值进行哈希运算得到第一哈希值。
其中,所述M个加密数据块与所述M个第二哈希值一一对应。通过分别对M个加密数据块进行哈希运算,得到M个第二哈希值,一方面,哈希运算输入的是一个加密后的数据块,加密后的数据块的相比于整个第二文件的数据量较小,因此,可提高第二哈希值的计算效率;另一方面,在得到M个第二哈希值后,将M个第二哈希值作为输入进行哈希 运算,得到第二文件的第一哈希值,M个第二哈希值相对于M个加密数据块的数据量更小,如此,可以进一步提高计算第一哈希值的运算效率。
一种可能的实施方式中,对M个第二哈希值进行哈希运算得到第一哈希值,可以是对M个第二哈希值进行哈希消息认证码(hash message authentication code,HMAC)运算,得到第一哈希值。HMAC运算是基于密钥的哈希算法,它的实现原理是:用散列函数、密钥和消息产生一个固定长度的值作为认证标识,用这个标识鉴别消息的完整性。具体是,以与接收端共享密钥和消息作为HMAC运算的输入,生成一个消息摘要(即固定长度的值)作为输出,将该消息摘要和消息一起传输至接收端,接收端利用与发送端共享密钥进行鉴别认证等接收端的合法性和消息的完整性,其中,共享密钥是双发预先约定的。散列函数包括但不限于消息摘要算法第五版(message digest algorithm,MD5),安全哈希算法(secure hash algorithm,SHA),比如SHA-1和SHA-2(SHA-256,SHA-384和SHA-512)。
结合图2,上述步骤S402和步骤S403可以是在TEE的可信操作系统的中的加密模块中执行的。本申请实施例中,共享密钥可存储在存储器的安全分区,与REE隔离,该共享密钥不能被REE获取到,如此,可提高该共享密钥的安全性。
步骤S404,将第二文件和M个第二哈希值写入普通分区,将第一哈希值写入安全分区。也就是说,仅把第一哈希值写入安全分区。第一哈希值的数据量较小,将数据量较小的第一哈希值存储在安全分区,可通过数据量较小的第一哈希值来防止第二文件的被篡改和/或回滚。而且,第二文件存储在存储器中的普通分区,可以实现数据量较大的第二文件的存储,且可以利用安全分区中的数据量较小的第一哈希值来防止整个第二文件被篡改和/或回滚。
步骤S405,将第二文件写入普通分区,将M个第二哈希值和第一哈希值写入安全分区。通过将M个第二哈希值写入安全分区,实现了将M个加密数据块和M个第二哈希值分开存储,提高了M个加密数据块的安全性。进一步,可以通过安全分区中M个第二哈希值中的每个第二哈希值实现防止每个加密数据块被篡改和/或回滚。
一种可能的实施方式中,将M个第二哈希值以哈希块为存储单元写入普通分区;或者,将M个第二哈希值以哈希块为存储单元写入安全分区。其中,一个哈希块中包括至少一个第二哈希值;哈希块的大小根据处理器存取数据粒度和第二哈希值的大小确定。比如,处理器存取数据粒度为4字节,则哈希块的大小可以确定为4字节的正整数倍。若哈希块的大小确定为4字节,且计算所述加密的数据块的哈希值是通过SHA-256,得到的第二哈希值的大小为256比特,则一个哈希块中包括128个第二哈希值。若哈希块的大小确定为4字节,且计算所述加密的数据块的哈希值是通过SHA-512,得到的第二哈希值的大小为512比特,则一个哈希块中包括64个第二哈希值。如此,通过将M个第二哈希值以哈希块为存储单元写入存储器的安全分区或者存储器中的普通分区,可以提高处理器存取数据的效率。
上述步骤S404和步骤S405之间不表示先后顺序,在步骤S403之后执行步骤S404或者步骤S405。也就是说,在步骤S403之后若执行步骤S404,则不执行步骤S405,若执行步骤S405,则不执行步骤S404。
为了便于方案的理解,本申请以如下例子示例性说明。图4a示例性示出了本申请实施例提供的一种将第一文件进行存储的架构示意图。如图4a所示,第一文件包括M个数据块;每个数据块的大小可根据处理器存取数据的粒度确定,本申请实施例以32位处理器 为例,假设每个数据块的大小确定为4字节。分别对M个数据块进行加密得到M个加密数据块,M个加密数据块组成第二文件。分别对M个加密数据块进行哈希运算,得到M个第二哈希值,并对M个第二哈希值进行HMAC运算得到第一哈希值;其中,哈希运算若采用SHA-256,则第二哈希值的大小256比特,则128个第二哈希值的大小为4K,因此,一个哈希块中包括128个第二哈希值,哈希块的大小为4字节,将M个第二哈希值按哈希块为存储单元写于安全分区,或者,写于普通分区。
本申请实施例中,为了进一步方便以哈希块为存储单元存储所述M个第二哈希值,可以根据计算第二哈希值时的哈希运算和处理器器存取数据的粒度对M个数据块进行分组。比如计算第二哈希值的哈希运算若采用SHA-256,则第二哈希值的大小为256比特,且处理器存取数据的粒度若为4字节,则需要128个第二哈希值组成一个哈希块,一个第二哈希值对应一个加密后的数据块,因此,可将128个数据块分为一个数据组。也就说,一个数据组对应128个第二哈希值,形成一个哈希块,以哈希块为存储单元,对M个第二哈希值进行存储。
本申请实施例提供了一种按上述步骤S401至步骤S402的存储方法存储第一文件后,更新第一文件中部分文件的可选地实施方式。可选地的实施方式为:接收更新请求;所述更新请求包括数据块标识和待更新的数据,所述数据块标识用于指示所述普通分区中待被更新的加密数据块;根据所述数据块标识,从所述普通分区中获取所述待被更新的加密数据块;获取所述待被更新的加密数据块对应的第二哈希值;若根据所述待被更新的加密数据块对应的第二哈希值确定所述待被更新的加密数据块合法,则根据所述待更新的数据,更新所述待被更新的加密数据块;更新所述待被更新的加密数据块对应的第二哈希值。
一种可能的实施方式中,获取到待被更新的加密数据块和待被更新的加密数据块对应的第二哈希值后,用相同的哈希运算对获取到的待被更新的加密数据块进行哈希运算,若计算得到的哈希值与获取到的待被更新的加密数据块对应的第二哈希值相同,则确定待被更新的加密数据块合法。
一种可能的实施方式中,在验证所述待被更新的加密数据块合法之后,对所述待被更新的加密数据块进行解密,得到待被更新的数据块;用所述待更新的数据更新所述待被更新的数据块,得到更新后的数据块;对所述更新后的数据块进行加密,得到更新后的加密数据块;对所述更新后的加密数据块进行哈希运算,得到第三哈希值;将所述待被更新的加密数据块对应的第二哈希值更新为所述第三哈希值。如此,不需要对整个第二文件进行解密、加密再计算更新后的整个第二文件的哈希值,降低了整体加密、解密、哈希运算带来的开销。
一种可能的实施方式中,用第三哈希值更新所述待被更新的加密数据块对应的第二哈希值之后,并对(M-1)个第二哈希值和第三哈值进行哈希运算得到第二文件对应的新的哈希值,用新的哈希值更新第一哈希值。
本申请实施例中,所述安全分区包括RPMB分区;或者,是基于RPMB分区技术的其它安全分区。其中,RPMB分区可以是EMMC中的一个具有安全特性的分区,也可以是通用闪存存储(universal flash storage,UFS)中的一个具有安全特性分区。RPMB分区或者基于RPMB分区技术的其它安全分区均具有防止写入该安全分区的文件被非法篡改和/或回滚的特性,因此,在实际应用中,通常将一些重要的文件写在安全分区中,比如指纹文件、密钥文件、序列号和数字版权管理文件等。
本申请实施例提供了一种将第一哈希值写入UFS的RPMB分区的可选地实施方式。该实施方式中,终端设备向UFS的RPMB分区写数据时,UFS会校验终端设备的合法性,只有特定的终端设备才能写入。而且,终端设备从UFS的RPMB分区读取数据时,也提供了校验机制,保证了终端设备读取到的数据是RPMB分区上的数据,不是攻击者伪造的数据。图5示例性示出了本申请实施例提供的一种向UFS的RPMB分区读取数据的方法流程示意图。该实施方式以读取UFS的RPMB分区中的计数值为例说明。如图5所示,该方法包括:
步骤S501,终端设备向UFS发送读取RPMB分区中计数值的请求。
其中,该读取RPMB分区中计数值的请求中还包括第一随机数,第一随机数是终端设备随机生成的。
步骤S502,UFS根据读取RPMB分区中计数值的请求,从RPMB分区中读出第一计数值,第一计数值为RPMB分区中的当前计数值。
一种可能的实施方式中,UFS维护一个计数值,该计数值的初始化值为零,每向RPMB分区成功写入一次数据,该计数值加一,且该计数值不能复原。
步骤S503,UFS将共享密钥、第一随机数和第一计数值作为HMAC运算的输入,生成第一消息认证码(Message Authentication Code,MAC)。
可选地,共享密钥是合法的终端设备和UFS预先约定的,在UFS出厂时烧录在UFS的RPMB分区中的。其中,MAC本质是哈希值,哈希运算的一个特点是,即使只改变原数据一比特数据,两者的哈希值也是完全不同的。如果恶意攻击者在数据传输过程中篡改了数据,那么UFS根据接收到的数据和共享密钥生成的消息认证码与接收到的消息认证码不一样,认证不通过,数据就不会写入UFS。
步骤S504,UFS将第一MAC、接收到的第一随机数和读取出的第一计数值发送至终端设备。
步骤S505,终端设备接收到UFS发送的第一MAC、第一随机数和第一计数值后,确定接收到的第一随机数和步骤S501中读取RPMB分区中计数值的请求中包括第一随机数是否一致;若一致,执行步骤S506;若不一致,执行步骤S509。
步骤S506,终端设备将本地存储的共享密钥、第一随机数和接收到的第一计数值作为HMAC运算的输入,生成第二MAC。
步骤S507,终端设备确定第二MAC和第一MAC是否相同;若相同,执行步骤S508;若不相同,执行步骤S509。
步骤S508,终端设备确定读取到的第一计数值是UFS的RPMB分区中的第一计数值。
步骤S509,终端设备丢弃读取到的数据。
通过上述步骤S501至步骤S509,终端设备读取UFS的RPMB分区中的第一计数值是需要认证的,UFS会计算第一消息认证码,然后终端设备根据接收到的第一消息认证码和生成的第二消息认证码认证该数据。这样,可以防止恶意攻击者在数据传输过程(从UFS到终端设备)用恶意数据更换第一计数值,如此,可以保证终端设备读取到的第一计数值是UFS的RPMB分区中的第一计数值,不是攻击者伪造的数据。本申请实施例中,从UFS的RPMB分区中读取其它数据的过程与上述读取第一计数值的过程相同,在此不再赘述。
终端设备在向RPMB分区写入数据之前,需要先获取RPMB分区中的当前计数值。基于上述图5读取到的UFS的RPMB分区中的第一计数值,图6示例性示出了本申请实 施例提供的一种向UFS的RPMB分区写数据的方法流程示意图。该实施例中以待存储的数据是第一哈希值为例说明,如图6所示,该方法包括:
步骤S601,终端设备将共享密钥、读取到的第一计数值和第一哈希值作为HMAC运算的输入,生成第三MAC。
一种可选地实施方式中,共享密钥与上述步骤S503中的共享密钥相同。
步骤S602,终端设备将第一哈希值、第一计数值和第三MAC发送至UFS。
步骤S603,UFS接收到终端设备发送的第一哈希值、第一计数值和第三MAC后,确定接收到的第一计数值和UFS的RPMB分区中的当前计数值是否一致;若一致,则执行步骤S604;若不一致,则执行步骤S607;
步骤S604,UFS将接收到的第一哈希值、第一计数值和共享密钥作为HMAC运算的输入,生成第四MAC;
步骤S605,UFS确定第四MAC是否与接收到的第三MAC相同;若相同,则执行步骤S606;若不相同,则执行步骤S607;
步骤S606,UFS将第一哈希值写入RPMB分区。
结合上述图1和图2,将第一哈希值写入RPMB分区有两种实现方式。第一种实现方式是通过TEE客户端API,通过共享内存方式实现将第一哈希值写入REE的RPMB分区,具体可为加密模块调用TEE客户端API,将第一哈希值写入共享内存中,通知普通执行环境中的普通执行环境硬件驱动模块(RPMB驱动程序),将共享内存中的数据写入RPMB分区。另一种实现方式是通过TEE通信代理和REE通信代理,具体可为:TEE通信代理向REE通信代理发送第一哈希值,REE通信代理接收第一哈希值后,向RPMB驱动程序发送将第一哈希值写入RPMB分区的指令,RPMB驱动程序将第一哈希值写入RPMB分区。
步骤S607,UFS拒绝第一哈希值的写入。
在上述步骤S606之后,RPMB分区中的第一计数值加一。这样,即便恶意攻击者窃取到步骤S602中第一哈希值、第一计数值和第三MAC,第三MAC是对第一计数值和第一哈希值运算生成的。在将第一哈希值成功写入RPMB分区后,RPMB分区中的第一计数值加一,窃取者无法生成第一计数值加一之后的MAC,因此,无法重复向UFS的RPMB分区写入第一哈希值。如此,可以防止写入RPMB分区的数据被回滚(也称为重放)。
可选地,将所述M个第二哈希值写入安全分区的过程与将第一哈希值写入安全分区的过程相同,在此不再赘述。
一种可能的实施方式中,将待存储的数据写入RPMB分区时,需要将待存储的数据封装为RPMB分区的数据结构。图7示例性示出了本申请实施例提供的一种RPMB分区的数据的结构示意图。如图7所示,RPMB分区的数据包括开始(start)字段、填充字节(stuff bytes)字段、MAC字段、数据(data)字段、随机数(nonce)字段、计数值(write counter)字段、数据地址(data address)字段、逻辑块计数值(block count)字段、操作结果(operation result)字段、请求/响应(request/response)字段、循环冗余校验(cyclic redundancy check,CRC)字段、结束(end)字段。循环冗余校验字段用于对数据传输功能检错,对数据进行多项计算,并将计算得到的结果附在数据的后面,接收设备也执行类似的算法,以保证数据传输的正确性和完整性,长度为2个字节。请求/响应字段定义了请求类型/响应类型,长度为2个字节,向RPMB分区写数据时,该字段为请求类型;从RPMB分区读取到数据时,该字段表示响应类型。计数值字段用于表示成功写入数据的次数,长度为4字节。MAC字 段依赖于请求类型/响应类型,长度为32字节。操作结果字段,包含有关写计算值的状态信息(有效、过期),长度为2字节。数据地址字段用于表示对RPMB分区读取或者写入数据的逻辑地址,长度为2个字节,可以是一系列被访问的半扇区的序列号,第一个地址是0x0000。随机数是在终端设备在向存储器发送请求时,生成的随机数,长度为16字节。数据表示待写入的数据或读取出的数据,待写入的数据可以是第一哈希值和/或M个第二哈希值,读取出的数据可以是计数值,数据的长度为256字节。块计数值字段用于表示指定读取逻辑块的数量(半扇区,256字节),或者,指定写入逻辑块的数量,长度为2个字节。填充字可用于内存对其,在将M个第二哈希值以哈希块的方式存储在RPMB分区时,可以将不满足一个哈希块的第二哈希值用0填充字节凑成一个哈希块,长度为196比特。
基于上述内容和相同构思,本申请提供一种文件存储装置800,用于执行上述方法。图8示例性示出了本申请提供的一种文件存储装置的结构示意图,如图8所示,文件存储装置800包括处理器801、存储器802和总线803;其中,处理器801和存储器802可通过总线803相互连接。
处理器801,用于在可信任执行环境TEE下,对第一文件进行加密得到第二文件,并对所述第二文件进行哈希运算得到所述第一哈希值;将所述第一哈希值写入存储器802中的安全分区,以及将所述第二文件写入所述存储器802中的普通分区;所述安全分区用于防止文件被篡改和/或回滚;所述第一哈希值用于在将所述第二文件解密得到所述第一文件时校验所述第二文件是否合法。
处理器801可以是中央处理器801(central processing unit,CPU),网络处理器801(network processor,NP)或者CPU和NP的组合。处理器801还可以进一步包括硬件芯片。上述硬件芯片可以是专用集成电路(application-specific integrated circuit,ASIC),可编程逻辑器件(programmable logic device,PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(comple programmable logic device,CPLD),现场可编程门阵列(field-programmable gate array,FPGA),通用阵列逻辑(generic array logic,GAL)或其任意组合。
存储器802,用于存储软件指令,处理器801调用所存储的程序指令,可以执行上述方案中所示实施例中的一个或多个步骤,或其中可选的实施方式。
存储器802可以包括包括非易失性存储器802(non-volatile memory),例如UFS、EMMC、快闪存储器802(flash memory),硬盘(hard disk drive,HDD)或固态硬盘(solid-state drive,SSD);存储器802还可以包括上述种类的存储器802的组合。
总线803可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图8中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
一种可能的设计中,存储器802也可以和处理器801集成在一起。
一种可选地实施方式中,所述第一文件包括M个数据块,所述第二文件包括M个加密数据块;其中,所述M为大于等于2的整数;所述处理器801具体用于:分别对所述M个数据块进行加密运算,得到所述M个加密数据块;分别对所述M个加密数据块进行哈希运算,得到M个第二哈希值;对所述M个第二哈希值进行哈希运算得到所述第一哈希值,其中,所述M个加密数据块与所述M个第二哈希值一一对应。
一种可能的实施方式中,所述处理器801具体用于:对所述M个第二哈希值进行哈希消息认证码HMAC运算,得到所述第一哈希值。
一种可选地实施方式中,所述处理器801还用于:将所述M个第二哈希值写入所述普通分区;或者,将所述M个第二哈希值写入所述安全分区。
一种可选地实施方式中,所述处理器801具体用于:将所述M个第二哈希值以哈希块为存储单元写入所述普通分区;或者,将所述M个第二哈希值以哈希块为存储单元写入所述安全分区;其中,一个哈希块中包括至少一个所述第二哈希值;所述哈希块的大小根据处理器读写数据粒度和所述第二哈希值的大小确定。
一种可选地实施方式中,所述安全分区包括回放受保护的内存块RPMB分区。
一种可选地实施方式中,所述装置还包括接口;所述接口用于:接收更新请求;所述更新请求包括数据块标识和待更新的数据,所述数据块标识用于指示所述普通分区中待被更新的加密数据块;所述处理器,还用于:根据所述数据块标识,从所述普通分区中获取所述待被更新的加密数据块;获取所述待被更新的加密数据块对应的第二哈希值;若根据所述待被更新的加密数据块对应的第二哈希值确定所述待被更新的加密数据块合法,则根据所述待更新的数据,更新所述待被更新的加密数据块;更新所述待被更新的加密数据块对应的第二哈希值。
一种可选地实施方式中,所述处理器801具体用于:对所述待被更新的加密数据块进行解密,得到待被更新的数据块;用所述待更新的数据更新所述待被更新的数据块,得到更新后的数据块;对所述更新后的数据块进行加密,得到更新后的加密数据块;对所述更新后的加密数据块进行哈希运算,得到第三哈希值;将所述待被更新的加密数据块对应的第二哈希值更新为所述第三哈希值。
基于上述内容和相同构思,本申请提供一种文件存储装置900,用于执行上述方法。图9示例性示出了本申请提供的一种文件存储装置的结构示意图,如图9所示,文件存储装置900包括加密单元901、处理单元902、安全分区903和普通分区904。
加密单元901用于:在可信任执行环境下,对第一文件进行加密得到第二文件,并对所述第二文件进行哈希运算得到第一哈希值;
处理单元902用于:将所述第一哈希值写入存储器中的所述安全分区,以及将所述第二文件写入所述存储器中的普通分区;所述安全分区用于防止文件被篡改和/或防止文件回滚;所述第一哈希值用于在将所述第二文件解密得到所述第一文件时校验所述第二文件是否合法。
应理解,以上文件存储装置的各单元的划分仅仅是一种逻辑功能的划分,实际实现时可以全部或部分集成到一个物理实体上,也可以物理上分开。本申请实施例中,图9涉及到的加密单元901和处理单元902可以由上述图8的处理器801实现。也就是说,本申请实施例中加密单元901和处理单元902可可以执行上述图8的处理器801所执行的方案,其余内容可以参见上述内容,在此不再赘述。
在上述实施例中,可以全部或部分地通过软件、硬件或者其组合来实现、当使用软件程序实现时,可以全部或部分地以计算机程序产品的形式实现。计算机程序产品包括一个或多个指令。在计算机上加载和执行计算机程序指令时,全部或部分地产生按照本申请实施例的流程或功能。计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。指令可以存储在计算机存储介质中,或者从一个计算机存储介质向另一个计算机 存储介质传输,例如,指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、双绞线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。计算机存储介质可以是计算机能够存取的任何介质或者是包含一个或多个介质集成的服务器、数据中心等数据存储设备。介质可以是磁性介质,(例如,软盘、硬盘、磁带、磁光盘(MO)等)、光介质(例如光盘)、或者半导体介质(例如ROM、EPROM、EEPROM、固态硬盘(solid state disk,SSD))等。
本申请实施例是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。

Claims (18)

  1. 一种文件存储方法,其特征在于,包括:
    在可信任执行环境TEE下,对第一文件进行加密得到第二文件,并对所述第二文件进行哈希运算得到第一哈希值;
    将所述第一哈希值写入存储器中的安全分区,以及将所述第二文件写入所述存储器中的普通分区;所述安全分区用于防止文件被篡改和/或回滚;所述第一哈希值用于在将所述第二文件解密得到所述第一文件时校验所述第二文件是否合法。
  2. 如权利要求1所述的方法,其特征在于,所述第一文件包括M个数据块,所述第二文件包括M个加密数据块;其中,所述M为大于等于2的整数;
    所述对第一文件进行加密得到第二文件,包括:
    分别对所述M个数据块进行加密运算,得到所述M个加密数据块;
    所述对所述第二文件进行哈希运算得到所述第一哈希值,包括:
    分别对所述M个加密数据块进行哈希运算,得到M个第二哈希值;
    对所述M个第二哈希值进行哈希运算得到所述第一哈希值,其中,所述M个加密数据块与所述M个第二哈希值一一对应。
  3. 如权利要求2所述的方法,其特征在于,所述对M个第二哈希值进行哈希运算得到所述第一哈希值,包括:
    对所述M个第二哈希值进行哈希消息认证码HMAC运算,得到所述第一哈希值。
  4. 如权利要求2所述的方法,其特征在于,所述方法还包括:
    将所述M个第二哈希值写入所述普通分区;或者,将所述M个第二哈希值写入所述安全分区。
  5. 如权利要求4所述的方法,其特征在于,所述将所述M个第二哈希值写入所述普通分区,包括:
    将所述M个第二哈希值以哈希块为存储单元写入所述普通分区;
    所述将所述M个第二哈希值写入安全分区,包括:
    将所述M个第二哈希值以哈希块为存储单元写入所述安全分区;
    其中,一个哈希块中包括至少一个所述第二哈希值;所述哈希块的大小根据处理器读写数据粒度和所述第二哈希值的大小确定。
  6. 如权利要求1至5任一项所述的方法,其特征在于,所述安全分区包括回放受保护的内存块RPMB分区。
  7. 如权利要求2至5任一项所述的方法,其特征在于,所述方法还包括:
    接收更新请求;所述更新请求包括数据块标识和待更新的数据,所述数据块标识用于指示所述普通分区中待被更新的加密数据块;
    根据所述数据块标识,从所述普通分区中获取所述待被更新的加密数据块;
    获取所述待被更新的加密数据块对应的第二哈希值;
    若根据所述待被更新的加密数据块对应的第二哈希值确定所述待被更新的加密数据块合法,则根据所述待更新的数据,更新所述待被更新的加密数据块;
    更新所述待被更新的加密数据块对应的第二哈希值。
  8. 如权利要求7所述的方法,其特征在于,所述根据所述待更新的数据,更新所述 待被更新的加密数据块,包括:
    对所述待被更新的加密数据块进行解密,得到待被更新的数据块;
    用所述待更新的数据更新所述待被更新的数据块,得到更新后的数据块;
    对所述更新后的数据块进行加密,得到更新后的加密数据块;
    更新所述待被更新的加密数据块对应的第二哈希值,包括:
    对所述更新后的加密数据块进行哈希运算,得到第三哈希值;
    将所述待被更新的加密数据块对应的第二哈希值更新为所述第三哈希值。
  9. 一种文件存储装置,其特征在于,包括:处理器和存储器;
    所述处理器,用于在可信任执行环境TEE下,对第一文件进行加密得到第二文件,并对所述第二文件进行哈希运算得到第一哈希值;
    所述处理器,还用于将所述第一哈希值写入所述存储器中的安全分区,以及将所述第二文件写入所述存储器中的普通分区;所述安全分区用于防止文件被篡改和/或回滚;所述第一哈希值用于在将所述第二文件解密得到所述第一文件时校验所述第二文件是否合法。
  10. 如权利要求9所述的装置,其特征在于,所述第一文件包括M个数据块,所述第二文件包括M个加密数据块;其中,所述M为大于等于2的整数;
    所述处理器,具体用于:
    分别对所述M个数据块进行加密运算,得到所述M个加密数据块;分别对所述M个加密数据块进行哈希运算,得到M个第二哈希值;对所述M个第二哈希值进行哈希运算得到所述第一哈希值,其中,所述M个加密数据块与所述M个第二哈希值一一对应。
  11. 如权利要求10所述的装置,其特征在于,所述处理器,具体用于:
    对所述M个第二哈希值进行哈希消息认证码HMAC运算,得到所述第一哈希值。
  12. 如权利要求10所述的装置,其特征在于,所述处理器,还用于:
    将所述M个第二哈希值写入所述普通分区;或者,将所述M个第二哈希值写入所述安全分区。
  13. 如权利要求12所述的装置,其特征在于,所述处理器,具体用于:
    将所述M个第二哈希值以哈希块为存储单元写入所述普通分区;或者,将所述M个第二哈希值以哈希块为存储单元写入所述安全分区;
    其中,一个哈希块中包括至少一个所述第二哈希值;所述哈希块的大小根据处理器读写数据粒度和所述第二哈希值的大小确定。
  14. 如权利要求9至13任一项所述的装置,其特征在于,所述安全分区包括回放受保护的内存块RPMB分区。
  15. 如权利要求10至14任一项所述的装置,其特征在于,所述装置还包括接口;
    所述接口,用于:
    接收更新请求;所述更新请求包括数据块标识和待更新的数据,所述数据块标识用于指示所述普通分区中待被更新的加密数据块;
    所述处理器,还用于:
    根据所述数据块标识,从所述普通分区中获取所述待被更新的加密数据块;获取所述待被更新的加密数据块对应的第二哈希值;若根据所述待被更新的加密数据块对应的第二哈希值确定所述待被更新的加密数据块合法,则根据所述待更新的数据,更新所述待被更新的加密数据块;更新所述待被更新的加密数据块对应的第二哈希值。
  16. 如权利要求15所述的装置,其特征在于,所述处理器,具体用于:
    对所述待被更新的加密数据块进行解密,得到待被更新的数据块;用所述待更新的数据更新所述待被更新的数据块,得到更新后的数据块;对所述更新后的数据块进行加密,得到更新后的加密数据块;对所述更新后的加密数据块进行哈希运算,得到第三哈希值;将所述待被更新的加密数据块对应的第二哈希值更新为所述第三哈希值。
  17. 一种文件存储装置,其特征在于,包括:加密单元、处理单元、安全分区和普通分区;
    所述加密单元,用于在可信任执行环境下,对第一文件进行加密得到第二文件,并对所述第二文件进行哈希运算得到第一哈希值;
    所述处理单元,用于将所述第一哈希值写入存储器中的所述安全分区,以及将所述第二文件写入所述存储器中的普通分区;所述安全分区用于防止文件被篡改和/或回滚;所述第一哈希值用于在将所述第二文件解密得到所述第一文件时校验所述第二文件是否合法。
  18. 一种计算机存储介质,其特征在于,所述存储介质中存储软件程序,所述软件程序在被一个或多个处理器读取并执行时实现权利要求1至8中任一项所述的文件存储方法。
PCT/CN2018/093929 2018-06-30 2018-06-30 一种文件存储方法、装置及存储介质 WO2020000491A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201880093094.8A CN112088376A (zh) 2018-06-30 2018-06-30 一种文件存储方法、装置及存储介质
PCT/CN2018/093929 WO2020000491A1 (zh) 2018-06-30 2018-06-30 一种文件存储方法、装置及存储介质

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/093929 WO2020000491A1 (zh) 2018-06-30 2018-06-30 一种文件存储方法、装置及存储介质

Publications (1)

Publication Number Publication Date
WO2020000491A1 true WO2020000491A1 (zh) 2020-01-02

Family

ID=68985847

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/093929 WO2020000491A1 (zh) 2018-06-30 2018-06-30 一种文件存储方法、装置及存储介质

Country Status (2)

Country Link
CN (1) CN112088376A (zh)
WO (1) WO2020000491A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112632641B (zh) * 2020-12-31 2024-07-12 深圳市九洲电器有限公司 一种生产软件安全加密传输方法和电子设备
CN114239050A (zh) * 2021-11-12 2022-03-25 希姆通信息技术(上海)有限公司 基于Android系统秘钥文件安全存储的方法及系统
CN116089967B (zh) * 2022-05-12 2024-03-26 荣耀终端有限公司 数据防回滚方法和电子设备
CN115292257B (zh) * 2022-10-09 2023-01-24 广州鲁邦通物联网科技股份有限公司 可检测文件非法删除的方法和系统

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100017446A1 (en) * 2008-07-17 2010-01-21 Samsung Electronics Co., Ltd. File system configuration method and apparatus for data security and for accessing same, and storage device accessed by same
CN103988463A (zh) * 2011-11-17 2014-08-13 索尼公司 信息处理装置、信息存储装置、信息处理系统和信息处理方法以及程序
CN104392188A (zh) * 2014-11-06 2015-03-04 三星电子(中国)研发中心 一种安全数据存储方法和系统

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103530201B (zh) * 2013-07-17 2016-03-02 华中科技大学 一种适用于备份系统的安全数据去重方法和系统
CN107659410A (zh) * 2017-08-30 2018-02-02 湖南众享政联科技有限公司 基于区块链防篡改公文传输和存储方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100017446A1 (en) * 2008-07-17 2010-01-21 Samsung Electronics Co., Ltd. File system configuration method and apparatus for data security and for accessing same, and storage device accessed by same
CN103988463A (zh) * 2011-11-17 2014-08-13 索尼公司 信息处理装置、信息存储装置、信息处理系统和信息处理方法以及程序
CN104392188A (zh) * 2014-11-06 2015-03-04 三星电子(中国)研发中心 一种安全数据存储方法和系统

Also Published As

Publication number Publication date
CN112088376A (zh) 2020-12-15

Similar Documents

Publication Publication Date Title
US11128471B2 (en) Accessibility controls in distributed data systems
WO2021013245A1 (zh) 一种数据密钥保护方法、系统及电子设备和存储介质
US10284372B2 (en) Method and system for secure management of computer applications
US10116645B1 (en) Controlling use of encryption keys
US9954826B2 (en) Scalable and secure key management for cryptographic data processing
US7953977B2 (en) Security and ticketing system control and management
US9037875B1 (en) Key generation techniques
US10904231B2 (en) Encryption using multi-level encryption key derivation
WO2020192406A1 (zh) 数据存储、验证方法及装置
US10911538B2 (en) Management of and persistent storage for nodes in a secure cluster
WO2020000491A1 (zh) 一种文件存储方法、装置及存储介质
US10003467B1 (en) Controlling digital certificate use
TW200832438A (en) Secure co-processing memory controller integrated into an embedded memory subsystem
US20120198235A1 (en) Secure messaging with read-undeniability and deletion-verifiability
WO2022028289A1 (zh) 数据加密方法、数据解密方法、装置、终端和存储介质
KR20120093375A (ko) 인증서 폐기 목록을 이용한 콘텐트 제어 방법
US20200004695A1 (en) Locally-stored remote block data integrity
US9367700B2 (en) System and method for establishing a shared secret for communication between different security domains
WO2023051337A1 (zh) 数据处理方法、装置、设备及存储介质
JP2021090151A (ja) ストレージシステムおよびストレージシステムのデータ保護方法
US11997192B2 (en) Technologies for establishing device locality
CN117157623A (zh) 结合容器化应用程序使用时保护秘密的系统和方法
US11340801B2 (en) Data protection method and electronic device implementing data protection method
US20230208821A1 (en) Method and device for protecting and managing keys
US20240345741A1 (en) System and method for managing data storage to identify undesired data modification

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

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

Country of ref document: EP

Kind code of ref document: A1