A data encryption method and system based on multi-terminal interaction

By constructing a hierarchical hash algorithm key derivation tree based on the master key seed, the device independently calculates the key, which solves the problems of offline devices being unable to obtain keys and the high complexity of key management, and achieves the effect of simplifying the addition of new devices and key storage management.

CN120979633BActive Publication Date: 2026-11-20SHENZHEN YOUQIAN INFORMATION TECH CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511136859.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-14
Publication Date
2026-11-20
Estimated Expiration
2045-08-14

AI Technical Summary

Technical Problem

Existing multi-device key management solutions rely on centralized servers or direct synchronization between devices, resulting in offline devices being unable to obtain keys, high complexity in key storage and management, and cumbersome and complex configuration when adding new devices.

Method used

A deterministic key derivation tree based on the master key seed as the root node is adopted. The key derivation tree is constructed through a hierarchical hash algorithm. The key derivation is carried out through three-level paths: device category, device identifier, and session identifier. Each device independently calculates its communication key and generates a unique key using the master password input by the user and the device attribute data.

Benefits of technology

It enables offline devices to generate keys, and new devices can join without synchronizing keys with existing devices, simplifying key storage and management, reducing complexity, and ensuring forward security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120979633B_ABST
    Figure CN120979633B_ABST
Patent Text Reader

Abstract

The application discloses a kind of data encryption method and system based on multi-terminal interaction, it is related to data encryption: when first registration, the main password data of user input is acquired, according to main password data, main key seed data is generated by key derivation function;Based on main key seed data, a layered hash algorithm is used to construct key derivation tree data structure, and the key derivation tree data structure is taken as the root node of main key seed data, and is expanded in layers according to device category and device identification to form tree-like derivation path;When new device requests authorization, according to key derivation tree data structure, the attribute data of corresponding new device is combined to calculate derivation path, and the exclusive key data of corresponding new device is derived from main key seed data along the derivation path;According to the exclusive key data of sending device, the path data of receiving device in key derivation tree is combined, and the data to be transmitted between devices is encrypted to generate encrypted data stream;The application improves offline device encryption efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data encryption, and in particular to a data encryption method and system based on multi-terminal interaction. Background Technology

[0002] With the rapid development of the Internet of Things (IoT) and mobile internet technologies, it has become commonplace for users to own and use multiple smart devices simultaneously. Statistics show that the average user owns 3-5 connected devices, including smartphones, tablets, laptops, and smartwatches. These devices require frequent data synchronization and secure communication; for example, password managers need to synchronize password data across all devices, note-taking applications need to synchronize documents across devices, and health data needs to be synchronized from smartwatches to mobile phones. To protect user privacy and data security, end-to-end encryption has become a fundamental requirement for data transmission between multiple devices.

[0003] In end-to-end encryption systems, key management is the most critical and complex technical aspect. Traditional multi-device key management schemes mainly employ two technical approaches:

[0004] The first type is a centralized key distribution scheme. This scheme deploys a key distribution center (KDC) where a server uniformly generates and distributes device keys. When device A needs to communicate with device B, both devices request a session key from the KDC. After generating the session key, the KDC encrypts and sends it using the long-term keys of device A and device B respectively. The main technical drawbacks of this scheme are: (1) The KDC becomes a single point of failure and a target for attack. Once the KDC is compromised, the communication security of all devices will be threatened; (2) Devices must be online to obtain keys from the KDC, and offline devices cannot participate in secure communication; (3) The KDC needs to maintain the key information of all devices, and as the number of devices increases, the complexity of key storage and management increases linearly.

[0005] The second approach is direct synchronization between devices. This approach establishes a secure channel between devices to directly exchange keys, for example, using the Diffie-Hellman key exchange protocol. In practice, when a new device joins, it needs to exchange keys with each existing device to generate a shared key between each pair of devices. This approach has the following technical problems: (1) Key exchange requires devices to be online simultaneously, and offline devices cannot complete key negotiation; (2) n devices need to maintain n(n-1) / 2 shared keys, and the key storage overhead increases quadratically with the number of devices; (3) When a new device joins, it needs to exchange keys with all existing devices one by one, and the configuration process is complex and time-consuming; (4) When a device is lost or stolen, it is necessary to notify all other devices to update the relevant keys, and the key revocation mechanism is complex.

[0006] The fundamental problem with existing solutions is that they treat keys as static data that needs to be stored and transmitted, rather than as dynamic results that can be derived through deterministic algorithms. This forces key management to rely on real-time network connections and complex synchronization mechanisms. In particular, existing solutions exhibit significant technical limitations in the following typical scenarios:

[0007] (1) Offline scenario: When users use their laptops on airplanes, they cannot connect to servers or other devices and therefore cannot obtain the keys required to decrypt synchronized data from other devices;

[0008] (2) New device initialization: After purchasing a new mobile phone, users need to wait for the key exchange with all existing devices to be completed before they can access synchronized data. The process is cumbersome and prone to errors.

[0009] (3) Temporary device use: When users log in temporarily in public places such as internet cafes, existing solutions either cannot provide security protection or require a complex temporary key distribution mechanism;

[0010] (4) Expanding the number of devices: With the popularization of smart home devices, users may have dozens of devices, and the key storage and management overhead of existing solutions will become unacceptable.

