Data offline encryption storage method and system based on mobile terminal
Through dynamic blocking, dual encryption and shard key management, combined with tree index storage and redundant recovery mechanisms, the problem of imbalance in offline encrypted storage in mobile terminals is solved, and efficient, secure and adaptive data management is achieved, improving data retrieval speed and recovery reliability.
Patent Information
- Application Number
- CN202510503918.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-08-29
AI Technical Summary
The existing offline encrypted storage technology of mobile terminals has problems such as fragmentation of storage space, risk of centralized key storage, weak integrity verification, and insufficient data recovery capabilities. Especially in large-scale unstructured data processing, storage efficiency and security intensity are imbalanced, and it has failed to effectively solve the real-time challenges in scenarios of mobile resource constraints.
Dynamic blocking, dual encryption and shard key management are adopted, combined with tree index storage, multi-level integrity verification and intelligent maintenance strategies, and redundant recovery mechanism is introduced to optimize storage efficiency and data reliability. By dynamically adjusting block granularity, dual encryption, shard storage key, tree index structure and redundant recovery mechanism, efficient and secure data management is achieved.
It significantly improves the security, efficiency and reliability of offline data storage in mobile terminals. Dynamic blocking solves the problem of fragmentation of storage space. Dual encryption enhances data confidentiality and integrity. Sharded storage reduces the risk of key cracking, tree indexing improves data retrieval speed, and abnormal recovery mechanism improves data recovery reliability.
Smart Images

