Cross-platform implementation method for national secret file encryption system compatible with exFAT

By multiplexing directory items in the exFAT file system to store encryption digests and generating lightweight file fingerprints, combining the national secret SM3 and SM4-CTR modes, the encryption module and cross-platform adaptation layer, the encryption compatibility and cross-platform access problems of the exFAT file system are solved, and secure and efficient encrypted storage and access are achieved.

CN120408670APending Publication Date: 2025-08-01GUANGXI POWER GRID CORP
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510501603.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-21
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

The existing exFAT file system lacks data encryption functions, making it difficult to take into account the compliance of encryption standards, cross-platform convenience and system compatibility. The national cryptographic encryption solution cannot be directly used in exFAT, and lacks a cross-platform unified key management mechanism.

Method used

Design a national security encrypted file system that is compatible with exFAT, multiplex the exFAT directory items through the metadata compatibility module to store encryption digests, dynamically identify encryption identification bits, generate lightweight file fingerprints, and use the national security SM3 hash algorithm and SM4-CTR mode for encryption, combining the cross-platform adaptation layer to realize encryption functions on Windows, Linux and macOS.

Benefits of technology

It realizes secure and efficient encrypted storage and access under multiple operating systems, meets national secrets standards, improves data confidentiality and integrity, and ensures the native compatibility and cross-platform convenience of the exFAT file system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120408670A_ABST
    Figure CN120408670A_ABST
Patent Text Reader

Abstract

The invention discloses a cross-platform implementation method for a national secret encryption file system compatible with exFAT, and belongs to the field of file system encryption and cross-platform application. In order to solve the encryption problem of an exFAT file system, a system architecture comprising metadata compatibility, national secret encryption and a cross-platform adaptation layer is constructed. The metadata compatible module reuses an exFAT directory entry reserved field, dynamically identifies an encryption identification bit and generates a file fingerprint; the national cryptographic encryption module performs key management and data encryption based on a national cryptographic algorithm, resists a replay attack and adopts a key destruction mechanism; and the cross-platform adaptation layer realizes encryption function integration in different operating systems (Windows, Linux and macOS). Cross-platform encrypted storage and access of the exFAT file system are realized through key algorithm processes such as generation of a temporary session key, calculation of metadata fingerprints, encryption and decryption of data streams and the like. According to the method, the encryption compliance, the cross-platform convenience, the system compatibility and the data security are improved, and the method is stably operated under multiple operating systems and different exFAT versions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of file system encryption and cross-platform applications, and particularly to a method for the exFAT file system that integrates national cryptographic algorithms and enables cross-platform encrypted access on multiple operating systems (Windows / Linux / macOS). Background Art

[0002] With the increasing importance of data security, the demand for file system encryption is growing. The exFAT file system is widely used due to its advantages in supporting large files and cross-platform compatibility, but it lacks native data encryption functionality. Most existing third-party encryption solutions are based on the AES algorithm, and there are problems such as incompatibility with national cryptographic standards, cross-platform access relying on specific drivers, and damage to exFAT compatibility. At the same time, national cryptographic encryption solutions are mostly adapted to file systems such as NTFS / EXT4 and cannot be directly used for exFAT, and lack a cross-platform unified key management mechanism. This makes it difficult to balance encryption standard compliance, cross-platform convenience, and system compatibility when ensuring the data security of the exFAT file system.

[0003] Terms and Abbreviation Full Names

[0004] ● xFAT: Extended File Allocation Table, Extended File Allocation Table;

[0005] ● AES: Advanced Encryption Standard, Advanced Encryption Standard;

[0006] ● SM3: National Cryptographic Hash Algorithm No. 3;

[0007] ● SM4: National Cryptographic Symmetric Encryption Algorithm No. 4;

[0008] ● HSM: Hardware Security Module, Hardware Security Module;

[0009] ● MAC: Message Authentication Code, Message Authentication Code;

[0010] ● FUSE: Filesystem in Userspace, User Space File System;

[0011] ● Minifilter: Lightweight File System Filter Driver for Windows Systems;

[0012] ● KEXT: Kernel Extension, Kernel Extension;

[0013] ● DriverKit: Driver Development Framework provided by Apple Inc. Summary of the Invention

[0014] The object of the present invention is to provide a cross - platform implementation method for a national cryptographic encryption file system compatible with exFAT, to solve the problems existing in the existing exFAT encryption scheme, such as incompatibility with the national cryptographic standard, inconvenient cross - platform access, and damage to the file system compatibility, and to realize the secure and efficient encrypted storage and access of the exFAT file system based on the national cryptographic algorithm under multiple operating systems.

[0015] Technical Solution

[0016] The cross - platform implementation method for a national cryptographic encryption file system compatible with exFAT proposed by the present invention mainly includes two major parts: system architecture design and key algorithm process, and realizes the function of the encrypted file system through the collaborative work of each module:

[0017] 1. System Architecture

[0018] 1.1 Metadata Compatibility Module

[0019] The metadata compatibility module is in a key hub position in the entire encrypted file system architecture, playing an indispensable role in connection and adaptation.