[0011] Therefore, there is an urgent need for a new key management scheme that can generate keys when devices are offline, simplify the process of adding new devices, and reduce the complexity of key storage and management while ensuring security. Summary of the Invention

[0012] To address the issue that existing technologies require a centralized server for key distribution or direct synchronization between devices for multi-device key management, which prevents offline devices from obtaining the necessary keys, this application provides a data encryption method and system based on multi-device interaction. By constructing a deterministic key derivation tree with the master key seed as the root node, and employing a hierarchical hash algorithm to deduce the key along three paths: device category, device identifier, and session identifier, each device can independently calculate the key required to communicate with any other device using only the master password and the derivation path information.

[0013] One aspect of this application provides a data encryption method based on multi-terminal interaction, comprising: S1, when a user registers for the first time, obtaining the master password data input by the user, and generating master key seed data based on the master password data through a key derivation function; S2, based on the master key seed data, constructing a key derivation tree data structure using a hierarchical hash algorithm, wherein the key derivation tree data structure is rooted at the master key seed data and expands layer by layer according to device category and device identifier to form a tree-like derivation path; S3, when a new device requests authorization, calculating the derivation path based on the key derivation tree data structure and the attribute data of the corresponding new device, and deriving the exclusive key data of the corresponding new device from the master key seed data along the derivation path; S4, encrypting the data to be transmitted between devices based on the exclusive key data of the sending device in S3, combined with the path data of the receiving device in the key derivation tree, to generate an encrypted data stream;

[0014] In this scheme, the hierarchical hashing algorithm is a multi-level key derivation mechanism. It's an algorithmic system that generates keys at different levels from a single master key seed by applying hash functions (such as HKDF-SHA256) at different levels. Specifically, it includes three levels: device category layer, device layer, and session layer. Lower-level keys can be derived from upper-level keys, but not in reverse. The same input always produces the same output, ensuring key reproducibility. The first level uses the HKDF algorithm, taking the master key seed and device category information as input to generate the device category key. The second level takes the device category key and a specific device identifier as input to generate a device-specific key. The third level takes the device key and a session counter as input to generate the session key.

[0015] The key derivation tree is a tree-shaped data structure used in this scheme to organize and manage the key relationships between multiple devices. It is a hierarchical key system formed by expanding step-by-step using a hierarchical hash algorithm, with the master key seed as the root node. Its structure consists of:

[0016] Root node (Level 0): Master key seed

[0017] ├── First-level node: Device category key (mobile phone, computer, tablet, etc.)

[0018] │├── Second-level node: Specific device key (iPhone 15, MacBook Pro, etc.)

[0019] ││└──Third-level node: Session key (Session 1, Session 2, Session 3, etc.);

[0020] The derivation path is the complete sequence of nodes and the set of derivation parameters traversed from the root node (master key seed) of the key derivation tree to a specific leaf node (target key), for example: master key seed → mobile phone category → iPhone15 → session #1234; it includes identifiers, hash inputs, and context data at each level.

[0021] Path data is a set of metadata describing the device's specific location and derivation parameters within the key derivation tree, containing all the non-sensitive information needed to reconstruct the device's key. For example:

[0022] Path data = {Device category: "Mobile phone"}

[0023] Device category hash: SHA256 (“phone”),

[0024] Device name: "My iPhone 15"

[0025] Device identifier hash: SHA256 ("my iPhone 15"),

[0026] Hierarchy depth: 2

[0027] Creation time: "2024-12-15"

[0028] Session counter: 1234};

[0029] The new device uses path data to calculate its own derivation path; the sender uses its own path data to locate the exclusive key; the receiver verifies the sender's identity through the exchanged path data; the path data is part of the encryption context.

[0030] Furthermore, it also includes: S5, adding timestamp data as an additional derivation parameter to the key derivation tree data structure in step S2, so that the proprietary key data generated in S3 and S4 is updated periodically over time. Here, the additional derivation parameter is a variable parameter introduced in addition to the necessary key materials and identification information during the basic key derivation process to enhance the dynamism and security of the key; in this application, it specifically refers to timestamp data.

[0031] Further, S1, the master key seed data is generated through a key derivation function, including: receiving the master password data input by the user; normalizing the master password data to generate standard format password data; obtaining the user's unique identity data; performing a hash operation on the unique identity data to generate the corresponding user's deterministic salt value data; wherein, the deterministic salt value data refers to a fixed salt value with reproducibility generated by hashing the user's unique identity. Unlike traditional random salt values, the deterministic salt value remains unchanged for the same user, ensuring that the same master key seed can be generated at different times and on different devices. The standard format password data and the deterministic salt value data are combined to form combined data;

[0032] Input the combined data into a key derivation function based on PBKDF2 (Password-Based Key Derivation Function 2) or Argon2, set the number of iterations and the output length, perform key derivation operations, and obtain the master key seed data.

[0033] Specifically, in traditional key derivation schemes, randomly generated salt values ​​are typically used to prevent rainbow table attacks. However, these random salt values ​​must be stored and synchronized between devices, which means that new or offline devices need to obtain the salt value to generate a key, but obtaining the salt value itself requires establishing a secure communication channel. This makes it impossible for offline devices to generate keys independently.