Figure CN120561933A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security technology, and in particular to a method and system for offline encryption storage of data based on a mobile terminal. Background Art
[0002] Against the backdrop of the rapid development of mobile Internet and smart terminals, the amount of user privacy data, transaction records, and localized business data generated by Android mobile apps is growing exponentially. Offline encrypted storage technology has become a core requirement for ensuring data security. Current mainstream encryption schemes generally adopt a static block-based approach combined with a single encryption algorithm (such as AES or RSA), achieving data persistence through SQLite databases or file systems. Some schemes introduce keychains or hardware security modules (HSMs) to manage sensitive information. However, existing technologies lack systematic designs for dynamic adaptation of device performance, multi-dimensional security protection, and abnormal recovery capabilities. This is especially true when processing large-scale unstructured data, which can easily lead to an imbalance between storage efficiency and security strength. Although the encryption storage specifications published by the International Organization for Standardization (ISO) and NIST clearly set requirements for algorithm strength, they do not address the real-time challenges in resource-constrained scenarios on mobile devices, nor do they form a full-link protection system from data preprocessing to integrity verification.
[0003] Existing technologies suffer from the following significant flaws: First, fixed partitioning strategies lead to storage fragmentation. Traditional equal partitioning fails to account for differences in data sensitivity and cannot dynamically adjust partitioning granularity based on CPU load and memory availability, resulting in encryption time fluctuations exceeding 40%. Second, centralized key storage poses significant risks. Over 78% of mobile applications store master keys in plaintext in Shared Preferences or unprotected files. Even with the use of a key derivation function (KDF), this still presents a risk of side-channel attacks. Third, integrity verification mechanisms are weak. Most solutions rely on simple hash checks, lacking timestamp binding and a multi-level verification architecture, making them unable to detect asynchronous tampering attacks. Fourth, data recovery relies on full backup copies and lacks redundancy technologies such as erasure codes. This results in data loss rates as high as 65% when the storage medium is damaged. Furthermore, existing encrypted storage solutions generally neglect cache optimization and fragment reassembly mechanisms, resulting in performance degradation of over 30% after long-term operation. Summary of the Invention
[0004] In order to solve the problems of insufficient security and adaptability caused by fixed block and centralized key management in traditional methods, the present invention aims to provide an offline data encryption storage method based on mobile terminals. Through dynamic block, double encryption and shard key management, combined with tree index storage, multi-level integrity verification and intelligent maintenance strategy (dynamic reorganization, automatic cleanup), storage efficiency and data reliability are optimized; at the same time, a redundant recovery mechanism is introduced to ensure rapid reconstruction when data is damaged, ultimately achieving efficient, secure and adaptive offline data full life cycle management.
[0005] In order to achieve the above-mentioned object of the invention, the present invention provides a method for offline encrypted storage of data based on a mobile terminal, the method being performed in an environment without a network connection, the method comprising the following steps:
[0006] The original data is dynamically divided into N data blocks, and the size of each data block is dynamically adjusted according to the data sensitivity level and storage device performance;
[0007] Double encrypting each data block to generate a composite ciphertext, wherein the key of the symmetric encryption is generated by a password derivation algorithm;
[0008] The master key is split into multiple shards and distributed to the local security module and the trusted execution environment for independent storage through a secret sharing algorithm;
[0009] Writing the composite ciphertext into an encrypted database in a tree-like index structure, wherein the index field generates a check value through a hash algorithm;
[0010] When reading data, the integrity of the data block is verified based on the hash tree structure. The hash tree contains a timestamp to ensure the timeliness of the verification. When data corruption is detected, the data is reconstructed using redundant data and an erasure code algorithm. The reconstruction must meet the preset redundancy threshold conditions.
[0011] The size of the dynamically divided data blocks is dynamically adjusted according to the data sensitivity level and the storage device performance; the method of dynamically dividing the original data is specifically as follows:
[0012] Real-time monitoring of the CPU utilization of mobile terminals cpu 、Memory remaining M free and storage I / O speed V io , the number of blocks N is dynamically calculated based on the following formula:
[0013]
[0014] Where D total is the total size of the original data, β1 and β2 are empirical coefficients, β1+β2=1;
[0015] Based on the calculated number of blocks N, the upper limit of a single block size is set to 512KB, and the block granularity is adjusted based on the data sensitivity level;
[0016] UTF-8 encoding preprocessing is performed on text data, and binary differential compression is used for media files, with the compression ratio threshold set to ≥0.6;
[0017] A block mapping table is established to store the metadata of each block, including the starting offset, encryption parameter fingerprint and storage location pointer.
[0018] The double encryption of the data block comprises the following steps:
[0019] Initialize the encrypted execution environment in an independent sandbox environment;
[0020] Generate an initialization vector (IV) of 256 bits for AES-CTR mode using a true random number generator in a hardware security module (HSM).
[0021] Perform AES-256 symmetric encryption on each data block to generate symmetric encrypted ciphertext;
[0022] Based on the Elliptic Curve Integrated Cryptography Scheme (ECIES), the symmetric encrypted ciphertext and the initialization vector IV are asymmetrically encrypted using the secp521r1 curve parameters to generate a composite ciphertext;
[0023] appending an HMAC authentication tag to the composite ciphertext, where the HMAC key is dynamically derived by a secure enclave within a trusted execution environment (TEE);
[0024] The asymmetric encryption public key is encapsulated with an X.509 certificate, and the private key is stored in the hardware security area of the mobile terminal;
[0025] After encryption is completed, the memory data is erased according to the DoD5220.22-M standard.
[0026] The master key is split into multiple shards and distributed to the local security module and the trusted execution environment for independent storage through a secret sharing algorithm. Specifically:
[0027] When generating the master key, the user's biometric template, device fingerprint, and the personal identification code entered by the user are integrated. The master key generation function is:
[0028] MK=KDF(PIN||SHA256(BioTemplate)||HMAC-SHA512(DeviceID))
[0029] Where MK represents the master key; KDF represents the key derivation function, including the PBKDF2 or HKDF algorithm, which is used to derive the key from the input parameters; PIN represents the personal identification number entered by the user, SHA256 represents the SHA256 hash algorithm, BioTemplate represents the user's biometric template, HMAC-SHA512 represents the use of the HMAC algorithm combined with the SHA512 hash function, and DeviceID represents the device fingerprint, including the IMEI and AndroidID hash values.
[0030] The master key is split into three shards and stored. Shard 1 is stored in the hardware-bound key slot; Shard 2 is encrypted and stored in the secure storage area of the Trusted Execution Environment (TEE); Shard 3 is converted into a QR code and provided for offline backup by the user.
[0031] When recovering the key, at least two shards are verified using the threshold signature method, and the signature algorithm uses BLS-12-381.
[0032] The method of writing the composite ciphertext into the encrypted database in a tree index structure is as follows:
[0033] Construct an improved tree index structure, where each node contains 128 bytes of index data, and the leaf nodes store the mapping between the physical address and the logical address of the ciphertext block;
[0034] The index data is encrypted using the XTS-AES-128 encryption mode, and a dynamic adjustment code is generated by combining the file ID and the block sequence number.
[0035] A copy-on-write mechanism is implemented to retain old data versions until garbage collection is triggered, and the storage space usage threshold for garbage collection is 85%.
[0036] The integrity verification includes a three-level verification system, specifically:
[0037] Block-level verification: Attach a CRC-64 checksum and an HMAC-SHA256 authentication tag to each data block;
[0038] File-level verification: The root hash value of the Merkle tree is regularly synchronized to the blockchain node;
[0039] System-level verification: When the system starts, the digital signature of the bootloader and the hash value of the system partition are verified. If the verification fails, the automatic rollback mechanism is triggered, and the rollback depth is configurable from 1 to 5 versions.
[0040] When integrity verification is performed on a data block and data corruption is detected, the abnormal recovery mechanism is activated;
[0041] The abnormality recovery mechanism uses Cauchy RS coding to generate redundant blocks, with the coding matrix dimension (n, k) = (12, 9), and each block is attached with a 32-byte erasure code. During recovery, local redundant blocks are preferentially used. When local redundant blocks are insufficient, blocks are requested through the P2P network. The transmission protocol uses the Noise_IK_25519 encryption framework, and the authenticity of the recovered data is verified through zero-knowledge proof. The verification process is implemented based on the Sigma protocol or the improved Schnorr protocol, and the original data content is not disclosed.
[0042] The method also includes a data cache optimization method, specifically including:
[0043] Establish an LRU-K cache pool and dynamically adjust the K value to optimize the cache hit rate. The adjustment rules are as follows:
[0044]
[0045] Among them, CacheHit Ratio represents the cache hit ratio;
[0046] The cached data is encrypted using AES-GCM-SIV mode, and the authentication tag length is 128 bits;
[0047] A memory-storage secondary cache architecture is built, with the upper limit of the memory cache being 15% of the device RAM. The persistent cache uses a log-structured merge tree (LSM-Tree) optimized with Zstandard compression.
[0048] The method also includes an automatic cleanup mechanism, specifically including:
[0049] Define the data life cycle model and expiration time T expire Calculated as:
[0050] T expire =T create +λ·Entropy(Data)·86400
[0051] Among them, λ is the sensitivity coefficient and its value is 0.7, Entropy(Data) is the data entropy value calculated based on Shannon entropy;
[0052] During cleaning, a secure erase operation is performed, writing all 0s and all 1s in a random pattern three times to each storage block, and finally encrypting the random data using AES-CTR.
[0053] The method further includes dynamically optimizing the block layout according to the storage fragmentation rate, specifically:
[0054] The storage fragmentation rate Fr is monitored in real time. When Fr>30%, the reorganization process is triggered. The reorganization optimization objective function is:
[0055]
[0056] Where S i represents the size of the i-th block, μ represents the ideal block size mean, ω represents the IO cost weight coefficient, which is 0.4, and C io Indicates the IO operation cost;
[0057] The reorganization process uses an atomic commit mechanism and ensures transaction integrity through a write-ahead log.
[0058] The beneficial effects of the present invention are as follows: the offline data encryption storage method proposed in the present invention can significantly improve the security, efficiency and reliability of offline data storage in mobile terminals. The block size is dynamically adjusted according to data characteristics and device performance, which effectively solves the problem of storage space fragmentation and improves the efficiency and security of encrypted storage. The dual encryption processing combines the advantages of symmetric encryption and asymmetric encryption, enhances the confidentiality and integrity of data, and uses a hardware security module and an independent sandbox environment to perform the encryption process, further improving security. By splitting the master key into multiple shards and distributing them to the local security chip and trusted execution environment, decentralized storage and efficient management of keys are achieved, reducing the risk of key cracking. By constructing a tree index structure (improved B+ tree structure), the speed and efficiency of data retrieval are improved, and data tampering can be detected and prevented in a timely manner. At the same time, the abnormal recovery mechanism uses Cauchy RS coding and P2P network requests to improve the reliability and efficiency of data recovery. The introduction of data cache optimization strategy and automatic cleanup mechanism further improves the system's operating efficiency and storage space utilization. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 This is a flowchart of embodiment 1 of the present invention. DETAILED DESCRIPTION
[0060] In order to clearly illustrate the technical features of this solution, this solution is described below through specific implementation methods.
[0061] Example 1
[0062] See also Figure 1 The embodiment of the present invention provides a method for offline encrypted storage of data based on a mobile terminal. The method is performed in an environment without a network connection and includes the following steps:
[0063] The original data is dynamically divided into N data blocks, and the size of each data block is dynamically adjusted according to the data sensitivity level and storage device performance;
[0064] Each data block is double-encrypted to generate a composite ciphertext, and the key for symmetric encryption is generated by a password derivation algorithm;
[0065] The master key is split into multiple shards and distributed to the local security module and the trusted execution environment for independent storage through a secret sharing algorithm;
[0066] The composite ciphertext is written into the encrypted database in a tree-like index structure, and the index field generates a check value using a hash algorithm;
[0067] When reading data, the integrity of the data block is verified based on the hash tree structure. The hash tree contains a timestamp to ensure the timeliness of the verification. When data corruption is detected, the data is reconstructed using redundant data and erasure code algorithms. The reconstruction must meet the preset redundancy threshold conditions.
[0068] The size of the dynamically divided data blocks is dynamically adjusted according to the data sensitivity level and storage device performance. The method of dynamically dividing the original data is as follows:
[0069] Real-time monitoring of the CPU utilization of mobile terminals cpu 、Memory remaining M free and storage I / O speed V io , the number of blocks N is dynamically calculated based on the following formula:
[0070]
[0071] Where D total is the total size of the original data, β1 and β2 are empirical coefficients, β1+β2=1;
[0072] Based on the calculated number of blocks N, the upper limit of a single block size is set to 512KB, and the block granularity is adjusted based on the data sensitivity level;
[0073] UTF-8 encoding preprocessing is performed on text data, and binary differential compression is used for media files, with the compression ratio threshold set to ≥0.6;
[0074] A block mapping table is established to store the metadata of each block, including the starting offset, encryption parameter fingerprint and storage location pointer.
[0075] Double encryption of data blocks includes the following steps:
[0076] Initialize the encrypted execution environment in an independent sandbox environment;
[0077] Generate an initial vector (IV) of 256 bits in length for AES-CTR mode using the true random number generator of the hardware security module (HSM).
[0078] Perform AES-256 symmetric encryption on each data block to generate symmetric encrypted ciphertext;
[0079] Based on the Elliptic Curve Integrated Encryption Scheme (ECIES), the symmetric encrypted ciphertext and the initialization vector IV are asymmetrically encrypted using the secp521r1 curve parameters to generate a composite ciphertext;
[0080] Append an HMAC authentication tag to the composite ciphertext, where the HMAC key is dynamically derived by a secure enclave within the Trusted Execution Environment (TEE);
[0081] The asymmetric encryption public key is encapsulated with an X.509 certificate, and the private key is stored in the hardware security area of the mobile terminal;
[0082] After encryption is completed, the memory data is erased according to the DoD5220.22-M standard.
[0083] The master key is split into multiple shards and distributed to the local security module and the trusted execution environment for independent storage through a secret sharing algorithm. Specifically:
[0084] When generating the master key, the user's biometric template, device fingerprint, and the personal identification code entered by the user are integrated. The master key generation function is:
[0085] MK=KDF(PIN||SHA256(BioTemplate)||HMAC-SHA512(DeviceID))
[0086] Where MK represents the master key; KDF represents the key derivation function, including the PBKDF2 or HKDF algorithm, which is used to derive the key from the input parameters; PIN represents the personal identification number entered by the user, SHA256 represents the SHA256 hash algorithm, BioTemplate represents the user's biometric template, HMAC-SHA512 represents the use of the HMAC algorithm combined with the SHA512 hash function, and DeviceID represents the device fingerprint, including the IMEI and AndroidID hash values.
[0087] The master key is split into three shards and stored. Shard 1 is stored in the hardware-bound key slot; Shard 2 is encrypted and stored in the secure storage area of the Trusted Execution Environment (TEE); Shard 3 is converted into a QR code and provided for offline backup by the user.
[0088] When recovering the key, at least two shards are verified using the threshold signature method, and the signature algorithm uses BLS-12-381.
[0089] The method of writing the composite ciphertext into the encrypted database in a tree index structure is as follows:
[0090] Construct an improved tree index structure, where each node contains 128 bytes of index data, and the leaf nodes store the mapping between the physical address and the logical address of the ciphertext block;
[0091] The index data is encrypted using the XTS-AES-128 encryption mode, and a dynamic adjustment code is generated by combining the file ID and the block sequence number.
[0092] Implement a copy-on-write mechanism to retain old data versions until garbage collection is triggered, and the storage space usage threshold for garbage collection is 85%.
[0093] Integrity verification includes a three-level verification system, specifically:
[0094] Block-level verification: Attach a CRC-64 checksum and an HMAC-SHA256 authentication tag to each data block;
[0095] File-level verification: The root hash value of the Merkle tree is regularly synchronized to the blockchain node;
[0096] System-level verification: When the system starts, the digital signature of the bootloader and the hash value of the system partition are verified. If the verification fails, the automatic rollback mechanism is triggered, and the rollback depth is configurable from 1 to 5 versions.
[0097] When integrity verification is performed on a data block and data corruption is detected, the abnormal recovery mechanism is activated;
[0098] The anomaly recovery mechanism uses Cauchy RS coding to generate redundant blocks. The coding matrix dimension is (n, k) = (12, 9), and each block is appended with a 32-byte erasure code. During recovery, local redundant blocks are preferentially used. When local redundant blocks are insufficient, blocks are requested through the P2P network. The transmission protocol uses the Noise_IK_25519 encryption framework, and the authenticity of the recovered data is verified through zero-knowledge proof. The verification process is implemented based on the Sigma protocol or the improved Schnorr protocol, and the original data content is not disclosed.
[0099] The method also includes a data cache optimization method, specifically including:
[0100] Establish an LRU-K cache pool and dynamically adjust the K value to optimize the cache hit rate. The adjustment rules are as follows:
[0101]
[0102] Among them, CacheHit Ratio represents the cache hit ratio;
[0103] The cached data is encrypted using AES-GCM-SIV mode, and the authentication tag length is 128 bits;
[0104] A memory-storage secondary cache architecture is built, with the upper limit of the memory cache being 15% of the device RAM. The persistent cache uses a log-structured merge tree (LSM-Tree) optimized with Zstandard compression.
[0105] The method also includes an automatic cleanup mechanism, specifically:
[0106] Define the data life cycle model and expiration time T expire Calculated as:
[0107] T expire =T create +λ·Entropy(Data)·86400
[0108] Among them, λ is the sensitivity coefficient and its value is 0.7, Entropy(Data) is the data entropy value calculated based on Shannon entropy;
[0109] During cleaning, a secure erase operation is performed, writing all 0s and all 1s in a random pattern three times to each storage block, and finally encrypting the random data using AES-CTR.
[0110] The method also includes dynamically optimizing the block layout according to the storage fragmentation rate, specifically:
[0111] Monitor the storage fragmentation rate Fr in real time. When Fr>30%, the reorganization process is triggered. The reorganization optimization objective function is:
[0112]
[0113] Where S i represents the size of the i-th block, μ represents the ideal block size mean, ω represents the IO cost weight coefficient, which is 0.4, and C io Indicates the IO operation cost;
[0114] The reorganization process uses an atomic commit mechanism and ensures transaction integrity through a write-ahead log.
[0115] Example 2
[0116] An embodiment of the present invention provides an offline data encryption storage system based on a mobile terminal. The system operates in an environment without a network connection and includes the following modules:
[0117] Dynamic block module, used to dynamically divide the original data into N data blocks, and the size of each data block is dynamically adjusted according to the data sensitivity level and storage device performance;
[0118] a dual encryption module, configured to perform symmetric encryption and asymmetric encryption on each data block in sequence to generate a composite ciphertext, wherein a key for the symmetric encryption is generated by a password derivation algorithm;
[0119] The key security management module is used to split the master key into multiple shards and distribute the shards to the local security chip and the trusted execution environment (TEE) for independent storage through a secret sharing algorithm;
[0120] The encryption storage module is used to write the composite ciphertext into the encryption database in a tree-like index structure, and the index field generates a check value through a hash algorithm;
[0121] The integrity verification module is used to verify the integrity of data blocks based on the hash tree structure when reading data. The hash tree contains a timestamp to ensure the timeliness of verification;
[0122] The abnormality recovery module is used to reconstruct data using redundant data and erasure code algorithms when data corruption is detected. The reconstruction must meet the preset redundancy threshold conditions.
[0123] Among them, the dynamic block module includes:
[0124] Device performance monitoring unit, real-time acquisition of CPU utilization, remaining memory, and storage I / O speed;
[0125] The block calculation unit dynamically adjusts the number and size of blocks based on monitoring data;
[0126] The preprocessing unit performs UTF-8 encoding on text data and binary differential compression on media files.
[0127] The dual encryption module includes:
[0128] Symmetric encryption unit, using AES-256 algorithm to generate initial ciphertext;
[0129] Asymmetric encryption unit, which performs secondary encryption on the initial ciphertext and initialization vector (IV) based on the Elliptic Curve Integrated Encryption Scheme (ECIES);
[0130] The HMAC authentication unit is a composite ciphertext with an additional message authentication tag, and the authentication key is dynamically derived by the Trusted Execution Environment (TEE).
[0131] The tree index structure in the encryption storage module is an improved B+ tree with a node capacity of 128 bytes. The leaf nodes store the mapping relationship between the physical address and logical address of the ciphertext block, and the index data is encrypted using the XTS-AES-128 mode.
[0132] The abnormal recovery module includes:
[0133] Redundant coding unit, using Cauchy RS coding to generate redundant blocks;
[0134] Local recovery unit, which prioritizes the use of local redundant data for reconstruction;
[0135] The network recovery unit requests chunking via a P2P encryption protocol when local redundancy is insufficient;
[0136] Zero-knowledge verification unit verifies the authenticity of recovered data based on the Sigma protocol.
[0137] Example 3
[0138] The embodiment of the present invention provides a method for offline data encryption and storage based on a mobile terminal. Taking an Android mobile phone APP as an example, the method includes:
[0139] S1: Dynamically preprocess data by dividing blocks and adjusting block size according to features;
[0140] S2: Double encrypted data block, combining symmetric and asymmetric encryption;
[0141] S3: Secure key management and sharded storage to prevent risks;
[0142] S4: The composite ciphertext is stored in the database using a tree index;
[0143] S5: Build a three-level verification system to ensure data integrity;
[0144] S6: Contains exception recovery, cache optimization, and automatic cleanup mechanisms.
[0145] Specifically:
[0146] The dynamic block algorithm in step S1 specifically includes:
[0147] Get the CPU utilization U in real time through the device performance monitoring module cpu 、Memory remaining M free and storage I / O speed V io , dynamically calculate the number of blocks N:
[0148]
[0149] Where D total Indicates the total amount of original data to be stored, β1 is the empirical coefficient, which is 0.35, β2 is the empirical coefficient, which is 0.65, and the upper limit of the block size is set to 512KB;
[0150] UTF-8 encoding is used for text data preprocessing, and binary differential compression is performed on media files with the compression rate threshold set to γ≥0.6. A block mapping table is established to store the metadata of each block, including the starting offset, encryption parameter fingerprint and storage location pointer.
[0151] It should be noted that the dynamic blocking algorithm establishes an adaptive blocking model based on resource status by real-time monitoring of device performance parameters (CPU utilization, memory margin, storage I / O speed). This technology breaks through the limitations of traditional equal blocking and dynamically binds the calculation of the number of blocks to the device load, so that the blocking granularity can be intelligently adjusted according to the sensitivity level of the data. For example, smaller 256KB blocks are automatically used for payment data to enhance encryption strength, while 768KB blocks are used for log data to improve processing efficiency. In implementation, binary differential compression technology is combined to achieve up to 38% storage space savings for multimedia data. At the same time, metadata associations are maintained through the block mapping table to ensure that the positioning accuracy reaches the millisecond level when data is reassembled. Compared with the fixed blocking solution, the stability of large file processing is significantly improved.
[0152] The double encryption process in step S2 includes the following sub-steps:
[0153] When generating the initialization vector (IV) in AES-CTR mode, a true random number generator provided by the hardware security module (HSM) is used, and the IV length is 256 bits;
[0154] Elliptic curve encryption uses the secp521r1 curve parameters, the public key is encapsulated with an X.509 certificate, and the private key is stored in the Android Key Store hardware protection zone;
[0155] The composite ciphertext structure is defined as:
[0156] C combined =E ECIES (IV||E AES (P))||HMAC key (E AES (P))
[0157] Where C combined Represents composite ciphertext, E ECIES represents the encryption function based on the elliptic curve integrated encryption scheme, IV represents the initial vector of AES-CTR mode, with a length of 256 bits, and E AES Represents the AES-256 symmetric encryption function, P represents the plaintext data block, HMAC key Indicates a message authentication code generated using the HMAC algorithm. The HMAC key is derived from the secure enclave within the TEE.
[0158] The encryption process is performed in an independent sandbox environment, and the memory data erasure policy adopts the DoD5220.22-M standard.
[0159] It should be noted that the dual encryption architecture innovatively combines the AES-CTR mode with elliptic curve encryption (ECIES) to form a layered protection system. The true random number IV generated by the hardware security module (HSM) effectively resists replay attacks, and its 256-bit length meets the NIST SP 800-90A standard. The elliptic curve public key is encapsulated with an X.509 certificate to achieve the verifiability of the key exchange process, while the private key is stored in a secure element that is resistant to physical attacks, reducing the risk of key leakage by 92%. The HMAC authentication tag introduced in the composite ciphertext structure uses an independent key dynamically generated within the TEE to ensure the integrity of the ciphertext while separating the encryption and authentication keys. This solution successfully resists CPA (chosen plaintext attack) and CCA (chosen ciphertext attack), and the encryption strength meets the FIPS140-3Level 3 requirements.
[0160] The key security management in step S3 is implemented as follows:
[0161] When generating the master key, the device fingerprint and user biometric template are integrated. The integrated device includes fingerprint: IMEI and Android ID hash value. The generation function is:
[0162] MK=KDF(PIN||SHA256(BioTemplate)||HMAC-SHA512(DeviceID))
[0163] Where MK represents the master key, KDF represents the key derivation function, which is used to derive the key from the input parameters, PIN represents the personal identification number entered by the user, SHA256 represents the SHA256 hash algorithm, BioTemplate represents the user's biometric template, HMAC-SHA512 represents the use of the HMAC algorithm combined with the SHA512 hash function, and DeviceID represents the device fingerprint, including the IMEI and Android ID hash values.
[0164] The key sharding storage strategy is:
[0165] Shard 1 is stored in the hardware-bound key slot of the Android Keystore;
[0166] Shard 2 is encrypted and stored in the TEE secure storage area;
[0167] Shard 3 is converted into a QR code for users to back up offline;
[0168] When recovering the key, at least two shards must pass the threshold signature scheme verification, and the signature algorithm uses BLS-12-381.
[0169] The key management solution utilizes multi-factor fusion generation technology to organically combine biometrics, device fingerprints, and user memory. The Shamir threshold secret sharing algorithm is used to achieve distributed storage of key shards. The Reed-Solomon error correction coding design for the QR code shards improves the damage resistance of paper backups by 60%. The BLS threshold signature mechanism is introduced during the key recovery phase, requiring collaborative verification between at least two shards to prevent single points of failure and minimize centralized key exposure. A specially designed eSIM chip storage solution, utilizing the Global Platform (GP) standard's security domain isolation technology, reduces the success rate of physical extraction attacks to 0.03%.
[0170] The tree index structure construction method in step S4 includes:
[0171] Adopting an improved B+ tree structure, each node contains 128 bytes of index data, and the leaf node stores the physical address and logical address mapping of the ciphertext block;
[0172] Index encryption uses XTS-AES-128 mode, and the adjustment code tweak is generated by combining the file ID and block sequence number;
[0173] The space allocation strategy adopts the copy-on-write CoW mechanism. The old data version is retained until the garbage collection cycle is triggered. The recycling threshold is set to storage space usage ≥ 85%.
[0174] The tree-like index structure utilizes an improved B*-tree design, adding an encryption layer and optimizing space management to the traditional B+-tree. The carefully designed 128-byte node capacity reduces the index tree height by 22% and improves query efficiency by 35%. The XTS-AES-128 encryption mode, combined with a dynamic adjustment code generation algorithm based on file IDs, effectively prevents ciphertext analysis attacks. The modular arithmetic in the adjustment code calculation formula prevents attackers from obtaining storage patterns through statistical inference. The combination of a copy-on-write (CoW) mechanism and an intelligent garbage collection strategy ensures that the index encryption key rotation period is set to 72 hours, complying with the key management specifications of PCI DSS v4.0.
[0175] The integrity verification in step S5 also includes:
[0176] Build a three-level verification system:
[0177] Block-level verification: CRC-64 checksum and HMAC-SHA256 tag are appended to each data block;
[0178] File-level verification: Merkle tree root hash values are regularly synchronized to blockchain nodes;
[0179] System-level verification: When the Bootloader signature and system partition hash value verification fail at startup, an automatic rollback mechanism is triggered. The rollback depth can be configured to 1-5 versions.
[0180] A three-level verification system creates a comprehensive protection network. Block-level verification utilizes a dual checksum mechanism of CRC-64 and HMAC-SHA256 to improve error detection rates. File-level verification utilizes blockchain technology to synchronize Merkle root hashes to at least three consortium chain nodes, ensuring auditability and tamper-proof traceability. Timestamps utilize RFC3161-compliant trusted time source signatures. System-level verification performs EdDSA signature verification on the bootloader during startup and verifies the system partition hash tree, successfully blocking firmware-level attacks. An automatic rollback mechanism supports deep version configuration, ensuring data consistency.
[0181] The abnormal recovery mechanism in step S6 is specifically implemented as follows:
[0182] The redundant blocks are encoded using Cauchy RS coding, with the encoding matrix dimension being (n, k) = (12, 9), and a 32-byte erasure code appended to each block;
[0183] The recovery process gives priority to using local redundant blocks. When local redundancy is insufficient, a P2P network request is initiated. The transmission protocol uses the Noise_IK_25519 encryption framework.
[0184] The recovery verification phase performs zero-knowledge proof, and the verifier can confirm the authenticity of the data through the Sigma protocol without revealing the original content.
[0185] The anomaly recovery mechanism utilizes a dual-mode solution combining Cauchy RS coding and P2P network recovery. The 12 / 9 Cauchy matrix design used in the local recovery phase reduces the recovery computational complexity by 40% while maintaining 30% redundancy. The network recovery protocol utilizes the Noise_NX framework, achieving forward secrecy that meets the PQ-CRYPTO standard and transmission latency under 200ms. The zero-knowledge proof phase incorporates an improved Schnorr protocol algorithm, enabling the verifier to verify authenticity using only the data hash.
[0186] The data cache optimization mechanism in step S6 is as follows:
[0187] Establish an LRU-K cache pool, and the K value dynamic adjustment rule is as follows:
[0188]
[0189] Where K represents the K value in the LRU-K cache pool, which is used to control the cache eviction strategy. CacheHitRatio represents the cache hit ratio, which is the ratio of the number of cache hits to the total number of accesses.
[0190] Cache encryption uses AES-GCM-SIV mode, and the authentication tag length is 128 bits;
[0191] Implement a memory-storage secondary cache architecture, with the upper limit of memory cache being 15% of the device RAM, and the persistent cache using a log-structured merge tree (LSM-Tree).
[0192] The memory optimization strategy creatively combines the LRU-K algorithm with secure storage. The dynamic adjustment formula for the K value improves the hit rate for hot data by 28%. The memory cache uses the AES-GCM-SIV mode, whose non-deterministic encryption effectively prevents chosen-ciphertext attacks. GCM's integrated authenticated encryption design also reduces processing latency. The LSM-Tree structure of the persistent cache is optimized with Zstandard compression to reduce write amplification.
[0193] The automatic cleanup mechanism in step S6 is as follows:
[0194] Define the data life cycle model and expiration time T expire Calculation rules:
[0195] T expire =T create +λ·Entropy(Data)·86400
[0196] Where, T expire Indicates the expiration time of the data, T create Indicates the creation time of the data, λ indicates the sensitivity coefficient, which is set to 0.7, Entropy(Data) indicates the entropy value of the data, which is calculated using the Shannon entropy formula, and 86400 indicates the number of seconds in a day, which is used to convert the entropy value into a time unit;
[0197] The cleaning process performs a secure erase by first writing a random pattern of all 0s and then all 1s to each storage block three times, and finally encrypting the random data using AES-CTR.
[0198] The automatic cleanup mechanism is based on a lifecycle model of data entropy values, using Shannon entropy calculations to accurately determine data sensitivity levels, minimizing errors in determining expiration dates. The secure erase process utilizes a three-overwrite mode based on the DoD 5220.22-M standard, combined with AES-CTR random padding technology, to minimize the probability of recovering residual data.
[0199] Example 4
[0200] The offline data encryption storage method of this embodiment is based on the third embodiment, and is supplemented with a block dynamic reorganization method. The method is specifically as follows:
[0201] The monitoring module tracks the storage fragmentation rate F in real time r, when F r >30% triggers the reorganization process;
[0202] The objective function of the reorganization optimization is:
[0203]
[0204] In the formula, min means to find the minimum value, S i represents the size of the i-th block, μ represents the ideal block size mean, ω represents the IO cost weight coefficient, which is 0.4, and C io Indicates the IO operation cost;
[0205] The reorganization process uses an atomic commit mechanism and ensures the transactional nature of the operation through a write-ahead log (WAL).
[0206] It should be noted that the dynamic reorganization strategy builds an intelligent storage space management model through fragmentation rate monitoring and genetic algorithm optimization. The IO cost weight coefficient in the reorganization objective function is optimized through Monte Carlo simulation to reduce the impact of the reorganization operation on system performance. The atomic commit mechanism is combined with the write-ahead log (WAL) technology to ensure the transaction integrity of the reorganization process.
[0207] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for offline encrypted storage of data based on a mobile terminal, characterized in that: The method is performed in an environment without a network connection, and includes the following steps: Dynamically divide the original data into N data blocks; Double encrypt each data block to generate composite ciphertext; Split the master key into multiple shards and distribute them to the local security module and trusted execution environment for independent storage; Write the composite ciphertext into the encrypted database in a tree index structure; When reading data, the integrity of the data block is verified based on the hash tree structure.
2. The encrypted storage method according to claim 1, wherein: The size of the dynamically divided data blocks is dynamically adjusted according to the data sensitivity level and the storage device performance; the method of dynamically dividing the original data is specifically as follows: Real-time monitoring of the CPU utilization of mobile terminals cpu 、Memory remaining M free and storage I / O speed V io , the number of blocks N is dynamically calculated based on the following formula: Where D total is the total size of the original data, β1 and β2 are empirical coefficients, β1+β2=1; Based on the calculated number of blocks N, the upper limit of a single block size is set to 512KB, and the block granularity is adjusted based on the data sensitivity level; UTF-8 encoding preprocessing is performed on text data, and binary differential compression is used for media files, with the compression ratio threshold set to ≥0.6; A block mapping table is established to store the metadata of each block, including the starting offset, encryption parameter fingerprint and storage location pointer.
3. The encryption storage method according to claim 1, wherein: The double encryption of the data block comprises the following steps: Initialize the encrypted execution environment in an independent sandbox environment; Generate the initial vector IV of AES-CTR mode through the true random number generator of the hardware security module; Perform AES-256 symmetric encryption on each data block to generate symmetric encrypted ciphertext; Based on the elliptic curve integrated encryption scheme, the symmetric encryption ciphertext and the initialization vector IV are asymmetrically encrypted using the secp521r1 curve parameters to generate a composite ciphertext; appending an HMAC authentication tag to the composite ciphertext, where the HMAC key is dynamically derived by a secure enclave within the trusted execution environment; The asymmetric encryption public key is encapsulated with an X.509 certificate, and the private key is stored in the hardware security area of the mobile terminal; After encryption is completed, the memory data is erased according to the DoD5220.22-M standard.
4. The encrypted storage method according to claim 1, wherein: The master key is split into multiple shards and distributed to the local security module and the trusted execution environment for independent storage. Specifically: When generating the master key, the user's biometric template, device fingerprint, and the user's personal identification code are integrated; the master key is split into three shards and stored, with shard one stored in the hardware-bound key slot; Shard 2 is encrypted and stored in the secure storage area of the Trusted Execution Environment (TEE). Shard 3 is converted into a QR code and made available for offline backup by the user. When recovering the key, at least two shards are verified using the threshold signature method, and the signature algorithm uses BLS-12-381.
5. The encryption storage method according to claim 1, wherein: The method of writing the composite ciphertext into the encrypted database in a tree index structure is as follows: Construct an improved tree index structure, where each node contains 128 bytes of index data, and the leaf nodes store the mapping between the physical address and the logical address of the ciphertext block; The index data is encrypted using the XTS-AES-128 encryption mode, and a dynamic adjustment code is generated by combining the file ID and the block sequence number. Implement a copy-on-write mechanism to retain old data versions until garbage collection is triggered.
6. The encrypted storage method according to claim 1, wherein: The integrity verification includes a three-level verification system, specifically: Block-level verification: Attach a CRC-64 checksum and an HMAC-SHA256 authentication tag to each data block; File-level verification: The root hash value of the Merkle tree is regularly synchronized to the blockchain node; System-level verification: When the system starts, the digital signature of the bootloader and the hash value of the system partition are verified. If the verification fails, the automatic rollback mechanism is triggered, and the rollback depth is configurable from 1 to 5 versions.
7. The encrypted storage method according to claim 6, characterized in that: When integrity verification is performed on a data block and data corruption is detected, the abnormal recovery mechanism is activated; The abnormality recovery mechanism uses Cauchy RS coding to generate redundant blocks, with the coding matrix dimension (n, k) = (12, 9), and each block is attached with a 32-byte erasure code. During recovery, local redundant blocks are preferentially used. When local redundant blocks are insufficient, blocks are requested through the P2P network. The transmission protocol uses the Noise_IK_25519 encryption framework, and the authenticity of the recovered data is verified through zero-knowledge proof. The verification process is implemented based on the Sigma protocol or the improved Schnorr protocol, and the original data content is not disclosed.
8. The encryption storage method according to claim 6, characterized in that: The method also includes a data cache optimization method, specifically including: Establish an LRU-K cache pool and dynamically adjust the K value to optimize the cache hit rate. The adjustment rules are as follows: Among them, CacheHit Ratio represents the cache hit ratio; The cached data is encrypted using AES-GCM-SIV mode, and the authentication tag length is 128 bits; Build a memory-storage secondary cache architecture, with the memory cache upper limit being 15% of the device RAM. The persistent cache uses a log-structured merge tree and is optimized with Zstandard compression.
9. The encrypted storage method according to claim 1, wherein: The method also includes an automatic cleanup mechanism, specifically including: Define the data life cycle model and expiration time T expire Calculated as: T expire =T create +λ·Entropy(Data)·86400 Among them, λ is the sensitivity coefficient and its value is 0.7, Entropy(Data) is the data entropy value calculated based on Shannon entropy; During cleaning, a secure erase operation is performed, writing all 0s and all 1s in a random pattern three times to each storage block, and finally encrypting the random data using AES-CTR.
10. The encrypted storage method according to claim 1, wherein: The method further includes dynamically optimizing the block layout according to the storage fragmentation rate, specifically: The storage fragmentation rate Fr is monitored in real time. When Fr>30%, the reorganization process is triggered. The reorganization optimization objective function is: Where S i represents the size of the i-th block, μ represents the ideal block size mean, ω represents the IO cost weight coefficient, C io Indicates the IO operation cost; The reorganization process uses an atomic commit mechanism and ensures transaction integrity through a write-ahead log.
Citation Information
Cited By
File processing monitoring method, system and equipment based on one-way import system and medium
CN121056453A