[0020] During the operation of the file system, when the upper - layer application program initiates a file system call, this module will quickly intercept these call requests. It has a powerful parsing ability and can accurately analyze the standard exFAT structure. This process is like accurately interpreting a complex technical document, ensuring that all key information of the exFAT file system can be understood correctly.

[0021] Based on the analysis of the exFAT structure, the module cleverly re - uses the 128 - bit field reserved in the exFAT directory entry to store the encryption digest. This design is very innovative. It is like reasonably using the originally idle space in a built building to store important materials. On the one hand, it makes full use of the existing resources of exFAT, avoiding large - scale changes to the file system structure, thereby reducing the complexity and risk of system implementation; on the other hand, it successfully integrates the encryption - related information into it, enabling the encryption function to be organically integrated with the exFAT file system, providing key data support for the smooth development of subsequent encryption operations.

[0022] To achieve effective management and identification of encrypted data, this module has the ability to dynamically identify the encrypted identification bit (0xAA55 flag). When the file system processes data, the module will monitor the file cluster linked list in real time. Once the encrypted identification bit is found, it can quickly respond. By adding the encrypted identification bit to the file cluster linked list, on the premise of ensuring the normal operation of the original positioning logic of the exFAT file cluster linked list, it provides a clear and definite basis for the identification and processing of encrypted data. This is like attaching a unique label to a specific target location on a complex map, facilitating people to quickly find and process relevant information, and ensuring the orderly flow and operation of encrypted data throughout the file system.

[0023] In generating lightweight file fingerprints, the module adopts the national cryptographic SM3 hash algorithm. The specific calculation formula is:

[0024] FP = SM3(FileName||FileSize||CreateTime||Nonce) mod 2 64

[0025] In this formula, "FileName" represents the name of the file, "FileSize" represents the size of the file, (CreateTime) represents the file creation timestamp, and after the random number (Nonce). The "||" symbol represents the string concatenation operation. By concatenating the file name and file size and then performing the SM3 hash operation, and taking the modulus 2 of the result 64 , a 64-bit lightweight file fingerprint FP is generated. After introducing the file creation timestamp (CreateTime) and the random number (Nonce), the file fingerprint has high uniqueness and stability. Just like everyone's fingerprint, it can accurately identify the characteristics of the file. It is widely used in subsequent encryption operations and data verification links. During the encryption process, the file fingerprint participates in the encryption operation as important metadata, enhancing the security of encryption; during the data verification stage, by comparing the stored file fingerprint and the recalculated file fingerprint, it can quickly determine whether the file data has been tampered with, ensuring the integrity and security of the file data.

[0026] In summary, through a series of operations such as reusing the reserved fields of the exFAT directory entry to store the encryption digest, dynamically identifying the encrypted identification bit, and generating lightweight file fingerprints, the metadata compatibility module has successfully implemented the metadata compatibility technology. While retaining the native compatibility of the exFAT file system, this technology builds a solid foundation for the implementation of the encryption function, enabling the entire encrypted file system to operate efficiently and securely without affecting the original functions of exFAT.

[0027] 1.2 National Cryptographic Encryption Module

[0028] The national cryptography encryption module, as the core hub of the entire encryption system, undertakes the key tasks of data encryption and decryption. Its performance and security directly determine the reliability of the entire encrypted file system.

[0029] In the operating mechanism of the encryption system, the generation and management of keys are the cornerstone of ensuring encryption security. The master key (K master ) is stored in the Hardware Security Module (HSM). HSM is a hardware device specifically used to protect and manage keys, with high security. Through various security mechanisms such as hardware encryption and access control, it effectively prevents the master key from being stolen or tampered with. When the system starts, the national cryptography encryption module securely reads the master key from the HSM and performs corresponding initialization operations. For example, only authorized users or processes can read the master key from the HSM, and the data will be encrypted during the reading process to prevent it from being stolen during transmission.

[0030] The national cryptography encryption module uses a unique key derivation function to generate dynamic keys for data encryption. The formula is:

[0031] K df =SM3(K master ||Nonce||Counter)

[0032] This function is based on the national cryptography SM3 hash algorithm. After the master key K master , the random number Nonce, and the counter Counter are concatenated in order, and then a hash operation is performed through the SM3 algorithm to finally generate the dynamic key K df . The random number Nonce is randomly generated during each encryption operation, and the counter Counter increases or changes according to specific rules, making the dynamic keys generated each time different, greatly increasing the complexity and security of encryption.

[0033] In the actual data encryption process, the national cryptography encryption module uses the SM4-CTR (Counter Mode) mode to implement block encryption. The encryption formula is:

[0034] C i =SM4(K df ,Nonce+i)⊕P i

[0035] Among them, P i represents the plaintext data block, and C i is the ciphertext data block generated after encryption. The SM4 algorithm has the characteristics of high efficiency and security. In the CTR mode, the dynamic key K df and the offset Nonce+i are used as the input of the SM4 algorithm to encrypt the plaintext data block P iPerform the encryption operation. In the offset Nonce + i, i increases sequentially with the encryption of each data block, ensuring that each data block can be encrypted independently and effectively, with good parallel processing capabilities, improving the encryption efficiency while ensuring the encryption quality and security.