[0034] This application generates a deterministic salt value by performing a hash operation on the user's unique identifier (such as the user's email address, mobile phone number, etc.). Any device that obtains the user's input identifier and master password can obtain the same salt value through the same hash operation, and then generate the same master key seed through the key derivation function. The entire process does not rely on any external data source, truly realizing computation-generation.

[0035] Even when the device is completely offline, it can independently reconstruct the entire key derivation tree as long as the user enters the correct identity and master password. This fundamentally solves the problem of offline devices being unable to participate in secure communication in existing solutions. When a user replaces a device or the device is lost, there is no need to restore any key data from backup, nor is there a need to synchronize keys with other devices. The new device can independently reconstruct the key system required to communicate with all other devices.

[0036] Furthermore, S2, based on the master key seed data, constructs a key derivation tree data structure using a hierarchical hash algorithm, including: using the master key seed data as the initial input data for the root node; receiving the device category name input by the user, performing a hash operation on each device category name to generate corresponding category index data; generating the first-level device category key data through hash operation based on the master key seed data and the category index data; when a device requests to join, receiving the custom device name set by the user for the corresponding device, and standardizing the custom device name; generating the second-level device key data through hash operation based on the standardized device name and the device category key data; when a session key needs to be generated, using the device key data and the session counter value as input, generating session key data through hash operation, thus forming a three-level derivation path from the master key seed data to the session key data.

[0037] Specifically, traditional device key generation schemes typically rely on hardware identifiers (such as MAC addresses, device serial numbers, and hardware fingerprints) as input parameters for key derivation. However, when a device replaces its network card, repairs its motherboard, reinstalls its system, or restores its factory settings, the hardware identifiers may change, making it impossible to regenerate the same device key. Users will permanently lose the ability to access the device's historical encrypted data.

[0038] This application adopts a deterministic key derivation mechanism based on user semantic input. By giving the user complete control over the device category and device name, it fundamentally solves the problem of unrecoverable keys caused by hardware dependence in traditional solutions.

[0039] Users can set meaningful and easy-to-remember names for their devices (such as "My iPhone", "Office Computer", "Living Room iPad", etc.). These names are entirely user-controlled and unaffected by hardware changes. Even if the device is completely replaced, the same device key can be derived as long as the user enters the same device name.

[0040] It is no longer limited to a predefined set of device categories, but accepts any device category name input by the user. This not only supports existing common categories such as "mobile phone" and "computer", but can also adapt to new device types that will emerge in the future (such as "smart glasses" and "brain-computer interface") or custom categories for specific user needs (such as "development equipment" and "testing equipment").

[0041] Furthermore, a hash operation is performed on each device category name to generate corresponding category index data, including: receiving the device category name string input by the user; performing Unicode NFC normalization on the device category name string, converting the processed string to lowercase to obtain a standardized device category name; where device categories include mobile phones, computers, watches, and tablets; converting the standardized device category name into a UTF-8 encoded byte sequence; performing a SHA-256 hash operation on the byte sequence to generate a 256-bit hash value as the category index data, and using the determinism of the hash function to ensure that the same device category name input always generates the same category index data.

[0042] Unicode NFC (Normalization Form Canonical Composition) is a string normalization form defined by the Unicode standard. It converts character sequences into a standard combination form, ensuring that visually identical strings have the same binary representation. UTF-8 (8-bit Unicode Transformation Format) is a variable-length character encoding method used to convert Unicode characters into byte sequences. SHA-256 (Secure Hash Algorithm 256-bit) is a member of the SHA-2 family, a cryptographically secure one-way hash function that converts an input of arbitrary length into a fixed 256-bit (32-byte) output.

[0043] Specifically, through Unicode NFC normalization and case conversion, it ensures that semantically identical text entered by users in different input methods and language environments will generate the same key. For example, "Office Computer", "officecomputer", and "OFFICE COMPUTER" will all generate the same device key.

[0044] Different device categories and device names generate completely independent key branches through hash operations, so even if an attacker obtains the key for one device, they cannot deduce the keys for other devices. At the same time, users can achieve semantic-level security isolation through reasonable naming strategies (such as using different naming rules for devices with different security levels).

[0045] Furthermore, standardization (Unicode normalization and lowercase conversion) ensures consistency across different representations and resolves the issue of extensibility limitations.

[0046] Furthermore, the device category key data for the first layer is generated through hash operations, including: using the master key seed data as the input key material for the HKDF algorithm; constructing a fixed domain separation label string as the salt value for HKDF; defining a hierarchy identifier 0x01 to represent the device category layer, and defining a separator 0x00 to separate different data segments to prevent boundary ambiguity during data concatenation; concatenating the hierarchy identifier, separator, domain separation label string, and category index data in sequence as the first layer context information; performing the HKDF-Extract operation to perform entropy processing on the master key seed data using the salt value to generate a pseudo-random key; and performing the HKDF-Expand operation to generate the device category key data corresponding to the corresponding device category through hash iteration using the pseudo-random key and context information.

[0047] The HKDF algorithm (HMAC-based Key Derivation Function) is an HMAC-based key derivation function that conforms to the RFC5869 standard and is used to derive cryptographically secure keys from high-entropy key materials. It employs an extract-then-expand paradigm, completing the key derivation in two steps.

[0048] The input structure in this application is as follows:

[0049] ├──IKM (Input Key Material): Master Key Seed (32 bytes)

[0050] ├──Salt: The hash value (16 bytes) of the domain separation label.

[0051] └──Info (Contextual Information): Hierarchical identifier + category index, etc. (Variable length)

[0052] Output:

[0053] └──OKM (Output Key Material): Device Category Key (32 bytes);

[0054] The level identifier 0x01 is a fixed single-byte value used to uniquely identify the level of the current deduction operation in the key deduction tree. 0x01 specifically represents the device category level. In this application, 0x01 - device category level (first level); 0x02 - device key level (second level); 0x03 - session key level (third level); ensuring that key deductions at different levels are independent of each other, preventing attackers from impersonating one level with data from another. For example: Category level deduction: 0x01||0x00||“Mobile”→Category key A; Device level deduction: 0x02||0x00||“Mobile”→Device key B; Result: A≠B (even if other parameters are the same).

[0055] The delimiter 0x00 is a null byte used to explicitly mark the boundaries of different data segments during data concatenation, preventing splicing ambiguity attacks. For example, in the case without a delimiter: Data 1: "AB" + Data 2: "CD" = "ABCD"; Data 1: "ABC" + Data 2: "D" = "ABCD"; Result: Different inputs produce the same concatenation result. In this application, a delimiter is set: Data 1: "AB" + 0x00 + Data 2: "CD" = "AB\0CD"; Data 1: "ABC" + 0x00 + Data 2: "D" = "ABC\0D"; Result: Different inputs remain different.

[0056] Context information is the input parameter (Info) of the HKDF-Expand stage, which contains all relevant information specific to this key derivation to ensure that the derived key is bound to a specific purpose.

[0057] HKDF-Extract is the first stage of the HKDF algorithm, responsible for extracting a uniformly distributed pseudo-random key (PRK) from the input key material (IKM), even if the randomness of the input key material is not perfect. Specifically, PRK = HMAC - Hash(Salt, IKM); where: Hash: the underlying hash function (this scheme uses SHA-256); Salt: the salt value (the hash value of the domain separation label); IKM: the input key material (master key seed).

[0058] HKDF-Expand is the second stage of the HKDF algorithm. It uses the PRK generated in the Extract stage and specific context information to generate the required length of output key material through iterative HMAC operations. Specifically, OKM = T(1)||T(2)||...||T(N); where: T(0) = empty string; T(i) = HMAC-Hash(PRK, T(i-1)||Info||i); for a 32-byte output (in this scheme): T(1) = HMAC-SHA256(PRK, Info||0x01); OKM = the first 32 bytes of T(1);

[0059] In particular, in hierarchical key derivation systems, ensuring cryptographically complete independence for keys at different levels and for different purposes is crucial. Simply concatenating multiple parameters directly can lead to ambiguity. For example, class "ABC" plus device "def" and class "AB" plus device "cdef" will produce the same concatenation result "abcdef", causing different devices to generate the same key. If similar derivation parameters are used at different levels, the key at one level may unexpectedly equal the key at another level, compromising the secure isolation of the key hierarchy.

[0060] This application introduces a hierarchical identifier and structured context information construction mechanism. Through clear data boundary division and hierarchical marking, it ensures the complete isolation of keys at different levels from a cryptographic perspective, and completely solves the risks of key confusion and cross-level attacks in hierarchical key derivation systems.

[0061] Each layer uses a unique identifier (0x01 for the device class layer, 0x02 for the device layer, and 0x03 for the session layer). This identifier, as the first byte of the context information, distinguishes the key derivation process of different layers from the source. Even if other parameters are exactly the same, different layers will generate completely different keys due to the different identifiers.

[0062] Furthermore, in UTF-8 encoding, 0x00 is a null character and will not appear in normal text encoding. Using it as a delimiter completely eliminates the ambiguity of parameter concatenation. For example, the structure "0x01\x00abc\x00def" clearly identifies three independent data segments and cannot conflict with other combinations.

[0063] By defining a well-defined structure (hierarchical identifier | delimiter | domain separation label | delimiter | business data), the derivation of each key is unique and cannot be forged: keys at different levels will generate different results even when using the same business data; different uses at the same level are distinguished by the domain separation label; attackers cannot manipulate input parameters to make one key be misused as another key.

[0064] Furthermore, a fixed domain separation label string is constructed as the salt value of HKDF, including: defining the identifier string "MultiDeviceEncryption-CategoryLayer-v1"; where MultiDeviceEncryption is used to identify the application domain of the key derivation system, CategoryLayer is used to identify the key derivation of the device category layer, and v1 is used to identify the version number.

[0065] Convert the identifier string into a UTF-8 encoded byte sequence; perform a SHA-256 hash operation on the UTF-8 encoded byte sequence to generate a 256-bit hash value; extract the first 128 bits of data from the 256-bit hash value as the salt value for the HKDF algorithm.

[0066] In this context, the domain separation label string is a fixed string identifier used in cryptographic applications to distinguish different key derivation contexts. In this application, it is a constant string used to ensure that key derivation processes for different purposes are independent, preventing misuse or confusion of keys across different security domains.