[0036] In the SM4-CTR mode, the dynamic management mechanism of Nonce and Counter is crucial for the security of encryption. Nonce is generated by a random number generator with high encryption strength. This random number generator adopts the random number generation algorithm of the national cryptographic standard to ensure that the generated Nonce has sufficient randomness and unpredictability. Each time an encryption operation is performed, a new Nonce is generated to ensure the independence and security of each encryption process. Counter increases according to a specific increment rule. For example, after encrypting each data block, the value of Counter increases by 1. In this way, when encrypting different data blocks, even if the same key is used, due to the differences in Nonce and Counter, the generated key streams will be different, improving the security of encryption.

[0037] To resist replay attacks, a timestamp and a Message Authentication Code (MAC) are introduced into the encrypted data. When sending encrypted data, in addition to sending the ciphertext, a timestamp and a MAC generated based on the ciphertext and the key are also attached. After receiving the data, the receiving party first verifies whether the timestamp is within a reasonable time range. If the timestamp has expired, it is considered that the data may be a replay and the processing is refused. Then, the receiving party recalculates the MAC based on the received ciphertext and the key and compares it with the received MAC. If the two are inconsistent, it means that the data may have been tampered with during transmission, and the processing is also refused. In this way, replay attacks are effectively resisted, ensuring the security and integrity of the data.

[0038] In addition, the national cryptographic encryption module is also applied in a hierarchical encryption architecture. The file encryption formula is:

[0039] F = E SM4 (K df , F plain ) ⊕ HMAC-SM3(Metadata)

[0040] The original plaintext file content F plain , after the operation of E SM4 (K df , F plain ), that is, using the SM4 encryption algorithm based on the dynamic key K df to encrypt the plaintext file. Here, K dfIt is dynamically generated through the SM2 key agreement protocol, which ensures the security and reliability of the key exchange process. Metadata contains extended attributes such as file fingerprints and timestamps. The Metadata is processed through the HMAC-SM3 algorithm to generate a hash value based on the metadata, and then a block-level exclusive-or encryption operation is performed with the file content encrypted by SM4 to ensure compatibility with the exFAT metadata area during the encryption process.

[0041] The temporary session key (K sess ) adopts a timeout automatic destruction mechanism. When generating the temporary session key, a validity period is set at the same time. When the file write or read operation is completed, the system starts a timer. If the temporary session key is not used for related operations again within the validity period, after the timer times out, the system will automatically destroy the temporary session key. For example, assume that the validity period of the temporary session key is set to 5 minutes. After the file write operation is completed, if no file read or other encryption operations related to this key are performed within 5 minutes, the system will automatically release the memory space occupied by the key and delete it from the temporary key buffer to prevent the security risks brought by long-term storage of the key.

[0042] In summary, the national cryptography encryption module realizes the all-round encryption protection of data through a carefully designed key derivation function, an efficient and secure encryption mode, and an organic combination with the hierarchical encryption architecture. At the same time, it ensures compatibility with the exFAT file system, providing strong security support for the entire encrypted file system.

[0043] 1.3 Cross-platform Adaptation Layer

[0044] To achieve the seamless application of the encrypted file system in a multi-operating system environment, this system specifically constructs a cross-platform adaptation layer. This key component is like a bridge that spans the differences between different operating systems, enabling the functions of the encrypted file system to run stably and efficiently on mainstream operating systems such as Windows, Linux, and macOS.

[0045] In the Windows operating system ecosystem, the cross-platform adaptation layer integrates the encryption function by leveraging the Hook file system filter driver (Minifilter). The file system filter driver mechanism provided by the Windows system offers developers a flexible way to monitor and modify file system operations. As a lightweight file system filter driver, the Minifilter driver can hook into the critical path of file system operations. When an upper-layer application initiates a file system operation request, such as file reading, writing, or deletion, the Minifilter driver quickly intercepts these requests. After intercepting the requests, the cross-platform adaptation layer encrypts these requests according to the encryption rules. For example, for a file write request, the data to be written is first encrypted and transformed, converting the plaintext data into ciphertext data; for a file read request, the decryption operation is performed after the data is read from the underlying file system. Only after the encrypted requests are processed will they be passed to the underlying file system for subsequent processing. In this way, not only is the encrypted storage of files achieved, ensuring that data exists in an encrypted form on the storage medium and enhancing data security, but for upper-layer applications and users, the entire encryption and decryption process is transparent. They do not need to be aware of the existence of the encryption operation and can still operate on encrypted files just like ordinary files, greatly improving the user experience.

[0046] The Linux system is widely used in fields such as servers and embedded devices due to its open-source and flexible characteristics. In the Linux environment, the cross-platform adaptation layer implements user-space encryption by leveraging the FUSE (Filesystem in Userspace) module. FUSE is a special mechanism that allows developers to create a file system in user space, which provides great convenience for the implementation of the encryption function. Compared with implementing encryption in the kernel space, implementing the encryption logic in user space has many advantages. First, it avoids deep modification of the Linux kernel. The kernel is the core part of the operating system, and modifying it often requires a high technical threshold and may introduce stability issues. Implementing encryption in user space does not affect the stability of the kernel. Even if there is a problem with the encryption module, it will not cause the entire system to crash. Second, it improves the maintainability of the system. It is more convenient to develop and debug encryption code in user space. Developers can use standard user-space development tools and debugging techniques to quickly locate and solve problems.