[0067] Furthermore, the device key data for the second layer is generated through hash operations, including: standardizing the user-defined device name and performing a hash operation to obtain the device identifier hash value; using the device category key data as the input key material for the HKDF algorithm; defining a level identifier 0x02 to represent the device layer, and constructing second-layer context information containing the level identifier 0x02, the separator 0x00, and the device identifier hash value; performing the HKDF-Extract operation, using the generated salt value to perform entropy processing on the device category key data to generate a second-layer pseudo-random key; and performing the HKDF-Expand operation, using the second-layer pseudo-random key and the second-layer context information, generating 256-bit device key data through hash iteration, which serves as the exclusive key for the corresponding device.

[0068] Furthermore, session key data is generated through hash operations to form a three-layer derivation path from master key seed data to session key data, including: obtaining the session counter value of the current session; using device key data as input key material for the HKDF algorithm; defining a level identifier 0x03 to represent the session layer; concatenating the level identifier 0x03, separator 0x00, and session counter value in sequence to form the third layer of context information; and performing the HKDF-Extract operation to perform entropy processing on the device key data using the generated salt value to generate the third layer of pseudo-random key.

[0069] The HKDF-Expand operation is performed, using the third-layer pseudo-random key and the third-layer context information to generate 256-bit session key data through hash iteration. The session counter value is incremented each time a session is established to ensure that each session uses a unique session key, forming a complete three-layer derivation path from the master key seed data through the device category key, the device key to the session key.

[0070] Another aspect of this application provides a data encryption system based on multi-terminal interaction, comprising: a master key generation module, which obtains the master password data input by the user during the user's first registration, and generates master key seed data based on the master password data through a key derivation function; a key derivation tree module, which constructs a key derivation tree data structure based on the master key seed data using a hierarchical hash algorithm, with the master key seed data as the root node, and expands layer by layer according to device category and device identifier to form a tree-like derivation path; a device key module, which calculates the derivation path based on the key derivation tree data structure and the attribute data of the corresponding new device when a new device requests authorization, and derives the exclusive key data of the corresponding new device from the master key seed data along the derivation path; a data encryption module, which encrypts the data to be transmitted between devices based on the exclusive key data of the sending device and the path data of the receiving device in the key derivation tree, generating an encrypted data stream; and a key update module, which adds timestamp data to the key derivation tree data structure as an additional derivation parameter, so that the exclusive key data is updated periodically over time.

[0071] Compared to existing technologies, the advantages of this application are:

[0072] To address the problems in existing technologies where multi-device key management relies on centralized servers for key distribution or direct synchronization between devices, resulting in offline devices being unable to obtain the required keys, and the exponential increase in key management complexity as the number of devices increases, this application provides a data encryption method based on multi-device interaction. By constructing a deterministic key derivation tree with the master key seed as the root node, and employing a hierarchical hash algorithm to deduce keys along three paths: device category, device identifier, and session identifier, each device can independently calculate the key required to communicate with any other device using only the master password and derivation path information.

[0073] This approach enables features such as eliminating the need for storing and transmitting actual keys, generating correct communication keys even when devices are offline, eliminating the need to update the key configurations of existing devices when new devices join, and achieving forward security through a session counter mechanism. Through hierarchical deterministic key derivation, each device can independently compute the required key, without relying on the online status of other devices. This computation-as-generation approach transforms the distributed storage problem into a deterministic computation problem, fundamentally simplifying the complexity of multi-terminal key management. Attached Figure Description

[0074] This application will be further described by way of exemplary embodiments, which will be described in detail with reference to the accompanying drawings. These embodiments are not limiting; in these embodiments, the same reference numerals denote the same structures, wherein:

[0075] Figure 1This is an exemplary flowchart of a data encryption method based on multi-terminal interaction, as shown in some embodiments of this application;

[0076] Figure 2 This is an exemplary flowchart illustrating the generation of master key seed data according to some embodiments of this application;

[0077] Figure 3 This is a schematic diagram of a three-layer derivation path according to some embodiments of this application;

[0078] Figure 4 This is a schematic diagram of first-level context information according to some embodiments of this application;

[0079] Figure 5 This is an exemplary flowchart illustrating the generation of session key data according to some embodiments of this application. Detailed Implementation

[0080] The methods and systems provided in the embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0081] Example 1

[0082] like Figure 1 As shown, in step S1, during the user's initial registration, the master password data input by the user is obtained, and master key seed data is generated based on the master password data using a key derivation function; in step S2, based on the master key seed data, a key derivation tree data structure is constructed using a hierarchical hash algorithm. The key derivation tree data structure is rooted at the master key seed data and expands layer by layer according to device category and device identifier to form a tree-like derivation path; in step S3, when a new device requests authorization, the derivation path is calculated based on the key derivation tree data structure and the attribute data of the corresponding new device, and the unique key data of the corresponding new device is generated from the master key seed data along the derivation path; in step S4, based on the unique key data of the sending device in step S3 and the path data of the receiving device in the key derivation tree, the data to be transmitted between devices is encrypted to generate an encrypted data stream; in step S5, by adding timestamp data to the key derivation tree data structure in step S2 as an additional derivation parameter, the unique key data generated in steps S3 and S4 is updated periodically over time.