[0047] In practical applications, the FUSE module mounts the exFAT file system to the user space. When there are file operation requests, the FUSE module forwards these requests to the encryption program in the user space. The encryption program encrypts or decrypts the data according to the national cryptographic algorithm, and then returns the processed result to the FUSE module, which completes the subsequent file system operations. In this way, the encryption support for the exFAT file system is realized, enabling users to securely store and access encrypted exFAT files in the Linux system.

[0048] The macOS system has a unique system architecture and security mechanism. On the macOS platform, the cross-platform adaptation layer actively introduces new technology frameworks while being compatible with existing implementation methods. On the one hand, it continues to implement the encryption function by implementing the kernel extension (KEXT) to be compatible with the APFS container; on the other hand, it evaluates and adapts to Apple's latest DriverKit framework.

[0049] The DriverKit framework provides a more secure and easier-to-manage way for developers to develop drivers. This solution fully considers the advantages of the DriverKit framework. In the newly developed functional modules, some functions are implemented using the DriverKit framework. For example, when processing the encryption and decryption logic of file reading and writing operations, the security features of the DriverKit framework are utilized to ensure the security of data during transmission. However, considering the need for deep integration of some functions with the kernel, the KEXT method is still retained to ensure compatibility with older versions of the macOS system.

[0050] Regarding the compatibility issues of KEXT in different versions of macOS, a version detection and dynamic loading strategy has been formulated. When the system starts up, it will first detect the version number of the current macOS system. For newer versions (such as macOS Catalina and later versions), it will first attempt to load the driver module developed based on the DriverKit framework; if the loading fails (for example, some specific functions are not fully supported by the DriverKit framework), it will automatically switch to the KEXT method to load the encryption function module. For older versions of the macOS system (such as macOS Mojave and earlier versions), since their support for the DriverKit framework is limited or even non-existent, the KEXT method is directly used for loading. In addition, to ensure the stable operation of KEXT on different versions of the macOS system and maintain compatibility with system security updates and feature upgrades, KEXT will be updated and maintained regularly. Through these measures, the cross-platform application of the encrypted file system can be achieved on the macOS platform, meeting the needs of Apple users for secure data storage and access, while ensuring the stability and security of the system, and providing reliable encrypted file system services for users.

[0051] 2 Key algorithm processes

[0052] 2.1 File writing process

[0053] (1) Generate a temporary session key: In the entire file writing process, generating a temporary session key is the primary and crucial step in the encryption operation. When the system receives a file writing instruction, it starts the temporary session key generation mechanism based on the national cryptographic SM2 key negotiation protocol. The specific formula is:

[0054] K sess = SM2_KeyExchange(DeviceCert,HostKey)

[0055] As an important part of the national cryptographic system, the SM2 key negotiation protocol plays a core role in ensuring communication security. Among them, the device certificate DeviceCert is a digital certificate stored on the device side, which contains key data such as the device's identity information and public key. It is like the device's "digital ID card" and is used to prove the legal identity of the device. The host key HostKey is the key secret information of the host in the encrypted communication and is an important basis for the host to participate in the key negotiation.

[0056] During the key exchange process, the device and the host exchange information based on their respective certificates and keys, following the complex mathematical operations and interaction processes specified by the SM2 key agreement protocol. This process involves complex calculations in elliptic curve cryptography, through which both parties can securely exchange key information in an insecure network environment. For example, the device uses its private key to sign a message containing the device identity and other relevant information, and then sends the signed message and the device certificate to the host. After receiving the message, the host first verifies the legality of the device certificate, and then uses the public key in the device certificate to verify the signature to ensure the authenticity and integrity of the message. Next, the host calculates a shared secret value according to its own key and the received device information according to the protocol rules. The device also obtains the same shared secret value through similar calculations. Finally, based on this shared secret value, through specific algorithm conversions, a temporary session key K is generated. sess 。

[0057] The generated temporary session key K sess has the characteristics of being one-time and time-limited. Being one-time ensures that each file writing operation uses a unique key for encryption. Even if a certain key is leaked, it will not affect the encryption security of other files; being time-limited guarantees that after a period of time, the key will become invalid, further enhancing the security of encrypted communication. This temporary session key K_{sess} will be used for subsequent encryption operations, providing a solid security guarantee for data encryption during the entire file writing process. Just like building a solid defense line for file encrypted communication, it effectively resists various potential security threats, such as man-in-the-middle attacks, eavesdropping, etc., ensuring the confidentiality and integrity of file data during transmission and storage.

[0058] (2) Calculate the metadata fingerprint: After the generation of the temporary session key is completed, the important link of calculating the metadata fingerprint immediately follows. The formula for calculating the metadata fingerprint is FP = SM3(FileName || CreateTime). The SM3 hash algorithm used here is an important tool in the national cryptography system for ensuring data integrity and security.

[0059] The file name FileName, as the identifier of the file in the file system, has uniqueness and certainty. It carries the user's intuitive understanding and positioning information of the file content. The file creation time CreateTime records the exact time point when the file was first created in the system and is the key timestamp information in the file metadata. Concatenating these two through the "||" operation forms a string combination containing the basic characteristics of the file and the creation time information.

[0060] The SM3 hashing algorithm, with its unique operation rules, performs complex mathematical transformations and calculations on the concatenated string. Through multiple rounds of non-linear operations, shift operations, and XOR operations with constants, etc., the algorithm maps the input string to a hash value of a fixed length, namely the file fingerprint FP. This file fingerprint is like the "digital fingerprint" of the file, with a high degree of uniqueness and stability. Even if there are extremely minor changes in the file name or creation time, the file fingerprint generated after calculation by the SM3 algorithm will be completely different.

[0061] The generated file fingerprint FP plays a crucial role throughout the encryption process. It is not only used to identify the metadata information of the file, encoding the basic attributes of the file in a compact and distinguishable way, but also plays a key role in the subsequent encryption digest generation and file integrity verification. During the encryption digest generation, the file fingerprint participates in the operation as the core identifier of the metadata, and together with other encryption-related information, constitutes the encryption digest, enhancing the security and reliability of the encryption. During file integrity verification, by recalculating the metadata fingerprint of the file and comparing it with the stored file fingerprint, it is possible to quickly and accurately determine whether the file has been tampered with during storage or transmission, ensuring the integrity of the file data.

[0062] (3) Encrypt the data stream: After completing the calculation of the metadata fingerprint, it enters the core step of encrypting the data stream. During this process, the SM4-CTR mode is used to encrypt the data stream, and the encryption formula is:

[0063] C i = SM4-CTR(K sess , i) ⊕ P i

[0064] As a national cryptographic symmetric encryption algorithm, the SM4 algorithm has the characteristics of high efficiency and security and is widely used in the field of data encryption. The CTR (Counter mode) gives unique advantages to the encryption process of the SM4 algorithm. The temporary session key K sess As the key secret information for encryption, it is the core element of the encryption operation. It is securely generated through the SM2 key agreement protocol in the previous step, providing a reliable key guarantee for the encryption operation.

[0065] The offset i is an important parameter in the CTR mode, and it increases sequentially with the order of the encrypted data blocks. During the encryption process, for each plaintext data block P i , the encryption system will use the temporary session key K sess and the current offset i to generate a key stream through the SM4 algorithm. This key stream is XORed with the plaintext data block P i to generate the corresponding ciphertext data block C i .

[0066] For example, when encrypting the first data block, the offset i = 0, and the first key stream is generated by using K sess and the offset 0 through the SM4 algorithm. This key stream is XORed with the first plaintext data block P0 to obtain the first ciphertext data block C0. As the data blocks are encrypted in sequence, the offset i increases continuously, and each data block is encrypted with a different key stream, ensuring the independence and security of each ciphertext data block.

[0067] This encryption method realizes the encrypted storage of file data, converting the plaintext data into ciphertext form and storing it on the storage medium. In the subsequent data reading process, only by possessing the correct temporary session key K sess and performing the decryption operation according to the same CTR mode can the original plaintext data be restored, effectively guaranteeing the confidentiality of file data during storage and transmission and preventing the data from being illegally obtained and tampered with.

[0068] (4) Update the directory entry: After the file data is encrypted, in order to facilitate subsequent file access and encryption verification, the directory entry needs to be updated. The operation of updating the directory entry is to store the calculated file fingerprint FP and the hash value SM3(C0) of the ciphertext data block C0 into the reserved field of the directory entry, that is, DirEntry.Reserved = FP||SM3(C0).

[0069] The directory entry in the file system is like the "index card" of the file, recording various key information of the file, such as file name, file size, file storage location, etc., facilitating the system to quickly locate and access the file. The reserved field is a part of the storage space reserved in advance by the file system for storing some additional information for specific purposes.

[0070] Storing the file fingerprint FP in the reserved field of the directory entry enables the system to quickly obtain the metadata fingerprint information of the file for file integrity verification during subsequent file access. The hash value SM3(C0) of the ciphertext data block C0 provides an important basis for encryption verification. By comparing the stored SM3(C0) with the hash value calculated from the re-read ciphertext data block C0, it can be verified whether the ciphertext data block has been tampered with during storage.

[0071] In this way, the encryption-related information is closely associated with the file directory entry. When a user or system needs to access a file, the encryption-related information, such as the file fingerprint and the ciphertext data block hash value, can be obtained from the directory entry first. Then, during file decryption and integrity verification, these information are used for corresponding calculation and comparison operations to ensure the security and integrity of the file. This process is like making a special index card for each book in a library. The card records the key features and encryption verification information of the book, which is convenient for readers to conduct identity verification and content integrity check when borrowing books, effectively improving the management and access efficiency of the file system for encrypted files.

[0072] 3. Innovation

[0073] The present invention focuses on the cross-platform implementation method of the national cryptographic encryption file system compatible with exFAT, showing innovation in many aspects. By unique design, it solves the existing technical problems and improves the performance and security of the file system.