[0083] like Figure 2 As shown, S1 is the original password string entered by the user via the keyboard, which may contain various character encodings, mixed uppercase and lowercase letters, special characters, spaces, etc.

[0084] The input password string is uniformly converted to UTF-8 encoding format to ensure consistency across different system platforms; invisible characters such as leading and trailing spaces, tabs, and newlines are removed from the password, but spaces in the middle of the password are retained; UnicodeNFC (standardized form C) is applied for normalization to ensure consistent representation of combined characters.

[0085] A user's unique identifier typically includes: an email address, a mobile phone number, or a username. For email addresses, verification is performed to ensure they conform to email format specifications; for mobile phone numbers, verification is performed to ensure they conform to international telephone number format; and for email addresses, the domain name portion is converted to lowercase.

[0086] The identity string is converted into a UTF-8 byte sequence, and a SHA-256 hash operation is performed on the byte sequence to generate a 256-bit (32-byte) hash value. The first 128 bits (16 bytes) are extracted from the 256-bit hash value as the salt value. Since SHA-256 is a deterministic function, the same input will always produce the same output. Therefore, the same identity will always generate the same salt value, and there is no need to store it.

[0087] The password byte sequence and salt value byte sequence are directly concatenated to form the data structure: [password byte sequence][salt value 16 bytes]. This combined data is then input into a key derivation function based on PBKDF2 or Argon2, with the iteration count and output length set, to perform key derivation operations and obtain the master key seed data.

[0088] like Figure 3 As shown, S2, based on the master key seed data, constructs a key derivation tree data structure using a hierarchical hash algorithm, including: using the master key seed data as the initial input data for the root node; receiving the device category name input by the user, performing a hash operation on each device category name to generate corresponding category index data, including: receiving the device category name string input by the user; performing Unicode NFC normalization processing on the device category name string, converting the processed string to lowercase form to obtain a standardized device category name; where device categories include mobile phones, computers, watches, and tablets; converting the standardized Unicode string into a UTF-8 byte sequence; for example, "mobile phone" is converted to the byte sequence: 0xE60x89 0x8B 0xE6 0x9C 0xBA (6 bytes); for example, "phone" is converted to the byte sequence: 0x70 0x68 0x6F0x6E 0x65 (5 bytes). The UTF-8 encoded byte sequence is then output.

[0089] Perform a SHA-256 hash operation on the byte sequence to generate a 256-bit hash value, which serves as the category index data. The deterministic nature of the hash function ensures that the same device category name input always generates the same category index data.

[0090] Based on the master key seed data and category index data, the device category key data for the first layer is generated through hash operations. This includes: using the master key seed data as input key material for the HKDF algorithm; constructing a fixed domain separation label string as the salt for HKDF, including: defining the identifier string "MultiDeviceEncryption-CategoryLayer-v1"; converting the identifier string into a UTF-8 encoded byte sequence; performing a SHA-256 hash operation on the UTF-8 encoded byte sequence to generate a 256-bit hash value; and extracting the first 128 bits of data from the 256-bit hash value as the salt for the HKDF algorithm. A layer identifier 0x01 is defined to represent the device category layer, and a separator 0x00 is defined to separate different data segments to prevent boundary ambiguity during data concatenation; the layer identifier, separator, domain separation label string, and category index data are concatenated sequentially as the first-layer context information, such as... Figure 4 As shown; the HKDF-Extract operation is performed to process the master key seed data with entropy using salt to generate a pseudo-random key; the HKDF-Expand operation is performed to generate the device category key data corresponding to the device category through hash iteration using the pseudo-random key and context information.

[0091] Custom names set by users for specific devices, such as "My iPhone 15 Pro", "Office MacBook", "Bedroom iPad mini", and "Sports Apple Watch", are standardized using the same processing method as the device level. The standardized device name is converted into a UTF-8 byte sequence; for example, "My iPhone 15 Pro" is converted into the corresponding UTF-8 bytes. A SHA-256 hash operation is performed on the byte sequence to generate a 256-bit hash value as the device identifier.

[0092] The device category key (256 bits / 32 bytes) generated from the previous layer already contains the master key seed and device category information. It serves as the input key material (IKM) for this layer's HKDF, ensuring the hierarchical inheritance relationship of key derivation and maintaining the structural integrity of the key tree.

[0093] Define a hierarchy identifier 0x02 to represent the device layer, and construct a second layer of context information containing the hierarchy identifier 0x02, the separator 0x00, and the device identifier hash value;

[0094] The HKDF-Extract operation applies entropy processing to the device category key data using the generated salt value to generate a second-layer pseudo-random key. The HKDF-Expand operation then uses the second-layer pseudo-random key and second-layer context information to generate a 256-bit device key through hash iteration, serving as the unique key for each device. Keys for different devices are independent; a leak in one device's key does not affect other devices. Devices with the same name always generate the same key, and key recovery is supported.

[0095] like Figure 5 As shown, the process involves: obtaining the session counter value for the current session; using the device key data as input key material for the HKDF algorithm; defining a level identifier 0x03 to represent the session layer; concatenating the level identifier 0x03, the separator 0x00, and the session counter value in sequence to form the third-layer context information; performing the HKDF-Extract operation to process the device key data using the generated salt value to generate the third-layer pseudo-random key; and performing the HKDF-Expand operation to generate 256-bit session key data through hash iteration using the third-layer pseudo-random key and the third-layer context information. The session counter value is incremented each time a session is established to ensure that each session uses a unique session key, forming a complete three-layer derivation path from the master key seed data through the device category key, the device key, to the session key.

[0096] S3, When a new device requests authorization, calculate the derivation path based on the key derivation tree data structure and the attribute data of the corresponding new device, and derive the exclusive key data of the corresponding new device from the master key seed data along the derivation path;

[0097] S4. Based on the exclusive key data of the sending device in S3, and combined with the path data of the receiving device in the key derivation tree, the data to be transmitted between the devices is encrypted to generate an encrypted data stream.

[0098] S5, by adding timestamp data to the key derivation tree data structure in step S2 as an additional derivation parameter, the exclusive key data generated in S3 and S4 is updated periodically over time.

[0099] Example 2

[0100] In a specific embodiment of this application, Mr. Zhang already has an iPhone and has now purchased a new iPad, which he needs to add to the password management system. The calculation derivation path is as follows: First, generate a master key seed from the master password; second, calculate the hash index of the "tablet" category; third, follow the path from master key to tablet category key; fourth, calculate the device identifier hash of "living room iPad Air"; fifth, follow the path from tablet category key to iPad device key.

[0101] Mr. Zhang added a new bank password on his iPhone and needs to sync it to his iPad. Data to be transferred: {"site":"bank.com","username":"zhangsan","password":"SecretPass123"}; iPhone device key: already stored locally; Current session counter: 1234.

[0102] Processing on the sending end (iPhone):

[0103] Generate a session key using the iPhone device key and counter 1234; generate the session key (32 bytes) for this transmission; split it into an encryption key (first 16 bytes) and an authentication key (last 16 bytes).

[0104] Data encryption is performed, a random initialization vector IV (16 bytes) is generated, the data is encrypted using AES-128-CBC mode, and an authentication tag is generated using HMAC-SHA256.

[0105] Construct encrypted transmission data: Version number: 1 byte (0x01); Sending device category hash: 32 bytes; Sending device identifier hash: 32 bytes; Session counter: 4 bytes; IV: 16 bytes; Encrypted data: variable length; HMAC tag: 32 bytes.

[0106] Receiver (iPad) processing:

[0107] Reconstruct the key: Extract the device class hash and device identifier hash from the encrypted packet; verify that the sender is a known device; derive the same session key using your own device key.

[0108] Data decryption: Verify the HMAC tag; decrypt the data using the session key; obtain the original password data. Update the local session counter and send a confirmation message to the iPhone.

[0109] Update the context information of each level based on the timestamp:

[0110] Device category layer: Context = 0x01 + 0x00 + Category index + 0x00 + Time period value (4 bytes);

[0111] Device layer: Context = 0x02 + 0x00 + Device identifier + 0x00 + Time period value (4 bytes);

[0112] Session layer: Context = 0x03 + 0x00 + Session counter + 0x00 + Time period value (4 bytes). This three-layer structure design realizes a complete key management system from user memory (password) to device management (category and name) to session security (temporary key), with each layer having clear security objectives and isolation mechanisms.

[0113] The foregoing illustrative description of the present application and its embodiments is not restrictive and can be implemented in other specific forms without departing from the spirit or essential characteristics of the present application. The accompanying drawings are only one embodiment of the present application, and the actual structure is not limited thereto. Therefore, if those skilled in the art are inspired by this description and design similar structures and embodiments without departing from the spirit of the present application, such designs should fall within the scope of protection of this application. Furthermore, the word "comprising" does not exclude other elements or steps, and the word "a" preceding an element does not exclude the inclusion of "a plurality" of that element. Terms such as "first," "second," etc., are used to indicate names and do not indicate any specific order.

Claims