[0074] (1) Innovative design of the metadata compatibility module: Reusing the reserved fields of the exFAT directory entry, this module reuses the 128-bit reserved field in the exFAT directory entry to store the encryption digest, avoiding large-scale modification of the file system structure, reducing the complexity and risk of system implementation, and realizing the organic integration of the encryption function and exFAT. Dynamically identifying the encryption identification bit, adding the 0xAA55 encryption identification bit to the file cluster linked list, which does not affect the exFAT file cluster linked list positioning logic, providing a clear basis for the identification and processing of encrypted data, and ensuring the orderly flow of encrypted data. Using the national cryptographic SM3 algorithm to generate a lightweight file fingerprint, the formula is FP = SM3(FileName||FileSize||CreateTime||Nonce) mod 2 [[ID=,10]] 64 , and the file fingerprint participates in the encryption operation and data verification, enhancing the encryption security and ensuring the integrity of the file data.

[0075] (2) Innovative mechanism of the national cryptographic encryption module: A unique key derivation function, constructing the key derivation function K based on the national cryptographic SM3 hash algorithm df = SM3(K master ||Nonce||Counter), generating a dynamic key by combining the master key, random number and counter, increasing the encryption complexity and security. Using the SM4-CTR encryption mode, implementing block encryption in the SM4-CTR mode, the formula is C i = SM4(K df , Nonce + i) ⊕ P i, in this mode, Nonce and Counter are dynamically managed, each data block is encrypted independently, and it has parallel processing capabilities, improving encryption efficiency and quality. Measures to resist replay attacks are taken. Timestamps and Message Authentication Codes (MACs) are introduced into the encrypted data. The receiver verifies the timestamps and MACs to prevent data replay and tampering, ensuring the security and integrity of the data. The hierarchical encryption architecture and key destruction mechanism are applied to the hierarchical encryption architecture. The file encryption formula is F = E SM4 (K df , F plain ) ⊕ HMAC-SM3(Metadata), ensuring compatibility with the exFAT metadata area; the temporary session key adopts an automatic timeout destruction mechanism to reduce the security risk of key storage.

[0076] (3) Innovative implementation of the cross-platform adaptation layer: The Windows system uses Minifilter to achieve transparent encryption. In the Windows system, the cross-platform adaptation layer intercepts file system operation requests through the Hook file system filter Minifilter and performs encryption processing, which is transparent to upper-layer applications and users, improving the user experience. The Linux system uses FUSE to achieve user-space encryption. Under the Linux system, the FUSE module is used to create a file system in user space to achieve encryption, avoiding modifying the kernel and improving system maintainability, which is convenient for developers to debug. The macOS system is compatible and adapted in multiple ways. On the macOS platform, it not only achieves encryption by kernel extension KEXT compatible with the APFS container, but also evaluates and adapts to the DriverKit framework, dynamically loading driver modules according to the system version to ensure compatibility with new and old versions of the system, providing users with stable and reliable encryption services.

[0077] Beneficial effects

[0078] The present invention has the following beneficial effects:

[0079] 1. Encryption standard compliance: The national cryptographic algorithm is adopted, which is compatible with the national cryptographic standard, meeting the requirements of domestic data encryption security standards, and improving the compliance and security of data encryption.

[0080] 2. Cross-platform convenience: The function of the encrypted file system can be realized on mainstream operating systems such as Windows, Linux, and macOS. Users can safely store and access encrypted exFAT files under different systems without additional complex operations, improving the cross-platform usage experience.

[0081] 3. System compatibility: Through the design of the metadata compatibility module, the existing resources of exFAT are reused, avoiding large-scale changes to the file system structure, ensuring the native compatibility of the exFAT file system, and reducing conflicts with other system functions.

[0082] 4. Improved data security: Multi-layered encryption mechanisms, such as dynamic key generation, layered encryption architecture, and measures to resist replay attacks, effectively protect the confidentiality, integrity, and availability of file data during storage and transmission, reducing the risk of data theft and tampering. BRIEF DESCRIPTION OF THE DRAWINGS

[0083] Attachment Figure 1 This paper demonstrates the key architectural components of a cross-platform implementation of a national secret encryption file system compatible with exFAT. From top to bottom, they are:

[0084] Application layer: Located at the top layer, it is the interface for users to interact with the encrypted file system. Users initiate file operation requests through various applications, such as file read, write, and delete instructions. These requests will be passed to the lower cross-platform adaptation layer for processing.

[0085] Cross-platform adaptation layer: As the connection between different operating systems and the encrypted file system, different operating systems have different implementation methods. Among them, the Windows system uses Minifilter, which can hook on the key path of file system operations, intercept the application's file system operation requests, encrypt the requests according to encryption rules, and then pass them to the underlying file system. The Linux system uses the FUSE module to mount the exFAT file system into user space and forward file operation requests to the user-mode encryption program to implement user-mode encryption. The macOS system uses the KEXT and DriverKit frameworks. For newer versions, it first attempts to load the driver module developed based on the DriverKit framework. If the loading fails, it switches to the KEXT method to ensure compatibility with different versions of the system and ensure the stable operation of the encryption function.

[0086] Metadata compatibility module: This module plays a core role in connecting and adapting the entire encrypted file system architecture. It intercepts file system call requests passed down from the upper layer and parses the standard exFAT structure. It reuses the 128-bit field reserved in exFAT directory entries to store encryption digests, dynamically identifies the encryption flag (0xAA55), and uses the national encryption SM3 hash algorithm to generate lightweight file fingerprints. This provides important data support for the implementation of encryption functions while ensuring native compatibility with the exFAT file system.

[0087] The exFAT file system, located at the bottom layer, serves as the foundational file system for data storage. After processing through the aforementioned layers, encrypted or decrypted data is ultimately stored and managed within the exFAT file system. By optimizing and adapting the exFAT file system through the metadata compatibility module, encryption functionality is seamlessly integrated with the exFAT file system, enabling secure and efficient data storage and access. Detailed implementation manners

[0088] The present invention will be further described below in conjunction with specific implementation manners:

[0089] Embodiment 1

[0090] 1 Implementation environment setup

[0091] This embodiment is set up in a simulated cross-platform storage scenario, including a computer installed with the Windows 10 operating system, a server running Ubuntu 20.04, and an Apple computer equipped with macOS Monterey. At the same time, a mobile solid-state drive in exFAT format is equipped as a storage device. Each device is connected through a USB 3.0 interface to ensure the efficiency of data transmission.

[0092] 2 Key module initialization

[0093] (1) Metadata compatibility module: Deploy the metadata compatibility module in each system. In the Windows system, integrate the module into the file system filter driver monitoring process through programming; in the Linux system, integrate it into the file operation preprocessing logic of the FUSE module; in the macOS system, embed it into the preprocessing link of the kernel extension for exFAT file system operations in the APFS container. During initialization, the module reads the directory structure of the exFAT file system, identifies and records the directory entry information of all files, including the initial state of the reserved fields. For different versions of exFAT (including FAT32 extensions), the module has been optimized. When processing the storage of long file names in FAT32 extensions, it can correctly parse and process them to ensure that the encryption function is not affected.

[0094] (2) SM4 encryption module: Generate and configure the master key (K master ) for each system and store it in the system security key library. When the system starts, the SM4 encryption module loads the master key from the key library, initializes the random number generator to generate the Nonce value, and initializes the counter (Counter) to 0. Among different systems, ensure the consistency and security of the master key through a secure key distribution mechanism.

[0095] (3) Cross-platform adaptation layer: In the Windows system, hook the file system filter driver (Minifilter) so that it can capture file system operation requests in real time and forward these requests to the national cryptography encryption module for processing; in the Linux system, start the FUSE module and mount the exFAT file system, and configure its interaction interface with the national cryptography encryption module; in the macOS system, load the developed kernel extension (KEXT) and ensure its compatibility with the APFS container and the exFAT file system to intercept and process file operation requests.

[0096] 3 File writing process operation

[0097] (1) Generate a temporary session key: Take the example of writing a file named "example.txt" to a mobile solid-state drive in the Windows system. When the system receives a write instruction, call the formula K sess = SM2_KeyExchange(DeviceCert,HostKey). Assume that the device certificate (DeviceCert) is stored in the security chip of the mobile solid-state drive, and the host key (HostKey) is stored in the key management service of the Windows system. The system obtains DeviceCert from the mobile solid-state drive through a secure channel, obtains HostKey from the local key management service, performs complex elliptic curve cryptographic operations according to the SM2 key negotiation protocol, and finally generates a temporary session key (K sess ), which is stored in the system's temporary key buffer for subsequent encryption operations.

[0098] (2) Calculate the metadata fingerprint: Obtain the file name (FileName) of "example.txt" and the current system time as the file creation time (CreateTime), and calculate according to the formula FP = SM3(FileName||CreateTime) using the SM3 hashing algorithm. For example, if FileName is "example.txt" and CreateTime is "2025-02-01 10:00:00", concatenate these two strings and input them into the SM3 algorithm to obtain a 256-bit hash value, and generate a 64-bit file fingerprint (FP) after modulo operation, which is temporarily stored in memory.

[0099] (3) Encrypt the data stream: Divide the content of "example.txt" into blocks according to the exFAT cluster size (assumed to be 128KB) to obtain plaintext data blocks (P i ). Encrypt the data stream using the SM4-CTR mode. According to the formula C i = SM4-CTR(K sess,i) ⊕P i , encrypt each plaintext data block using the temporary session key (K sess ) and the offset (i). Starting from i = 0, encrypt each data block in sequence to generate the corresponding ciphertext data block (C i ), and store the ciphertext data blocks in sequence at the specified location on the removable solid-state drive. This removable solid-state drive is a large-capacity storage device in this test (assumed to be a 2TB SSD), and during the writing process, the solution performs stably without data loss or damage.

[0100] (4) Update the directory entry: Calculate the hash value of the ciphertext data block C0, i.e., SM3(C0). Store the previously calculated file fingerprint (FP) and SM3(C0) in the reserved field of the directory entry of "example.txt" in the exFAT file system according to the rule DirEntry.Reserved = FP || SM3(C0). In this way, the encryption-related information is closely associated with the file directory entry, facilitating subsequent file access and encryption verification.

[0101] 4 File reading process operations