1. A data encryption method based on multi-terminal interaction, characterized in that, include: S1: When a user registers for the first time, obtain the master password data entered by the user, and generate master key seed data based on the master password data through the key derivation function; S2, based on the master key seed data, uses a hierarchical hash algorithm to construct a key derivation tree data structure. The key derivation tree data structure takes the master key seed data as the root node and expands layer by layer according to the device type, device identifier and session identifier to form a tree-like derivation path. S2, in particular, employs a hierarchical hash algorithm to construct a key derivation tree data structure, including: Use the master key seed data as the initial input data for the root node; Receive the device category name input by the user, perform a hash operation on each device category name, and generate the corresponding category index data; Based on the master key seed data and category index data, the device category key data of the first layer is generated through hash operation; When a device requests to join, the system receives the custom device name set by the user for the corresponding device and standardizes the custom device name. Based on the standardized device name and device category key data, a second-layer device key data is generated through hash operation; When a session key needs to be generated, the device key data and session counter value are used as inputs, and the session key data is generated through hash operation to form a three-layer derivation path from the master key seed data through the device category key data, the device key data to the session key data. S3, When a new device requests authorization, calculate the derivation path based on the key derivation tree data structure and the attribute data of the corresponding new device, and derive the device key data of the corresponding new device from the master key seed data along the derivation path; S4, generate session key data based on the device key data of the sending device and the session counter value, and encrypt the data to be transmitted between devices based on the session key data to generate an encrypted data stream; wherein, the session counter value is incremented each time a session is established to ensure that each session uses unique session key data; The device key data for the second layer is generated through hash operations, including: The user-defined device name is standardized and hashed to obtain the device identifier hash value; Use device category key data as input key material for the HKDF algorithm; Define a hierarchy identifier 0x02 to represent the device layer, and construct a second layer of context information containing the hierarchy identifier 0x02, the separator 0x00, and the device identifier hash value; Perform the HKDF-Extract operation to entropy process the device category key data using the generated salt value, and generate a second-layer pseudo-random key. The HKDF-Expand operation is performed, using the second-layer pseudo-random key and the second-layer context information to generate a 256-bit device key data through hash iteration, which serves as the exclusive key for the corresponding device. The process of generating session key data through hash operations includes: Get the session counter value for the current session; Use device key data as input key material for the HKDF algorithm; Define the layer identifier 0x03 to represent the session layer; The hierarchy identifier 0x03, the separator 0x00, and the session counter value are concatenated in sequence to form the third layer of context information; Perform the HKDF-Extract operation to process the device key data using the generated salt value and generate a third-layer pseudo-random key. The HKDF-Expand operation is performed, using the third-layer pseudo-random key and the third-layer context information to generate 256-bit session key data through hash iteration. The session counter value is incremented each time a session is established to ensure that each session uses a unique session key, forming a complete three-layer derivation path from the master key seed data through the device category key data, the device key data to the session key data.

2. The data encryption method based on multi-terminal interaction according to claim 1, characterized in that: Also includes: S5, by adding timestamp data to the key derivation tree data structure in step S2 as an additional derivation parameter, the device key data and session key data generated in S3 and S4 are updated periodically over time.

3. The data encryption method based on multi-terminal interaction according to claim 1, characterized in that: S1 generates master key seed data through a key derivation function, including: Receive the master password data input by the user, standardize the master password data, and generate password data in a standard format; Obtain the user's unique identification data; Perform a hash operation on the unique identity data to generate deterministic salt value data for the corresponding user; Standard format cryptographic data and deterministic salt value data are combined to form combined data; Input the combined data into a key derivation function based on PBKDF2 or Argon2, set the number of iterations and the output length, perform key derivation operations, and obtain the master key seed data.

4. The data encryption method based on multi-terminal interaction according to claim 1, characterized in that: Generate the corresponding category index data, including: Receives a string representing the device category name input by the user; Perform Unicode NFC normalization on the device category name string, convert the processed string to lowercase, and obtain the standardized device category name; where device categories include mobile phone, computer, watch, and tablet; Convert standardized device category names into UTF-8 encoded byte sequences; Perform a SHA-256 hash operation on the byte sequence to generate a 256-bit hash value, which serves as the category index data. The deterministic nature of the hash function ensures that the same device category name input always generates the same category index data.

5. The data encryption method based on multi-terminal interaction according to claim 1, characterized in that: The device category key data for the first layer is generated through hash operations, including: Use the master key seed data as the input key material for the HKDF algorithm; Construct a fixed domain-separated tag string as the salt of the HKDF; Define the hierarchical identifier 0x01 to represent the device category layer, and define the separator 0x00 to separate different data segments to prevent boundary ambiguity when splicing data; The hierarchy identifier, separator, field separation label string, and category index data are concatenated in order to form the first layer of context information; The HKDF-Extract operation is performed to process the master key seed data using entropy with salt to generate a pseudo-random key. The HKDF-Expand operation is performed, using a pseudo-random key and context information to generate device category key data corresponding to the corresponding device category through hash iteration.

6. The data encryption method based on multi-terminal interaction according to claim 5, characterized in that: Construct a fixed domain-separated tag string as the salt for HKDF, including: Define the identifier string "MultiDeviceEncryption-CategoryLayer-v1"; Convert the identifier string into a UTF-8 encoded byte sequence; Perform a SHA-256 hash operation on the UTF-8 encoded byte sequence to generate a 256-bit hash value; The first 128 bits of data are extracted from the 256-bit hash value and used as the salt for the HKDF algorithm.

7. A data encryption system based on multi-terminal interaction, used to execute the method according to any one of claims 1 to 6, characterized in that, include: The master key generation module obtains the master password data entered by the user during the user's first registration, and generates master key seed data based on the master password data through the key derivation function; The key derivation tree module, based on the master key seed data, uses a hierarchical hash algorithm to construct the key derivation tree data structure. The key derivation tree data structure takes the master key seed data as the root node and expands layer by layer according to the device category and device identifier to form a tree-like derivation path. The device key module, when a new device requests authorization, calculates the derivation path based on the key derivation tree data structure and the attribute data of the corresponding new device, and derives the exclusive key data of the corresponding new device from the master key seed data along the derivation path; The data encryption module encrypts the data to be transmitted between devices based on the sender's exclusive key data and the path data of the receiver in the key derivation tree, generating an encrypted data stream. The key update module adds timestamp data to the key derivation tree data structure as an additional derivation parameter, so that the exclusive key data is updated periodically over time.

Citation Information

Patent Citations

  • A method and a system for generating a sub-key of a binding device based on master key negotiation

    CN109698746A

  • Key derivation method

    CN116547942A