[0102] (1) Obtain encryption-related information: When reading "example.txt" in the Ubuntu system, the metadata compatibility module intercepts the file reading request, obtains the content of the reserved field from the directory entry of the exFAT file system, and parses out the file fingerprint (FP) and the hash value of the ciphertext data block C0 (SM3(C0).

[0103] (2) Verify file integrity: According to the file name of the currently read "example.txt" and the file creation time obtained by the system, recalculate the file fingerprint (FP new ), and compare it with the FP obtained from the directory entry. At the same time, read the ciphertext data block C0, calculate its hash value (SM3(C 0new )) and compare it with SM3(C0) in the directory entry. If FP new is consistent with FP, and SM3(C 0new ) is consistent with SM3(C0), it indicates that the file has not been tampered with during storage and the file integrity is verified.

[0104] (3) Decrypt the data stream: If the file integrity verification passes, the system calls the national cryptography encryption module to regenerate the temporary session key (K sess ) according to the key-related information previously stored in the secure area of the removable solid-state drive (used to regenerate the temporary session key). According to the decryption rule of the SM4-CTR mode, use K sessand the offset (i) decrypt the ciphertext data block (C i ) stored on the mobile solid-state drive to obtain the plaintext data block (P i ). Concatenate all the decrypted plaintext data blocks to restore the original content of "example.txt" and present it to the user. During the reading process, no compatibility issues occurred for different versions of exFAT and large-capacity storage devices (such as the 2TB SSD in this embodiment), and the file reading and decryption operations could be successfully completed.

[0105] After compatibility tests on the standard versions of exFAT (including FAT32 extensions), this solution can run stably in exFAT versions 1.0 and above. A large number of file read / write, encryption, and decryption tests were conducted on different versions of the exFAT file system, and no compatibility issues were found. At the same time, large-capacity storage devices (such as TB-level SSDs) were tested. Multiple different brands and models were used, and SSDs with different capacities from 1TB to 8TB were tested. During long-term file storage, encryption, and decryption operations, the solution performed stably, could perform encryption and decryption operations normally, and there was no data loss or damage, and no compatibility issues related to the scale of the storage device were found.

[0106] The embodiments of the present invention are not limited to the above description. The device configuration, file system version, encryption algorithm parameters, etc. can be adjusted according to the actual application scenario, and such improvements all fall within the protection scope of the present invention.

Claims

1. A cross-platform implementation method of a national secret encryption file system compatible with exFAT, characterized in that It includes the following steps: 1.1 System architecture construction: A metadata compatibility module is established to intercept the file system call requests of upper-layer application programs, parse the standard exFAT structure, reuse the reserved 128-bit field in the exFAT directory entry to store the encryption digest, dynamically identify the encryption identification bit (0xAA55 flag), and generate a lightweight file fingerprint using the national cryptographic SM3 hashing algorithm. The formula is FP = SM3(FileName||FileSize||CreateTime||Nonce) mod 2 64 ; Build a national cryptographic encryption module, store the master key (K master ) in the Hardware Security Module (HSM), and use the key derivation function K df = SM3(K master || Nonce || Counter) to generate dynamic keys, and use the SM4-CTR mode for data encryption. The formula is C i = SM4(K df , Nonce + i) ⊕ P i . Introduce timestamps and Message Authentication Codes (MACs) to resist replay attacks, adopt a hierarchical encryption architecture, and the temporary session key (K sess ) adopts a timeout automatic destruction mechanism; Build a cross-platform adaptation layer. On the Windows system, use the Hook file system filter driver (Minifilter), on the Linux system, utilize the FUSE module, and on the macOS system, implement the integration of encryption functions under multiple operating systems through kernel extensions (KEXT) and the DriverKit framework. 1.2 Key algorithm process: When writing a file, generate a temporary session key K based on the national cryptography SM2 key negotiation protocol sess = Sm2_KeyExchange(DeviceCert,HostKey), calculate the metadata fingerprint FP = SM3(FileName||CreateTime), encrypt the data stream using the SM4-CTR mode, and store the file fingerprint and the hash value of the ciphertext data block in the directory entry reserved field; When reading a file, obtain encryption-related information from the directory entry, verify the file integrity. If it passes, regenerate the temporary session key and decrypt the data stream to restore the file content.

2. The cross-platform implementation method of the national secret encryption file system compatible with exFAT according to claim 1, wherein When the metadata compatibility module parses the exFAT structure, it is optimized for different exFAT versions (including FAT32 extensions) to ensure the correct handling of special cases such as long file name storage.

3. The cross-platform implementation method of the national secret encryption file system compatible with exFAT according to claim 1, characterized in that, In the national cipher encryption module, the random number Nonce is generated by a national cipher standard random number generator with high encryption strength, and the counter Counter changes according to a specific increment rule. After encrypting each data block, the value of Counter increases by 1.

4. The cross-platform implementation method of the national cryptographic encryption file system compatible with exFAT according to claim 1, characterized in that, In the cross-platform adaptation layer, the macOS system dynamically loads the encryption function module according to the system version. For newer versions (such as macOS Catalina and later), it preferentially tries to load the driver module developed based on the DriverKit framework. If the loading fails, it automatically switches to the KEXT method for loading; for older versions (such as macOS Mojave and earlier), it directly uses the KEXT method for loading.

Citation Information

Cited By

  • Mobile solid state disk data encryption storage method based on trusted computing module

    CN121234421A